Inheritance: ActingInterface
Exemplo n.º 1
0
        private float restingTime;     // time elapsed since resting time started

        void Start()
        {
            // get the steerings that are going to be used by this FSM
            arrive = GetComponent <Arrive>();
            if (arrive == null)
            {
                Debug.LogError(gameObject + " has no Arrive attached in " + this);
            }

            pursue = GetComponent <Pursue>();
            if (pursue == null)
            {
                Debug.LogError(gameObject + " has no Pursue attached in " + this);
            }


            // get the internal state + world representation (the "BLACKBOARD")
            blackboard = GetComponent <BATCAT_Blackboard>();
            if (blackboard == null)
            {
                blackboard = gameObject.AddComponent <BATCAT_Blackboard>();
            }

            arrive.enabled = false;
            pursue.enabled = false;
        }
Exemplo n.º 2
0
    // Use this for initialization
    protected override void Start()
    {
        waterSource   = GameObject.Find("Daylight Water");
        thirst        = 100;
        health        = 100;
        energy        = 100;
        currentState  = ankyState.IDLE;
        ankyWander    = GetComponent <Wander>();
        ankyFlee      = GetComponent <Flee>();
        ankyView      = GetComponent <FieldOfView>();
        ankyFace      = GetComponent <Face>();
        ankyFaceEnemy = GetComponent <FaceEnemy>();
        ankyPursue    = GetComponent <Pursue>();
        ankySeek      = GetComponent <Seek>();
        ankyAgent     = GetComponent <Agent>();
        anim          = GetComponent <Animator>();

        // Assert default animation booleans and floats
        anim.SetBool("isIdle", true);
        anim.SetBool("isEating", false);
        anim.SetBool("isDrinking", false);
        anim.SetBool("isAlerted", false);
        anim.SetBool("isGrazing", false);
        anim.SetBool("isAttacking", false);
        anim.SetBool("isFleeing", false);
        anim.SetBool("isDead", false);
        anim.SetFloat("speedMod", 1.0f);
        // This with GetBool and GetFloat allows
        // you to see how to change the flag parameters in the animation controller

        base.Start();
    }
Exemplo n.º 3
0
    public override void Update()
    {
        if (agent.remainingDistance < 1)
        {
            if (currentIndex >= GameEnvironment.Singleton.Checkpoints.Count - 1)
            {
                currentIndex = 0;
            }
            else
            {
                currentIndex++;
            }
            agent.SetDestination(GameEnvironment.Singleton.Checkpoints[currentIndex].transform.position);
        }

        if (CanSeePlayer())
        {
            nextState = new Pursue(npc, agent, anim, player);
            stage     = EVENT.EXIT;
        }
        else if (IsPlayerBehind())
        {
            nextState = new Flee(npc, agent, anim, player);
            stage     = EVENT.ENTER;
        }
    }
Exemplo n.º 4
0
    public override void Update()
    {
        // Check if agent hasn't finished walking between waypoints.
        if (agent.remainingDistance < 1)
        {
            // If agent has reached end of waypoint list, go back to the first one, otherwise move to the next one.
            if (currentIndex >= GameEnvironment.Singleton.Checkpoints.Count - 1)
            {
                currentIndex = 0;
            }
            else
            {
                currentIndex++;
            }

            agent.SetDestination(GameEnvironment.Singleton.Checkpoints[currentIndex].transform.position); // Set agents destination to position of next waypoint.
        }

        if (CanSeePlayer())
        {
            nextState = new Pursue(npc, agent, anim, player);
            stage     = EVENT.EXIT; // The next time 'Process' runs, the EXIT stage will run instead, which will then return the nextState.
        }
        if (OnAttack())
        {
            nextState = new Sleep(npc, agent, anim, player);
            stage     = EVENT.EXIT;
        }
    }
Exemplo n.º 5
0
            public override void Enter()
            {
                pursueBehaviour = ship.boid.GetBehaviour <Pursue> ();

                if (pursueBehaviour != null)
                {
                    pursueBehaviour.enabled         = true;
                    pursueBehaviour.target          = target.boid;
                    pursueBehaviour.desiredDistance = desiredDistance;
                }

                Wander wanderBehaviour = ship.boid.GetBehaviour <Wander> ();

                if (wanderBehaviour != null)
                {
                    wanderBehaviour.enabled = true;
                    wanderBehaviour.weight  = 10f;
                }

                Flee targetFlee = target.boid.GetBehaviour <Flee> ();

                if (targetFlee != null)
                {
                    targetFlee.avoidingBoids.Add(ship.transform);
                }

                target.pursuers++;
                ship.pursuing = target;

                ship.guns[0].enabled = true;

                ship.StartCoroutine(IUpdate());
            }
            public override void Enter()
            {
                ship.StartCoroutine(IUpdate());

                patrolBehaviour = ship.boid.GetBehaviour <OffsetPursue> ();
                Pursue pursueBehaviour = ship.boid.GetBehaviour <Pursue> ();

                Wander wanderBehaviour = ship.boid.GetBehaviour <Wander> ();

                if (wanderBehaviour != null)
                {
                    wanderBehaviour.enabled = true;
                    wanderBehaviour.weight  = 0.25f;
                }

                if (patrolBehaviour != null)
                {
                    patrolBehaviour.enabled = true;
                }

                if (pursueBehaviour != null)
                {
                    pursueBehaviour.enabled = false;
                }
            }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        paths.Clear();
        eships.Clear();
        av8ships.Clear();
        foreach (Path p in gameObject.GetComponentsInChildren(typeof(Path)))
        {
            paths.Add(p);
        }
        //Creates the enemy to get shot by
        GameObject leader = GameObject.Instantiate <GameObject> (enemyprefab);

        leader.transform.parent   = this.transform;
        leader.transform.position = this.transform.GetChild(1).position;          //position at the start of the epath
        leader.transform.rotation = this.transform.GetChild(1).rotation;
        FollowPath fpath = leader.AddComponent <FollowPath> ();

        fpath.path    = paths [1];      //follows the epath
        fpath.enabled = fpath.enabled;
        eships.Add(leader);

        //Creates the enemy that will shoot the av8 plane
        leader = GameObject.Instantiate <GameObject> (enemyprefab);
        leader.transform.parent   = this.transform;
        leader.transform.position = this.transform.GetChild(0).TransformPoint(new Vector3(0, 0, -10));            //position at the start of the apath with offset
        leader.transform.rotation = this.transform.GetChild(0).rotation;
        eships.Add(leader);

        //Creates the av8 plane that will shoot the enemy
        leader = GameObject.Instantiate <GameObject> (av8prefab);
        leader.transform.parent   = this.transform;
        leader.transform.position = this.transform.position;
        leader.transform.rotation = this.transform.rotation;
        //Add boid and seek to the  bombs(missiles)
        int count = leader.transform.Find("Bombs").gameObject.transform.childCount;

        for (int i = 0; i < count; i++)
        {
            Boid b = leader.transform.Find("Bombs").GetChild(i).gameObject.AddComponent <Boid> ();
            b.maxSpeed        = 45f;
            b.explosionPrefab = expPrefab;
            Pursue sb = leader.transform.Find("Bombs").GetChild(i).gameObject.AddComponent <Pursue> ();
            sb.target  = eships [0].GetComponent <Boid> ();
            sb.enabled = !sb.enabled;
        }
        av8ships.Add(leader);

        //Creates the av8 plane that will get shot by
        leader = GameObject.Instantiate <GameObject> (av8prefab);
        leader.transform.parent   = this.transform;
        leader.transform.position = this.transform.GetChild(0).position;          //position at the start of the apath
        leader.transform.rotation = this.transform.GetChild(0).rotation;
        fpath         = leader.AddComponent <FollowPath> ();
        fpath.path    = paths [0];      //follows the apath
        fpath.enabled = !fpath.enabled;
        av8ships.Add(leader);

        StartCoroutine(Enemykill());
    }
 protected void PursueIfPlayerIsVisible()
 {
     if (!CanSeePlayer())
     {
         return;
     }
     NextState = new Pursue(Npc, Agent, Animator, PlayerTransform);
 }
Exemplo n.º 9
0
    private void Start()
    {
        kinematic = GetComponent <Kinematic>();

        switch (moveType)
        {
        case SteeringType.Pursue:
            pursueAI           = new Pursue();
            pursueAI.character = kinematic;
            pursueAI.target    = target;
            break;

        case SteeringType.Evade:
            evadeAI           = new Evade();
            evadeAI.character = kinematic;
            evadeAI.target    = target;
            break;

        case SteeringType.FollowPath:
            followAI           = new PathFollow();
            followAI.character = kinematic;
            followAI.path      = pathOfObjects;
            break;

        case SteeringType.Seek:
            seekAI           = new Seek();
            seekAI.character = kinematic;
            seekAI.target    = target;
            break;

        case SteeringType.Flee:
            fleeAI           = new Flee();
            fleeAI.character = kinematic;
            fleeAI.target    = target;
            break;

        case SteeringType.Seperation:
            seperationAI           = new Seperation();
            seperationAI.character = kinematic;
            seperationAI.targets   = seperateObstacles;
            break;

        case SteeringType.Arrive:
            arriveAI           = new Arrive();
            arriveAI.character = kinematic;
            arriveAI.target    = target;
            break;
        }

        switch (lookType)
        {
        case LookType.Align:
            alignAI           = new Align();
            alignAI.character = kinematic;
            alignAI.target    = target;
            break;
        }
    }
Exemplo n.º 10
0
    // Start is called before the first frame update
    protected override void Start()
    {
        myRotateType           = new LookWhereYoureGoing();
        myRotateType.character = this;
        myRotateType.target    = target;

        myMoveType           = new Pursue();
        myMoveType.character = this;
        myMoveType.target    = target;
    }
Exemplo n.º 11
0
 private void Start()
 {
     targetingSystem = GetComponent <TargetingSystem>();
     pursue          = GetComponent <Pursue>();
     arrive          = GetComponent <Arrive>();
     seek            = GetComponent <Seek>();
     flee            = GetComponent <Flee>();
     fleeAndArrive   = GetComponent <FleeAndArrive>();
     offsetPursue    = GetComponent <OffsetPursue>();
 }
Exemplo n.º 12
0
 void Awake()
 {
     _patrol = GetComponent <Patrol>();
     _anim   = GetComponent <Animator>();
     _pursue = GetComponent <Pursue>();
     canSee  = GetComponent <CanSeeObject>();
     _shoot  = GetComponentInChildren <EnemyShoot>();
     //Initialize State Machine Engine
     fsm = StateMachine <States> .Initialize(this);
 }
Exemplo n.º 13
0
    // Start is called before the first frame update
    void Start()
    {
        myRotateType           = new LookWhereGoing();
        myRotateType.character = this;
        myRotateType.target    = myTarget;

        myMoveType           = new Pursue();
        myMoveType.character = this;
        myMoveType.target    = myTarget;
    }
Exemplo n.º 14
0
    public static Steering GetSteering(Agent target, Agent npc, float maxAccel, float maxPrediction, bool visibleRays = false)
    {
        Steering steering = -Pursue.GetSteering(target, npc, maxAccel, maxPrediction, false);

        if (visibleRays)
        {
            drawRays(npc.position, steering.linear, Color.magenta);
        }

        return(steering);
    }
Exemplo n.º 15
0
        // Start is called before the first frame update
        void Start()
        {
            myMoveType           = new Pursue();
            myMoveType.character = this;
            myMoveType.target    = myTarget;

            myRotateType           = new LookWhereGoing();
            myRotateType.character = this;
            myRotateType.target    = myTarget;
            character = GetComponent <ThirdPersonCharacter>();
        }
Exemplo n.º 16
0
    void Start()
    {
        //Inicializamos las estructuras necesarias de otros componentes
        enemy         = GameObject.Find(enemyName).GetComponent <static_data>();
        kineticsEnemy = enemy.kineticsAgent;

        kineticsAgent = agent.kineticsAgent;
        steeringAgent = agent.steeringAgent;

        //Inicializamos movimientos
        pursue = new Pursue(kineticsAgent, kineticsEnemy, maxPrediction);
    }
Exemplo n.º 17
0
 // Use this for initialization
 void Start()
 {
     aligned    = new Align();
     looky      = new Look_Where_Going();
     facing     = new Face();
     pathFollow = new Path_Follow();
     seeking    = new Seek_And_Flee();
     separate   = new Separation();
     pursuing   = new Pursue();
     avoid      = new CollisionAvoidance();
     obstacles  = new Obstacle_Avoidance();
 }
Exemplo n.º 18
0
 public override void Update()
 {
     if (CanSeePlayer())
     {
         nextState = new Pursue(npc, agent, anim, player);
         stage     = EVENT.EXIT;
     }
     else if (Random.Range(0, 100) < 10)
     {
         nextState = new Patrol(npc, agent, anim, player);
         stage     = EVENT.EXIT;
     }
 }
Exemplo n.º 19
0
 public override void Update()
 {
     if (CanAttackPlayer())
     {
         nextState = new Pursue(npc, agent, anim, player);
         stage     = EVENT.EXIT;
     }
     else if (!CanSeePlayer())
     {
         nextState = new Patrol(npc, agent, anim, player);
         stage     = EVENT.EXIT;
     }
 }
Exemplo n.º 20
0
    void Start()
    {
        // Separate from other birds
        Separation separate = new Separation();

        separate.character = this;
        GameObject[] goBirds = GameObject.FindGameObjectsWithTag("bird");
        kBirds = new GameObject[goBirds.Length - 1];
        int j = 0;

        for (int i = 0; i < goBirds.Length - 1; i++)
        {
            if (goBirds[i] == this)
            {
                continue;
            }
            kBirds[j++] = goBirds[i];
        }
        separate.targets = kBirds;

        // Cohere to center of mass - ez mode
        Seek cohere = new Seek();

        cohere.character = this;
        cohere.target    = myCohereTarget;

        Pursue pursue = new Pursue();

        pursue.character = this;
        pursue.target    = myTarget;

        // look where center of mass is going - ez mode
        LookWhereGoing myRotateType = new LookWhereGoing();

        myRotateType.character = this;

        mySteering                       = new BlendedSteering();
        mySteering.behaviors             = new BehaviorAndWeight[4];
        mySteering.behaviors[0]          = new BehaviorAndWeight();
        mySteering.behaviors[0].behavior = separate;
        mySteering.behaviors[0].weight   = .2f;
        mySteering.behaviors[1]          = new BehaviorAndWeight();
        mySteering.behaviors[1].behavior = cohere;
        mySteering.behaviors[1].weight   = .3f;
        mySteering.behaviors[2]          = new BehaviorAndWeight();
        mySteering.behaviors[2].behavior = pursue;
        mySteering.behaviors[2].weight   = .5f;
        mySteering.behaviors[3]          = new BehaviorAndWeight();
        mySteering.behaviors[3].behavior = myRotateType;
        mySteering.behaviors[3].weight   = 1f;
    }
Exemplo n.º 21
0
 public override void Update()
 {
     if (CanSeePlayer())
     {
         nextState = new Pursue(npc, agent, anim, player);
         stage     = EVENT.EXIT; // The next time 'Process' runs, the EXIT stage will run instead, which will then return the nextState.
     }
     // The only place where Update can break out of itself. Set chance of breaking out at 10%.
     else if (Random.Range(0, 100) < 10)
     {
         nextState = new Patrol(npc, agent, anim, player);
         stage     = EVENT.EXIT; // The next time 'Process' runs, the EXIT stage will run instead, which will then return the nextState.
     }
 }
Exemplo n.º 22
0
    public void createPursue(SteeringOutput steering)
    {
        Pursue myPursue = new Pursue
        {
            character = this,
            target    = myTarget
        };

        steering = myPursue.getSteering();
        if (steering != null)
        {
            linearVelocity  += steering.linear * Time.deltaTime;
            angularVelocity += steering.angular * Time.deltaTime;
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        myMoveType           = new Pursue();
        myMoveType.character = this;
        myMoveType.target    = myTarget;
        myMoveType.evade     = evade;

        myPursueRotateType           = new Face();
        myPursueRotateType.character = this;
        myPursueRotateType.target    = myTarget;

        myEvadeRotateType           = new LookWhereGoing();
        myEvadeRotateType.character = this;
        myEvadeRotateType.target    = myTarget;
    }
Exemplo n.º 24
0
    // Use this for initialization
    void Start()
    {
        arrive     = new Arrival();
        aligned    = new Align();
        looky      = new Look_Where_Going();
        facing     = new Face();
        pathFollow = new Path_Follow();
        seeking    = new Seek_And_Flee();
        separate   = new Separation();
        pursuing   = new Pursue();
        avoid      = new CollisionAvoidance();
        obstacles  = new Obstacle_Avoidance();
        flocking   = new Blended_Steering();

        behaviors = new BehaviorAndWeight[4];
    }
Exemplo n.º 25
0
 public void Enter()
 {
     levelSndInstance = levelSnd.CreateInstance();
     //levelSndInstance.Play();
     rectangles = state.levelManager.levels[2].rectangles;
     //gate
     gateRectangle = new RectangleObjects(336, 24, 96, 72);
     rectangles.Add(gateRectangle);
     //reset
     resetRectangle = new Rectangle(336, 662, 98, 10);
     collide        = new Collision(rectangles, actors, state);
     grabThrow      = new GrabThrow(actors);
     patrol         = new Patroling(rectangles, actors, resetRectangle);
     rockHit        = new RockHit(actors, grabThrow);
     checkWin       = new CheckWin(actors);
     pursue         = new Pursue(actors, state);
 }
Exemplo n.º 26
0
    public override void Update()
    {
        base.Update();

        if (Vector3.Distance(player.transform.position, transform.position)
            <= 7f)
        {
            Pursue myPursue = gameObject.AddComponent <Pursue>() as Pursue;
            myPursue.target         = player;
            myPursue.targetAux      = player;
            myPursue.chasePlayer    = true;
            myPursue.minDist        = 2;
            myPursue.attackStrength = 7;
            myPursue.enabled        = true;
            Destroy(this);
        }
    }
Exemplo n.º 27
0
    // Start is called before the first frame update
    protected virtual void Start()
    {
        mySeek           = new Seek();
        mySeek.character = this;
        mySeek.target    = target;
        myFlee           = new Flee();
        myFlee.character = this;
        myFlee.target    = target;

        myArrv           = new Arrive();
        myArrv.character = this;
        myArrv.target    = target;

        myAlgn           = new Align();
        myAlgn.character = this;
        myAlgn.target    = target;

        myFace           = new Face();
        myFace.character = this;
        myFace.target    = target;

        myLWYG           = new LookWhereGoing();
        myLWYG.character = this;
        myLWYG.target    = target;

        myFPth           = new FollowPathDemo();
        myFPth.character = this;
        myFPth.path      = waypointList;

        mySepr           = new Separation();
        mySepr.character = this;

        myPrsu           = new Pursue();
        myPrsu.character = this;
        myPrsu.target    = target;

        myClAv           = new CollAvoid();
        myClAv.character = this;
        myClAv.targets   = collAvoidTargets;

        myObAv           = new ObstAvoid();
        myObAv.character = this;

        controlledSteeringUpdate = new SteeringOutput();
    }
Exemplo n.º 28
0
    // Use this for initialization
    void Start()
    {
        arrive     = new Arrival();
        aligned    = new Align();
        looky      = new Look_Where_Going();
        facing     = new Face();
        pathFollow = new Path_Follow();
        seeking    = new Seek_And_Flee();
        separate   = new Separation();
        pursuing   = new Pursue();
        avoid      = new CollisionAvoidance();
        obstacles  = new Obstacle_Avoidance();
        flocking   = new Blended_Steering();
        //finding = new Pathfinder();

        behaviors = new BehaviorAndWeight[4];

        // Use if doing Path Finding:
        //Graph myGraph = new Graph();

        //myGraph.Build();

        //List<Connection> path = Dijkstra.pathfind(myGraph, start, goal);

        //// path is a list of connections - convert this to gameobjects for the FollowPath steering behavior

        //aiTargets = new GameObject[path.Count + 1];

        //int i = 0;

        //foreach (Connection c in path)

        //{

        //    Debug.Log("from " + c.getFromNode() + " to " + c.getToNode() + " @" + c.getCost());

        //    aiTargets[i] = c.getFromNode().gameObject;

        //    i++;

        //}

        //aiTargets[i] = goal.gameObject;
    }
Exemplo n.º 29
0
    void Start()
    {
        //POKEMONES
        pokemons = GameObject.FindGameObjectsWithTag("Pokemon");

        for (int i = 0; i < pokemons.Length; i++)//le sacamos todos los kinetics a los pokes
        {
            kinsList.Add(pokemons[i].GetComponent <static_data>().kineticsAgent);
        }

        pokemonKins   = kinsList.ToArray();
        amountPokemon = pokemons.Length;

        //TRAINER
        kineticsAgent = agent.kineticsAgent;
        steeringAgent = agent.steeringAgent;


        //Inicializamos movimientos con el primer pokemon
        pursue = new Pursue(kineticsAgent, pokemonKins[currentPokemon], maxPrediction);
    }
Exemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        AIHelper           helper  = GameObject.Find("AIHelper").GetComponent <AIHelper>();
        IList <GameObject> enemies = helper.GetShips(enemyTeam);

        if (!enemies.Any())
        {
            hasTarget = false;
            return;
        }

        GameObject target = GetClosest(enemies);

        Pursue pursueBehaviour  = transform.GetComponent <Pursue> ();
        float  distanceToTarget = (target.transform.position - transform.position).magnitude;

        if (distanceToTarget > pursuitFadeOffRange)
        {
            pursueBehaviour.Weight = pursuitWeight * (pursuitFadeOffRange / (distanceToTarget * distanceToTarget));
        }
        else
        {
            pursueBehaviour.Weight = pursuitWeight;
        }

        if (pursuitWeight > 0.1)
        {
            hasTarget     = true;
            gizmoLocation = target.transform.position;
        }
        else
        {
            hasTarget = false;
        }

        pursueBehaviour.TargetAgent = target.GetComponent <SteeringAgent> ();
        // Shoot ();
    }
Exemplo n.º 31
0
    // Use this for initialization
    void Start () {
        steeringBasics = GetComponent<SteeringBasics>();
        pursue = GetComponent<Pursue>();
	}