Exemplo n.º 1
0
		void _SetupFaction(){
			for(int i=0; i<factionList.Count; i++){
				if(factionList[i].isPlayerFaction){
					playerFactionIDList.Add(factionList[i].ID);
					
					for(int n=0; n<factionList[i].allUnitList.Count; n++){
						UpdateHostileUnitTriggerStatus(factionList[i].allUnitList[n]);
					}
				}
				
				if(TurnControl.GetTurnMode()!=_TurnMode.UnitPerTurn){
					if(TurnControl.GetMoveOrder()!=_MoveOrder.Random){
						factionList[i].allUnitList=ArrangeUnitListToMovePriority(factionList[i].allUnitList);
					}
				}
				
				factionList[i].NewTurn(true);	//pass true to call new turn on all unit
				//for(int n=0; n<factionList[i].allUnitList.Count; n++) factionList[i].allUnitList[n].ResetUnitTurnData();
				
				totalUnitCount+=factionList[i].allUnitList.Count;
			}
			
			if(factionList.Count==playerFactionIDList.Count) hasAIInGame=false;
			
			Debug.Log("SetupFaction  "+TurnControl.GetTurnMode());
			if(TurnControl.GetTurnMode()==_TurnMode.UnitPerTurn){
				for(int i=0; i<factionList.Count; i++){
					for(int n=0; n<factionList[i].allUnitList.Count; n++) allUnitList.Add(factionList[i].allUnitList[n]);
				}
				
				allUnitList=ArrangeUnitListToMovePriority(allUnitList);
				Debug.Log("SetupFaction  allUnitList");
			}
			
		}
Exemplo n.º 2
0
		public void _EndTurn_FactionUnitPerTurn(){
			selectedFactionID+=1;
			if(selectedFactionID>=factionList.Count) selectedFactionID=0;
			if(TurnControl.GetMoveOrder()==_MoveOrder.Free){
				factionList[selectedFactionID].NewTurn(true);	//enabled if there's no need to cycle through all unit
				factionList[selectedFactionID].SelectRandomAvailableUnit();
			}
			else factionList[selectedFactionID].SelectNextUnitInQueue();
		}
Exemplo n.º 3
0
		public void _UnitTurnPriorityChanged(List<int> facIDList){
			if(TurnControl.GetTurnMode()==_TurnMode.UnitPerTurn){
				allUnitList=ArrangeUnitListToMovePriority(allUnitList);
			}
			else if(TurnControl.GetMoveOrder()!=_MoveOrder.Random){
				for(int i=0; i<factionList.Count; i++){
					if(facIDList.Contains(factionList[i].ID)){
						factionList[i].allUnitList=ArrangeUnitListToMovePriority(factionList[i].allUnitList);
					}
				}
			}
		}
Exemplo n.º 4
0
		public void _EndTurn_FactionPerTurn(){
			GameControl.ClearSelectedUnit();
			
			selectedFactionID+=1;
			if(selectedFactionID>=factionList.Count) selectedFactionID=0;
			factionList[selectedFactionID].NewTurn(true);
			
			if(factionList[selectedFactionID].isPlayerFaction){	//if it's a player's faction, select a unit
				if(TurnControl.GetMoveOrder()==_MoveOrder.Free) _SelectNextUnitInFaction_Free();
				else _SelectNextUnitInFaction_NotFree();
			}
			else{															//if it's a AI's faction, execute AI move
				if(TurnControl.GetMoveOrder()==_MoveOrder.Free) AIManager.MoveFaction(factionList[selectedFactionID]);
				else _SelectNextUnitInFaction_NotFree();
			}
		}
Exemplo n.º 5
0
 public static bool CanSelectUnit(Unit unit)
 {
     if (TurnControl.GetMoveOrder() != _MoveOrder.Free)
     {
         return(false);
     }
     if (TurnControl.GetTurnMode() == _TurnMode.FactionUnitPerTurn && TurnControl.HasMoved())
     {
         return(false);
     }
     if (TurnControl.GetTurnMode() == _TurnMode.UnitPerTurn)
     {
         return(false);
     }
     if (FactionManager.GetSelectedFactionID() != unit.factionID)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 6
0
        //called by FactionManager.SelectNextFaction in FactionPerTurn mode (resetSelectedID=true)
        public void NewTurn(bool processUnit = false)
        {
            selectedUnitID = -1;
            movedUnitList  = new List <Unit>();

            if (abilityInfo != null)
            {
                abilityInfo.energy = Mathf.Min(abilityInfo.energy + abilityInfo.energyGainPerTurn, abilityInfo.energyFull);
            }

            if (processUnit)
            {
                for (int i = 0; i < allUnitList.Count; i++)
                {
                    allUnitList[i].NewTurn();
                }
            }

            if (TurnControl.GetTurnMode() == _TurnMode.UnitPerTurn)
            {
                return;
            }

            if (TurnControl.GetMoveOrder() == _MoveOrder.Random)
            {
                //random order, shuffle the unit order
                List <Unit> newList = new List <Unit>();
                while (allUnitList.Count > 0)
                {
                    int rand = Random.Range(0, allUnitList.Count);
                    newList.Add(allUnitList[rand]);
                    allUnitList.RemoveAt(rand);
                }
                allUnitList = newList;
            }
        }