예제 #1
0
    public void InitiateCombat(Territory atkTer, Territory defTer, Player atkPlayer, TerritoryOwner defPlayer)
    {
        float combatDif = atkTer.Atk / defTer.Def;

        if (combatDif <= 0.2)
        {
            GameManager.Instance.ShowMessage("You lose!", 3);
            LoseUnits(atkPlayer);
        }
        else if (combatDif >= 1.5)
        {
            defTer.ChangeOwnership(atkPlayer);
            atkPlayer.fortune = 0;
            GameManager.Instance.ShowMessage("You win!", 3);
        }
        else if (combatDif > 0.2 && combatDif < 1.5)
        {
            float result = Random.Range(0f, 1f);
            Debug.Log(result + atkPlayer.fortune + "/" + combatDif);
            if (result + atkPlayer.fortune >= combatDif)
            {
                defTer.ChangeOwnership(atkPlayer);
                atkPlayer.fortune = 0;
                GameManager.Instance.ShowMessage("You win!", 3);
            }
            else if (result + atkPlayer.fortune < combatDif)
            {
                atkPlayer.fortune += combatDif - result;
                GameManager.Instance.ShowMessage("You lose!", 3);
                LoseUnits(atkPlayer);
            }
        }
        defPlayer.UpdateStats();
        atkPlayer.UpdateStats();
        //atkPlayer.EndStep();
    }
 protected virtual void WinCombat(Territory defTer)
 {
     defTer.ChangeOwnership(owner);
     defTer.units += Mathf.RoundToInt(units / 2);
     units        -= Mathf.RoundToInt(units / 2);
     owner.fortune = 0;
     if (!defTer.isTargetTer)
     {
         GameManager.Instance.ShowMessage("You Win!", 3);
         if (GameManager.Instance.whoseTurn.playerName == "Eye")
         {
             EventManager.Instance.OnStartCombatAnimation("Victory", "attackEye");
         }
         if (GameManager.Instance.whoseTurn.playerName == "Teeth")
         {
             EventManager.Instance.OnStartCombatAnimation("Victory", "attackTeeth");
         }
     }
     else if (defTer.isTargetTer)
     {
         GameManager.Instance.OnGameWin(owner);
     }
 }