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();
        }
Esempio n. 2
0
    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();
    }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 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);
Esempio n. 7
0
 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;
     }
 }