コード例 #1
0
        /// <summary>
        /// Updates the creature behaviour.
        /// </summary>
        public override void Update()
        {
            if (OwningCreatureAI.reachedEndOfPath && !IsDone && OwningCreatureAI.CreatureStats.IsDrinkFull())
            {
                OwningCreatureAI.SetAnimation("Idle");
                Done();
            }
            else if (!IsDone)
            {
                if (DrinkTimer >= 1)
                {
                    if (OwningCreatureAI.GetCurrentAnimation().AnimationName != "Extracting")
                    {
                        OwningCreatureAI.SetAnimation("Extracting");
                    }

                    OwningCreatureAI.CreatureStats.AddDrink(10);
                    DrinkTimer = 0;
                }
                else
                {
                    DrinkTimer += Time.deltaTime;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Starts the execution of the creature behaviour.
        /// </summary>
        public override void Start()
        {
            Vector3 coord = Vector3.zero;

            if (FindClosestPathToBuildingOfType <Bonfire>(out coord, out m_Bonfire))
            {
                OwningCreatureAI.SetAnimation("Moving");
                OwningCreatureAI.destination = coord;
            }
        }
コード例 #3
0
        /// <summary>
        /// Updates the creature behaviour.
        /// </summary>
        public override void Update()
        {
            if (OwningCreatureAI.GetCurrentAnimation().AnimationName != "Moving")
            {
                OwningCreatureAI.SetAnimation("Moving");
            }

            if (OwningCreatureAI.reachedEndOfPath && !IsDone)
            {
                Done();
            }
        }
コード例 #4
0
        /// <summary>
        /// Updates the creature behaviour.
        /// </summary>
        public override void Update()
        {
            if (OwningCreatureAI.reachedEndOfPath && !IsDone && OwningCreatureAI.CreatureStats.IsFoodFull())
            {
                OwningCreatureAI.SetAnimation("Idle");
                if (m_CurrentResourceSource != null)
                {
                    m_CurrentResourceSource.m_WorkedByVillager = null;
                }
                Done();
            }
            else if (!IsDone && m_CurrentResourceSource != null)
            {
                if (EatTimer >= 1)
                {
                    if (m_CurrentResourceSource != null)
                    {
                        if (m_CurrentResourceSource.ExtractResource(1).Value != 0)
                        {
                            OwningCreatureAI.CreatureStats.AddFood(10);
                            EatTimer = 0;
                        }
                    }
                }
                else
                {
                    EatTimer += Time.deltaTime;
                }
            }
            else
            {
                List <ResourceSource> rs = PlanetDatalayer.Instance.GetManager <ResourceManager>().GetResourceSourcesInArea(new Rect(OwningCreatureAI.transform.position.x - 2, OwningCreatureAI.transform.position.z - 2, 4, 4), Resources.ResourceType.Food);
                if (rs.Count > 0)
                {
                    m_CurrentResourceSource = rs[0];
                }
                else
                {
                    m_Tries++;
                }

                if (m_Tries >= 3)
                {
                    OwningCreatureAI.SetAnimation("Idle");
                    if (m_CurrentResourceSource != null)
                    {
                        m_CurrentResourceSource.m_WorkedByVillager = null;
                    }

                    Done();
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Collision Event
 /// </summary>
 /// <param name="collision">The collision triggering the event.</param>
 protected override void OnCollisionExit(Collision collision)
 {
     if (m_CurrentResourceSource == null)
     {
         ResourceSourceWrapper resourceSource = collision.gameObject.GetComponent <ResourceSourceWrapper>();
         if (resourceSource == null)
         {
             OwningCreatureAI.SetAnimation("Idle");
             Done();
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// Starts the execution of the creature behaviour.
        /// </summary>
        public override void Start()
        {
            Vector3 coord = Vector3.zero;

            if (FindClosestPathToResource(m_TargetResourceType, out coord))
            {
                OwningCreatureAI.SetAnimation("Moving");
                OwningCreatureAI.destination = coord;
            }
            else
            {
                OwningCreatureAI.SetAnimation("Idle");
                Done();
            }
        }
コード例 #7
0
        /// <summary>
        /// Starts the execution of the creature behaviour.
        /// </summary>
        public override void Start()
        {
            m_StartPos = OwningCreatureAI.position;
            Vector3 coord = Vector3.zero;

            if (FindClosestPathToBuildingOfType <T>(out coord, out TargetBuilding))
            {
                OwningCreatureAI.SetAnimation("Moving");
                OwningCreatureAI.destination = coord;
            }
            else
            {
                OwningCreatureAI.SetAnimation("Idle");
                Done();
            }
        }
コード例 #8
0
        /// <summary>
        /// Updates the creature behaviour.
        /// </summary>
        public override void Update()
        {
            if (OwningCreatureAI.reachedEndOfPath && !IsDone && (m_CurrentResourceSource == null || IsInventoryFull()))
            {
                if (m_CurrentResourceSource != null)
                {
                    m_CurrentResourceSource.m_WorkedByVillager = null;
                }
                Done();
            }
            else if (OwningCreatureAI.reachedEndOfPath && !IsDone && (m_CurrentResourceSource != null && !IsInventoryFull()))
            {
                if (OwningCreatureAI.GetCurrentAnimation().AnimationName != "Extracting")
                {
                    OwningCreatureAI.SetAnimation("Extracting");
                }

                if (ExtractTimer >= 1)
                {
                    if (m_CurrentResourceSource != null)
                    {
                        if (m_CurrentResourceSource.ExtractResource(1).Value != 0)
                        {
                            ((VillagerAI)OwningCreatureAI).GetVillagerStats().VillagerInventory.AddResource(m_TargetResourceType, 1);
                            PlanetDatalayer.Instance.GetManager <FoMManager>().IncreaseFoM(PlanetDatalayer.Instance.GetManager <VillagerManager>().m_VillagerList.IndexOf((VillagerAI)OwningCreatureAI), 1);
                            ExtractTimer = 0;
                        }
                    }
                }
                else
                {
                    ExtractTimer += Time.deltaTime;
                }
            }
            else
            {
                List <ResourceSource> rs = PlanetDatalayer.Instance.GetManager <ResourceManager>().GetResourceSourcesInArea(new Rect(OwningCreatureAI.transform.position.x - 2, OwningCreatureAI.transform.position.z - 2, 4, 4), m_TargetResourceType);
                if (rs.Count > 0)
                {
                    m_CurrentResourceSource = rs[0];
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Updates the creature behaviour.
        /// </summary>
        public override void Update()
        {
            m_Timer += Time.deltaTime;

            if (OwningCreatureAI.GetCurrentAnimation().AnimationName != "Moving")
            {
                OwningCreatureAI.SetAnimation("Moving");
            }

            if (OwningCreatureAI.reachedEndOfPath && !IsDone)
            {
                Done();
            }

            // if you didnt move more than 2 units in the last 10sec then you are probably stuck, so just call done
            if (m_Timer >= 10)
            {
                if ((m_StartPos - OwningCreatureAI.position).magnitude < 2f)
                {
                    Done();
                }
            }
        }
コード例 #10
0
 /// <summary>
 /// Updates the creature behaviour.
 /// </summary>
 public override void Update()
 {
     if (OwningCreatureAI.reachedEndOfPath && !IsDone && foundViable)
     {
         OwningCreatureAI.SetAnimation("Idle");
         Done();
     }
     else if (!foundViable && !IsDone)
     {
         ResourceType resource = (ResourceType)UnityEngine.Random.Range(1, Enum.GetValues(typeof(ResourceType)).Length);
         Vector3      coord    = Vector3.zero;
         if (FindClosestPathToResource(resource, out coord))
         {
             OwningCreatureAI.SetAnimation("Moving");
             OwningCreatureAI.destination = coord;
             foundViable = true;
         }
         else if (curTry >= maxTries)
         {
             OwningCreatureAI.SetAnimation("Idle");
             Done();
         }
     }
 }