private void NpcSetRoamMovement(bool useAStar, GameTime gt) { moving = true; // go towards random tile Vector2 targetLoc; if (useAStar) { targetLoc = currentPath[0].GetBoundingBox().Center.ToVector2(); } else { targetLoc = randomRegionRoamTile.location; } Tuple <int, int> frames = AIUtility.SetAIGroundMovement(targetLoc, location); currRowFrame = frames.Item1 + nIdleRowFrames; directionalFrame = frames.Item2; // FIND a better way to get this value - can't have references if (npcInInterior != null) { randomRegionRoamTile = npcInInterior.interiorTiles.ToList()[npcInInterior.interiorTiles.ToList().IndexOf((TilePiece)randomRegionRoamTile)]; } if (useAStar) { // we have found the next tile in path if (currentPath != null && currentPath[0].GetBoundingBox().Intersects(GetBoundingBox())) { currentPath.RemoveAt(0); if (currentPath.Count == 0) // found the end of the path { roaming = false; } } } else { // found roam tile if (GetBoundingBox().Intersects(randomRegionRoamTile.GetBoundingBox())) { roaming = false; flying = false; // for anything flying } } }
private void NpcSetAttackInRange(GameTime gt) { // attack range Vector2?targetV = AIUtility.ChooseTargetVector(teamType, GetBoundingBox().Width * 2, GetBoundingBox(), inInteriorId); if (targetV != null) { idle = false; // IN COMBAT if (!inCombat) { currColumnFrame = combatFrameIndex; } inCombat = true; Tuple <int, int> frames = AIUtility.SetAIGroundMovement((Vector2)targetV, location); currRowFrame = frames.Item1 + nIdleRowFrames; // plus one to skip the idle frame directionalFrame = frames.Item2; } }
private void NpcSetMoveTowardsTarget(int bbRange, GameTime gt) { // if target within range, move towards it Vector2?targetV = AIUtility.ChooseTargetVector(teamType, GetBoundingBox().Width *bbRange, GetBoundingBox(), inInteriorId); if (targetV != null) { idle = false; Tuple <int, int> frames = AIUtility.SetAIGroundMovement((Vector2)targetV, location); currRowFrame = frames.Item1 + nIdleRowFrames; // plus one to skip the idle frame directionalFrame = frames.Item2; moving = true; defense = true; } else { idle = true; defense = false; } }