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(); } }
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); } } } } }