Example #1
0
        /// <summary>
        /// Calls the base Start Method and sets the Animation as well as the Behaviour to its default values.
        /// </summary>
        protected override void Start()
        {
            base.Start();
            SetAnimation("Idle");
            BehaviourBlockQueue.AddFirst(new GoToBonfire(this));

            switch (m_VillagerSpecialization)
            {
            case VillagerSpecialization.WoodCutter:
                BehaviourBlockQueue.AddLast(new FindAndExtractResource(this, ResourceType.Wood));
                break;

            case VillagerSpecialization.StoneMason:
                BehaviourBlockQueue.AddLast(new FindAndExtractResource(this, ResourceType.Rock));
                break;
            }
        }
Example #2
0
        /// <summary>
        /// Updates the Villager, checks for a free home if he is homeless and gets one if there is a free spot in the house.
        /// Activates and deactivates the torch based on the time of day as well as add the default work behaviour block if the villager got nothing todo.
        /// </summary>
        protected override void Update()
        {
            base.Update();

            if (m_Home == null)
            {
                List <House> houses = PlanetDatalayer.Instance.GetManager <BuildingManager>().GetBuildingsOfType <House>();
                foreach (House h in houses)
                {
                    if (h.AddResident(this))
                    {
                        m_Home = h;
                        PlanetDatalayer.Instance.GetManager <FoMManager>().IncreaseFoM(PlanetDatalayer.Instance.GetManager <VillagerManager>().m_VillagerList.IndexOf(this), 10);
                        break;
                    }
                }
            }

            if (CurrentCreatureBehaviourBlock != null)
            {
                currentBlock = CurrentCreatureBehaviourBlock.GetType().Name;
            }
            else
            {
                currentBlock = "None";
            }

            if (LastCompletedBehaviourBlock != null)
            {
                lastCompletedBlock = LastCompletedBehaviourBlock.GetType().Name;
            }
            else
            {
                lastCompletedBlock = "None";
            }

            if (m_Torch != null)
            {
                if (m_Sun != null)
                {
                    if (m_HasTorch)
                    {
                        if (m_Sun.intensity <= 0.6f && !m_Torch.activeInHierarchy)
                        {
                            m_Torch.SetActive(true);
                        }
                        else if (m_Torch.activeInHierarchy && m_Sun.intensity > 0.6f)
                        {
                            m_Torch.SetActive(false);
                        }
                    }
                }
            }

            if (BehaviourBlockQueue.Count <= 0 && CurrentCreatureBehaviourBlock == null)
            {
                switch (m_VillagerSpecialization)
                {
                case VillagerSpecialization.WoodCutter:
                    BehaviourBlockQueue.AddLast(new FindAndExtractResource(this, ResourceType.Wood));
                    break;

                case VillagerSpecialization.StoneMason:
                    BehaviourBlockQueue.AddLast(new FindAndExtractResource(this, ResourceType.Rock));
                    break;
                }
            }
        }