Esempio n. 1
0
    //显示士兵信息
    public void showUnitInformation(bool bShowInformation)
    {
        if (selectedUnit == null)
        {
            return;
        }

        if (bShowInformation == true)
        {
            SoldierType.Soldiers thisUnit = selectedUnit.m_pSoldier;
            int maxHP = thisUnit.getMaxHP();
            UIManager.Instance.maxHP.GetComponent <Text>().text = maxHP.ToString();
            int attack = thisUnit.getAttack();
            UIManager.Instance.attackValue.GetComponent <Text>().text = attack.ToString();
            int maxStep = thisUnit.getMaxMoveStep();
            UIManager.Instance.maxMoveStep.GetComponent <Text>().text     = maxStep.ToString();
            UIManager.Instance.soldierTypeName.GetComponent <Text>().text = thisUnit.returnTypeName();
            int currentHP = thisUnit.getCurrentHP();
            UIManager.Instance.currentHP.GetComponent <Text>().text = currentHP.ToString();
            int currentMoveStep = thisUnit.getCurrentMoveStep();
            UIManager.Instance.currentMoveStep.GetComponent <Text>().text = currentMoveStep.ToString();
            UIManager.Instance.soldierTypeImage.sprite = UIManager.Instance.unitSprites[thisUnit.returnSpriteIndex()];
        }
        else
        {
            UIManager.Instance.maxHP.GetComponent <Text>().text           = null;
            UIManager.Instance.attackValue.GetComponent <Text>().text     = null;
            UIManager.Instance.maxMoveStep.GetComponent <Text>().text     = null;
            UIManager.Instance.soldierTypeName.GetComponent <Text>().text = null;
            UIManager.Instance.soldierTypeImage.sprite = UIManager.Instance.noSprite;
            UIManager.Instance.currentMoveStep.GetComponent <Text>().text = null;
            UIManager.Instance.currentHP.GetComponent <Text>().text       = null;
        }
    }
Esempio n. 2
0
 //左键攻击
 void pressLeftMouseButtonToAttack(GameObject enemyObj)
 {
     if (Input.GetMouseButtonUp(0))
     {
         if (enemyObj.GetComponent <Unit>() == null || selectedSoldier.GetComponent <Unit>() == null)
         {
             return;
         }
         SoldierType.Soldiers thisEnemyObj = enemyObj.GetComponent <Unit>().m_pSoldier;
         SoldierType.Soldiers mySoldier    = selectedSoldier.GetComponent <Unit>().m_pSoldier;
         int attack = mySoldier.getAttack();
         Debug.Log("attack: " + attack);
         int defense = thisEnemyObj.getDefense();
         if (defense > 0)
         {
             if (attack > defense)
             {
                 attack -= defense;
                 thisEnemyObj.setDefense(0);
             }
             else
             {
                 attack = 0;
                 thisEnemyObj.modifyDefense(-attack);
             }
         }
         thisEnemyObj.modifyHP(-attack);
         GameObject floatingTextObj = Instantiate(floatingText, enemyObj.transform.position, Quaternion.identity);
         floatingTextObj.GetComponent <TextMesh>().text = "-" + attack.ToString();
         Instantiate(bloodPS, enemyObj.transform.position, Quaternion.identity);
         int selectedSoldierType = selectedSoldier.GetComponent <Unit>().entityType;
         //攻击音效
         if (selectedSoldierType == 1 || selectedSoldierType == 2 || selectedSoldierType == 3)
         {
             SoundEffectManager.Instance.playAudio(5);
         }
         else if (selectedSoldierType == 4)
         {
             SoundEffectManager.Instance.playAudio(8);
         }
         else if (selectedSoldierType == 5 || selectedSoldierType == 7)
         {
             SoundEffectManager.Instance.playAudio(6);
         }
         else if (selectedSoldierType == 6)
         {
             SoundEffectManager.Instance.playAudio(9);
         }
         else if (selectedSoldierType == 8)
         {
             SoundEffectManager.Instance.playAudio(10);
         }
         selectedSoldier.GetComponent <Unit>().m_pSoldier.modifyCurrentMoveStep(-1);
         myCamShakeScript.shake(0.15f, 0.3f);
         //bCancelAttackMode = true;
         // actionModeName = null;
         destroyAttackArrow();
         attackEndFrame = Time.frameCount;
         //Reset();
     }
 }