Ejemplo n.º 1
0
 void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.CompareTag("Currency"))
     {
         CurrencyManager.goldCount += (1 + Player.GetGoldBonus());
         other.transform.GetComponent <ObstacleCurrency>().isPickUp = true;
         other.gameObject.collider.enabled = false;
     }
 }
Ejemplo n.º 2
0
        void OnCollisionEnter(Collision other)
        {
            if (other.gameObject.CompareTag("Obstacle") && !Player.isJumpPowerUp && !Player.isRevive)
            {
                if (other.collider.bounds.center.y < 10)
                {
                    if (other.collider.bounds.size.y * .9f < other.contacts[0].point.y)
                    {
                        fContactPointY = other.contacts[0].point.y;
                        return;
                    }
                }

                var targetX = Mathf.Round(other.transform.position.x);
                var playerX = Mathf.Round(transform.position.x);

                if (Waypoint.currentWP != Waypoint.transitWP)
                {
                    Waypoint.changeWP(Waypoint.currentWP < Waypoint.transitWP);
                    return;
                }

                if (ID == 4)
                {
                    other.transform.localScale        = Vector3.zero;
                    other.gameObject.collider.enabled = false;
                }

                soldierLife--;

                if (soldierLife <= 0)
                {
                    onDeath();
                }
            }
            else if (other.gameObject.CompareTag("Bridge"))
            {
                isBridge      = true;
                brigeDistance = Player.Distance;
                bridgeHeight  = Vector3.zero;
            }
            else if (other.gameObject.CompareTag("Currency"))
            {
                CurrencyManager.goldCount += (1 + Player.GetGoldBonus());
                other.transform.GetComponent <ObstacleCurrency>().isPickUp = true;
                other.gameObject.collider.enabled = false;
            }
            else if (other.gameObject.CompareTag("PowerUp"))
            {
                PowerUp.UseBonus(other.gameObject.GetComponent <ObstaclePowerUp>());
            }
            else if (other.gameObject.CompareTag("Human"))
            {
                other.gameObject.collider.enabled = false;
                other.gameObject.GetComponent <ObstacleHuman>().movement.speed = 0;

                if (Player.currentList.Count < Player.GetMaxPlayers())
                {
                    particle.Emit(50);

                    Player.currentList.Add((Runner.PlayerController)GameObject.Instantiate(Player.GetById(other.gameObject.GetComponent <ObstacleHuman>().ID)));
                    Player.currentList[Player.currentList.Count - 1].isPatientZero = false;
                    Player.currentList[Player.currentList.Count - 1].Initialize();
                    Player.currentList[Player.currentList.Count - 1].gameID = Player.currentList.Count - 1;

                    var game = GameObject.FindGameObjectWithTag("Player");
                    Player.currentList[Player.currentList.Count - 1].gameObject.transform.parent = game.transform;
                }
            }
        }