Example #1
0
 //升级攻击力加5;
 public void addAttack()
 {
     if (selectedSoldier.GetComponent <Unit>() == null || selectedSoldier == null)
     {
         return;
     }
     if (selectedSoldier.GetComponent <Unit>().beenUpgraded == false)
     {
         if (GameManager.Instance.getTurn() == 0)
         {
             if (m_pUnit.getXPToLevelUp() > m_player1.getXP())
             {
                 return;
             }
             else
             {
                 SoldierType.Soldiers mySoldier = selectedSoldier.GetComponent <Unit>().m_pSoldier;
                 mySoldier.modifyAttack(5);
                 selectedSoldier.GetComponent <Unit>().beenUpgraded = true;
                 GameObject popText = Instantiate(floatingText, selectedSoldier.transform.position, Quaternion.identity);
                 popText.GetComponent <TextMesh>().text  = "Attack + 5";
                 popText.GetComponent <TextMesh>().color = Color.white;
                 SoundEffectManager.Instance.playAudio(2);
                 m_player1.modifyXP(-m_pUnit.getXPToLevelUp());
             }
         }
         else if (GameManager.Instance.getTurn() == 1)
         {
             if (m_pUnit.getXPToLevelUp() > m_player2.getXP())
             {
                 return;
             }
             else
             {
                 SoldierType.Soldiers mySoldier = selectedSoldier.GetComponent <Unit>().m_pSoldier;
                 mySoldier.modifyAttack(5);
                 selectedSoldier.GetComponent <Unit>().beenUpgraded = true;
                 GameObject popText = Instantiate(floatingText, selectedSoldier.transform.position, Quaternion.identity);
                 popText.GetComponent <TextMesh>().text  = "Attack + 5";
                 popText.GetComponent <TextMesh>().color = Color.white;
                 SoundEffectManager.Instance.playAudio(2);
                 m_player1.modifyXP(-m_pUnit.getXPToLevelUp());
             }
         }
     }
 }