Beispiel #1
0
        private void h_FillByFile(int iLevel)
        {
            string sFn = $"../$Data/{iLevel}.csv";

            if (!File.Exists(sFn))
            {
                return;
            }

            string[] arLines = File.ReadAllLines(sFn);
            for (int iY = 0; iY < arLines.Length; iY++)
            {
                string[] arCells = arLines[iY].Split(';');
                for (int iX = 0; iX < arCells.Length; iX++)
                {
                    string s = arCells[iX];
                    // s @ iX, iY
                    switch (s)
                    {
                    case "+":
                    {
                        CPlayerDynamicObject pO =
                            new CPlayerDynamicObject("Player", iX, iY);
                        DynamicObjects.Add(pO);
                        break;
                    }

                    case "*": {
                        CWallStaticObject pO =
                            new CWallStaticObject(iX, iY);
                        StaticObjects.Add(pO);
                        break;
                    }

                    //case "-": {
                    //  CEmptyStaticObject pO =
                    //    new CEmptyStaticObject(iX, iY);
                    //  StaticObjects.Add(pO);
                    //  break;
                    //}
                    case "?": {
                        CBoxDynamicObject pO =
                            new CBoxDynamicObject(iX, iY);
                        DynamicObjects.Add(pO);
                        break;
                    }

                    case "!": {
                        CExitStaticObject pO =
                            new CExitStaticObject(iX, iY);
                        StaticObjects.Add(pO);
                        break;
                    }
                    }
                }
            }
        }
Beispiel #2
0
        private void h_FillStage1()
        {
            CWallStaticObject pWall1 = new CWallStaticObject(0, 0);
            CWallStaticObject pWall2 = new CWallStaticObject(0, 1);
            CWallStaticObject pWall3 = new CWallStaticObject(0, 2);
            CWallStaticObject pWall4 = new CWallStaticObject(0, 3);

            StaticObjects.Add(pWall1);
            StaticObjects.Add(pWall2);
            StaticObjects.Add(pWall3);
            StaticObjects.Add(pWall4);
            ///...
        }