예제 #1
0
    public override void Execute(Steerable steerable)
    {
        base.Execute(steerable);

        // Retrieve the amount of light energy possessed by the NPC performing this action
        float myLightEnergy = steerable.GetComponent <LightSource>().LightEnergy.CurrentEnergy;

        if (targetLightSource)
        {
            // If this fish has less light than its target
            if (!alwaysSeek && (myLightEnergy < targetLightSource.LightEnergy.CurrentEnergy || alwaysFlee))
            {
                // Flee the light source since it is stronger than this fish
                fleeWhenWeaker.Execute(steerable);

                //Debug.Log("FLEE THE FISH: " + targetLightSource.name);
            }
            // Else, if this fish has more light than its target
            else
            {
                // Seek the light source
                seekWhenStronger.Execute(steerable);
            }
        }
        else
        {
            // If the light source has been destroyed, stop performing this action.
            ActionCompleted();
        }

        wallAvoidance.Execute(steerable);
    }
    public override void Execute(Steerable steerable)
    {
        base.Execute(steerable);

        // Retrieve the amount of light energy possessed by the NPC performing this action
        float myLightEnergy = steerable.GetComponent<LightSource>().LightEnergy.CurrentEnergy;

        if (targetLightSource)
        {
            // If this fish has less light than its target
            if(!alwaysSeek && (myLightEnergy < targetLightSource.LightEnergy.CurrentEnergy || alwaysFlee))
            {
                // Flee the light source since it is stronger than this fish
                fleeWhenWeaker.Execute(steerable);

                //Debug.Log("FLEE THE FISH: " + targetLightSource.name);
            }
            // Else, if this fish has more light than its target
            else
            {
                // Seek the light source
                seekWhenStronger.Execute(steerable);
            }
        }
        else
        {
            // If the light source has been destroyed, stop performing this action.
            ActionCompleted();
        }

        wallAvoidance.Execute(steerable);
    }