📜  c# 我们中间 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:50.343000             🧑  作者: Mango

代码示例1
//1. Watch this Tutorial: https://www.youtube.com/watch?v=47U1PJ0RVvo
//2. Somewhere at the Bottom of your Code you'll find a Function called:
public static void Postfix(PlayerControl __instance)
// Also: Everything you put in this function, will be executed forever,
// meaning that its getting executed each frame and not only just one Time.
//3. In there you can write your Code, starting on each line with writing:
__instance.
//4. It should Popup a huge list of things you can do. Here are a few examples
//   what you could do with that:
  
//
__instance.SetKillTimer(0); //Sets the Kill Cooldown of the Impostor to 0 Secs.
//
__instance.SetColor(3); //Sets the Body Color of all the Players (and Dummy's)
                        //to Pink. See a List of Id's of Body Colors here:
                        //https://among-us.fandom.com/wiki/Colors
//
if (!__instance.isDummy) {  //Will only set the Body Color of Players, not (!)
    __instance.SetColor(10);  //of Dummy's to Cyan.
}
//
if (!__instance.isDummy) {  //Sets the Body Color of only Players, not (!) of
    __instance.SetColor(Random.Range(0, 17));  //dummy's to a random Color Id
}                                               //(0-17)
//
if (__instance.isDummy) {       //(x, ------------y-----------, z)
    __instance.transform.Translate(0, 1.1 * Time.deltaTime * 2, 0);
//Moves all Dummy's up (y) forever at normal 1x Speed. (Can be used for a
//Singleplayer Mod, where all the Dummy's are Bots. If you want to move them on
//the x, just copy the code in the y (between the 2 Commas, and replace the 0
//at x with that Code. If you want to change the Speed, experiment with the 1.1
//in the Code.
  
//
__instance.Die(DeathReason.Exile); //Kills all Players (and Dummy's) because of
__instance.Die(DeathReason.Disconnect);  //Exile, Disconnecting or Kill.
__instance.Die(DeathReason.Kill);
//
__instance.ClearTasks(); //Clears all tasks of all Players, (Crewmate win)
//
__instance.RpcSendChat("This is your Chat Message");
//All Players and Dummy's will Spam the Message in Chat forever (Can be combined
//with if (!__instance.isDummy), to only force Players to write the Message
//in Chat
  
//
if (__instance.inVent) //Executes some Code, in case an Instance is in a Vent
//
if (__instance.name == "Dummy 2") {  //Only Players / Dummy's named "Dummy 2"
    __instance.Die(DeathReason.Kill);  //will be killed at the beginning of the
}  //game (VERY USEFULL, CAN BE USED ON ALL OF THE ABOVE)

//
__instance.moveable = false;  // Will disable movement of all Players
__instance.moveable = true;  // Will enable movement of all Players
//
  
// Additional Information: In the List, that shows up when you type __instance.
// there are option with a wrench and Options with a purple Box. The wrench
// signalizes, that this parameter is only checkable (with if). A purple Box
// means, that the parameter is executable (e.g. __instance.SetColor())

//5. Correct me if im wrong, I know this all only since one Day. I needed two
//   Days to figure all this out, because there is no tutorial anywhere on
//   the Internet and I wasted 2 Days of my lifetime. I hope this help! :)
//   This is all I know until now.