private void OnCollisionEnter(Collision collision) { /* * if (TryGetComponent<BallCmdGhost>(out BallCmdGhost ghost)) * { * if (ghost.ghostActive) * return; * } * * if (collision.gameObject.TryGetComponent<BallCmdGhost>(out BallCmdGhost theirGhost)) * { * if (theirGhost.ghostActive) * return; * } */ if (collision.gameObject.tag == "Ball") { lastHitByName = collision.transform.parent.name; lastHitByGameObject = collision.gameObject; doCrit = RollCrit(); //Bomb check if (hasBomb) { BallBomb oldBomb = GetComponent <BallBomb>(); if (oldBomb.cooldown < 0 && collision.gameObject.GetComponent <BallBomb>() == null) { if (gameObject.TryGetComponent <BallCmdBomb>(out var component)) { Debug.Log("Destroyed bomb command!"); component.SelfDestruct(); } BallBomb newBomb = collision.gameObject.AddComponent <BallBomb>(); newBomb.PassValues(oldBomb.explosionTimer, oldBomb.originPlayer, oldBomb.timerText); Destroy(oldBomb); } } HitEnemy(collision); } else if (collision.gameObject.tag == "Obstacle") { doCrit = false; HitEnemy(collision); } if (gameObject.tag == "Ball") { nameplate.ColorName(ballDur.RPM); } }
public override void DoAbility() { // Instantiate bomb BallBomb ballBomb = gameObject.AddComponent <BallBomb>(); ballBomb.originPlayer = gameObject.name; GameObject obj = Resources.Load("Prefabs/Gameplay prefabs/BombDisplay") as GameObject; Transform trans = GameObject.FindGameObjectWithTag("PowerupCanvas").transform; ballBomb.timerText = Instantiate(obj, trans).GetComponentInChildren <Text>(); }