Exemple #1
0
 void Take()
 {
     nav.destination = chestPosition;
     if (Vector2.Distance(transform.position, nav.destination) <= actionDist)
     {
         UIText.text = "Looking for resources...";
         anim.SetTrigger("Action");
         int c = chest.DropResource(currentMining, inventory.maxCapacity);
         chest.AddResource(currentMining, inventory.AddResource(currentMining, c));
         if (inventory.GetInventoryValue(currentMining) >= currentNeed)
         {
             UIText.text           = "FAIL : not enought material";
             targetPattern.choosen = false;
             oldPattern            = targetPattern;
             currentState          = defaultState;
             Debug.Log("TAKE -> " + defaultState.ToString());
         }
         else
         {
             UIText.text  = "Can't carry more material";
             currentState = State.POSE;
             Debug.Log("TAKE -> POSE");
         }
     }
 }
 void Pose()
 {
     nav.destination = chest.gameObject.transform.position;
     if (Vector3.Distance(transform.position, nav.destination) <= actionDist)
     {
         Debug.Log("Pose : Depot dans le coffre");
         chest.AddResource(ResourceType.MEAT, inventory.GetInventoryValue(ResourceType.MEAT));
         chest.AddResource(ResourceType.ROCK, inventory.GetInventoryValue(ResourceType.ROCK));
         chest.AddResource(ResourceType.WATER, inventory.GetInventoryValue(ResourceType.WATER));
         chest.AddResource(ResourceType.WOOD, inventory.GetInventoryValue(ResourceType.WOOD));
         currentState = defaultState;
         Debug.Log("Poser -> Attente");
     }
 }
 void Take()
 {
     nav.destination = chestPosition;
     if (Vector3.Distance(transform.position, nav.destination) <= actionDist)
     {
         Debug.Log("Prendre : Recherche dans le coffre");
         int c = chest.DropResource(currentMining, currentNeed);
         inventory.AddResource(currentMining, c);
         if (inventory.GetInventoryValue(currentMining) < currentNeed)
         {
             Debug.Log("Prendre : Pas assez de ressources dans le coffre");
             currentState = State.MINE;
             Debug.Log("Prendre -> Minage");
         }
         if (inventory.IsFull)
         {
             Debug.Log("Prendre : Inventaire plein");
             currentState = State.POSE;
             Debug.Log("Prendre -> Poser");
         }
     }
 }