// my classes public void TakeAction(WorkerNPC npc) { Debug.Log("Perform Action... custom to each "); workerScript = npc; if (tree) { Debug.Log("Chop the tree"); treeScript.Chop(); } else if (strut) { Debug.Log("Build the strut"); if (npc.hasResource) { strutScript.Build(npc); } else { npc.FetchResource(); } } else if (channelBuilder) { Debug.Log("Construct the channel"); if (npc.hasResource) { channelBuilderScript.Build(npc); } else { npc.FetchResource(); } } else if (channel) { Debug.Log("Build the channel"); // no resources needed to erect a channel channelScript.Build(npc); } else if (windmill) { Debug.Log("Build the windmill"); } else if (waterWheel) { Debug.Log("Build the waterWheel"); } }
IEnumerator BuildStrut(WorkerNPC npc) { yield return(new WaitForSeconds(workTime)); Debug.Log("Built the strut"); transform.position = new Vector3(transform.position.x, transform.position.y + heightIncrease, transform.position.z); if (!groundStructureScript.groundPlatform.struts.Contains(this)) { groundStructureScript.groundPlatform.struts.Add(this); } npc.hasResource = false; npc.FetchResource(); }
IEnumerator ConstructChannel(WorkerNPC npc) { yield return(new WaitForSeconds(workTime)); amountPaid++; Debug.Log("Built section of the channel"); npc.hasResource = false; if (amountPaid >= cost) { Debug.Log("Completed a channel"); amountPaid = 0; GameObject builtChannel = (GameObject)Instantiate(channelPrefab, transform.position, Quaternion.identity); groundStructureScript.groundPlatform.structures.Add(builtChannel.GetComponent <GroundStructure>()); } else { Debug.Log("Still building a channel"); } npc.FetchResource(); }