protected void Awake() { _steeringController = GetComponent <SteeringController>(); _wander = GetComponent <FS_Homer_Wander>(); _escape = GetComponent <FS_Homer_Escape>(); _homer = GetComponent <Homer>(); }
protected void Awake() { _steeringController = GetComponent<SteeringController>(); _flock = GetComponent<FS_Homer_Flock>(); _escape = GetComponent<FS_Homer_Escape>(); _homer = GetComponent<Homer>(); }
public Homer GetClosestHomer() { Homer curHomer = null; float curDistance = 0; _factory.homers.ForEach( (Homer h) => { if (h.capturer == this.gameObject) { return; } Vector3 vec = this.gameObject.transform.position - h.gameObject.transform.position; float distance = vec.sqrMagnitude; if (distance <= distToCatchHomer * distToCatchHomer) { if (curHomer == null || distance < curDistance) { curHomer = h; curDistance = distance; } } } ); return(curHomer); }
public override FiniteState CheckState() { Homer h = _marge.GetClosestHomer(); if (h != null) { _catch.target = h; return(_catch); } if (_path == null || _path.Count == 0) { CreateNewPath(); // If is possible Marge is in a position where a path cannot be determined. // If this happens move Marge a little bit and try again if (_path == null || _path.Count == 0) { _steeringController.SetBehaviours( new List <SteeringBehaviour> () { new SteerAvoidBuildings(transform), new SteerWanderXZ(transform) } ); _steeringController.Steer(); return(this); } } _steeringController.SetBehaviours( new List <SteeringBehaviour>() { new SteerAvoidBuildings(transform), new SteerAlongPath(transform, _path) } ); _steeringController.Steer(); return(this); }
private void DecideOnNextIteration() { if (_person == null) { _takeABreakNow = true; return; } if (Homer.CheckIfCanBeWheelBar(_person)) { //so it restarted Init(); } else { _person.CreateProfession(Job.Builder); } }
public void CreateNewPath(Homer homer) { _caughtHomer = homer; homer.SetCaught(this.gameObject); _path = _pathFinder.FindPath( this.gameObject.transform.position, _dropPoint.position ); _steeringController.SetBehaviours( new List <SteeringBehaviour>() { new SteerAvoidBuildings(this.transform), new SteerAlongPath(this.gameObject.transform, _path) } ); }
protected void Awake() { _steeringController = GetComponent<SteeringController>(); _wander = GetComponent<FS_Homer_Wander>(); _homer = GetComponent<Homer>(); }
public bool WithinRange(Homer h, float min, float max) { return(WithinRange(h.gameObject, min, max)); }
public void DeepClone_ClassWithInterfaceAndBaseClass(TypeModel model) { var homer = new Homer() { Color = "yellow", Job = "Power Plant", NbHair = 2 }; var cloneHomer = (Homer)model.DeepClone(homer); Assert.AreEqual(homer.Color, cloneHomer.Color); Assert.AreEqual(homer.Job, cloneHomer.Job); Assert.AreEqual(homer.NbHair, cloneHomer.NbHair); }
public void Update() { rnd = new System.Random(); checkInvincibility(); if (checkStun()) { stunTimer -= Time.deltaTime; moveController.Move(0, 0); } else if (player != null) { health.cancelKnockback(); findPos(); float xSp = player.transform.position.x - transform.position.x; float ySp = player.transform.position.y - transform.position.y; distance = player.transform.position - transform.position; if (distance.magnitude <= AgroRange) { isAgro = true; } else { isAgro = false; } distanceFromPoint = locArr[loc % 4] - transform.position; if (distanceFromPoint.magnitude < 0.3) { loc++; distanceFromPoint = locArr[loc % 4] - transform.position; } moveController.Move(distanceFromPoint.normalized/8); if (isAgro) { if (cooldown >= 2) { cooldown = 0; findPos(); //No prep animation, just has default spinning and creates projectiles if (mine_CD > 5) { mine = Instantiate(mineObj, transform.position, transform.rotation) as BombScript; mine_CD = 0; } if (homing_CD > 8) { homing = Instantiate(homingObj, transform.position, transform.rotation) as Homer; homing_CD = 0; } else if (bomb_CD > 8) { //bomb = Instantiate(bombObj, transform.position, transform.rotation) as BombScript; // bomb.GetComponent<Rigidbody>().velocity = direction * 6; bomb_CD = 0; bomb = Instantiate(bombObj, transform.position, transform.rotation) as BombScript; Vector2 toPlayer = new Vector2(player.transform.position.x - transform.position.x, player.transform.position.y - transform.position.y); bomb.GetComponent<Rigidbody2D>().velocity = (toPlayer.normalized/3); } else if (shot_CD > 6) { float angle = Mathf.Atan2(direction.x, direction.y) * Mathf.Rad2Deg; var q = Quaternion.AngleAxis(angle, Vector3.forward); missile = Instantiate(missileObj, transform.position, q) as WindupProjectile; missile.Shoot(0,direction.normalized); shot_CD = 0; } else { cooldown = 1; } } } bomb_CD += Time.deltaTime; shot_CD += Time.deltaTime; mine_CD += Time.deltaTime; homing_CD += Time.deltaTime; cooldown += Time.deltaTime; } }
public bool WithinRange(Homer h, float min, float max) { return WithinRange(h.gameObject, min, max); }