Beispiel #1
0
    public void HealRegen()
    {
        int bonusHealth = 10;

        DamageIndicatorController.CreateDamageIndicator("+" + bonusHealth.ToString(), rb.transform, Color.green);
        Health += bonusHealth;
    }
Beispiel #2
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();
        }
    }
Beispiel #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();
        }
    }
Beispiel #4
0
    void Start()
    {
        DrawRoute = false;
        DamageIndicatorController.Initialize();
        AgentInformationController.Initialize();
        Path = new PathInfo.PathRoute
        {
            PathList = new Vector3[200]
        };
        OpenList     = new List <Map.MapNode>(SetupScript.width * SetupScript.height);
        ClosedList   = new List <Map.MapNode>(SetupScript.width * SetupScript.height);
        rb           = GetComponent <Rigidbody>();
        Board        = new Blackboard();
        Mess         = GetComponent <Messager>();
        StateMachine = new StateMachine <AI>(this);

        MaxAmmo           = 20;
        Ammo              = MaxAmmo;
        MaxHealth         = 100;
        Health            = MaxHealth;
        MaxSpeed          = 4.0f;
        MaxBulletVelocity = 4.0f;
        MaxFireRate       = 0.5f;
        MaxDamage         = 25;

        Time          = 0;
        RespawnTimer  = 20;
        Respawn       = 20;
        GameTimer     = UnityEngine.Time.deltaTime;
        TimesDied     = 0;
        PlayersKilled = 0;

        NodeChangeDistance = 0.04f * MaxSpeed;

        HaveFlag   = false;
        AtSafeSpot = false;
        SeenEnemy  = false;
    }
        protected override void Start()
        {
            base.Start();
            health = MaxHealth / 2;

            var barPrefab = Resources.Load <GameObject>("UI/Bar");

            _healthBarController = Instantiate(barPrefab, transform).GetComponent <BarController>();
            _healthBarController.UpdatePosition();
            _healthBarController.UpdateName(GetResource().name);

            var borderPrefab = Resources.Load <GameObject>("UI/CreatureBorder");

            _creatureBorderController = Instantiate(borderPrefab, transform).GetComponent <CreatureBorderController>();
            _creatureBorderController.Hide();

            var damageIndicatorPrefab = Resources.Load <GameObject>("UI/DamageIndicator");

            _damageIndicatorController =
                Instantiate(damageIndicatorPrefab, transform).GetComponent <DamageIndicatorController>();

            SpriteRenderingController.UpdateSprite(GetResource().idleAnimations.Down);
        }