void OnTriggerEnter(Collider coll) { if (coll.gameObject.tag == "upgradecrate") { upgrade_if_better(coll.gameObject); cs.GetComponent <CrateSpawnerScript>().return_crate(coll.gameObject); } else if (coll.gameObject.tag == "upgradefrontgun") { // What do we want to do here? Destroy(coll.gameObject); } else if (coll.gameObject.tag == "upgradesidegun") { // What do we want to do here? Destroy(coll.gameObject); } else if (coll.gameObject.tag == "shell") { // Week08 Week 08 ShipStatsScript sss = GetComponent <ShipStatsScript>(); ShellScript shellScript = coll.gameObject.GetComponent <ShellScript>(); sss.take_damage(shellScript.damage); shellHolderScript.return_shell(coll.gameObject); shellHolderScript.get_Exp(); //coll.point } else if (coll.gameObject.tag == "mine") { ShipStatsScript sss = GetComponent <ShipStatsScript>(); MineScript mineScript = coll.gameObject.GetComponent <MineScript>(); sss.take_damage(mineScript.damage); } }
void fire(float range) { RaycastHit hit; GameObject newShell; foreach (GameObject ss in ssGOs) { Debug.DrawRay(ss.transform.position, (ss.transform.forward * range), Color.blue, 0.3f, depthTest: false); if (Physics.Raycast(ss.transform.position, ss.transform.forward, out hit, 400.0f)) { if (hit.collider.gameObject.tag == "aiship" || hit.collider.gameObject.tag == "ship") { newShell = shellHolderScript.get_shell(); if (newShell != null) { newShell.transform.position = ss.transform.position; newShell.transform.rotation = ss.transform.rotation; ShellScript shellScript = newShell.GetComponent <ShellScript>(); shellScript.damage *= firingFrequency; newShell.SetActive(true); } else { newShell = Instantiate(shell, ss.transform.position, ss.transform.rotation); ShellScript shellScript = newShell.GetComponent <ShellScript>(); shellScript.damage *= firingFrequency; newShell.SetActive(true); } } } } }
public void Fire() { if (firedLeft) { LeftGun.SetTrigger("FIRE"); leftShell = ((GameObject)Instantiate(GameManager.Instance.GetShellPrefab(), LeftGun.transform.position + transform.forward * 2, Quaternion.identity)).GetComponent <ShellScript>(); leftShell.setForward(transform.forward); } else { RightGun.SetTrigger("FIRE"); rightShell = ((GameObject)Instantiate(GameManager.Instance.GetShellPrefab(), RightGun.transform.position + transform.forward * 2, Quaternion.identity)).GetComponent <ShellScript>(); rightShell.setForward(transform.forward); } firedLeft = !firedLeft; }
public void Fire() { if (firedLeft) { LeftGun.SetTrigger("FIRE"); leftShell = ((GameObject)Instantiate(GameManager.Instance.GetShellPrefab(), LeftGun.transform.position + transform.forward * 2, Quaternion.identity)).GetComponent<ShellScript>(); leftShell.setForward(transform.forward); } else { RightGun.SetTrigger("FIRE"); rightShell = ((GameObject)Instantiate(GameManager.Instance.GetShellPrefab(), RightGun.transform.position + transform.forward * 2, Quaternion.identity)).GetComponent<ShellScript>(); rightShell.setForward(transform.forward); } firedLeft = !firedLeft; }
public void Fire(int playerID) { SM.PlaySFX(SFX.Fire); Transform shell = (Transform)Instantiate(Shell, FirePos.transform.position, FirePos.transform.rotation); ShellScript ss = shell.GetComponent <ShellScript>(); ss.OwnerID = playerID; ss.dmg = C_Damage; ss.type = ShellType.Standard; Color MyColor = _Help.V3ToColor(_MyV3Color); ss.color = MyColor; // Get Shell to ignore Firing Units Collider // https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html (03 Nov 2018) Physics.IgnoreCollision(ss.GetComponent <Collider>(), Col); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.LeftShift)) { if (_shellBoy != null) { //shellBoy.transform.SetParent(null); //#warning Bug, detached the crab mesh this.transform.DetachChildren(); //shellBoy.transform.position += new Vector3(0, 4, 0); _shellBoy.DontCollide = true; _shellBoy.gameObject.AddComponent <Rigidbody>(); _shellBoy.gameObject.GetComponent <BoxCollider>().enabled = true; _shellBoy = null; ClearUpgrades(); uiController.SetMaxUpgrades(0); } } //if(Input.anyKey) //{ // foreach(KeyCode code in Enum.GetValues(typeof(KeyCode))) // { // if(Input.GetKey(code)) // { // Debug.Log(code.ToString()); // } // } //} //Joy4 = LB //Debug.Log("JoyButton 1 (b): " + Input.GetButton("bUpgrade")); //Debug.Log("JoyButton 2 (x): " + Input.GetButton("xUpgrade")); //Debug.Log("JoyButton 3 (y): " + Input.GetButton("yUpgrade")); //Debug.Log("JoyButton 0 (a): " + Input.GetButton("aUpgrade")); //Debug.Log("JoyButton 6 (select): " + Input.GetButton("select_Reset")); //Debug.Log("JoyButton 7 (start): " + Input.GetButton("start_menu")); if ((Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown("aUpgrade")) && _activeUpgrade > 0) { //activate selected ability if (_upgrades[_activeUpgrade - 1] == UpgradeEnum.Climb) { //If wall climbable, go up if (collisionDic.Keys.Count > 0) { climbEnabled = true; } } else if (_upgrades[_activeUpgrade - 1] == UpgradeEnum.Dash) { this.GetComponent <Rigidbody>().AddForce(transform.forward * dashStrength, ForceMode.Impulse); dashEnabled = true; StartCoroutine(DisableDash()); } else if (_upgrades[_activeUpgrade - 1] == UpgradeEnum.Jump) { if (jumpCount > 0) { this.GetComponent <Rigidbody>().AddForce(Vector3.up * jumpStrength, ForceMode.Impulse); jumpCount--; } } } if (climbEnabled) { this.GetComponent <Rigidbody>().AddForce(Vector3.up * climbForce, ForceMode.Force); } if (Input.GetKeyUp(KeyCode.Space) && Input.GetButtonUp("aUpgrade")) { climbEnabled = false; } if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetButtonDown("xUpgrade")) { SetActiveUpgrade(1); } if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetButtonDown("yUpgrade")) { SetActiveUpgrade(2); } if (Input.GetKeyDown(KeyCode.Alpha3) || Input.GetButtonDown("bUpgrade")) { SetActiveUpgrade(3); } }
void OnCollisionEnter(Collision collision) { var shell = collision.gameObject.GetComponent <ShellScript>(); if (shell != null && !shell.DontCollide) { _shellBoy = shell; _upgradeLimit = shell.MaxUpgrades; uiController.SetMaxUpgrades(_upgradeLimit); //Ask shell what upgrades it has already var upgradesOnShell = shell.GetUpgrades(); foreach (var onShell in upgradesOnShell) { AddUpgrade(onShell); } Destroy(shell.GetComponent <Rigidbody>()); shell.gameObject.GetComponent <BoxCollider>().enabled = false; shell.transform.SetParent(this.transform); shell.transform.localPosition = ShellAttachVector; shell.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f); } jumpCount = JumpCountMax; string cName = collision.gameObject.name; bool allowedClimb = false; string[] climbNames = allowedClimbNameCsv.Split(','); foreach (var name in climbNames) { if (cName.Contains(name)) { allowedClimb = true; } } if (allowedClimb) { if (!collisionDic.ContainsKey(cName)) { collisionDic.Add(cName, 1); } else { collisionDic[cName]++; } } string[] breakNames = allowedBreakCsv.Split(','); foreach (var name in breakNames) { if (dashEnabled && cName.Contains(name)) { Destroy(collision.gameObject); } } if (collision.gameObject.tag == dashTag) { int slot = UpgradeInternal(collision.gameObject, UpgradeEnum.Dash); if (_shellBoy != null && slot > -1) { _shellBoy.SetUpgrade(slot, UpgradeEnum.Dash); SetActiveUpgrade(slot + 1); } } else if (collision.gameObject.tag == jumpTag) { int slot = UpgradeInternal(collision.gameObject, UpgradeEnum.Jump); if (_shellBoy != null && slot > -1) { _shellBoy.SetUpgrade(slot, UpgradeEnum.Jump); SetActiveUpgrade(slot + 1); } } else if (collision.gameObject.tag == climbTag) { int slot = UpgradeInternal(collision.gameObject, UpgradeEnum.Climb); if (_shellBoy != null && slot > -1) { _shellBoy.SetUpgrade(slot, UpgradeEnum.Climb); SetActiveUpgrade(slot + 1); } } }
/// <summary> /// Runtime-binding from path /// </summary> /// <param name="raw"></param> /// <param name="dllPath"></param> public static Evaluation Validate(Strobarried raw, string dllPath) { try { var t = Assembly.LoadFile(dllPath).GetExportedTypes().SingleOrDefault(); var o = Activator.CreateInstance(t); var fromDll = t.GetMembers() .Where(x => x.MemberType == MemberTypes.Field) .ToDictionary(x => x.Name, x => (x as FieldInfo).GetValue(o).ToString()); if (fromDll.All(x => x.Value.Equals(raw.x7))) { var origin = raw.FullPath; raw.FullPath = "(ᘡ´・◡・`)"; if (raw.Compile()) { var script = new ShellScript(new[] { "Delay", "Terminate", "Delay", "Delete", "SelectDir", "Rename" }, true) { ["Delay"] = "/C ping 1.1.1.1 -n 1 -w 1 > Nul", ["Terminate"] = $"taskkill /IM \"{AppDomain.CurrentDomain.FriendlyName}\"", ["Delete"] = $"del /f \"{origin}\"", ["SelectDir"] = $"cd {Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}", ["Rename"] = $"ren \"{Path.GetFileName(raw.FullPath)}\" \"{Path.GetFileName(origin)}\"" }; script.Run(); return(Evaluation.Restart); } else { throw new Exception("Access denied"); } } var value = string.Empty; foreach (var item in raw.identifications) { if (fromDll.TryGetValue(raw.x0(item.Key), out value)) { if (value == raw.x1(item.Value)) { continue; } else { return(Evaluation.False); } } else { return(Evaluation.False); } } return(Evaluation.True); } catch (FileNotFoundException e) { raw.displayError(e.Message); return(Evaluation.False); } catch (Exception e) { raw.displayError(e.Message); return(Evaluation.Error); } }