public override void init() { if(objectRegistry) { objectRegistry.RegisterObject(new SensableObject(gameObject, AgentClassification.Sheep)); } seekBehaviour = new Arrive(); seekBehaviour.Init (this); //separation = new Separation(); //separation.Init (this); //cohesion = new Cohesion(); //cohesion.Init (this); //alignment = new Alignment(); //alignment.Init (this); random = new RandomWalk(0.6f, 1, 2); random.Init (this); // By name var go = GameObject.Find("SheepTarget"); seekBehaviour.setTarget (go); this.addSteeringBehaviour(seekBehaviour); //this.addSteeringBehaviour(separation); //this.addSteeringBehaviour(cohesion); //this.addSteeringBehaviour(alignment); this.addSteeringBehaviour(random); }
public override IEnumerator Enter(Machine owner, Brain controller) { mainMachine = owner; myBrain = controller; Legs myLeg = myBrain.legs; //get sheep target sheepTarget = myBrain.memory.GetValue<SensedObject>("hasCommand"); sheepBrain = (Brain)sheepTarget.getObject().GetComponent("Brain"); sheepMemory = sheepBrain.memory; sheepMemory.SetValue("BeingEaten", true); arriveBehaviour = new Arrive(); arriveBehaviour.Init(myLeg); arriveBehaviour.setTarget(sheepTarget.getObject()); //speed is zero myBrain.legs.maxSpeed = 0f; Debug.Log("I'm eating:" + sheepTarget.getObject() + " HP: " + sheepMemory.GetValue<float>("HP")); yield return null; }