Exemplo n.º 1
0
    //关卡开始时初始化所有行动单元,赋予速度
    public void initAction(List <BattleRoleData> allUnits)
    {
        stopAction();
        foreach (Transform t in actionUnitParent)
        {
            Destroy(t.gameObject);
        }
        //
        standardSpeedArray = new int[allUnits.Count];
        allActionUnits     = new List <ActionRoleData>();
        for (int i = 0; i < allUnits.Count; i++)
        {
            BattleRoleData BUnit      = allUnits[i];
            Transform      actionUnit = Instantiate(actionUnitPrefab) as Transform;
            actionUnit.SetParent(actionUnitParent);
            actionUnit.GetComponent <ActionRoleData>().nameText.text = BUnit.name;
            ActionRoleData unit = actionUnit.GetComponent <ActionRoleData>();
            //
            int speed = BUnit.ThisBasicRoleProperty()._role.ReadCurrentRoleRA(AttributeData.Speed);
            standardSpeedArray[i] = speed;
            unit.speed            = speed;
            //
            //actionUnit.GetComponent<Canvas>().sortingOrder = i;
            if (BUnit._Tag == SDConstants.CharacterType.Enemy)
            {
                actionUnit.position = startEnemyPos.position;
                unit.isEnemy        = true;
                if (BUnit.IsBoss)
                {
                    unit.headImage.initCharacterModelById
                        (BUnit.UnitId, SDConstants.CharacterAnimType.Enemy, 0.15f, true);
                }
                else
                {
                    unit.headImage.initCharacterModelById
                        (BUnit.UnitId, SDConstants.CharacterAnimType.Enemy, 0.3f, true);
                }
            }
            else
            {
                actionUnit.position = startHeroPos.position;
                unit.isEnemy        = false;
                int    hashcode = BUnit.unitHashcode;
                string heroId   = SDDataManager.Instance.getHeroIdByHashcode(hashcode);
                SDConstants.CharacterAnimType type
                    = (SDConstants.CharacterAnimType)
                          (SDDataManager.Instance.getHeroCareerById(heroId));
                //unit.headImage.initCharacterModel(hashcode, type, 3f);
            }
            actionUnit.localScale = Vector3.one;
            if (BUnit.ReadThisStateEnable(StateTag.Dizzy))
            {
                unit.stateBgImage.sprite = unit.stateSprites[1];
            }
            else
            {
                unit.stateBgImage.sprite = unit.stateSprites[0];
            }
            unit.battleUnit = BUnit;
            unit.isActed    = false;
            allActionUnits.Add(unit);
            if (BUnit.IsDead)
            {
                actionUnit.gameObject.SetActive(false);
            }
        }

        BuildABMoveSpeed(allActionUnits);
        //BM.NextActionUnit();
        startAction();
    }
Exemplo n.º 2
0
 public void NextActionUnit()
 {
     if (Remaining_ORL.Count == 0)
     {
         return;
     }
     if (Remaining_SRL.Count == 0)
     {
         return;
     }
     if (_currentBattleUnit != null)
     {
         _currentBattleUnit.actionSign.gameObject.SetActive(false);
     }
     _currentBattleUnit = All_Array[0];
     All_Array.Remove(_currentBattleUnit);
     All_Array.Add(_currentBattleUnit);
     if (_currentBattleUnit.IsDead)
     {
         NextActionUnit();
         return;
     }
     if (_currentBattleUnit.ReadThisStateEnable(StateTag.Dizzy))
     {
         _currentBattleUnit.CheckStates();
         if (SDGameManager.Instance.isFastModeEnabled)
         {
             NextActionUnit();
         }
         return;
     }
     _currentBattleUnit.actionSign.gameObject.SetActive(true);
     _currentActionPanel = _currentBattleUnit.APC;
     checkCurrentUnitTag();
     //
     _currentBattleUnit.CheckStates();//计算角色状态对其影响
     if (_currentBattleUnit.IsDead)
     {
         NextActionUnit();
         return;//重新进行死亡判断
     }
     if (_currentBUType != SDConstants.CharacterType.Enemy)
     {
         if (SDDataManager.Instance.SettingData.isAutoBattle)
         {
             _currentActionPanel.chooseRandomSkillFromGroup();
             chooseAutoBattleTarget();
             handleAction();
         }
         else
         {
             SDGameManager.Instance.isUsingProp = false;
             //
             IsWaitingPlayerAction = true;
             //显示全部可用交互
             _currentActionPanel.showActionPanel();
             //UsingPropBtn.interactable = true;
             CancelBtn.interactable = true;
         }
     }
     else
     {
         _currentActionPanel.showActionPanel();
         _currentActionPanel.chooseASkillFromSkillGroup();
         chooseRandomHeroToAttack();
         handleAction();
     }
     currentTouchId   = -1;
     confirmSkillStep = 0;
 }