Beispiel #1
0
        /// <summary>
        /// Test supplementary scales (via LevelParser). Alternative for TestSupplementaryScales method above.
        /// </summary>
        /// <param name="headerformat">Report header format.</param>
        /// <param name="input">Input level to parse.</param>
        /// <remarks>
        /// LevelParser is used here to get levels directly (and not via intermediate quantity as in
        /// TestSupplementaryScales above). On the other hand, if you also need to input quantities
        /// (e.g. temperature increase) then you will have to apply QuantityParser in addition (meaning
        /// two methods instead of one).
        /// </remarks>
        static void TestSupplementaryScalesWithLevelParser(string headerformat, string input)
        {
            Console.WriteLine();
            Console.WriteLine(headerformat, input);

            var parser = new LevelParser <double>(Kelvin.Family);

            ILevel <double> temperature;

            if (!parser.TryParse(input, out temperature))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("{0}: invalid number or unit other than any of the following: {1}.", input, string.Join(", ", parser.Scales.Select(s => s.Unit.Symbol.ToString())));
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Green;
                int i = 0;
                foreach (var scale in parser.Scales)
                {
                    string          scaleinfo = string.Format("{0,2}. {1}", ++i, scale);
                    ILevel <double> output    = scale.From(temperature);
                    Console.WriteLine("{0,-40}  {1} -> {2}", scaleinfo, input, output);
                }
            }
            Console.ResetColor();
        }
Beispiel #2
0
        public void TestParseCustomLevelPlatformEnemy()
        {
            List <string> columns = new List <string>()
            {
                "--------------------------------------A-----------------"
            };
            List <string> result = LevelParser.BreakColumnsIntoSimplifiedTokens(columns, Games.Custom);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[0]);

            columns.Add("------------------------------------Bbb-----------------");
            result = LevelParser.BreakColumnsIntoSimplifiedTokens(columns, Games.Custom);
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[0]);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[1]);

            columns.Add("-------------------------------------bbb---------------C");
            result = LevelParser.BreakColumnsIntoSimplifiedTokens(columns, Games.Custom);
            Assert.AreEqual(3, result.Count);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[0]);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[1]);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[2]);

            columns.Add("---------------------------------------------Ab---------");
            result = LevelParser.BreakColumnsIntoSimplifiedTokens(columns, Games.Custom);
            Assert.AreEqual(4, result.Count);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[0]);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[1]);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[2]);
            Assert.AreEqual(SimplifiedColumns.PlatformForcedEnemy, result[3]);
        }
    public void UpdateChallengePreview()
    {
        Vector2      indexes      = LevelParser.GetLevelPackLevelIndexes(LevelLoader.GetLevelName());
        ChallengeLog challengeLog = ChallengeManager.GetCurrentChallengeLog((int)indexes.x, (int)indexes.y);

        challengePreview.SetLevelChallengePreview(challengeLog, LevelLoader.GetLevelName());
    }
Beispiel #4
0
            public ClearReplacer(Th06Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelParser.Parse(match.Groups[1].Value);
                    var chara = CharaParser.Parse(match.Groups[2].Value);

                    var key = new CharaLevelPair(chara, level);
                    if (parent.allScoreData.Rankings.ContainsKey(key))
                    {
                        var stageProgress =
                            parent.allScoreData.Rankings[key].Max(rank => rank.StageProgress);
                        if (stageProgress == StageProgress.Extra)
                        {
                            return("Not Clear");
                        }
                        else
                        {
                            return(stageProgress.ToShortName());
                        }
                    }
                    else
                    {
                        return(StageProgress.None.ToShortName());
                    }
                });
            }
            public PracticeReplacer(Th10Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelParser.Parse(match.Groups[1].Value);
                    var chara = (CharaWithTotal)CharaParser.Parse(match.Groups[2].Value);
                    var stage = StageParser.Parse(match.Groups[3].Value);

                    if (level == Level.Extra)
                    {
                        return(match.ToString());
                    }
                    if (stage == Stage.Extra)
                    {
                        return(match.ToString());
                    }

                    if (parent.allScoreData.ClearData.ContainsKey(chara))
                    {
                        var key       = new LevelStagePair(level, stage);
                        var practices = parent.allScoreData.ClearData[chara].Practices;
                        return(practices.ContainsKey(key)
                            ? Utils.ToNumberString(practices[key].Score * 10) : "0");
                    }
                    else
                    {
                        return("0");
                    }
                });
            }
Beispiel #6
0
    public void LoadLevel()
    {
        Dictionary <string, GameObject> mapping = new Dictionary <string, GameObject>();

        foreach (GameObject m in typeMappings)
        {
            mapping[m.name] = m;
        }

        LevelParser l            = new LevelParser();
        string      objectsFile  = "Assets/Levels/" + levels[currentLevel].levelName + "_Objects.csv";
        string      platformFile = "Assets/Levels/" + levels[currentLevel].levelName + "_Platform.csv";
        string      floorFile    = "Assets/Levels/" + levels[currentLevel].levelName + "_Floor.csv";

        Level level = l.ParseLevelFile(objectsFile, floorFile, platformFile, tilesetFile);

        Bounds allBounds = SpawnSet(level.floor, floorContainer.transform, mapping);

        SpawnSet(level.objects, objectsContainer, mapping);
        SpawnSet(level.platform, platformContainer, mapping);

        platformContainer.transform.position = -allBounds.center + Vector3.up * platformContainer.transform.position.y;
        objectsContainer.transform.position  = -allBounds.center + Vector3.up * objectsContainer.transform.position.y;
        floorContainer.transform.position    = -allBounds.center + Vector3.up * floorContainer.transform.position.y;
        Physics.SyncTransforms();
        floorContainer.UpdateBounds();
        historianManager.LoadHistorians();
        historianManager.Record();
    }
Beispiel #7
0
            public PracticeReplacer(Th06Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelParser.Parse(match.Groups[1].Value);
                    var chara = CharaParser.Parse(match.Groups[2].Value);
                    var stage = StageParser.Parse(match.Groups[3].Value);

                    if (level == Level.Extra)
                    {
                        return(match.ToString());
                    }
                    if (stage == Stage.Extra)
                    {
                        return(match.ToString());
                    }

                    var key = new CharaLevelPair(chara, level);
                    if (parent.allScoreData.PracticeScores.ContainsKey(key))
                    {
                        var scores = parent.allScoreData.PracticeScores[key];
                        return(scores.ContainsKey(stage)
                            ? Utils.ToNumberString(scores[stage].HighScore) : "0");
                    }
                    else
                    {
                        return("0");
                    }
                });
            }
Beispiel #8
0
        private Tuple <List <string>, List <string> > GetColumnsSemiGuaranteed(ICompiledGram compiled, ICompiledGram simpleCompiled)
        {
            List <string> columns;
            List <string> simplified;

            if (simplifiedGram == null)
            {
                columns    = NGramGenerator.Generate(compiled, startInput, size, includeStart: false);
                simplified = LevelParser.BreakColumnsIntoSimplifiedTokens(
                    columns,
                    game);
            }
            else
            {
                simplified = NGramGenerator.GenerateBestAttempt(
                    simpleCompiled,
                    LevelParser.BreakColumnsIntoSimplifiedTokens(startInput, game),
                    size,
                    maxAttempts);

                Games localGame = game;
                columns = NGramGenerator.GenerateRestricted(
                    compiled,
                    startInput,
                    simplified,
                    (inColumn) =>
                {
                    return(LevelParser.ClassifyColumn(inColumn, localGame));
                },
                    includeStart: false);
            }

            return(new Tuple <List <string>, List <string> >(columns, simplified));
        }
Beispiel #9
0
            public ScoreReplacer(Th06Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelParser.Parse(match.Groups[1].Value);
                    var chara = CharaParser.Parse(match.Groups[2].Value);
                    var rank  = Utils.ToZeroBased(
                        int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture));
                    var type = int.Parse(match.Groups[4].Value, CultureInfo.InvariantCulture);

                    var key   = new CharaLevelPair(chara, level);
                    var score = parent.allScoreData.Rankings.ContainsKey(key)
                        ? parent.allScoreData.Rankings[key][rank] : InitialRanking[rank];

                    switch (type)
                    {
                    case 1:         // name
                        return(Encoding.Default.GetString(score.Name).Split('\0')[0]);

                    case 2:         // score
                        return(Utils.ToNumberString(score.Score));

                    case 3:         // stage
                        return(score.StageProgress.ToShortName());

                    default:        // unreachable
                        return(match.ToString());
                    }
                });
            }
Beispiel #10
0
    private void Start()
    {
        //Camera.main.transparencySortMode = TransparencySortMode.Orthographic;
        levelParser = GetComponent <LevelParser>();
        levelData   = levelParser.LoadLevelFromFile();
        currBlock   = 0;

        currScrollSpeed = normalScrollSpeed;

        bottomBlock = GenLoadedLevelBlock(currBlock, new Vector2(0f, 0f), currScrollSpeed, 0.5f, 20f);
        topBlock    = GenLoadedLevelBlock(currBlock + 1, new Vector2(0f, 10f), currScrollSpeed, 0f, 20f);
        currBlock++;
        //bottomBlock = CreateLevelBlock(new Vector2(0f, 0f), currScrollSpeed, 0.5f, 20f,
        //    new List<Vector2>() { new Vector2(3.5f, 0) },
        //    new List<Vector2>() { new Vector2(-9f, 3) },
        //    new List<Vector2>() { new Vector2(3.5f, -2f), new Vector2(-3.5f, -2f) },
        //                                backgroundTex[0]);

        //topBlock = CreateLevelBlock(new Vector2(0f, 10f), currScrollSpeed, 0f, 20f,
        //    new List<Vector2>() { new Vector2(3.5f, 0) },
        //    new List<Vector2>() { new Vector2(-9f, 3) },
        //    new List<Vector2>() { new Vector2(3.5f, -2f), new Vector2(-3.5f, -2f) },
        //                                backgroundTex[0]);


        character.boundary      = screenBoundary;
        character.PeakTouched  += OnCenteringBegin;
        character.CenteringEnd += OnCenteringEnd;
        //OnPhaseChange

        centering = false;
        StartCoroutine(CheckLevelEndCoroutine());
    }
            public CardReplacer(Th095Converter parent, bool hideUntriedCards)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelParser.Parse(match.Groups[1].Value);
                    var scene = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture);
                    var type  = int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture);

                    var key = new LevelScenePair(level, scene);
                    if (!SpellCards.ContainsKey(key))
                    {
                        return(match.ToString());
                    }

                    if (hideUntriedCards)
                    {
                        var score = parent.allScoreData.Scores.Find(
                            elem => (elem != null) && elem.LevelScene.Equals(key));
                        if (score == null)
                        {
                            return("??????????");
                        }
                    }

                    return((type == 1) ? SpellCards[key].Enemy.ToLongName() : SpellCards[key].Card);
                });
            }
Beispiel #12
0
        public void InitializeGameState()
        {
            backGroundImage = new Entity(
                new StationaryShape(new Vec2F(0.0f, 0.0f), new Vec2F(1.0f, 1.0f)),
                new Image(Path.Combine("Assets", "Images", "SpaceBackground.png")));

            titel = new Text("Select Level", new Vec2F(0f, 0.4f), new Vec2F(1f, 0.4f));
            titel.SetColor(new Vec3F(1f, 1f, 0f));
            titel.SetFontSize(65);

            maxMenuButtons   = LevelParser.GetInstance().LevelNames.Length + 1;
            menuButtons      = new Text[maxMenuButtons];
            activeMenuButton = 2;
            for (int i = 0; i < maxMenuButtons - 1; i++)
            {
                var levelName = LevelParser.GetInstance().LevelNames[i];
                var text      = new Text(levelName,
                                         new Vec2F(0.3f, i * 0.1f + 0.2f), new Vec2F(0.8f, 0.4f));
                text.SetColor(new Vec3F(1.0f, 1.0f, 1.0f));
                text.SetFontSize(20);
                menuButtons[maxMenuButtons - i - 2] = text;
            }
            menuButtons[maxMenuButtons - 1] =
                new Text("Return", new Vec2F(0.3f, -0.2f), new Vec2F(0.8f, 0.4f));
            menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f));
        }
Beispiel #13
0
    private void UpdateDifficultyNGram()
    {
        Vector3 playerPosition = blackBoard.LevelInfo.Player.transform.position;
        int     toRight        = blackBoard.ConfigUI.Config.DifficultyNGramRightColumns;
        int     toLeft         = blackBoard.ConfigUI.Config.DifficultyNGramLeftColumns;
        Tilemap tilemap        = blackBoard.Tilemap;

        Vector3Int tilePosition = tilemap.WorldToCell(playerPosition);

        int x    = Math.Max(tilePosition.x - toLeft, tilemap.cellBounds.xMin);
        int xMax = Math.Min(tilePosition.x + toRight, tilemap.cellBounds.xMax - 1);

        blackBoard.DifficultyNGram.UpdateMemory(blackBoard.ConfigUI.Config.DifficultyNGramMemoryUpdate);

        List <string> difficultPart = blackBoard.LevelColumns.GetRange(x, xMax - x + 1);

        NGramTrainer.Train(blackBoard.DifficultyNGram, difficultPart);

        if (blackBoard.ConfigUI.Config.UsingSimplifiedNGram)
        {
            blackBoard.SimpleDifficultyNGram.UpdateMemory(blackBoard.ConfigUI.Config.DifficultyNGramMemoryUpdate);
            NGramTrainer.Train(
                blackBoard.SimpleDifficultyNGram,
                LevelParser.BreakColumnsIntoSimplifiedTokens(
                    difficultPart,
                    blackBoard.ConfigUI.Config.Game));
        }
    }
            public ClearReplacer(Th09Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelParser.Parse(match.Groups[1].Value);
                    var chara = CharaParser.Parse(match.Groups[2].Value);
                    var type  = int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture);

                    var count = parent.allScoreData.PlayStatus.ClearCounts[chara].Counts[level];

                    if (type == 1)
                    {
                        return(Utils.ToNumberString(count));
                    }
                    else
                    {
                        if (count > 0)
                        {
                            return("Cleared");
                        }
                        else
                        {
                            var score = parent.allScoreData.Rankings[new CharaLevelPair(chara, level)][0];
                            var date  = Encoding.Default.GetString(score.Date).TrimEnd('\0');
                            return((date != "--/--") ? "Not Cleared" : "-------");
                        }
                    }
                });
            }
            public ScoreReplacer(Th09Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelParser.Parse(match.Groups[1].Value);
                    var chara = CharaParser.Parse(match.Groups[2].Value);
                    var rank  = Utils.ToZeroBased(
                        int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture));
                    var type = int.Parse(match.Groups[4].Value, CultureInfo.InvariantCulture);

                    var score = parent.allScoreData.Rankings[new CharaLevelPair(chara, level)][rank];
                    var date  = string.Empty;

                    switch (type)
                    {
                    case 1:         // name
                        return(Encoding.Default.GetString(score.Name).Split('\0')[0]);

                    case 2:         // score
                        return(Utils.ToNumberString((score.Score * 10) + score.ContinueCount));

                    case 3:         // date
                        date = Encoding.Default.GetString(score.Date).Split('\0')[0];
                        return((date != "--/--") ? date : "--/--/--");

                    default:        // unreachable
                        return(match.ToString());
                    }
                });
            }
    public void SetLevelChallengePreview(ChallengeLog challengeLog, string levelName)
    {
        int challengeCount = challengeLog?.GetChallengeCount() ?? 0;

        if (challengeCount <= 0)
        {
            noChallengeText.gameObject.SetActive(true);
            challengeParent.SetActive(false);
        }
        else
        {
            noChallengeText.gameObject.SetActive(false);
            challengeParent.SetActive(true);

            if (packIndex == -1 || levelIndex == -1)
            {
                Vector2 indexes = LevelParser.GetLevelPackLevelIndexes(levelName);
                packIndex  = (int)indexes.x;
                levelIndex = (int)indexes.y;
            }

            for (int i = 0; i < challengeEntries.Count; i++)
            {
                if (i <= challengeCount - 1)
                {
                    challengeEntries[i].gameObject.SetActive(true);
                    challengeEntries[i].UpdateChallengeEntry(challengeLog.GetChallengeData(i), packIndex, levelIndex);
                }
                else
                {
                    challengeEntries[i].gameObject.SetActive(false);
                }
            }
        }
    }
        public void LevelParser_ExtractHighscores_checkReturnsList()
        {
            ctrl.SaveFile();
            ctrl.LoadFile();
            List <int> actual = new LevelParser().ExtractHighscores();

            Assert.IsInstanceOfType(actual, List <int>);
        }
        public void LevelParser_ExtractLevelHeight_checkReturnsInt()
        {
            ctrl.SaveFile();
            ctrl.LoadFile();
            Int32 actual = new LevelParser().ExtractLevelHeight();

            Assert.IsInstanceOfType(actual, Int32);
        }
        public void LevelParser_ExtractLevelDifficulty_checkReturnsString()
        {
            ctrl.SaveFile();
            ctrl.LoadFile();
            string actual = new LevelParser().ExtractLevelDifficulty();

            Assert.IsInstanceOfType(actual, String);
        }
        public void LevelParser_ExtractLevelDateTime_checkReturnsDate()
        {
            ctrl.SaveFile();
            ctrl.LoadFile();
            DateTime actual = new LevelParser().ExtractLevelDateTime();

            Assert.IsInstanceOfType(actual, DateTime);
        }
Beispiel #21
0
        public void TestParse6()
        {
            var parser = new LevelParser();
            int length;

            parser.Parse("FATAL", 0, out length).Should().Be(LevelFlags.Fatal);
            length.Should().Be(5);
        }
    public void Initialize()
    {
        var levelNo = _contexts.game.level.LevelNo;

        var selectedLevel = LevelParser.ParseLevel(levelNo);

        SpawnLevel(selectedLevel);
    }
Beispiel #23
0
        public void TestParse4()
        {
            var parser = new LevelParser();
            int length;

            parser.Parse("WARNING", 0, out length).Should().Be(LevelFlags.Warning);
            length.Should().Be(7);
        }
Beispiel #24
0
        public void TestParse2()
        {
            var parser = new LevelParser();
            int length;

            parser.Parse("DEBUG", 0, out length).Should().Be(LevelFlags.Debug);
            length.Should().Be(5);
        }
Beispiel #25
0
        public void TestParse5()
        {
            var parser = new LevelParser();
            int length;

            parser.Parse("ERROR", 0, out length).Should().Be(LevelFlags.Error);
            length.Should().Be(5);
        }
Beispiel #26
0
        public void TestParse1()
        {
            var parser = new LevelParser();
            int length;

            parser.Parse("TRACE", 0, out length).Should().Be(LevelFlags.Trace);
            length.Should().Be(5);
        }
Beispiel #27
0
        public void TestParse3()
        {
            var parser = new LevelParser();
            int length;

            parser.Parse("DEBUG INFO", 6, out length).Should().Be(LevelFlags.Info);
            length.Should().Be(4);
        }
 public static void Initialize()
 {
     tileMaps         = LoadTileMaps();
     tileSets         = TileSetParser.LoadTileSets(tileMaps);
     levelList        = LevelParser.LoadLevelList();
     cachedLevelsInfo = new Dictionary <int, LevelInfo>();
     currentLevelId   = -1;
 }
Beispiel #29
0
    private void GenerateNGram()
    {
        if (blackBoard.ConfigUI.Config.HeiarchalEnabled)
        {
            grammar = NGramFactory.InitHierarchicalNGram(
                blackBoard.ConfigUI.Config.N,
                blackBoard.ConfigUI.Config.HeiarchalMemory);

            simpleGrammar = NGramFactory.InitHierarchicalNGram(
                blackBoard.ConfigUI.Config.N,
                blackBoard.ConfigUI.Config.HeiarchalMemory);
        }
        else if (blackBoard.ConfigUI.Config.BackOffEnabled)
        {
            grammar = NGramFactory.InitHierarchicalNGram(
                blackBoard.ConfigUI.Config.N,
                blackBoard.ConfigUI.Config.BackOffMemory);

            simpleGrammar = NGramFactory.InitHierarchicalNGram(
                blackBoard.ConfigUI.Config.N,
                blackBoard.ConfigUI.Config.BackOffMemory);
        }
        else
        {
            grammar       = NGramFactory.InitGrammar(blackBoard.ConfigUI.Config.N);
            simpleGrammar = NGramFactory.InitGrammar(blackBoard.ConfigUI.Config.N);
        }

        for (int i = 0; i <= blackBoard.ProgressIndex; ++i)
        {
            if (blackBoard.ConfigUI.Config.UsingTieredGeneration || blackBoard.ProgressIndex == i)
            {
                JsonObject tierInfo   = blackBoard.GameFlow[i].AsJsonObject;
                JsonArray  tierLevels = tierInfo[FlowKeys.LevelNames].AsJsonArray;
                foreach (string levelName in tierLevels)
                {
                    List <string> columns = LevelParser.BreakMapIntoColumns(levelName);
                    columns.RemoveAt(columns.Count - 1); // remove flag at the end
                    List <string> simpleColumns = LevelParser.BreakColumnsIntoSimplifiedTokens(
                        columns,
                        blackBoard.ConfigUI.Config.Game);

                    levelColumns.Add(columns);
                    simplifiedLevelColumns.Add(simpleColumns);

                    NGramTrainer.Train(grammar, columns, skipFirst: true);
                    NGramTrainer.Train(simpleGrammar, simpleColumns, skipFirst: true);

                    if (blackBoard.ProgressIndex != i)
                    {
                        grammar.UpdateMemory(blackBoard.ConfigUI.Config.TieredGenerationMemoryUpdate);
                        levelColumns.Clear();
                        simplifiedLevelColumns.Clear();
                    }
                }
            }
        }
    }
Beispiel #30
0
 /// <summary>
 /// Manages all things
 /// </summary>
 /// <param name="graphicsDevice">Used to draw</param>
 /// <param name="content">Used to load content</param>
 public GameStateManager(GraphicsDevice graphicsDevice, ContentManager content)
 {
     this.LayerManager = new LayerManager(graphicsDevice, content);
     this.Camera       = new CameraManager(graphicsDevice, 300, 1);
     this.Content      = content;
     this.LayerManager = LevelParser.LoadLevel("test", graphicsDevice, content);
     //Centers the camera around the player
     Camera.MoveTo(new Point(-LayerManager.Player.Position.X, -LayerManager.Player.Position.Y));
 }
Beispiel #31
0
    void Start()
    {
        //todo: put this in MenuManager ?//
        Time.timeScale = 1;

        var stageComplete = StageCompleteCanvas.GetComponent<CanvasGroup>();

        stageComplete.alpha = 0x00;
        stageComplete.blocksRaycasts = false;

        var gameMenu = GameMenu.GetComponent<CanvasGroup>();
        gameMenu.alpha = 0x00;
        gameMenu.blocksRaycasts = false;
        //end todo//

        Player.HitSomething += Player_HitSomethingWithGun;

        _levelTexture = LevelTextures[_levelIndex];

        _levelParser = new LevelParser
        {
            GrassTile = FloorTiles[0],
            GrayTile = FloorTiles[1],
            GrayTileWithGrass = FloorTiles[2],
            GrayTileWithGrassRight = FloorTiles[3],
            GrayTileWithGrassTop = FloorTiles[4],
            GrayTileWithGrassLeft = FloorTiles[5],
            WallTile = WallTiles[0],
            //BreakableWallTile = WallTiles[3],
            FountainTile = WallTiles[1],
            KnightStatueTile = WallTiles[2],
            BadGuy1 = BadGuy1,
            BadGuy2 = BadGuy2,
            AmmoPickup = AmmoPickup,
            HealthPickup = HealthPickup,
            Switch = Switch,
        };
        _currentLevelTiles = _levelParser.GetLevelData(_levelTexture).ToList();
        LoadLevel(_currentLevelTiles, _currentLevelXOffset);
    }
Beispiel #32
0
    private void InitGame()
    {
        // Get and parse level
        Level level = new Level("Default");
        LevelParser levelParser = new LevelParser(level.GetLevelXml());
        Fields = levelParser.AllFields;

        // Get all colors
        List<Color> colors = new List<Color>();
        foreach (Color color in Enum.GetValues(typeof(Color)))
	    {
		    colors.Add(color);
	    }

        // Set player settings
        for (int i = 0; i < Players.Count(); i++)
        {
            // Set color
            Players.ElementAt(i).Color = colors.ElementAt(i);

            // Set start fields
            switch (i)
            {
                case 0:
                    Players.ElementAt(i).StartFields = levelParser.StartFieldsPlayerOne;
                    break;
                case 1:
                    Players.ElementAt(i).StartFields = levelParser.StartFieldsPlayerTwo;
                    break;
                case 2:
                    Players.ElementAt(i).StartFields = levelParser.StartFieldsPlayerThree;
                    break;
                case 3:
                    Players.ElementAt(i).StartFields = levelParser.StartFieldsPlayerFour;
                    break;
                default:
                    Players.ElementAt(i).StartFields = levelParser.StartFieldsPlayerOne;
                    break;
            }

            // Add pawns
            List<Pawn> pawns = new List<Pawn>();
            for (int j = 0; j < 4; j++)
            {
                Pawn newPawn = new Pawn { Color = colors.ElementAt(i) };
                int coordx = Players.ElementAt(i).StartFields.ElementAt(j).CoordX;
                int y = Players.ElementAt(i).StartFields.ElementAt(j).CoordY;
                IField startField = levelParser.AllFields.Where(x => x.CoordX == Players.ElementAt(i).StartFields.ElementAt(j).CoordX && x.CoordY == Players.ElementAt(i).StartFields.ElementAt(j).CoordY).First();
                newPawn.Position = startField;
                startField.Moveables.Add(newPawn);
                pawns.Add(newPawn);
            }
            Players.ElementAt(i).Pawns = pawns;

            
        }

        // Selected starting player
        Random r = new Random();
        activePlayer = Players.ElementAt(r.Next(0, Players.Count()));

    }
Beispiel #33
0
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void Awake()
 {
     instance = this;
 }
        public override void Initialize()
        {
            levelParser = new LevelParser();
            level = levelParser.generateLevel(@"Content\Level1.csv", 1);

            camera = new Camera(1, Vector2.Zero, 0, false, Game.GraphicsDevice);

            //pacman = new PacMan(level.getCell(1, 1), level,
            //                                                new PlayerController(Direction.Down, "Player 1", PlayerIndex.One, ), Direction.None, 2f,
            //                                                new Point(50, 50));
            //pacman.Scale = 1;

            base.Initialize();
        }