public void Tick(SceneGame scene) { var active = Curio.GetActionHolder(ActionSlot.Active); var lastSeen = Curio.GetBehavior <BehaviorLastSeen>(); var pathfinder = Curio.GetBehavior <BehaviorPathfinder>(); var orientable = Curio.GetBehavior <BehaviorOrientable>(); var tile = Curio.GetMainTile(); if (tile != null && active.Done && Curio.IsAlive()) { var map = tile.Map; var mace = Curio.GetBehavior <BehaviorMace>(); var delta = scene.PlayerCurio.GetVisualTarget() - Curio.GetVisualTarget(); if (mace != null && mace.IsInArea(scene.PlayerCurio) && map.CanSee(Curio.GetVisualTarget(), scene.PlayerCurio.GetVisualTarget())) { var angleCurrent = orientable.Angle; var angleTarget = Enumerable.Range(0, 8).Select(x => MathHelper.PiOver4 * x).GetClosestAngle(Util.VectorToAngle(delta)); var angleDelta = MathHelper.WrapAngle(angleTarget - angleCurrent); var attack = new List <ActionWrapper>() { //new ActionMaceAttack(Curio, scene.PlayerCurio, 20f, 5f).InSlot(ActionSlot.Active), new ActionMaceGoreAttack(Curio, scene.PlayerCurio, 40f, 20f, 5f).InSlot(ActionSlot.Active), new ActionTurn(Curio, angleDelta, 3).InSlot(ActionSlot.Active), }; attack.Apply(Curio); } else if (lastSeen.LastSeenTile != null) { var nextMove = pathfinder.GetNextMove(new Point(tile.X, tile.Y)); if (lastSeen.LastSeenTile != pathfinder.GetDestination() || !nextMove.HasValue) { pathfinder.FindPath(lastSeen.LastSeenTile); } if (nextMove.HasValue) { var angleCurrent = orientable.Angle; var angleTarget = Util.PointToAngle(nextMove.Value); var angleDelta = MathHelper.WrapAngle(angleTarget - angleCurrent); var movement = new List <ActionWrapper>(); if (Math.Abs(angleDelta) < 0.0001) { movement.Add(new ActionMoveForward(Curio, nextMove.Value.ToVector2(), 8).InSlot(ActionSlot.Active)); } else if (angleDelta < 0) { movement.Add(new ActionTurn(Curio, -MathHelper.PiOver4, 4).InSlot(ActionSlot.Active)); } else if (angleDelta > 0) { movement.Add(new ActionTurn(Curio, MathHelper.PiOver4, 4).InSlot(ActionSlot.Active)); } movement.Apply(Curio); } } } }
public void Tick(SceneGame scene) { var active = Curio.GetActionHolder(ActionSlot.Active); if (StabTargets.Any()) { active.CurrentActions.RemoveAll(x => x is ActionKeepMoving); } StabTargets.RemoveAll(x => x.Removed); }
public void Tick(SceneGame scene) { var active = Curio.GetActionHolder(ActionSlot.Active); var lastSeen = Curio.GetBehavior <BehaviorLastSeen>(); var pathfinder = Curio.GetBehavior <BehaviorPathfinder>(); var orientable = Curio.GetBehavior <BehaviorOrientable>(); var tile = Curio.GetMainTile(); if (active.Done && Curio.IsAlive()) { var delta = scene.PlayerCurio.GetVisualTarget() - Curio.GetVisualTarget(); var distance = delta.Length(); if (distance < 24f) { var angleCurrent = orientable.Angle; var angleTarget = Enumerable.Range(0, 8).Select(x => MathHelper.PiOver4 * x).GetClosestAngle(Util.VectorToAngle(delta)); var angleDelta = MathHelper.WrapAngle(angleTarget - angleCurrent); var attack = new List <ActionWrapper>() { new ActionDaggerAttack(Curio, Util.ToTileOffset(Util.AngleToVector(angleTarget)), 5f, 2.5f).InSlot(ActionSlot.Active), new ActionTurn(Curio, angleDelta, 3).InSlot(ActionSlot.Active), }; attack.Apply(Curio); } else if (lastSeen.LastSeenTile != null) { var nextMove = pathfinder.GetNextMove(new Point(tile.X, tile.Y)); if (lastSeen.LastSeenTile != pathfinder.GetDestination() || !nextMove.HasValue) { pathfinder.FindPath(lastSeen.LastSeenTile); } if (nextMove.HasValue) { var angleCurrent = orientable.Angle; var angleTarget = Util.PointToAngle(nextMove.Value); var angleDelta = MathHelper.WrapAngle(angleTarget - angleCurrent); var movement = new List <ActionWrapper>(); if (Math.Abs(angleDelta) < 0.0001) { movement.Add(new ActionMoveForward(Curio, nextMove.Value.ToVector2(), 10).InSlot(ActionSlot.Active)); } else if (angleDelta < 0) { movement.Add(new ActionTurn(Curio, -MathHelper.PiOver4, 5).InSlot(ActionSlot.Active)); } else if (angleDelta > 0) { movement.Add(new ActionTurn(Curio, MathHelper.PiOver4, 5).InSlot(ActionSlot.Active)); } movement.Apply(Curio); } } } }
public void Tick(SceneGame scene) { var active = Curio.GetActionHolder(ActionSlot.Active); var lastSeen = Curio.GetBehavior <BehaviorLastSeen>(); if (active?.Done ?? true && Curio.IsAlive()) { bool specialAction = PerformSpecialAction(); if (!specialAction && lastSeen.LastSeenTile != null) { PerformMovement(lastSeen); } } }
public void Tick(SceneGame scene) { var active = Curio.GetActionHolder(ActionSlot.Active); var lastSeen = Curio.GetBehavior <BehaviorLastSeen>(); var pathfinder = Curio.GetBehavior <BehaviorPathfinder>(); var orientable = Curio.GetBehavior <BehaviorOrientable>(); var alive = Curio.GetBehavior <BehaviorAlive>(); var tile = Curio.GetMainTile(); var enemyDistance = Vector2.Distance(scene.PlayerCurio.GetVisualTarget(), Curio.GetVisualTarget()); var isEnemyFar = enemyDistance > 200; var isEnemyClose = enemyDistance < 100; var isEnemyArmed = scene.PlayerCurio.HasBehaviors <BehaviorSword>(); WingsOpen.Update(); ForwardBack.Update(); if (active.Done && alive.CurrentDead) { var actions = new List <ActionWrapper>(); actions.Add(new ActionNemesisRevive(Curio, 120).InSlot(ActionSlot.Active)); actions.Apply(Curio); if (!actions.Any(x => x.Action is ActionNemesisRevive)) { scene.GameOver(GameOverType.NemesisKill); } } if (active.Done && Curio.IsAlive()) { if (ForwardBack.End > 0 && State != NemesisState.Forward) { ForwardBack.Set(0, LerpHelper.Quadratic, 30); } if (ForwardBack.End < 1 && State == NemesisState.Forward) { ForwardBack.Set(1, LerpHelper.Quadratic, 30); } if (State == NemesisState.Back) { if (isEnemyArmed) { ParryTimer += scene.TimeModCurrent; if (ParryTimer.Done) { State = NemesisState.Parry; ParryTimer.Time = 0; } } if (isEnemyFar) { ChaseTimer += scene.TimeModCurrent; if (ChaseTimer.Done) { State = NemesisState.Forward; ChaseTimer.Time = 0; } } } if (State == NemesisState.Parry) { if (!isEnemyArmed || isEnemyFar) { ParryTimer += scene.TimeModCurrent; if (ParryTimer.Done) { State = NemesisState.Back; ParryTimer.Time = 0; } } } if (State == NemesisState.Forward) { if (isEnemyClose) { State = NemesisState.Back; } ChaseTimer += 1; if (lastSeen.LastSeenTile != null) { var nextMove = pathfinder.GetNextMove(new Point(tile.X, tile.Y)); if (lastSeen.LastSeenTile != pathfinder.GetDestination() || !nextMove.HasValue) { pathfinder.FindPath(lastSeen.LastSeenTile); } if (nextMove.HasValue) { var angleCurrent = orientable.Angle; var angleTarget = Util.PointToAngle(nextMove.Value); var angleDelta = MathHelper.WrapAngle(angleTarget - angleCurrent); var movement = new List <ActionWrapper>(); if (ChaseTimer.Done) { var randomPath = pathfinder.Path.Pick(Random); var randomPathTile = Curio.GetMap().GetTileOrNull(randomPath.X, randomPath.Y); if (randomPathTile != tile) { var dist = Vector2.Distance(randomPathTile.VisualTarget, Curio.GetVisualTarget()); movement.Add(new ActionMoveNemesis(Curio, scene.PlayerCurio, randomPathTile, dist / 8f + 10).InSlot(ActionSlot.Active)); ChaseTimer.Time = 0; } } else if (Math.Abs(angleDelta) < 0.0001) { movement.Add(new ActionMoveForward(Curio, nextMove.Value.ToVector2(), 5).InSlot(ActionSlot.Active)); } else if (angleDelta < 0) { movement.Add(new ActionTurn(Curio, -MathHelper.PiOver4, 3).InSlot(ActionSlot.Active)); } else if (angleDelta > 0) { movement.Add(new ActionTurn(Curio, MathHelper.PiOver4, 3).InSlot(ActionSlot.Active)); } movement.Apply(Curio); } } } } }
public static void Apply(this List <ActionWrapper> actions, ICurio curio) { EventBus.PushEvent(new EventAction(actions)); var slots = actions.Select(x => x.Slot).Distinct().ToDictionary(x => x, x => curio.GetActionHolder(x)); foreach (var slot in slots) { slot.Value?.Cleanup(); } foreach (var wrapper in actions) { var slot = slots.GetOrDefault(wrapper.Slot, null); var action = wrapper.Action; action.Run(); slot?.Add(action); } }
public void Tick(SceneGame scene) { var active = Curio.GetActionHolder(ActionSlot.Active); var lastSeen = Curio.GetBehavior <BehaviorLastSeen>(); var pathfinder = Curio.GetBehavior <BehaviorPathfinder>(); var orientable = Curio.GetBehavior <BehaviorOrientable>(); var tile = Curio.GetMainTile(); var map = Curio.GetMap(); if (Curio.IsDead()) { Decay += scene.TimeModCurrent; } if (Decay.Done) { var actions = new List <ActionWrapper>(); actions.Add(new ActionRatGib(scene.PlayerCurio, Curio, 2000, SoundLoader.AddSound("content/sound/splat.wav")).InSlot(ActionSlot.Active)); actions.Apply(Curio); } if (active.Done && Curio.IsAlive()) { if (lastSeen.LastSeenTile != null) { var nextMove = pathfinder.GetNextMove(new Point(tile.X, tile.Y)); if (!pathfinder.HasPath) { var positions = map.EnumerateTiles().Shuffle(Random); foreach (var escapeTile in positions) { if (Vector2.Distance(escapeTile.VisualTarget, tile.VisualTarget) < 300) { continue; } if (escapeTile.IsChasm() || escapeTile.IsSolid()) { continue; } pathfinder.FindPath(escapeTile); SoundRat.Play(1, Random.NextFloat(-0.5f, +0.5f), 0); break; } } else if (nextMove.HasValue) { var angleCurrent = orientable.Angle; var angleTarget = Util.PointToAngle(nextMove.Value); var angleDelta = MathHelper.WrapAngle(angleTarget - angleCurrent); var movement = new List <ActionWrapper>(); if (Math.Abs(angleDelta) < 0.0001) { movement.Add(new ActionMoveForward(Curio, nextMove.Value.ToVector2(), 4).InSlot(ActionSlot.Active)); } else if (angleDelta < 0) { movement.Add(new ActionTurn(Curio, -MathHelper.PiOver4, 5).InSlot(ActionSlot.Active)); } else if (angleDelta > 0) { movement.Add(new ActionTurn(Curio, MathHelper.PiOver4, 5).InSlot(ActionSlot.Active)); } movement.Apply(Curio); } else { var actions = new List <ActionWrapper>(); actions.Add(new ActionRatGib(scene.PlayerCurio, Curio, 2000, SoundLoader.AddSound("content/sound/splat.wav")).InSlot(ActionSlot.Active)); actions.Apply(Curio); } } } }
public void Tick(SceneGame scene) { Fade.Update(); var tile = Curio.GetMainTile(); var passive = Curio.GetActionHolder(ActionSlot.Passive); var active = Curio.GetActionHolder(ActionSlot.Active); var levelEnd = tile?.GetBehavior <BehaviorLevelEnd>(); if (levelEnd != null && !scene.WaitForCutscene && passive.Done && active.Done && levelEnd.CanEscape() && Curio.IsAlive()) { EndLevel(scene); } UpdateFootstep(scene); bool faceForward = (Momentum.Amount > 0 || LevelTransition); if (ForwardBack.End > 0 && !faceForward) { ForwardBack.Set(0, LerpHelper.Quadratic, 30); } if (ForwardBack.End < 1 && faceForward) { ForwardBack.Set(1, LerpHelper.Quadratic, 30); } ForwardBack.Update(); HairFrame += LevelTransition ? 1 : scene.TimeModCurrent; if (Curio.IsDead() && !scene.IsGameOver) { scene.GameOver(GameOverType.Death); SoundDeath.Play(1, -0.5f, 0); } if (!scene.WaitForPlayer) { //MovePassive(); } else if (Momentum.Amount <= 0 && SwordReady) { SheatheSword(); } }