Example #1
0
 void OnTriggerEnter(Collider other)
 {
     if (TrackDeath)
     {
         heatmap.Post(transform.position, deathTag);
     }
     Respawn();
 }
Example #2
0
    public override void Damage(float damageTaken = 0)       // -1 means fell off screen, -2 means lava
    {
        bool isUnderWater     = (inWater && isCrouched);
        bool fellOffInGodMode = (damageTaken == -1 || damageTaken == -2) && (godMode || invincibleFlag);

        if (isUnderWater || ((invincibleFlag || godMode) && !fellOffInGodMode))
        {
            return;
        }

        MovingFloorSegment[] movingFloors = FindObjectsOfType(typeof(MovingFloorSegment)) as MovingFloorSegment[];
        foreach (MovingFloorSegment floor in movingFloors)
        {
            MovingFloorSegment floorScript = (MovingFloorSegment)floor.GetComponent(typeof(MovingFloorSegment));
            floorScript.BillIsDead();
        }

        //Debug.Log("Dead!!");
        // Do death animation
        if (fellOffInGodMode)
        {
            Respawn();
            return;
        }
        else
        {
            health--;

            if (Application.loadedLevelName == "Level_1")
            {
                if (TrackDeath)
                {
                    heatmap.Post(transform.position, deathTag);
                }
            }

            string healthString = "";

            if (health == 1f)
            {
                healthString = "O";
            }
            else if (health == 2f)
            {
                healthString = "O O";
            }

            billHealth.text = healthString;
        }

        if (health > 0)
        {
            Respawn();
        }
        else
        {
            Debug.Log("Game Over");
            Destroy(gameObject);
            Application.LoadLevel(Application.loadedLevel);
        }
    }