예제 #1
0
        public void SetExitDir(Direction getExitDirection)
        {
            switch (getExitDirection)
            {
            case Direction.North:
                ExitXPos = NumGen.Next(Xpos, Xpos + Width);
                ExitYPos = YPos;

                break;

            case Direction.East:
                ExitXPos = Xpos + Width - 1;
                ExitYPos = NumGen.Next(YPos, YPos + Height);

                break;

            case Direction.South:
                ExitXPos = NumGen.Next(Xpos, Xpos + Width);
                ExitYPos = YPos + Height - 1;

                break;

            case Direction.West:
                ExitXPos = Xpos;
                ExitYPos = NumGen.Next(YPos, YPos + Height);;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(getExitDirection), getExitDirection, null);
            }

            ExitDirection = getExitDirection;
        }
    //Randomly destroy a wall to make a path
    private void DestroyWall(int row, int column)
    {
        bool wallDestroyed = false;

        while (!wallDestroyed)
        {
            int direction = NumGen.GetNextNumber();
            Debug.Log("Direction" + direction);
            if (direction == 1 && row > 0 && mazeCells [row - 1, column].visited)
            {
                DestroyWallIfItExists(mazeCells [row, column].nWall);
                DestroyWallIfItExists(mazeCells [row - 1, column].sWall);
                wallDestroyed = true;
            }
            else if (direction == 2 && row < (mazeRows - 2) && mazeCells [row + 1, column].visited)
            {
                DestroyWallIfItExists(mazeCells [row, column].sWall);
                DestroyWallIfItExists(mazeCells [row + 1, column].nWall);
                wallDestroyed = true;
            }
            else if (direction == 3 && column > 0 && mazeCells [row, column - 1].visited)
            {
                DestroyWallIfItExists(mazeCells [row, column].wWall);
                DestroyWallIfItExists(mazeCells [row, column - 1].eWall);
                wallDestroyed = true;
            }
            else if (direction == 4 && column < (mazeColumns - 2) && mazeCells [row, column + 1].visited)
            {
                DestroyWallIfItExists(mazeCells [row, column].eWall);
                DestroyWallIfItExists(mazeCells[row, column + 1].wWall);
            }
        }
    }
예제 #3
0
        /*
         * Main function.
         */
        static void Main(string[] args)
        {
            Stopwatch sw = new Stopwatch();

            if (args.Length < 1)
            {
                printHelp();
            }
            else if (args.Length == 1)
            {
                sw.Start();
                Console.WriteLine("BitLength: " + args[0] + " bits");
                var numGen = new NumGen(int.Parse(args[0]) / 8);
                numGen.generatePrimes();
                sw.Stop();
                Console.WriteLine("Time to Generate: {0}:{1}:{2}.{3}",
                                  sw.Elapsed.Hours,
                                  sw.Elapsed.Minutes,
                                  sw.Elapsed.Seconds,
                                  sw.Elapsed.Ticks);
            }
            else if (args.Length == 2)
            {
                sw.Start();
                Console.WriteLine("BitLength: " + args[0] + " bits");
                var numGen = new NumGen(int.Parse(args[0]) / 8, int.Parse(args[1]));
                numGen.generatePrimes();
                sw.Stop();
                Console.WriteLine("Time to Generate: {0:00}:{1:00}:{2:00}.{3:00}",
                                  sw.Elapsed.Hours,
                                  sw.Elapsed.Minutes,
                                  sw.Elapsed.Seconds,
                                  sw.Elapsed.Ticks);
            }
            else
            {
                printHelp();
            }
        }
    //Kill Part of our Algorithim
    private void Kill()
    {
        while (AvailbleRoute(currentRow, currentCol))
        {
            int direction = NumGen.GetNextNumber();
            Debug.Log("Direction for KillMethod " + direction);

            if (direction == 1 && CellIsAvailable(currentRow - 1, currentCol))
            {
                // North Wall
                DestroyWallIfItExists(mazeCells [currentRow, currentCol].nWall);
                DestroyWallIfItExists(mazeCells [currentRow - 1, currentCol].sWall);
                currentRow--;
            }
            else if (direction == 2 && CellIsAvailable(currentRow + 1, currentCol))
            {
                // South Wall
                DestroyWallIfItExists(mazeCells [currentRow, currentCol].sWall);
                DestroyWallIfItExists(mazeCells [currentRow + 1, currentCol].nWall);
                currentRow++;
            }
            else if (direction == 3 && CellIsAvailable(currentRow, currentCol + 1))
            {
                // east wall
                DestroyWallIfItExists(mazeCells [currentRow, currentCol].eWall);
                DestroyWallIfItExists(mazeCells [currentRow, currentCol + 1].wWall);
                currentCol++;
            }
            else if (direction == 4 && CellIsAvailable(currentRow, currentCol - 1))
            {
                // west wall
                DestroyWallIfItExists(mazeCells [currentRow, currentCol].wWall);
                DestroyWallIfItExists(mazeCells [currentRow, currentCol - 1].eWall);
                currentCol--;
            }

            mazeCells [currentRow, currentCol].visited = true;
        }
    }
예제 #5
0
    // Use this for initialization
    void Awake()
    {
        activated        = true;
        playerController = GameObject.Find("Player").GetComponent <PlayerController> ();
        NumGen ng = NumGen.getInatance();

        row = ng.getX();
        col = ng.getY();

        //map = new GameObject[row, col];
        //ob_map = new GameObject[row, col];

        Room     r1 = new Room(room_num);
        Obstical obstical;

        if (room_num == 5)
        {
            obstical = new Obstical(GameVars.num_exit, row, col);
        }
        else
        {
            obstical = new Obstical(GameVars.num_Room_Random, row, col);
        }

        Create(row, col, obstical.grid);
        Create(row, col, r1.grid);
        if (transform.position.x == 0 && gameObject.name == "Room4(Clone)")
        {
            AddPlayerSpawn();
        }
        BoxCollider2D collider = gameObject.AddComponent <BoxCollider2D>();

        collider.size      = new Vector2((row * tileSize) - tileSize * 2, (col * tileSize) - tileSize * 2);
        collider.isTrigger = true;
        Vector2 v = new Vector2(((row * tileSize) / 2) - tileSize / 2, ((col * tileSize) / 2) - tileSize / 2);

        collider.center = v;
    }
예제 #6
0
 internal int Next()
 {
     return(NumGen.Next(Min, Max + 1));
 }
예제 #7
0
 public NumGen_NumGenShould()
 {
     _numGen = new NumGen();
 }
예제 #8
0
        /// <summary>
        /// Called once at the startup of the game
        /// </summary>
        public void Initialize()
        {
            DriverInstance.Assets.LoadCoreContent(DriverInstance);

            CurState = State.Menu;

            Shader.Load();

            // Intialize all UI elements in the game
            #region UI Interface Initialization

            #region Menu Buttons

            InterfaceManager.AddComponent(new Bar("menuTopBar", new Rectangle(0, 20, (int)Dimensions.X, 80), 1.0f, 0.65f,
                                                  Color.Black, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down,
                                                  DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("playButton", new Rectangle(120, 20, 200, 80), Color.White,
                                                     "Play", 1.5f, EasingFunctions.AnimationType.QuinticOut, GUIComponent.AnimationDirection.Up,
                                                     DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("mapEditorButton", new Rectangle(400, 20, 200, 80), Color.White,
                                                     "Editor", 1.5f, EasingFunctions.AnimationType.QuinticOut, GUIComponent.AnimationDirection.Up,
                                                     DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("optionsButton", new Rectangle(750, 20, 200, 80), Color.White,
                                                     "Options", 1.5f, EasingFunctions.AnimationType.QuinticOut, GUIComponent.AnimationDirection.Up,
                                                     DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("quitButton", new Rectangle(1100, 20, 200, 80), Color.White, "Quit",
                                                     1.5f, EasingFunctions.AnimationType.QuinticOut, GUIComponent.AnimationDirection.Up,
                                                     DriverInstance.Assets));

            InterfaceManager.FormPage("defaultMenu");

            #endregion

            #region Play Menu

            InterfaceManager.AddComponent(new Bar("playBar", new Rectangle(0, 100, (int)Dimensions.X, 600), 1.0f, 0.8f,
                                                  Color.Black, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down,
                                                  DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("connectButton", new Rectangle(150, 200, 200, 80), Color.White,
                                                     "Connect", 1.0f, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.None,
                                                     DriverInstance.Assets));

            InterfaceManager.FormPage("playMenu");

            #endregion

            #region Options Menu

            InterfaceManager.AddComponent(new Bar("optionsBar", new Rectangle(0, 100, (int)Dimensions.X, 600), 1.0f, 0.8f,
                                                  Color.Black, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down,
                                                  DriverInstance.Assets));

            InterfaceManager.AddComponent(new TextBox("masterVolumeText", new Vector2(200, 200), "Master Volume",
                                                      Color.White, 1.0f, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down,
                                                      DriverInstance.Assets));

            InterfaceManager.AddComponent(new TextBox("uiVolumeText", new Vector2(200, 250), "UI Volume",
                                                      Color.White, 1.1f, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down,
                                                      DriverInstance.Assets));

            InterfaceManager.AddComponent(new TextBox("musicVolumeText", new Vector2(200, 300), "Music Volume",
                                                      Color.White, 1.2f, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down,
                                                      DriverInstance.Assets));

            InterfaceManager.AddComponent(new TextBox("sfxVolumeText", new Vector2(200, 350), "Sound Effects Volume",
                                                      Color.White, 1.3f, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down,
                                                      DriverInstance.Assets));

            InterfaceManager.AddComponent(new TextBox("voiceVolumeText", new Vector2(200, 400), "Voice Volume Volume",
                                                      Color.White, 1.4f, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down,
                                                      DriverInstance.Assets));

            InterfaceManager.FormPage("optionsMenu");

            #endregion

            #region Buy Menu

            InterfaceManager.AddComponent(new Bar("buyMenuBar", new Rectangle(90, 20, 1100, 650), 0.4f,
                                                  0.8f, Color.Black, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Right,
                                                  DriverInstance.Assets));

            InterfaceManager.AddComponent(new TextBox("buyMenuTitle", new Vector2(94, 20), "Buy Menu", Color.White, 0.4f,
                                                      EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down, DriverInstance.Assets));

            InterfaceManager.FormPage("buyMenu");

            #endregion

            #region Team Select Menu

            InterfaceManager.AddComponent(new TextBox("teamSelectTitle", new Vector2(94, 20), "Buy Menu", Color.White, 0.4f,
                                                      EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("ctButton", new Rectangle(90, 50, 549, 630), new Color(0, 81, 200),
                                                     Color.DarkBlue, Color.Gray,
                                                     "Counter-Terrorists", 0.8f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Up, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("tButton", new Rectangle(639, 50, 549, 630), new Color(255, 0, 25),
                                                     Color.DarkRed, Color.Gray,
                                                     "Terrorists", 0.8f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Up, DriverInstance.Assets));

            InterfaceManager.FormPage("teamSelectMenu");

            #endregion

            #region Buy Menu Buttons

            InterfaceManager.AddComponent(new Button("pistolMenuButton", new Rectangle(100, 80, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "1. PISTOLS", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("heavyMenuButton", new Rectangle(100, 160, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "2.  HEAVY", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("smgMenuButton", new Rectangle(100, 240, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "3.  SMGs", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("rifleMenuButton", new Rectangle(100, 320, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "4. RIFLES", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("gearMenuButton", new Rectangle(100, 400, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "5.  GEAR", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("grenadeMenuButton", new Rectangle(100, 480, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "6. GRENADES", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.FormPage("buyButtonMenu");

            #endregion

            #region Pistol Menu Buttons

            InterfaceManager.AddComponent(new Button("uspMenuButton", new Rectangle(100, 80, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "USP-S", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("dualMenuButton", new Rectangle(100, 160, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "Dual Berettas", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("p250menuButton", new Rectangle(100, 240, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "P250", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("57menuButton", new Rectangle(100, 320, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "Five-SeveN", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("deagleMenuButton", new Rectangle(100, 400, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "Desert Eagle", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.FormPage("pistolButtonMenu");

            #endregion

            #region CT Rifle Menu Buttons

            InterfaceManager.AddComponent(new Button("famasMenuButton", new Rectangle(100, 80, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "Famas", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("m4a1MenuButton", new Rectangle(100, 160, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "M4A1", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("ssgMenuButton", new Rectangle(100, 240, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "SSG 08", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("augMenuButton", new Rectangle(100, 320, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "AUG", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("awpMenuButton", new Rectangle(100, 400, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "AWP", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.FormPage("ctRifleButtonMenu");

            #endregion

            #region T Rifle Menu Buttons

            InterfaceManager.AddComponent(new Button("galilMenuButton", new Rectangle(100, 80, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "Galil", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("ak47MenuButton", new Rectangle(100, 160, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "AK47", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("ssgMenuButton", new Rectangle(100, 240, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "SSG 08", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("sg558MenuButton", new Rectangle(100, 320, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "SG558", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new Button("awpMenuButton", new Rectangle(100, 400, 200, 40), Color.Gray,
                                                     Color.White, Color.DarkGray, "AWP", 0.4f, EasingFunctions.AnimationType.QuinticInOut,
                                                     GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.FormPage("tRifleButtonMenu");

            #endregion

            #region Scoreboard Menu

            InterfaceManager.AddComponent(new Bar("scoreboardBar", new Rectangle(90, 20, 1100, 650), 0.4f,
                                                  0.8f, Color.Black, EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Right,
                                                  DriverInstance.Assets));

            InterfaceManager.AddComponent(new TextBox("scoreboardTitle", new Vector2(94, 20), "Scoreboard", Color.White, 0.4f,
                                                      EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Down, DriverInstance.Assets));

            InterfaceManager.AddComponent(new TextBox("ctTitle", new Vector2(94, 50), "Counter-Terrorists", ServerClientInterface.CT_Colour,
                                                      0.4f,
                                                      EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.AddComponent(new TextBox("tTitle", new Vector2(645, 50), "Terrorists", ServerClientInterface.T_Colour, 0.4f,
                                                      EasingFunctions.AnimationType.QuinticInOut, GUIComponent.AnimationDirection.Right, DriverInstance.Assets));

            InterfaceManager.FormPage("scoreboard");

            #endregion

            #endregion

            // Show the menu
            InterfaceManager.ShowPage("defaultMenu");

            // Set the default address to empty
            Address = string.Empty;

            // Determine menu background, true if the number is not 0
            MenuBackgroundType = NumGen.Next(0, 2) != 0;

            FadeIn = true;

            // Initialize camera
            Camera = new Camera2D
            {
                Position = Vector2.Zero
            };
        }
예제 #9
0
    // Use this for initialization
    void Awake()
    {
        NumGen ng = NumGen.getInatance();

        numTiles_inRow = ng.getX();
        numTiles_inCol = ng.getY();


        map  = new GameObject[row, col];
        grid = new int[row, col];
        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                grid[i, j] = 0;
                //map[i,j] = (GameObject)Instantiate(prefab,new Vector3(i*.32f*4,j*.32f*4,0),Quaternion.identity);
            }
        }
        int x = 0;
        int y = Random.Range(0, col);

        grid [x, y] = -1;
        CreatMap(x, y);
        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                float position_x = transform.position.x + i * tileWidth * numTiles_inRow;
                float position_y = transform.position.y + j * tileHeight * numTiles_inCol;
                if (grid[i, j] != 0)
                {
                    if (grid[i, j] == 3)
                    {
                        map[i, j] = (GameObject)Instantiate(room3, new Vector3(position_x, position_y, 0), Quaternion.identity);
                        map[i, j].transform.parent = transform;
                    }
                    if (grid[i, j] == 2)
                    {
                        map[i, j] = (GameObject)Instantiate(room1, new Vector3(position_x, position_y, 0), Quaternion.identity);
                        map[i, j].transform.parent = transform;
                    }
                    if (grid[i, j] == 5)
                    {
                        map[i, j] = (GameObject)Instantiate(roomFinal, new Vector3(position_x, position_y, 0), Quaternion.identity);
                        map[i, j].transform.parent = transform;
                    }
                    if (grid[i, j] == 4)
                    {
                        map[i, j] = (GameObject)Instantiate(room4, new Vector3(position_x, position_y, 0), Quaternion.identity);
                        map[i, j].transform.parent = transform;
                    }
                    if (grid[i, j] == -1)
                    {
                        map[i, j] = (GameObject)Instantiate(room1, new Vector3(position_x, position_y, 0), Quaternion.identity);
                        map[i, j].transform.parent = transform;
                    }
                    if (grid[i, j] == 1)
                    {
                        map[i, j] = (GameObject)Instantiate(room1, new Vector3(position_x, position_y, 0), Quaternion.identity);
                        map[i, j].transform.parent = transform;
                    }
                }
                if (grid[i, j] == 0)
                {
                    map[i, j] = (GameObject)Instantiate(room0, new Vector3(position_x, position_y, 0), Quaternion.identity);
                    map[i, j].transform.parent = transform;
                }
                map[i, j].GetComponent <RoomGen>().roomDifficulty = (int)(i + Random.Range(1, 2)) * Random.Range(5, 10);
            }
        }
    }