Пример #1
0
    public void Attack()
    {
        AbstractEnemy enemy    = enemySelected != null ? enemySelected : enemyAggro;
        float         distance = Vector3.Distance(transform.position, enemy.transform.position);

        if (distance <= rangePunch)
        {
            if (!canPunch)
            {
                return;
            }
            cooldownPunch = delayPunch;
            enemy.TakeDamage(damagePunch);
            Debug.Log("Punch !!!");
        }
        else if (distance <= rangeShot)
        {
            if (!canShot)
            {
                return;
            }
            cooldownShot = delayShot;
            var shot = Instantiate(ammo, transform.position, Quaternion.identity).GetComponent <Shot>();
            shot.SetDirection(transform.forward, Shot.Emetteur.player);
            Debug.Log("Shot !");
        }
    }
Пример #2
0
        public override void OnCollision(ICollidable obj, Direction dir, World world)
        {
            if (obj is Realm.Blocks.Block)
            {
                switch (dir)
                {
                case Direction.Down:
                    Velocity = new Vector2(Velocity.X, Y_VELOCITY);
                    break;

                case Direction.Up:
                    Velocity = new Vector2(Velocity.X, -Y_VELOCITY);
                    break;

                case Direction.Left:
                case Direction.Right: Kill(); break;
                }
            }
            else if (obj is AbstractEnemy && (obj as AbstractEnemy).IsAlive)
            {
                AbstractEnemy enemy = (AbstractEnemy)obj;
                enemy.TakeDamage();
                Kill();
                world.EarnPoints(100);
            }
        }
Пример #3
0
 public override void OnCollision(ICollidable obj, Direction dir, World world)
 {
     if (obj is Realm.Blocks.Block)
     {
         Kill();
     }
     else if (obj is AbstractEnemy && (obj as AbstractEnemy).IsAlive)
     {
         AbstractEnemy enemy = (AbstractEnemy)obj;
         enemy.TakeDamage();
         Kill();
         world.EarnPoints(100);
     }
 }
Пример #4
0
 private void OnTriggerEnter2D(Collider2D hitInfo)
 {
     if (hitInfo.CompareTag("Enemigo"))
     {
         Enemigo = hitInfo.GetComponent <AbstractEnemy>();
         Enemigo.TakeDamage(damage);
         _audio.InpactoBellota();
         Destroy(gameObject);
     }
     else if (hitInfo.CompareTag("Boss"))
     {
         Boss = hitInfo.GetComponent <BossFightController>();
         Boss.TakeDmg(damage);
         Destroy(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }