Esempio n. 1
0
 public Movement(MapObject o, int x, int y, Direction direction)
 {
     this.parentObject = o;
     this.oldX = x;
     this.oldY = y;
     this.direction = direction;
 }
Esempio n. 2
0
        public void StartMovement(Direction playerDirection)
        {
            // the player movement is special; if it fails, everything fails.
            Movement playerMovement;

            List<Movement> movements = new List<Movement> ();
            foreach (Tile t in this.occupiedTiles) {
                Movement m = new Movement (t.contains, t.x, t.y, t.contains.Move (playerDirection));
                movements.Add (m);

                if (m.ParentObject ().IsCharacter ())
                    playerMovement = m;
            }

            foreach (Movement m1 in movements) {
                // if we already marked it invalid, skip
                if (m1.Invalid ())
                    continue;

                if (m1.NewX () < 0 || m1.NewX () >= this.width
                    || m1.NewY () < 0 || m1.NewY () >= this.height) {
                    m1.SetInvalid ();
                    continue;
                }

                foreach (Movement m2 in movements) {
                    if (m1 == m2)
                        continue;
                    if (m1.Conflicts (m2)) {
                        m1.SetInvalid ();
                        m2.SetInvalid ();
                        break;
                    }
                }
            }

            this.currentMovements = movements;
        }
Esempio n. 3
0
 public override Direction Move(Direction playerMovement)
 {
     return new Direction (-playerMovement.x, -playerMovement.y);
 }
Esempio n. 4
0
 public override Direction Move(Direction playerMovement)
 {
     return new Direction (0, 0);
 }
Esempio n. 5
0
 public override Direction Move(Direction playerMovement)
 {
     return playerMovement;
 }
Esempio n. 6
0
 public abstract Direction Move(Direction playerMovement);