Example #1
0
 void AddToGroundPlatformList(Ground groundPlatform)
 {
     if (npc)
     {
         WorkerNPC npcScript = GetComponent <WorkerNPC>();
         if (!groundPlatform.workers.Contains(npcScript))
         {
             groundPlatform.ResetResourceFetching();
             groundPlatform.workers.Add(npcScript);
         }
     }
     else if (structure)
     {
         GroundStructure groundStructureScript = GetComponent <GroundStructure>();
         groundStructureScript.Landed();
         if (!groundPlatform.structures.Contains(groundStructureScript))
         {
             groundPlatform.ResetResourceFetching();
             groundPlatform.structures.Add(groundStructureScript);
         }
     }
     else if (resource)
     {
         ProcessedResource processedResourceScript = GetComponent <ProcessedResource>();
         if (!groundPlatform.resources.Contains(processedResourceScript))
         {
             groundPlatform.ResetResourceFetching();
             groundPlatform.resources.Add(processedResourceScript);
         }
     }
 }
Example #2
0
    void Update()
    {
        if (chopped)
        {
            float angle = Mathf.Lerp(transform.rotation.z, 90, (elapsedTime / timeToFall));
            transform.rotation = Quaternion.Euler(new Vector3(-180, 0, angle));
            elapsedTime       += Time.deltaTime;
            if (elapsedTime >= timeToFall)
            {
                elapsedTime = 0.0f;
                chopped     = false;
                regrowing   = true;

                GameObject        producedResource = (GameObject)Instantiate(processedResourcePrefab, transform.position, Quaternion.identity);
                ProcessedResource resourceScript   = producedResource.GetComponent <ProcessedResource>();
                groundStructureScript.groundPlatform.resources.Add(resourceScript);

                groundStructureScript.FinishAction();

                gameObject.SetActive(false);                // don't want workerNPC to think its found another structure // activate later when regrown
            }
        }
    }