Beispiel #1
0
    public void deliverTo(GameObject takeFrom, GameObject bringTo, ressourceStack stack)
    {
        print(this.name + " is delivering to: " + bringTo);

        lastTarget = null;

        if (stack.getAmount() > this.GetComponent <inventory>().maxSize)
        {
            stack.setAmount(this.GetComponent <inventory>().maxSize);
        }

        if (this.GetComponent <inventory>().maxSize - this.GetComponent <inventory>().getAmount() < stack.getAmount())
        {
            Debug.Log("mover is idle and not enough inv space to deliver, emptying now (inv:)" + this.GetComponent <inventory>());
            goToBase();
            target = null;
            return;
        }

        curState = State.ConstructionDelivering;
        this.setTarget(takeFrom);
        deliverTarget = bringTo;
        deliverFrom   = takeFrom;
        delivery      = stack;
        idleTimer     = 0;

        GetComponent <movementController>().setTarget(takeFrom.transform);
    }
Beispiel #2
0
 public void add(ressourceStack stack)
 {
     this.newContent[stack.getRessource()] += stack.getAmount();
 }
Beispiel #3
0
 public void remove(ressourceStack stack)
 {
     newContent[stack.getRessource()] -= stack.getAmount();
 }
Beispiel #4
0
 //checks if there's enough ressources to be taken
 public bool canTake(ressourceStack stack)
 {
     return(newContent[stack.getRessource()] >= stack.getAmount());
 }