Ejemplo n.º 1
0
    void PlayerAttacksNPC(GameObject aiUnit)
    {   // Player Attacks NPC pointed by mouse click
        //Debug.Log("Player attacking NPC........");
        //PlayerCombat.SetStats(soldier.Unit.GetAttack(), soldier.Unit.GetDefense, target.Unit.GetAttack(), target.Unit.GetDefense); FIX LATER*****
        PlayerCombat pc = new PlayerCombat();

        //pc.SetStats(5, 5, 5, 5);

        if (aiUnit == null)
        {
            return;                 // When enemy is destroyed
        }
        int dmg = pc.AttackPhase(true, this.GetComponent <Unit>().GetAttack(), this.GetComponent <Unit>().GetDefense(), aiUnit.GetComponent <Unit>().GetAttack(), aiUnit.GetComponent <Unit>().GetDefense());

        aiUnit.GetComponent <Unit>().TakeDmg(dmg);
        Debug.Log("Player hits for: " + dmg);
        Debug.Log("Player has: " + this.GetComponent <Unit>().GetHealth());

        attacking           = false;
        willAttackAfterMove = false;

        StartCoroutine(WaitTime(1.0f));
        //Debug.Log("I done waited");
        //TurnManager.EndTurn();
    }
Ejemplo n.º 2
0
    void NPCAttacksPlayer(GameObject playerUnit)
    {
        if (playerUnit == null)
        {
            return;
        }
        animateAttack = true;

        PlayerCombat pc = new PlayerCombat();

        int dmg = pc.AttackPhase(true, this.GetComponent <Unit>().GetAttack(), this.GetComponent <Unit>().GetDefense(), playerUnit.GetComponent <Unit>().GetAttack(), playerUnit.GetComponent <Unit>().GetDefense());

        playerUnit.GetComponent <Unit>().TakeDmg(dmg);
        Debug.Log("NPC hits for: " + dmg);
        Debug.Log("Player has: " + this.GetComponent <Unit>().GetHealth());
        attacking           = false;
        willAttackAfterMove = false;
        NPC_WillAttack      = false;
        TurnManager.EndTurn();
    }