protected override void OnHitShotBullet(GunSlinger shooter, Gun usedGun, Bullet bullet, Collider2D collider)
    {
        TriggerVolume triggerVolume = collider.gameObject.GetComponent <TriggerVolume>();

        if (triggerVolume != null)
        {
            switch (triggerVolume.type)
            {
            case TriggerVolume.Type.EnemyBarrack:
                //Debug.Log(shooter + " hits EnemyBarrack!");
                bullet.Ricochet();
                break;

            case TriggerVolume.Type.OurBarrack:
                //Debug.Log(shooter + " hits OurBarrack!");
                bullet.Ricochet();
                break;

            default:
                break;
            }
        }
        else
        {
            MyUnit  hittedUnit = collider.gameObject.GetComponent <MyUnit>();
            MyBotAi hittedAi   = collider.gameObject.GetComponent <MyBotAi>();
            if (hittedUnit != null && hittedAi != null && !hittedUnit.IsDead)
            {
                MyUnit  shotUnit = shooter.GetComponent <MyUnit>();
                MyBotAi shotAi   = shooter.GetComponent <MyBotAi>();

                if (shotUnit != null && shotAi != null)
                {
                    if (!shotAi.IsSameSide(hittedAi))
                    {
                        bullet.Ricochet();
                        hittedUnit.TakeDamage(0.5f);
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    IEnumerator PlayerAttack()
    {
        bool isDead = enemyUnit.TakeDamage(playerUnit.damage);

        enemyHUD.SetHp(enemyUnit.currentHP);
        dialogueText.text = "The attack is successful!";

        yield return(new WaitForSeconds(2.0f));

        if (isDead)
        {
            state = MyBattleState.WON;
            EndBattle();
        }
        else
        {
            state = MyBattleState.ENMYTURN;
            StartCoroutine(EnemyAttack());
        }
    }
Exemplo n.º 3
0
    IEnumerator EnemyAttack()
    {
        dialogueText.text = enemyUnit.unitName + " attacks!";
        yield return(new WaitForSeconds(1f));

        bool isDead = playerUnit.TakeDamage(enemyUnit.damage);

        playerHUD.SetHp(playerUnit.currentHP);
        yield return(new WaitForSeconds(1.0f));

        if (isDead)
        {
            state = MyBattleState.LOST;
            EndBattle();
        }
        else
        {
            state = MyBattleState.PLAYERTURN;
            PlayerTurn();
        }
    }