Пример #1
0
 public void MoveUnitToPOI(POI targetPOI)
 {
     if (player.GetComponent <Player>().CurrentPOI.GetComponent <POI>().ConnectedNodes.Contains(targetPOI))
     {
         if (player.GetComponent <Player>().Resource >= targetPOI.GetComponent <POI>().PathCost)
         {
             gamestate = GameStates.PlayerMovement;
             player.GetComponent <Player>().visitedNodes.Add(player.GetComponent <Player>().CurrentPOI);
             player.gameObject.transform.DOMove(targetPOI.transform.position, 2).OnComplete(() => MovementCompleted(targetPOI));
         }
         else
         {
             Debug.Log("Not Enough Resources!");
             CheckVictory();
         }
     }
     else
     {
         Debug.Log("Nodes have no connection!");
     }
 }
Пример #2
0
 private void MovementCompleted(POI targetPOI)
 {
     player.GetComponent <Player>().CurrentPOI = targetPOI.gameObject;
     player.GetComponent <Player>().Resource   = player.GetComponent <Player>().Resource - targetPOI.GetComponent <POI>().PathCost;
     CheckVictory();
     RevealNeighbours(player.GetComponent <Player>().CurrentPOI);
     targetPOI.gameObject.GetComponent <Renderer>().material.color = Color.yellow;
     if (targetPOI.RandomEvent != false && targetPOI.Events.Count > 0 && player.GetComponent <Player>().CurrentPOI != MG.endPOI)
     {
         targetPOI.RandomEvent = false;
         LaunchEvent(targetPOI.Events[0]);
     }
     else
     {
         gamestate = GameStates.GlobalMap;
         UpdateResources();
     }
 }