Exemplo n.º 1
0
    public override IEnumerator Enter(Machine owner, Brain controller)
    {
        mainMachine = owner;
        myBrain = controller;
        Legs myLeg = myBrain.legs;

        arriveBehaviour = new PathfindToPoint();
        seekBehaviour = new Seek();

        arriveBehaviour.Init(myLeg,myBrain.levelGrid);
        seekBehaviour.Init(myLeg);

        myLeg.addSteeringBehaviour(arriveBehaviour);
        myLeg.addSteeringBehaviour(seekBehaviour);

        //set speed back to normal
        myBrain.legs.maxSpeed = 5f;

        if(firstActivation)
        {
            //set cowardLevel for sheep. Random.value returns a random number between 0.0 [inclusive] and 1.0 [inclusive].
            float coward = 0.5f;

            myBrain.memory.SetValue("cowardLevel", coward);
            myBrain.memory.SetValue("chasedBy", new List<Brain>());
            myBrain.memory.SetValue("BeingEaten", false);
            myBrain.memory.SetValue("HP", 100f);

            firstActivation = false;
        }

        time = 0f;
        seekingTime = 0f;
        yield return null;
    }
Exemplo n.º 2
0
 private Seek getSeekBehaviour()
 {
     if (seek == null)
     {
         seek = new Seek();
         seek.Init (this.getLegs ());
     }
     return seek;
 }
Exemplo n.º 3
0
    public override IEnumerator Enter(Machine owner, Brain controller)
    {
        mainMachine = owner;
        myBrain = controller;
        Legs myLeg = myBrain.legs;
        runTo = new Seek();
        runTo.Init(myLeg);

        player = GameObject.FindGameObjectWithTag("Player").transform;

        hiddenTime = 0;

        myBrain.memory.SetValue ("shouldHide", 0f);
        myBrain.legs.maxSpeed = 11f;
        myLeg.addSteeringBehaviour(runTo);
        yield return null;
    }
Exemplo n.º 4
0
    public override IEnumerator Enter(Machine owner, Brain controller)
    {
        mainMachine = owner;
        myBrain = controller;
        Legs myLeg = myBrain.legs;
        arriveBehaviour = new PathfindToPoint();
        seekBehaviour = new Seek();

        arriveBehaviour.Init(myLeg, myBrain.levelGrid);
        seekBehaviour.Init(myLeg);

        myLeg.addSteeringBehaviour(arriveBehaviour);
        myLeg.addSteeringBehaviour(seekBehaviour);

        myLeg.maxSpeed = 11f;
        time = 0f;
        ferocityRate = controller.memory.GetValue<float>("ferocity");

        sheepTarget = myBrain.memory.GetValue<SensedObject>("hasCommand");
        sheepMemory = sheepTarget.getMemory();
        sheepBrain = (Brain)sheepTarget.getObject().GetComponent("Brain");

        arriveBehaviour.setTarget(sheepTarget.getObject());

        //for machine learning
        float panic = sheepBrain.memory.GetValue<float>("Panic");
        float courage = sheepBrain.memory.GetValue<float>("cowardLevel");
        float chasedBy = sheepBrain.memory.GetValue<List<Brain>>("chasedBy").Count;
        float distanceWithMe = Vector2.Distance(sheepBrain.legs.getPosition(), myBrain.legs.getPosition());
        float distanceWithSheperd = Vector2.Distance(sheepBrain.legs.getPosition(), ((Legs)GameObject.FindGameObjectWithTag("Player").GetComponent<Legs>()).getPosition());
        float hungry = myBrain.memory.GetValue<float>("hungryLevel");
        float sheepHP = sheepBrain.memory.GetValue<float>("HP");

        string sheep = panic + "," + courage + "," + chasedBy + "," + distanceWithMe + "," + distanceWithSheperd + "," + hungry + "," + sheepHP;

        myBrain.memory.SetValue("targeting", sheep);

        yield return null;
    }