public virtual void UsePowerup() { transform.position = Owner.transform.position + Vector3.Up; string audioName = "use_" + powerupType.ToString().ToLower(); if (Audio.Contains(audioName)) { Audio.Play(audioName, transform.position); } else { Audio.Play("use_various", transform.position); } }
public void Buy() { G.Sys.dataMaster.Coins -= _currentPrice; if (_isPowerUp) { G.Sys.dataMaster.SetPowerupLevel(G.Sys.dataMaster.PowerupLevel(_currentPowerUp) + 1, _currentPowerUp); ShopWindow.SetActive(false); Event <ShopResetEvent> .Broadcast(new ShopResetEvent()); Debug.Log(_currentPowerUp.ToString() + " " + G.Sys.dataMaster.PowerupLevel(_currentPowerUp)); } else { G.Sys.dataMaster.SetCosmeticsLevel(true, _currentCosmetics); ShopWindow.SetActive(false); Event <ShopResetEvent> .Broadcast(new ShopResetEvent()); Debug.Log(_currentCosmetics.ToString() + " " + G.Sys.dataMaster.CosmeticsLevel(_currentCosmetics).ToString()); } }
public void GivePowerup(PowerupType pow) { if (Powerup != PowerupType.None) { return; } Powerup = pow; PlaySound(PowerUpSound); if (pow == PowerupType.Shield) { // invulnerable period m_InvulnTime = Tuning.PLAYER_INVULN_TIME_SHIELD; PlaySound(ShieldSound); } else if (pow == PowerupType.RapidFire) { m_RapidTime = Tuning.PLAYER_RAPIDFIRE_TIME; } // and a nice message to go with it ShowScoreMessage(pow.ToString().ToUpper(), true); }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { for (int i = 0; i < 3; i++) { print(other.gameObject); string ary = ""; foreach (PowerupType type in other.gameObject.GetComponent <PlayerProperties>().currPowerups) { ary += type.ToString() + ","; } print(ary); print("i: " + i); print(other.gameObject.GetComponent <PlayerProperties>()); if (other.gameObject.GetComponent <PlayerProperties>().currPowerups[i] == PowerupType.none) { other.gameObject.GetComponent <PlayerProperties>().PowerupCollected(GetComponent <MeshRenderer>().material.color, type); Destroy(gameObject); break; } } } }
public void AddFallingPowerUp(Vector3 position, PowerupType newPowerUpType) { var fallingPowerUp = dash.GetDashObject(newPowerUpType.ToString()); fallingPowerUp.StartFalling(position); }
public override string GetDashID() { return(powerUpType.ToString()); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Player")) { if (collision.gameObject.GetComponent <Player>().powerup != PowerupType.None) { return; } if (collision.gameObject.GetComponent <Player>().IsMe) { collision.gameObject.GetComponent <Player>().PickUpPowerup(myType); //Debug.Log("Collison with:" + myType); //initialising gameobject prefab with the powerup picked up in game with the relevant powerup in the powerups folder prefab GameObject powerIconPrefab = (GameObject)Resources.Load(Path.Combine("Powerups", myType.ToString()), typeof(GameObject)); //Debug.Log("PowerupPrefab:" + powerIconPrefab); powerUpIcon = powerIconPrefab.GetComponent <SpriteRenderer>().sprite; // Debug.Log("PowerupIcon:" + powerUpIcon); inventory.AddPowerup(powerUpIcon); } Destroy(gameObject); } }