protected override void Action(int slot) { float cursorPosX = GadgetCoreAPI.GetCursorPos().x; Vector3 playerPos = InstanceTracker.PlayerScript.gameObject.transform.position; int xDirection = cursorPosX < playerPos.x ? -1 : 1; Vector3 spawnPos = playerPos + new Vector3(2f * xDirection, 0f, 0f); GameObject gameObject = (GameObject)Network.Instantiate(Resources.Load("MoreCombatChips/AttackerDrone"), spawnPos, Quaternion.identity, 0); gameObject.GetComponent <AttackerDroneScript>().Set(Damage, xDirection); }
public static bool Prefix(Menuu __instance, ref Ray ___ray, ref RaycastHit ___hit) { if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { ___ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(___ray, out ___hit, 10f)) { if (___hit.transform.gameObject.name.Equals("bModMenu")) { __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/confirm"), Menuu.soundLevel / 10f); if (GadgetCore.IsUnpacked) { __instance.StartCoroutine(ModMenu(__instance)); } else { __instance.StartCoroutine(UnpackGadgetCore()); } return(false); } else if (___hit.transform.gameObject.name.Equals("bQuit")) { foreach (System.Diagnostics.Process process in ModDescPanelController.ConfigHandles) { if (process != null && !process.HasExited) { process.Kill(); } } } else if (___hit.transform.gameObject.name.Equals("bPlay") && !GadgetCore.IsUnpacked) { GadgetCore.Log(GadgetCoreAPI.GetCursorPos().ToString()); GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("txtError"), GadgetCoreAPI.GetCursorPos() + new Vector3(0, 0, 9), Quaternion.identity); gameObject.SendMessage("InitError", "You must unpack Gadget Core before playing!"); return(false); } } } return(true); }
private Vector3 ComputeDirection(Vector3 initialPosition) { // Z coordinate is also being updated. return((GadgetCoreAPI.GetCursorPos() - initialPosition).normalized); }