示例#1
0
        // Use this for initialization
        void Start()
        {
            var panels = new List<Panel>();
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GLASS, Panel.Attribute.IMMORTAL, false));

            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GLASS, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GLASS, Panel.Attribute.IMMORTAL, false));

            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GRABEL, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GLASS, Panel.Attribute.IMMORTAL, false));
            panels.Add(new Panel(Panel.Type.GLASS, Panel.Attribute.IMMORTAL, false));

            var field = new Field(new Point2D(6, 3), panels);

            fieldCreator = new Libs.Renderer.FieldRenderer(field);

            var pref = (GameObject)Resources.Load("models/character/Character1");

            var camera = (Camera)FindObjectOfType<Camera>();

            var obj = (GameObject)Instantiate(pref, new Vector3(-2.0f, 0.0f, -1.0f), Quaternion.identity);
            obj.GetComponentInChildren<LookForward>().target = camera;

            var obj1 = (GameObject)Instantiate(pref, new Vector3(-6.0f, 0.0f, -1.0f), Quaternion.identity);
            obj1.GetComponentInChildren<LookForward>().target = camera;

            var obj2 = (GameObject)Instantiate(pref, new Vector3(-4.0f, 0.0f, -3.0f), Quaternion.identity);
            obj2.GetComponentInChildren<LookForward>().target = camera;

            var obj3 = (GameObject)Instantiate(pref, new Vector3(-4.0f, 0.0f,  1.5f), Quaternion.identity);
            obj3.GetComponentInChildren<LookForward>().target = camera;
        }
示例#2
0
        private static void Main()
        {
            string command = string.Empty;
            List<Point> champions = new List<Point>(6);
            Field fields = new Field();

            char[,] field = fields.CreatePlayingField();
            char[,] bombs = Field.LayingBombs();

            bool startGame = true;
            bool startNewGame = false;
            bool endGame = false;

            int counter = 0;
            int row = 0;
            int column = 0;
            const int Max = 35;

            do
            {
                if (startGame)
                {
                    Console.WriteLine(Messages.WelcomeMessage + " " + Messages.HelpMessage);
                    Field.PrintMatrix(field);
                    startGame = false;
                }

                if (startNewGame)
                {
                    Console.WriteLine(Messages.Bravo);
                    Field.PrintMatrix(bombs);
                    Console.WriteLine(Messages.GiveYourName);
                    string name = Console.ReadLine();
                    Point points = new Point(name, counter);
                    champions.Add(points);
                    Rating.ViewRating(champions);

                    // create new field (board)
                    field = fields.CreatePlayingField();
                    bombs = Field.LayingBombs();
                    counter = 0;
                    startNewGame = false;
                    startGame = true;
                }

                if (endGame)
                {
                    Field.PrintMatrix(bombs);
                    Console.Write(Messages.EndGame, counter);
                    string name = Console.ReadLine();
                    Point t = new Point(name, counter);
                    if (champions.Count < 5)
                    {
                        champions.Add(t);
                    }
                    else
                    {
                        for (int i = 0; i < champions.Count; i++)
                        {
                            if (champions[i].Points < t.Points)
                            {
                                champions.Insert(i, t);
                                champions.RemoveAt(champions.Count - 1);
                                break;
                            }
                        }
                    }

                    champions.Sort((Point r1, Point r2) => r2.Name.CompareTo(r1.Name));
                    champions.Sort((Point r1, Point r2) => r2.Points.CompareTo(r1.Points));
                    Rating.ViewRating(champions);

                    field = fields.CreatePlayingField();
                    bombs = Field.LayingBombs();
                    counter = 0;
                    endGame = false;
                    startGame = true;
                }

                Console.Write(Messages.GiveRowAndColumn);
                var readLine = Console.ReadLine();
                if (readLine != null)
                {
                    command = readLine.Trim();
                    if (command == "exit")
                    {
                        break;
                    }
                }

                if (command.Length >= 3)
                {
                    if (int.TryParse(command[0].ToString(), out row) && 
                        int.TryParse(command[2].ToString(), out column) && 
                        row <= field.GetLength(0) && 
                        column <= field.GetLength(1))
                    {
                        command = "turn";
                    }
                }

                switch (command)
                {
                    case "top":
                        Rating.ViewRating(champions);
                        break;
                    case "restart":
                        field = fields.CreatePlayingField();
                        bombs = Field.LayingBombs();
                        Field.PrintMatrix(field);
                        endGame = false;
                        startGame = false;
                        break;
                    case "turn":
                        if (bombs[row, column] != '*')
                        {
                            if (bombs[row, column] == '-')
                            {
                                Move(field, bombs, row, column);
                                counter++;
                            }

                            if (Max == counter)
                            {
                                startNewGame = true;
                            }
                            else
                            {
                                Field.PrintMatrix(field);
                            }
                        }
                        else
                        {
                            endGame = true;
                        }

                        break;
                }
            }
            while (command != "exit");
            Console.WriteLine(Messages.MadeInBulgaria);
            Console.WriteLine(Messages.GoodBye);
        }