public void Load(string filePath) { var text = File.ReadAllText(filePath); //Remove \r to fix OS compatibility text = text.Replace("\r", ""); var list = text.Split('\n'); for (var y = 0; y < YSize; y++) { var line = list[y]; for (var x = 0; x < XSize; x++) { var character = line[x]; var linkedList = new LinkedList <EntityBase>(); Grid[y, x] = linkedList; linkedList.AddFirst(new Space()); var point = new Point(x, y); switch (character) { case Constant.PlayerChar: { var p = new Player(); p.Start(this, point); linkedList.AddFirst(p); break; } case Constant.GhostChar: { var p = new Ghost(); p.Start(this, point); linkedList.AddFirst(p); break; } case Constant.WallChar: { var p = new Wall(); p.Start(this, point); linkedList.AddFirst(p); break; } case Constant.ScoreChar: { var p = new Score(); p.Start(this, point); linkedList.AddFirst(p); _scoreInMap++; break; } } } } }
public virtual void Start(GameScene scene, IPoint point) { this.Scene = scene; /*this.X = X; * this.Y = Y;*/ Point = new Point.Point(point.X, point.Y); }