Exemplo n.º 1
0
 public void Damage(float damageAmount, Vector3 hitPosition, ProjectSpaceship.GameAgent sender)
 {
     foreach (IDamageable value in TargetList)
     {
         value.ReceiveDamage(damageAmount, hitPosition, sender);
     }
     TargetList.Clear();
 }
Exemplo n.º 2
0
 public void ReceiveHeal(float healAmount, Vector3 hitPosition, GameAgent sender)
 {
     if (ReceiveHeal_ != null)
     {
         ReceiveHeal_(healAmount);
     }
     _health           = Mathf.Clamp(_health + healAmount, 0, _maxHealth);
     HealthPlayer.text = _health.ToString(CultureInfo.InvariantCulture);
     if (slider != null)
     {
         slider.value = _health / _maxHealth;
     }
 }
Exemplo n.º 3
0
        public void ReceiveDamage(float damageAmount, Vector3 hitPosition, GameAgent sender)
        {
            if (ReceiceDamage_ != null)
            {
                ReceiceDamage_(damageAmount);
            }


            _health = Mathf.Clamp(_health - damageAmount, 0, _maxHealth);
            if (_SpaceShip.Agent.AgentFaction == GameAgent.Factions.Player)
            {
                HealthPlayer.text = _health.ToString(CultureInfo.InvariantCulture);
            }

            if (slider != null)
            {
                slider.value = _health / _maxHealth;
            }
            //AddForce(damageAmount, hitPosition);
            if (_health <= 0)
            {
                if (_SpaceShip.Agent.AgentFaction == GameAgent.Factions.Enemies)
                {
                    ManagerEvents.Instance.AddScore(score);
                    ManagerEnemy.Instance.EnemyDie();
                }
                else if (_SpaceShip.Agent.AgentFaction == GameAgent.Factions.Friends)
                {
                    ManagerEvents.Instance.AddScore(-score);
                }
                else if (_SpaceShip.Agent.AgentFaction == GameAgent.Factions.Player)
                {
                    ManagerEvents.Instance.GameLost_();
                }

                Destroy(gameObject);
            }
        }
        public void ReceiveDamage(float damageAmount, Vector3 hitPosition, GameAgent sender)
        {
            _health -= damageAmount;

            if (_health <= 0)
            {
                PoolManager.Instance.Active(0, transform.position);
                Destroy(gameObject);

                if (_smallAsteroid != null && MaxDivisionCounter >= DivisionCounter)
                {
                    var spread = Random.Range(0.5f, 1.5f);

                    var asteroid1 = Instantiate(_smallAsteroid, new Vector3(transform.position.x - spread, transform.position.y - spread, transform.position.z - spread),
                                                Quaternion.identity).GetComponent <AsteroidInteractive>();
                    asteroid1.DivisionCounter = DivisionCounter + 1;

                    var asteroid2 = Instantiate(_smallAsteroid, new Vector3(transform.position.x + spread, transform.position.y + spread, transform.position.z + spread),
                                                Quaternion.identity).GetComponent <AsteroidInteractive>();
                    asteroid2.DivisionCounter = DivisionCounter + 1;
                }
                ManagerEvents.Instance.AddScore(_score);
            }
        }
 public void ReceiveHeal(float healAmount, Vector3 hitPosition, GameAgent sender)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 6
0
 private void Awake()
 {
     gameAgent = transform.GetComponentInParent <GameAgent>();
     Weapons   = GetComponentsInChildren <IWeapon>().ToList();
 }
Exemplo n.º 7
0
 public virtual void OnAgentEnterShip(GameAgent newAgent)
 {
     Agent = newAgent;
 }