public override void RunBehaviour(IMindAI mind) { chaseVector = Vector2.Subtract(mind.getSetTarget.getSetLocation, mind.getSetEntity.getSetLocation); mind.getSetMoveVector = new Vector2(0, 0); if (Vector2.Distance(mind.getSetTarget.getSetLocation, mind.getSetEntity.getSetLocation) > 60) { mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("ChaseEntity"); } //Console.WriteLine("Attack " + mind.getSetID); }
public override void RunBehaviour(IMindAI mind) { // Choose a random point nearby Vector2 chaseVector = new Vector2(0, 0); if (mind.getSetTarget != null && Vector2.Distance(mind.getSetTarget.getSetLocation, mind.getSetEntity.getSetLocation) < 250) { mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("ChaseEntity"); } mind.getSetMoveVector = chaseVector; //Console.WriteLine("Idle passive... " + mind.getSetID); }
public override void RunBehaviour(IMindAI mind) { // Cast ray to target // if false // then use vectors // else use A* if (!rayHit && !RayM.getInstance.CastRayToPlayer(mind.getSetLocation)) { rayHit = true; } else { rayHit = false; } if (rayHit) { if (path.Count > 0) { path.Clear(); nodeNumber = 0; } chaseVector = Vector2.Subtract(mind.getSetTarget.getSetLocation, mind.getSetEntity.getSetLocation); } else { if (path.Count == 0) { // Can't Reach The Player Entity //Console.WriteLine("Using A* - ChaseEntity"); //Point start = new Point((int)mind.getSetLocation.X / 64, (int)mind.getSetLocation.Y / 64); //Point end = new Point((int)mind.getSetTarget.getSetLocation.X / 64, (int)mind.getSetTarget.getSetLocation.Y / 64); Point start = mind.getSetEntity.getSetPointLocation; Point end = mind.getSetTarget.getSetPointLocation; SearchParameters sp = new SearchParameters(start, end); APathfinder ap = new APathfinder(sp); path = ap.FindPath(); ap.ResetNodes(); nodeNumber = 0; once = false; //newAstar = false; } else { //Point current = new Point((int)mind.getSetEntity.getSetPointLocation.X, (int)mind.getSetEntity.getSetPointLocation.Y); if (nodeNumber >= path.Count) { path.Clear(); newAstar = true; } else { if (mind.getSetEntity.getSetPointLocation == path[nodeNumber]) { nodeNumber++; once = false; } else if (!once) { Vector2 pathNode = new Vector2((path[nodeNumber].X * 64) - 20, (path[nodeNumber].Y * 64) - 20); //Vector2 direction = mind.getSetEntity.getSetLocation - pathNode; chaseVector = pathNode - mind.getSetEntity.getSetLocation; //chaseVector.Normalize(); once = true; } } //chaseVector = Vector2.Subtract(mind.getSetTarget.getSetLocation, mind.getSetEntity.getSetLocation); //Console.WriteLine("ChaseEntity aggressive... " + mind.getSetID); } } if (mind.getSetTarget != null && Vector2.Distance(mind.getSetTarget.getSetLocation, mind.getSetEntity.getSetLocation) < 50) { mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("Attack"); } else if (mind.getSetTarget == null || Vector2.Distance(mind.getSetTarget.getSetLocation, mind.getSetEntity.getSetLocation) > 100) { mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("Idle"); } mind.getSetMoveVector = chaseVector; }
/// <summary> /// Runs the behaviour /// </summary> public virtual void RunBehaviour(IMindAI mind) { }