示例#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");
         }
     }
 }
示例#2
0
    void Build()
    {
        Pattern p = target.GetComponent <Pattern>();

        p.choosen = true;
        if (inventory.GetInventoryValue(p.type) < p.quantity)
        {
            Debug.Log("Construction : Pas assez de ressource");
            currentMining = p.type;
            currentNeed   = p.quantity;
            currentState  = State.TAKE;
            Debug.Log("Construction -> Prendre");
        }
        else
        {
            Debug.Log("Construction : Deplacement");
            nav.destination = target.transform.position;
            if (Vector3.Distance(transform.position, nav.destination) <= actionDist)
            {
                Debug.Log("Construction : Construction");
                p.DoAction(this.gameObject);
                currentState = defaultState;
                Debug.Log("Construction -> Attente");
            }
        }
    }
示例#3
0
 bool canConstruct()
 {
     if (chest.GetInventoryValue(ResourceType.MEAT) < meatNeed)
     {
         return(false);
     }
     if (chest.GetInventoryValue(ResourceType.ROCK) < rockNeed)
     {
         return(false);
     }
     if (chest.GetInventoryValue(ResourceType.WOOD) < woodNeed)
     {
         return(false);
     }
     if (chest.GetInventoryValue(ResourceType.WATER) < waterNeed)
     {
         return(false);
     }
     return(true);
 }