Exemple #1
0
    protected override void OnUpdate()
    {
        if (!Creature.IsHungry)
        {
            if (collectBehaviour.ItemInHand != null)
            {
                collectBehaviour.DropItem();
            }
            return;
        }

        if (collectBehaviour.ItemInHand == null)
        {
            targetFood = GetNextFood();

            if (!targetFood)
            {
                return;
            }

            if (Vector3.Distance(Creature.transform.position, targetFood.transform.position) > 2.5f)
            {
                // baby yoda is small, lets not make him run super far to fetch
                // the apples. Let him use the force instead.
                collectBehaviour = pickupWithForce;
            }
        }

        if (targetFood)
        {
            collectBehaviour.Update(targetFood);
        }
    }
Exemple #2
0
    public FoodCollectState(CreatureController creature, ObjectRegistry objRegistry) : base(creature)
    {
        this.objRegistry = objRegistry;
        pickupWithForce  = new PickupWithForce(this, creature);
        pickupWithHands  = new PickupWithHands(this, creature);
        collectBehaviour = pickupWithHands;

        RegisterEvent("OnCollect", OnCollect);//() => collectBehaviour.OnCollect(targetFood));
        RegisterEvent("OnConsume", OnConsume);
        RegisterEvent("OnComplete", OnComplete);
    }
Exemple #3
0
    private void SelectNextBehaviour()
    {
        CollectBehaviour newBehaviour = pickupWithHands;

        if (UnityEngine.Random.value >= 0.5f)
        {
            newBehaviour = pickupWithForce;
        }

        if (newBehaviour != collectBehaviour)
        {
            collectBehaviour = newBehaviour;
        }
    }