Exemple #1
0
    IEnumerator OffloadAtDocks()
    {
        yield return(new WaitForSeconds(kingScript.offloadTime));

        kingScript.availableResources [carriedResourceIndex]++;
        carryingResource = false;

        // This is responsible for instantiating the resource object and positioning it properly at the docks
        kingScript.CreateAndPositionResource(carriedResourceIndex);

        // instantiating resource object
//		if (carriedResourceIndex == 0) {
//			GameObject foodResource = (GameObject)Instantiate(kingScript.foodResourcePrefab, kingScript.foodResourceStore.position, Quaternion.identity);
//		}else if (carriedResourceIndex == 1){
//			GameObject woodResource = (GameObject)Instantiate(kingScript.woodResourcePrefab, kingScript.woodResourceStore.position, Quaternion.identity);
//		}else if (carriedResourceIndex == 2){
//			GameObject stoneResource = (GameObject)Instantiate(kingScript.stoneResourcePrefab, kingScript.stoneResourceStore.position, Quaternion.identity);
//		}

        kingScript.CheckResourceArrived();         // activate builder at front of queue to check and see if his resource has arrived, if not then go to the back of the queue
        GoToWorkPlatformPeasant();
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

        // RESOURCE SENSING

        if (Input.GetKeyDown("down"))
        {
            if (currentInventory < maxInventory)
            {
//				Debug.Log ("Pick up NPC or resource");
                // picking up resource takes priority over NPC, because itherwise may interrupt NPC from doing work
                if (canLoadFood && currentKingScript.availableResources[0] > 0)
                {
//					Debug.Log("Pick up FOOD");
                    inventoryResources[0]++;
                    currentKingScript.availableResources[0]--;
                    currentKingScript.RemoveAndPositionResource(0);
                    currentInventory++;
                }
                else if (canLoadWood && currentKingScript.availableResources[1] > 0)
                {
//					Debug.Log("Pick up WOOD");
                    inventoryResources[1]++;
                    currentKingScript.availableResources[1]--;
                    currentKingScript.RemoveAndPositionResource(1);
                    currentInventory++;
                }
                else if (canLoadStone && currentKingScript.availableResources[2] > 0)
                {
//					Debug.Log("Pick up STONE");
                    inventoryResources[2]++;
                    currentKingScript.availableResources[2]--;
                    currentKingScript.RemoveAndPositionResource(2);
                    currentInventory++;
                }
                else if (npcsInRange.Count > 0)
                {
                    passengers.Add(npcsInRange[npcsInRange.Count - 1]);
                    npcsInRange[npcsInRange.Count - 1].PickUp();
                    currentInventory++;
                }
            }
            else
            {
                Debug.Log("Inventory full");
            }
        }

        if (Input.GetKeyDown("up"))
        {
            if (canLoadFood && inventoryResources[0] > 0)
            {
//				Debug.Log("Drop off FOOD");
                inventoryResources[0]--;
                currentInventory--;
                currentKingScript.availableResources[0]++;
                currentKingScript.CreateAndPositionResource(0);
                currentKingScript.CheckResourceArrived();                 // activate builder at front of queue to check and see if his resource has arrived, if not then go to the back of the queue
            }
            else if (canLoadWood && inventoryResources[1] > 0)
            {
//				Debug.Log("Drop off WOOD");
                inventoryResources[1]--;
                currentInventory--;
                currentKingScript.availableResources[1]++;
                currentKingScript.CreateAndPositionResource(1);
                currentKingScript.CheckResourceArrived();                 // activate builder at front of queue to check and see if his resource has arrived, if not then go to the back of the queue
            }
            else if (canLoadStone && inventoryResources[2] > 0)
            {
//				Debug.Log("Drop off STONE");
                inventoryResources[2]--;
                currentInventory--;
                currentKingScript.availableResources[2]++;
                currentKingScript.CreateAndPositionResource(2);
                currentKingScript.CheckResourceArrived();                 // activate builder at front of queue to check and see if his resource has arrived, if not then go to the back of the queue
            }
            else if (passengers.Count > 0 && currentKingScript != null)
            {
                NPC droppedOffNPC = passengers[passengers.Count - 1];
                droppedOffNPC.gameObject.SetActive(true);
                droppedOffNPC.DropOff(currentKingScript.foodResourceStore.position, currentKingScript);                // Drop NPC off at specific position on teh docks... food point for now
                passengers.RemoveAt(passengers.Count - 1);
                currentInventory--;
            }
            else
            {
                Debug.Log("Haven't got any NPCs in the inventory... or there's no currentKingScript");
            }
        }

        transform.Translate(new Vector3(0.3f * input.x, 0, 0));
    }