Пример #1
0
        /// ToDO
        /// perasyt si metoda, isskaidyti i mazesnius ir t.t.


        //judejimo metodas, na toks nemenkas gausis
        public void SetMovment(int x, int y)
        {
            Vector3 head = snake.GetSnakeHead();
            Vector3 tail = snake.GetSnakeTail();

            //RemoveBug(bug.GetCoord());
            RemoveBug(bug.GetCoord());


            if (x == 1) //x as fiksuotas
            {
                if (y == 1)
                {
                    if (MoveX((int)head.X + x))
                    {
                        head.X += 1;
                        head.Z  = 1;
                        snake.Move(head);
                    }
                    else
                    {
                        //gyvate atsimuse
                        snakeSound.PlaySnakeHit();
                        SnakeHit();
                    }
                }
                else
                {
                    if (MoveY((int)head.Y - 1))
                    {
                        head.Y -= 1;
                        head.Z  = 2;
                        snake.Move(head);
                    }
                    else
                    {
                        //gyvate atsimuse
                        snakeSound.PlaySnakeHit();
                        SnakeHit();
                    }
                }
            }
            else
            {
                if (y == 1)
                {
                    if (MoveX((int)head.X - 1))
                    {
                        head.Z  = -1;
                        head.X -= 1;
                        snake.Move(head);
                    }
                    else
                    {
                        //gyvate atsimuse
                        snakeSound.PlaySnakeHit();
                        SnakeHit();
                    }
                }
                else
                {
                    if (MoveY((int)head.Y + 1))
                    {
                        head.Z  = -2;
                        head.Y += 1;
                        snake.Move(head);
                    }
                    else
                    {
                        //gyvate atsimuse
                        snakeSound.PlaySnakeHit();
                        SnakeHit();
                    }
                }
            }
            if (!EatFood(snake.GetSnakeHead()))
            {
                stage.RemoveSnkaeTail(new Vector2(tail.X, tail.Y), new Vector2(snake.GetSnakeTail().X, snake.GetSnakeTail().Y));
            }
            else
            {
                snakeSound.PlayeSnakeEat();
                snake.GrowSnake(tail);
            }
            if (level == 2)
            {
                backgroundSound.PlayOwl();
            }
            if (level == 1)
            {
                if (snake.SnakeLenght() < 70)
                {
                    snake.GrowSnake(tail);
                }
            }
            StageUpdate();
            bug.SetDirection(snake.GetSnakeHead(), stage.GetStageCoord());
            if (level == 3)
            {
                EatBug(head);
                FillBugCoord();
            }
        }