void Start() { EndGame = false; TimePause = Time.time + GameInits.Pause; GameLogic = new CustomisingLogic ( GameInits.GameoverPredicates, GameInits.SnakeNames, GameInits.Assembly, GameInits.MapSize, GameInits.FoodCount, GameInits.LeftDeadSnakeBody ); Map = GameLogic.GetCurrentPlayingMap(); SetTileBases(); FillBackground(); SetGridScale(); ShowFood(); ShowSnakes(); ShowBarriers(); SetUpStatisticsTable(); }
void Start() { GameLogic = new StandartLogic ( GameInits.GameoverPredicates, GameInits.SnakeNames, new AssemblySnakeFactory(), GameInits.MapSize, GameInits.FoodCount, GameInits.LeftDeadSnakeBody ); Map = GameLogic.GetCurrentPlayingMap(); SimbolMap = new string[Map.sideSize, Map.sideSize]; FillMapEmptyObjects(); InsertElements(); //ShowMapConsole(); ShowMapTexture(); }
public override void OnAchievedLength(PlayingMapAttributes.Snake snake, PlayingMap currentMap, PlayingMap previousMap, GameLogicBase gl) { snake.SnakeB.Statistics.Length = snake.Cordinates.Count(); List <Cordinates> cordinates = new List <Cordinates>(); var count = snake.Cordinates.Count; for (int i = count - 1; i >= Length / 2; i--) { cordinates.Add(new Cordinates(snake.Cordinates[i])); snake.Cordinates.RemoveAt(i); } string name = Names[new Random().Next(0, Names.Count)]; var newSnake = gl.AddSnake(name, cordinates); newSnake.Statistics.Length = newSnake.SnakeBody.Count; Snakes.Add(new PlayingMapAttributes.Snake(newSnake)); }
public override void OnAchievedLength(PlayingMapAttributes.Snake snake, PlayingMap currentMap, PlayingMap previousMap, GameLogicBase gl) { }
public void OnStepDid(PlayingMapAttributes.Snake snake, PlayingMap currentMap, PlayingMap previousMap, GameLogicBase gl) { if (!DidStepsWithoutFoodById.ContainsKey(snake.SnakeB.ID)) { DidStepsWithoutFoodById.Add(snake.SnakeB.ID, 0); } if (snake.FoundFoodAfterStep) { DidStepsWithoutFoodById[snake.SnakeB.ID] = 0; } else { DidStepsWithoutFoodById[snake.SnakeB.ID]++; } if (DidStepsWithoutFoodById[snake.SnakeB.ID] == StepsWithoutFood) { DidStepsWithoutFoodById[snake.SnakeB.ID] = 0; OnStepsWithoutFoodDid(snake, currentMap, previousMap, gl); } }
protected abstract void OnStepsWithoutFoodDid(PlayingMapAttributes.Snake snake, PlayingMap currentMap, PlayingMap previousMap, GameLogicBase gl);
protected override void OnStepsWithoutFoodDid(PlayingMapAttributes.Snake snake, PlayingMap currentMap, PlayingMap previousMap, GameLogicBase gl) { snake.Cordinates.RemoveAt(snake.Cordinates.Count - 1); if (snake.Cordinates.Count < 3) { snake.IsAlive = false; } }