public SeekingState(Wolfie wofile, SteeringCharacter steeringCharacter) { _wolfie = wofile; _steeringCharacter = steeringCharacter; chicken = _steeringCharacter.chickenPooler.GetComponent <NewObjectPoolerScript>(); isHunting = false; }
public Separation(SteeringCharacter _character, float _threshold = 5.0f, float _decayCoefficient = 100.0f, float _maxAcceleration = 10.0f) { this.character = _character; this.threshold = _threshold; this.decayCoefficient = _decayCoefficient; this.maxAcceleration = _maxAcceleration; }
public VelocityMatch(SteeringCharacter _character, Vector3 _target, float _maxAcceleration = 20.0f, float _timeToTarget = 0.1f) { this.character = _character; this.target = _target; this.maxAcceleration = _maxAcceleration; this.timeToTarget = _timeToTarget; }
public EvasionState(Wolfie wofile, SteeringCharacter steeringCharacter) { _wolfie = wofile; _steeringCharacter = steeringCharacter; fleeDirection = steeringCharacter.transform.position - steeringCharacter.center.transform.position; steeringCharacter.transform.Rotate(Vector3.up, 180); }
public Arrive(SteeringCharacter _character, Vector3 _target, float _maxAcceleration = 10.0f, float _maxSpeed = 10.0f, float _slowRadius = 10.0f, float _timeToTarget = 0.1f) { this.character = _character; this.target = _target; this.maxAcceleration = _maxAcceleration; this.maxSpeed = _maxSpeed; this.slowRadius = _slowRadius; this.timeToTarget = _timeToTarget; }
private SteeringCharacter _steeringCharacter; // _steeringCharacter's function is steering wolfie and percept environment public WanderingState(Wolfie wolfie, SteeringCharacter steeringCharacter) { _wolfie = wolfie; _steeringCharacter = steeringCharacter; r = new System.Random((int)DateTime.Now.Ticks % int.MaxValue); r2 = new System.Random((int)DateTime.Now.Ticks % int.MaxValue); rotateDirection = r2.Next(0, 99); V1 = _steeringCharacter.transform.position - _steeringCharacter.center.transform.position; rotateAngle = r.Next(120, 240); checkTime = Time.time; rotateTime = Time.time; _velocity = new Vector3(0, 0f, 0); temp = _steeringCharacter.obstaclePooler.GetComponent <NewObjectPoolerScript>(); // +++++++++++++++++++ chicken = _steeringCharacter.chickenPooler.GetComponent <NewObjectPoolerScript>(); }
// Update is called once per frame void Update() { /* * My Implementation of flocking */ //Get the average group velocity and position Vector3 averagePosition = new Vector3(); Vector3 averageVelocity = new Vector3(); foreach (GameObject character in characters) { averagePosition += character.transform.position; averageVelocity += character.GetComponent <SteeringCharacter>().velocity; } averagePosition *= 1.0f / characters.Count; averageVelocity *= 1.0f / characters.Count; //averagePosition = targetObject.transform.position; //Set to arrive at the average position arrivalBehavior.target = averagePosition; //Set to match the average velocity velocityMatchBehavior.target = averageVelocity; //Loop through every character foreach (GameObject character in characters) { SteeringCharacter thisChar = character.GetComponent <SteeringCharacter>(); arrivalBehavior.character = thisChar; separationBehavior.character = thisChar; velocityMatchBehavior.character = thisChar; SteeringOutput arrivalSteering = arrivalBehavior.getSteering(); SteeringOutput separationSteering = separationBehavior.getSteering(); SteeringOutput velocityMatchSteering = velocityMatchBehavior.getSteering(); thisChar.steering = new SteeringOutput(); //Combine all steering behaviors thisChar.steering.linear = arrivalSteering.linear + separationSteering.linear + velocityMatchSteering.linear; } }
public Seek(SteeringCharacter _character, GameObject _target, float _maxAcceleration = 10.0f) { this.character = _character; this.target = _target; this.maxAcceleration = _maxAcceleration; }
public Evade(SteeringCharacter _character, GameObject _target, float _maxAcceleration = 10.0f, float _maxPrediction = 5.0f) : base(_character, _target, _maxAcceleration) { this.maxPrediction = _maxPrediction; }
public Wolfie(SteeringCharacter steeringCharacter) { _steeringCharacter = steeringCharacter; _state = new WanderingState(this, _steeringCharacter); }