/// <summary> /// Initializes a new instance of the <see cref="Monster"/> class. /// </summary> /// <param name="Params">The params.</param> /// <param name="way">The way.</param> /// <param name="id">The id.</param> /// <param name="scaling">The scaling.</param> internal Monster(MonsterParam Params, List<Point> way, int id = -1, float scaling = 1F) { _params = Params; _way = way; Scaling = scaling; ID = id; _currentBaseParams = Params.Base; //CurrentBaseParams.CanvasSpeed = 3F;//Debug, что бы не сидеть и не ждать когда же монстр добежит до финиша _effects = new List<AttackModificators>(); NewLap = false; _arrayPos = new Point(way[0].X, way[0].Y); _wayPos = 0; DestroyMe = false; _movingPhase = 0; SetCanvaDirectionAndPosition(true); }
/// <summary> /// Loads the level, from file with levels configurations /// </summary> /// <param name="level">If -1, using _position. Otherwise, the level number to be loaded</param> private void LoadLevel(int level = -1) { #region Level configuration loading using (FileStream levelLoadStream = new FileStream(_pathToLevelConfigurations, FileMode.Open, FileAccess.Read)) { IFormatter formatter = new BinaryFormatter(); if (level == -1) { levelLoadStream.Seek(_position, SeekOrigin.Begin); _currentLevelConf = (MonsterParam)(formatter.Deserialize(levelLoadStream)); } else { for (int i = 0; i < level; i++) _currentLevelConf = (MonsterParam)(formatter.Deserialize(levelLoadStream)); } _position = levelLoadStream.Position; levelLoadStream.Close(); } #endregion Level configuration loading //Chache for monsters in visible area checking if (_currentLevelConf.NumberOfPhases != 0) { Monster.HalfSizes = new[] { _currentLevelConf[MonsterDirection.Up, 0].Height/2, _currentLevelConf[MonsterDirection.Right, 0].Width/2, _currentLevelConf[MonsterDirection.Down, 0].Height/2, _currentLevelConf[MonsterDirection.Left, 0].Width/2 }; } }
/// <summary> /// New level adding /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void BAddLevel_Click(object sender, EventArgs e) { MonsterParam tmp = new MonsterParam(1, 100, 1, 1, "", 1); _levelsConfig.Insert(_currentLevel++, tmp); _numberOfMonstersAtLevel.Insert(_currentLevel - 1, 20); _goldForSuccessfulLevelFinish.Insert(_currentLevel - 1, 40); _goldForKillMonster.Insert(_currentLevel - 1, 10); LCurrentNCountLevel.Text = "Level: " + _currentLevel.ToString(CultureInfo.InvariantCulture) + "/" + _levelsConfig.Count.ToString(CultureInfo.InvariantCulture); if (_levelsConfig.Count == 2)//If number of levels>1, user needs to switch between them { BNextLevel.Enabled = true; BPrevLevel.Enabled = true; } if (_levelsConfig.Count == 1) { BLoadMonsterPict.Enabled = true;//User can add monster picture GBNumberOfDirections.Enabled = true; CBLevelInvisible.Enabled = true; } DefaultForNewLevel();//Set a level template BRemoveLevel.Enabled = true; BNewGameConfig.Tag = 1; }