public override void SteerOther(BasicSteering controller) { GoblinSteering steering = controller as GoblinSteering; if (steering.SurfaceContact.normal == Vector2.zero) { controller.SetStrategy(JumpingGoblinFloatStrategy.Instance()); } GoblinCombatStrategy.CheckTargets(steering,2); if (steering.Targets.Count != 0) { GameObject mainTarget = steering.Targets[0]; if (mainTarget.tag == "Enemy") { if (mainTarget.GetComponent<PhysicsObject>().GetExtents().min.x - steering.GetComponent<PhysicsObject>().GetExtents().max.x < 0.1) { steering.Stopped = true; } } else if (TargetJumpTags.Contains(mainTarget.tag) && mainTarget.GetComponent<PhysicsObject>().GetExtents().min.x - steering.GetComponent<PhysicsObject>().GetExtents().max.x > 1.5) { float height = mainTarget.GetComponent<PhysicsObject>().FindMaxHeight() - steering.GetComponent<PhysicsObject>().GetExtents().min.y; controller.GetComponent<JumpingGoblinLocomotion>().Jump(new Vector2(height / 4, height)); } else { controller.SetStrategy(JumpingGoblinCombatStrategy.Instance()); } } }
public virtual void SteerOther(BasicSteering controller) { GoblinSteering steering = controller as GoblinSteering; if (steering.SurfaceContact.normal != Vector2.zero) { controller.SetStrategy(GoblinMoveStrategy.Instance()); } }
public override void SteerOther(BasicSteering controller) { JumpingGoblinSteering steering = controller as JumpingGoblinSteering; if (steering.SurfaceContact.normal != Vector2.zero) { controller.SetStrategy(JumpingGoblinMoveStrategy.Instance()); } }
public static List<RaycastHit2D> GetForwardObjectsList(BasicSteering controller, float range = 1f) { Collider2D controllerCollider = controller.GetComponent<Collider2D>(); float xMax = controllerCollider.bounds.max.x; float yMax = controllerCollider.bounds.max.y; float yMin = controllerCollider.bounds.min.y; Vector2 dirVector = new Vector2(range, yMax - yMin); HashSet<RaycastHit2D> hits = new HashSet<RaycastHit2D>(Physics2D.RaycastAll(new Vector2(xMax, yMin), dirVector, dirVector.magnitude, Constants.RaycastMaskPhysics)); Debug.DrawRay(new Vector2(xMax, yMin), dirVector, Color.red); dirVector.y = -dirVector.y; hits.UnionWith(Physics2D.RaycastAll(new Vector2(xMax, yMax), dirVector, dirVector.magnitude, Constants.RaycastMaskPhysics)); Debug.DrawRay(new Vector2(xMax, yMax), dirVector, Color.red); return hits.ToList(); }
public override void SteerPhysics(BasicSteering controller) { JumpingGoblinSteering parentController = controller as JumpingGoblinSteering; Vector2 normal = Vector2.up; float angle = 0; angle = Vector2.Angle(parentController.transform.up, normal) * Mathf.Sign(parentController.transform.up.x - normal.x); angle = Utility.NormalizeAngle(angle); parentController.GetComponent<GoblinLocomotion>().KeepBalance(angle); if (controller.GetComponent<Rigidbody2D>().velocity.y < ParachuteOpenSpeed) { controller.SendMessage("Break", 4f); controller.SendMessage("ParachuteOpen"); } }
public override void SteerOther(BasicSteering controller) { GoblinSteering steering = controller as GoblinSteering; if (steering.SurfaceContact.normal == Vector2.zero) { steering.SetStrategy(JumpingGoblinFloatStrategy.Instance()); } CheckTargets(steering,2); if (steering.Targets.Count == 0 || steering.Targets[0].tag == "Enemy" || steering.Targets[0].GetComponent<Collider2D>().bounds.min.x - steering.GetComponent<Collider2D>().bounds.max.x > 1.5) { steering.SetStrategy(JumpingGoblinMoveStrategy.Instance()); } else { steering.GetComponent<GoblinLocomotion>().Kick(steering.Targets[0].GetComponent<PhysicsObject>()); } }
public virtual void SteerOther(BasicSteering controller) { GoblinSteering steering = controller as GoblinSteering; if (steering.SurfaceContact.normal == Vector2.zero) { steering.SetStrategy(GoblinFloatStrategy.Instance()); } CheckTargets(steering); if (steering.Targets.Count == 0 || steering.Targets[0].tag == "Enemy") { steering.SetStrategy(GoblinMoveStrategy.Instance()); } else { GameObject mainTarget = steering.Targets[0]; steering.GetComponent<GoblinLocomotion>().Kick(mainTarget.GetComponent<PhysicsObject>()); } }
public virtual void SteerOther(BasicSteering controller) { GoblinSteering steering = controller as GoblinSteering; if(steering.SurfaceContact.normal == Vector2.zero) { controller.SetStrategy(GoblinFloatStrategy.Instance()); } GoblinCombatStrategy.CheckTargets(steering); if(steering.Targets.Count!=0) { if (steering.Targets[0].tag != "Enemy") { controller.SetStrategy(GoblinCombatStrategy.Instance()); } else if (steering.Targets[0].GetComponent<PhysicsObject>().GetExtents().min.x-steering.GetComponent<GoblinPhysics>().GetExtents().max.x<0.1) { steering.Stopped = false; } } }
public virtual void SteerPhysics(BasicSteering parent) { GoblinSteering parentController = parent as GoblinSteering; if (parentController.Stopped) { parentController.Stopped = false; } else { Vector2 normal = parentController.SurfaceContact.normal; if (normal == Vector2.zero) normal = Vector2.up; float angle = 0; angle = Vector2.Angle(parentController.transform.up, normal) * Mathf.Sign(parentController.transform.up.x - normal.x); angle = Utility.NormalizeAngle(angle); parentController.GetComponent<GoblinLocomotion>().MoveForward(20); parentController.GetComponent<GoblinLocomotion>().KeepBalance(angle); if (parentController.GetComponent<Rigidbody2D>().velocity.magnitude < 0.001f && parentController.SurfaceContact.normal != Vector2.zero) { parentController.GetComponent<GoblinLocomotion>().StandUp(parentController.SurfaceContact.normal); } } }
public virtual void SteerPhysics(BasicSteering controller) { }
public virtual void ExitState(BasicSteering controller) { }
public override void ExitState(BasicSteering controller) { controller.SendMessage("ParachuteClose"); }