void Update() { if (photonView.IsMine && Input.GetMouseButtonDown(0) && powerup != null) { powerup.Activate(this); } }
public IEnumerator HandlePowerup() { soundController.PlayPowerupSound(); Powerup pu = null; int i = 0; do { i = Random.Range(0, powerups.Length); pu = powerups[i]; } while (remainingEscapeCards >= 1 && i == 1); GameObject prefabInst = Instantiate(powerupUIPrefab); prefabInst.transform.SetParent(uiController.canvas.transform, false); RectTransform rectTransform = prefabInst.GetComponent <RectTransform>(); PowerupUI powerupUI = prefabInst.GetComponent <PowerupUI>(); powerupUI.ApplyPowerup(pu); pu.Activate(this); yield return(new WaitForSeconds(5.5f)); Destroy(prefabInst); CheckPlayerTurnStatus(); }
private void OnCollisionEnter2D(Collision2D collision) { Powerup powerup = collision.gameObject.GetComponent <Powerup>(); if (powerup != null) { powerup.Activate(); } }
// This is called when a pickup is acquired by the pad public void OnPickup() { powerupActive = true; DestroyAllPickups(); // Select a powerup at random currentPowerup = powerups[Random.Range(0, powerups.Length)]; // Start the new powerup currentPowerup.Activate(); }
private void Update() { if (powerup != null) { if (Input.GetButtonDown("Left Mouse Button")) { hud.PowerupSlot.Useable = false; powerup.Activate(this); } powerup.PlayerUpdate(this); } }
void EnableCheats() { if (Input.GetKeyUp(KeyCode.LeftControl) || Input.touchCount == 3) { powerupActive = true; currentPowerup = GameObject.Find("LazerGunPowerup").GetComponent <Powerup>(); currentPowerup.Activate(); } if (Input.GetKeyUp(KeyCode.LeftAlt)) { powerupActive = true; currentPowerup = GameObject.Find("LifePowerup").GetComponent <Powerup>(); currentPowerup.Activate(); } if (Input.GetKeyUp(KeyCode.LeftShift) || Input.touchCount == 5) { powerupActive = true; currentPowerup = GameObject.Find("ExtraSpherePowerup").GetComponent <Powerup>(); currentPowerup.Activate(); } if (Input.GetKeyUp(KeyCode.Tab) || Input.touchCount == 4) { powerupActive = true; currentPowerup = GameObject.Find("PadResizePowerup").GetComponent <Powerup>(); currentPowerup.Activate(); } if (Input.GetKeyUp(KeyCode.E)) { OnGameOver(); } if (Input.GetKeyUp(KeyCode.P)) { OnPickup(); } }
private bool HandlePickup() { m_Pickupable = null; int hitCount = Physics2D.OverlapCircleNonAlloc(transform.position, 4, m_PickupScanResults, Layers.PickupMask); if (hitCount == 0) { return(false); } Collider2D bestColl = m_PickupScanResults[0]; float bestDist = Vector2.Distance(transform.position, bestColl.transform.position); for (int i = 1; i < hitCount; i++) { Collider2D coll = m_PickupScanResults[i]; float dist = Vector2.Distance(transform.position, coll.transform.position); if (dist < bestDist) { bestColl = coll; bestDist = dist; } } Pickup pickup = bestColl.GetComponent <Pickup>(); if (pickup == null) { return(false); } m_Pickupable = pickup.Value; Weapon weapon = pickup.Value as Weapon; if (weapon != null) { int equipSlot = -1; if (Input.GetButtonDown(m_Equip0InputButton)) { equipSlot = 0; } else if (Input.GetButtonDown(m_Equip1InputButton)) { equipSlot = 1; } else if (Input.GetButtonDown(m_Equip2InputButton)) { equipSlot = 2; } else if (Input.GetButtonDown(m_Equip3InputButton)) { equipSlot = 3; } if (equipSlot < 0) { return(false); } Weapon oldWeapon = m_WeaponSlots[equipSlot].Weapon; m_WeaponSlots[equipSlot].Weapon = weapon; pickup.Value = oldWeapon; if (pickup.Value == null) { pickup.gameObject.Free(); } } Powerup powerup = pickup.Value as Powerup; if (powerup != null) { if (!Input.GetButtonDown(m_Equip0InputButton)) { return(false); } powerup.Activate(this); pickup.gameObject.Free(); } return(true); }
// This is called when a pickup is acquired by the pad public void OnPickup() { powerupActive = true; // All pickups are destroyed to prevent having muliple powerups active at the same time foreach ( GameObject pickup in GameObject.FindGameObjectsWithTag("Pickup")) { Destroy (pickup); } // Select a powerup at random currentPowerup = powerups[Random.Range (0, powerups.Length)]; // Start the new powerup currentPowerup.Activate(); }
void EnableCheats() { if(Input.GetKeyUp(KeyCode.LeftControl) || Input.touchCount == 3) { powerupActive = true; currentPowerup = GameObject.Find("LazerGunPowerup").GetComponent<Powerup>(); currentPowerup.Activate(); } if(Input.GetKeyUp(KeyCode.LeftAlt)) { powerupActive = true; currentPowerup = GameObject.Find("LifePowerup").GetComponent<Powerup>(); currentPowerup.Activate(); } if(Input.GetKeyUp(KeyCode.LeftShift) || Input.touchCount == 5) { powerupActive = true; currentPowerup = GameObject.Find("ExtraSpherePowerup").GetComponent<Powerup>(); currentPowerup.Activate(); } if(Input.GetKeyUp(KeyCode.Tab) || Input.touchCount == 4) { powerupActive = true; currentPowerup = GameObject.Find("PadResizePowerup").GetComponent<Powerup>(); currentPowerup.Activate(); } if(Input.GetKeyUp(KeyCode.P)) { OnPickup(); } }