Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (spawnTime == 0)
     {
         rock clone = (Instantiate(r, transform.position, transform.rotation)) as rock;
         if (goodRock)
         {
             clone.tag = "goodRock";
         }
         clone.Drop(right);
         spawnTime = spawnCooldown;
         //clone.rigidbody.AddForce(1000, 0, 0);
     }
     else
     {
         spawnTime -= 1;
     }
 }
Пример #2
0
        public static void SeedMap(Graphics g)
        {
            for (int i = 0; i < mapWidth; i++)
            {
                for (int j = 0; j < mapHeight; j++)
                {
                    if (map[i, j] == 10)
                    {
                        //rock Rock = new rock(j * cellSize, i * cellSize);
                        //rocks.Add(Rock);

                        g.DrawImage(spriteSheet, new Rectangle(new Point(j * cellSize, i * cellSize), new Size(cellSize * 3, cellSize * 3)), 202, 298, 107, 114, GraphicsUnit.Pixel);
                    }
                    if (map[i, j] == 11)
                    {
                        rock Rock = new rock(j * cellSize, i * cellSize);
                        rocks.Add(Rock);
                        g.DrawImage(spriteSheet, new Rectangle(new Point(j * cellSize, i * cellSize), new Size(20, 11)), 581, 114, 19, 11, GraphicsUnit.Pixel);
                    }
                }
            }
        }
Пример #3
0
        static void Main()
        {
            int playFild = 50;
            Console.BufferHeight = Console.WindowHeight = 30;
            Console.BufferWidth = Console.WindowWidth = 70;

            user newUser = new user();
            newUser.rowX = playFild / 2;
            newUser.columY = Console.WindowHeight - 1;
            newUser.symbol = "0";
            newUser.userColor = ConsoleColor.White;

            Random randomGenerator = new Random();
            int livesCount = 5;
            int score = 0;
            int newScore = 0;
            int speed = 0;
            int level = 1;

            List<rock> rocks = new List<rock>();

            while (true)
            {

                bool hitted = false;
                {
                    Random colorRandom = new Random();
                    ConsoleColor[] color = new ConsoleColor[8] { ConsoleColor.Cyan, ConsoleColor.Gray, ConsoleColor.Green, ConsoleColor.Red, ConsoleColor.White, ConsoleColor.Yellow, ConsoleColor.Magenta, ConsoleColor.DarkCyan };
                    Random symbolRandom = new Random();
                    string[] symbol = new string[12] { "!", "@", "#", "$", "%", "^", "&", "*", "+", ".", ";", "B"};
                    string newSymbol = symbol[symbolRandom.Next(0, 12)];

                    rock newRock = new rock();
                    newRock.rowX = randomGenerator.Next(0, playFild);
                    newRock.columY = 0;
                    newRock.symbol = newSymbol;
                    newRock.rockColor = color[colorRandom.Next(0,8)];
                    rocks.Add(newRock);
                }

                while (Console.KeyAvailable)
                {
                    ConsoleKeyInfo pressedKey = Console.ReadKey(true);
                    while (Console.KeyAvailable) Console.ReadKey(true);
                    if (pressedKey.Key == ConsoleKey.LeftArrow)
                    {
                        if (newUser.rowX - 1 >= 0)
                        {
                            newUser.rowX--;
                        }
                    }
                    else if (pressedKey.Key == ConsoleKey.RightArrow)
                    {
                        if (newUser.rowX + 1 < playFild)
                        {
                            newUser.rowX++;
                        }
                    }
                }
                List<rock> newList = new List<rock>();
                for (int i = 0; i < rocks.Count; i++)
                {
                    rock oldRock = rocks[i];
                    rock newRock = new rock();
                    newRock.rowX = oldRock.rowX;
                    newRock.columY = oldRock.columY + 1;
                    newRock.symbol = oldRock.symbol;
                    newRock.rockColor = oldRock.rockColor;

                    if ((newRock.columY == newUser.columY && newRock.rowX == newUser.rowX)&&(newRock.symbol == "B"))
                    {
                        score++;
                        newScore = score;
                        if ((newScore % 10) == 0)
                        {
                            level++;
                            speed = speed + 10;
                        }

                    }

                    else if (newRock.columY == newUser.columY && newRock.rowX == newUser.rowX)
                    {
                        livesCount--;
                        speed = 0;
                        hitted = true;

                        if (livesCount <= 0)
                        {
                            printOnInfoPosition(52, 11, "GAME OVER", ConsoleColor.Green);
                            printOnInfoPosition(51, 12, "Press ENTER to exit", ConsoleColor.Green);
                            Console.ReadLine();
                            return;
                        }
                    }
                    if (newRock.columY < Console.WindowHeight)
                    {
                        newList.Add(newRock);
                    }

                }
                rocks = newList;
                Console.Clear();

                if (hitted)
                {
                    rocks.Clear();
                    printOnPosition(newUser.rowX, newUser.columY, "X", ConsoleColor.Red);
                }
                else
                {
                    printOnPosition(newUser.rowX, newUser.columY, newUser.symbol, newUser.userColor);
                }
                foreach (rock rock in rocks)
                {
                    printOnPosition(rock.rowX, rock.columY, rock.symbol, rock.rockColor);
                }

                printOnInfoPosition(48, 1, "Info for Falling Rocks", ConsoleColor.Green);
                printOnInfoPosition(52, 6, "\"B\"is point", ConsoleColor.Green);
                printOnInfoPosition(52, 10, "Lives:" + livesCount, ConsoleColor.Green);
                printOnInfoPosition(52, 11, "Score:" + score, ConsoleColor.Green);
                printOnInfoPosition(52, 12, "Level:" + level, ConsoleColor.Green);
                printOnInfoPosition(52, 13, "Speed:" + speed, ConsoleColor.Green);
                printOnInfoPosition(55, 20, "Controls:", ConsoleColor.Green);
                printOnInfoPosition(52, 22, "     <   >     ", ConsoleColor.Green);
                //Console.Beep();
                Thread.Sleep(150-speed);
            }
        }
Пример #4
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     rock = animator.GetComponent <rock>();
     Move = animator.transform.position;
 }