// plants currently not implemented
    // Feast()
    // find plants, hit plants, eat plant drops
    /// <summary>
    /// Checks surroundings, if there is a drop move to it and eat it, if there aren't any drops attack nearest prey
    /// </summary>
    public void Feast(bool melee)
    {
        #region Surroundings
        GameObject cDrop = Checks.ClosestDrop();
        GameObject cHittable;
        #endregion
        if (cDrop != null && this.tag != "Predator")
        {
            // go to the nearest drop
            if (Behaviour.MoveTo(cDrop.transform.position, AiData.Speed, 1f))
            {
                Behaviour.Feed(cDrop);
            }
        }
        else
        {
            // go to nearest thing that drops drops
            if (this.tag == "Prey")
            {
                cHittable = Checks.ClosestPlant();
                //Debug.Log("closest plant is " + cHittable.name);
            }
            else
            {
                cHittable = Checks.ClosestCreature(new string[] { "Predator" });
                if (cHittable == null)
                {
                    cHittable = Checks.ClosestPlant();
                }
            }

            // go to the nearest drop
            if (cHittable != null)
            {
                if (melee)
                {
                    Melee(cHittable);
                }
                else
                {
                    Ranged(cHittable);
                }
            }
            else
            {
                Wander(5f, 5f);
            }
        }
    }
Beispiel #2
0
    public override void Invoke()
    {
        switch (curr)
        {
        case Behavior.Idle:
            _behave.Idle();
            break;

        case Behavior.MoveTo:
            _behave.MoveTo(targetPos, speed, threshold);
            break;

        case Behavior.MoveAwayFrom:
            _behave.MoveFrom(targetPos, speed, threshold + 1);
            break;

        case Behavior.Feed:
            _behave.Feed(target);
            break;

        case Behavior.Attack:
            _behave.MeleeAttack(targetPos);
            break;

        case Behavior.Ranged:
            _behave.RangedAttack(targetPos, speed);
            break;

        case Behavior.Socialize:
            _behave.Socialize();
            break;

        case Behavior.Custom:
            custom.InvokeBehavior();
            break;
        }
    }