public void Init() { var rnd = new Random(31); StepX = 32; StepY = 32; Position = new Vector2(128, 0); Velocity = Vector2.Zero; Direction = General.eDirection.Idle; LastDirection = General.eDirection.Down; TheAction = General.ePlayerAction.MoveOnGround; Map = InitMapWith(TMD.GroundMap); }
public override void UpdatePosition() { base.UpdatePosition(); // current player position before moving Point current = new Point((int)(Position.X / StepX), (int)(Position.Y / StepY)); // next point on player map towards player will eventually set its Direction & Velocity in Move() function call Point next = current; if (OutOfScreen()) { Stop(current); return; } if (((int)Position.Y % StepY) == 0 && ((int)Position.X % StepX) == 0) { if (TMD.GroundMap[current.Y][current.X] == (int)General.Legend.Crater) { Map[current.Y][current.X] = (int)General.Legend.DragonPath; UpdateMap(current.Y, current.X); this.TheAction = General.ePlayerAction.MoveInCrater; } else if (TMD.GroundMap[current.Y][current.X] == (int)General.Legend.PlayerPath && this.TheAction == General.ePlayerAction.MoveInCrater) { // returns Stop(current); this.TheAction = General.ePlayerAction.MoveOnGround; if (DragonEyeCompleted()) { ShowMatrix(Map); } return; } Move(); if (CanMove(ref next)) { if (TMD.GroundMap[next.Y][next.X] == (int)General.Legend.Crater && TMD.GroundMap[current.Y][current.X] == (int)General.Legend.PlayerPath) { // player leaves path TheAction = General.ePlayerAction.MoveInCrater; } } } Position += Velocity; }