Example #1
0
    public void TakeDamage(int MaxDamage, GameObject attacker, GameObject scoreboard) //this deducts health and checks if we have died, if we had the flag reset its position.
    {
        int Damage = -MaxDamage;

        DamageIndicatorController.CreateDamageIndicator(Damage.ToString(), rb.transform, Color.red);
        Health -= MaxDamage;

        if (Health < 1)
        {
            ++TimesDied;

            if (HaveFlag)
            {
                HaveFlag = false;
                if (TeamColour == "Red")
                {
                    GameObject.Find("BlueFlag").GetComponent <FlagScript>().ResetPosition();
                    Mess.SendMessage(gameObject, 2); //we have lost enemy flag go back to normal
                }

                else if (TeamColour == "Blue")
                {
                    GameObject.Find("RedFlag").GetComponent <FlagScript>().ResetPosition();
                }
            }
            StateMachine.ChangeState(RespawningState.Instance);
            resetPath();
            attacker.GetComponent <AI>().IncreaseKillsMade();
            attacker.GetComponent <AttackingScript>().Targets.Remove(gameObject);
            scoreboard.GetComponent <ScoresTable>().UpdateScores();
        }
    }
Example #2
0
    public void HealRegen()
    {
        int bonusHealth = 10;

        DamageIndicatorController.CreateDamageIndicator("+" + bonusHealth.ToString(), rb.transform, Color.green);
        Health += bonusHealth;
    }
Example #3
0
    public void TakeDamage(int damage)
    {
        health -= damage;
        DamageIndicatorController.CreateDamageIndicator(damage.ToString(), gameObject.transform, Color.red);

        if (health < 1)
        {
            Destroy(gameObject);
            TurretOwner.GetComponent <TurretSpawner>().ResetTimer();
        }
    }