Ejemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        var bullet = col.gameObject.GetComponent <Bullet>();

        if (bullet && bullet.Team != team)
        {
            tankHealth.TakeDamage(bullet.attack);
            HandleHpChange?.Invoke(this, tankHealth.GetCurrentHealth());
            if (tankHealth.GetCurrentHealth() <= 0)
            {
                Destroy(this.gameObject);
            }
        }
    }
Ejemplo n.º 2
0
    void Awake()
    {
        tankInput      = new PlayerControlInput();
        tankEngine     = new TankEngine(tankInput, this.transform, property);
        tankHeadRotate = new TankHeadRotate(tankInput, tankHead, property);
        tankFire       = new TankFire(tankInput, tankShootPoint, property, fireAnimator, team);
        tankHealth     = new TankHealth(property);

        HandleHpChange?.Invoke(this, tankHealth.GetCurrentHealth());
    }
Ejemplo n.º 3
0
    private void OnCollisionEnter2D(Collision2D col)
    {
        var bullet = col.gameObject.GetComponent <Bullet>();

        if (bullet && bullet.Team != Team)
        {
            tankHealth.TakeDamage(bullet.attack);
            EnemyHpChange?.Invoke(this, tankHealth.GetCurrentHealth());
        }
    }