Пример #1
0
        public bool SelectRandomAvailableUnit()
        {
            List <int> availableIDList = new List <int>();

            for (int i = 0; i < allUnitList.Count; i++)
            {
                if (!allUnitList[i].IsAllActionCompleted() && !allUnitList[i].IsStunned())
                {
                    availableIDList.Add(i);
                }
            }

            if (availableIDList.Count > 0)
            {
                selectedUnitID = availableIDList[Random.Range(0, availableIDList.Count)];
                Debug.Log("selectedUnitID " + selectedUnitID);
                if (allUnitList[selectedUnitID].isAIUnit)
                {
                    AIManager.MoveUnit(allUnitList[selectedUnitID]);
                }
                else
                {
                    GameControl.SelectUnit(allUnitList[selectedUnitID], false);
                }
                //GameControl.SelectUnit(allUnitList[selectedUnitID]);
                return(true);
            }

            GameControl.ClearSelectedUnit();

            return(false);
        }
Пример #2
0
        //for FactionPerTurn mode, breakWhenExceedLimit is set to true, where selectUnitID resets when it reachs end
        //for FactionUnitPerTurn mode, breakWhenExceedLimit is set to false, where selectUnitID loops forever
        public bool SelectNextUnitInQueue(bool breakWhenExceedLimit = false)
        {
            //if(TurnControl.GetMoveOrder()==_MoveOrder.Free) return true;

            selectedUnitID += 1;

            //skipped stunned unit
            //while(allUnitList[selectedUnitID].IsStunned()){
            //	selectedUnitID+=1;
            //	if(selectedUnitID>=allUnitList.Count) break;
            //}
            if (selectedUnitID >= allUnitList.Count)
            {
                if (breakWhenExceedLimit)                       //for FactionPerTurn mode, reset the ID
                {
                    selectedUnitID = -1;
                    return(true);
                }
                selectedUnitID = 0;
            }

            if (TurnControl.GetTurnMode() != _TurnMode.FactionPerTurn)
            {
                bool isUnitActive = allUnitList[selectedUnitID].NewTurn();                      //in case unit is destroyed by damage over time effect
                if (!isUnitActive)
                {
                    return(SelectNextUnitInQueue());
                }
            }

            if (allUnitList[selectedUnitID].isAIUnit)
            {
                AIManager.MoveUnit(allUnitList[selectedUnitID]);
            }
            else
            {
                GameControl.SelectUnit(allUnitList[selectedUnitID], false);
            }

            return(false);
        }
Пример #3
0
		public void _EndTurn_UnitPerTurn(){
			selectedUnitID+=1;
			if(selectedUnitID>=allUnitList.Count) selectedUnitID=0;
			
			selectedFactionID=allUnitList[selectedUnitID].factionID;
			
			bool isUnitActive=allUnitList[selectedUnitID].NewTurn();	//in case unit is destroyed by damage over time effect
			if(isUnitActive){
				// Debug.LogWarning(allUnitList[selectedUnitID].unitName + " "  + allUnitList[selectedUnitID].canDrawCards);
				if (allUnitList[selectedUnitID].canDrawCards) {
					Unit.AbilitySelection abilitySelection = Unit.DrawCard(allUnitList.Where(u => u.factionID == selectedFactionID).ToList());
					if (abilitySelection != null){
						abilitySelection.cardOwner.AddAbility(abilitySelection.abilityId);
					}
				}
			} else {
				_EndTurn_UnitPerTurn();
				return;
			}
			
			if(allUnitList[selectedUnitID].isAIUnit) AIManager.MoveUnit(allUnitList[selectedUnitID]);
			else GameControl.SelectUnit(allUnitList[selectedUnitID], false);
		}