Example #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        // here temporarily cos lazy change scene
        // proper place should be when player selects single player or multiplayer
        //PlayerPrefs.SetString("Game_Mode", "Online_Coop");

        if (PlayerPrefs.GetString("Game_Mode") == "Single_Player")
        {
            b_foundLocalPlayer = true;
            gameType           = GAME_TYPE.SINGLE_PLAYER;

            GameObject playerPrefab = Resources.Load("Prefabs/PlayerHero") as GameObject;
            localPlayer = GameObject.Instantiate(playerPrefab);
            Debug.Log("DDD");
        }
        else if (PlayerPrefs.GetString("Game_Mode") == "Online_Versus")
        {
            gameType = GAME_TYPE.ONLINE_VS;
        }
        else if (PlayerPrefs.GetString("Game_Mode") == "Online_Coop")
        {
            gameType = GAME_TYPE.ONINE_COOP;
        }
    }
Example #2
0
 public void GameStart()
 {
     mMainScene.GameStart();
     mBirdObject.GameStart();
     mHurdleEnemyObject.GameStart();
     GameType = GAME_TYPE.PLAYING;
 }
Example #3
0
 public string buildHostInfo(string a_host, GAME_TYPE a_game)
 {
     if (a_game == GAME_TYPE.GAME_H3_NEW_TYPE)
     {
         return(MSG_HOST_INFO + DELIMITER + GAME_H3_NEW_INFO + DELIMITER + Regex.Replace(a_host, @"\s+", ""));
     }
     else if (a_game == GAME_TYPE.GAME_H3_LOAD_TYPE)
     {
         return(MSG_HOST_INFO + DELIMITER + GAME_H3_LOAD_INFO + DELIMITER + Regex.Replace(a_host, @"\s+", ""));
     }
     return("");
 }
Example #4
0
        public NewGame(int seconds, int tiles, GAME_TYPE gameType)
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.gameType        = gameType;
            this.tiles           = tiles;
            this.seconds         = seconds;
            counter     = 0;
            leaderBoard = new Leaderboard();
            stopwatch   = new Stopwatch();
            random      = new Random();

            if (gameType == GAME_TYPE.TIMER_GAME)
            {
                timer          = new Timer();
                timer.Interval = seconds * 1000;
                timer.Tick    += timer_Tick;
            }
        }
Example #5
0
 public MSG_TYPE parse(string a_message)
 {
     try
     {
         string[] words = Regex.Replace(a_message, @"\s+", "").Split(DELIMITER);
         if (words[0].Contains(MSG_SERVER_INFO))
         {
             m_serverIP = words[1];
             return(MSG_TYPE.MSG_SERVER_INFO_TYPE);
         }
         else if (words[0].Contains(MSG_CLIENT_INFO))
         {
             m_clientLogin = words[1];
             m_clientIP    = words[2];
             return(MSG_TYPE.MSG_CLIENT_INFO_TYPE);
         }
         else if (words[0].Contains(MSG_RESET_INFO))
         {
             return(MSG_TYPE.MSG_RESET_INFO_TYPE);
         }
         else if (words[0].Contains(MSG_HOST_INFO))
         {
             string game = words[1];
             m_hostIP = words[2];
             if (game.Contains(GAME_H3_NEW_INFO))
             {
                 m_hostGame = GAME_TYPE.GAME_H3_NEW_TYPE;
             }
             else if (game.Contains(GAME_H3_LOAD_INFO))
             {
                 m_hostGame = GAME_TYPE.GAME_H3_LOAD_TYPE;
             }
             return(MSG_TYPE.MSG_HOST_INFO_TYPE);
         }
     }
     catch (Exception)
     {
         // nothing to do
     }
     return(MSG_TYPE.MSG_UNKNOWN_TYPE);
 }
Example #6
0
        private static string PLAYER2 = "Player_2";             // Second Player Name

        public static void RunConsoleGame(Setting?setting, GameSave?save = null, GAME_TYPE gameType = GAME_TYPE.HU_VS_HU)
        {
            try
            {
                hasOutcome = false;
                lastAction = null;
                if (setting == null)
                {
                    setting = new Setting();
                }
                if (gameType == GAME_TYPE.HU_VS_HU)
                {
                    PLAYER1_CONTROLLER = Selector;
                    PLAYER2_CONTROLLER = Selector;
                }
                else if (gameType == GAME_TYPE.HU_VS_AI)
                {
                    PLAYER1_CONTROLLER = Selector;
                    PLAYER2_CONTROLLER = AISelector;
                }
                if (save == null)
                {
                    restart = true;
                    game    = new Battleships(setting);
                }
                else
                {
                    restart = false;
                    game    = new Battleships(save);
                }
                PLAYER1 = game.Player_1;
                PLAYER2 = game.Player_2;
                bool           loop = true;
                ConsoleKeyInfo pressedKey;
                Init();
                if (save == null)
                {
                    if (setting.PlaceType == PlaceShips.Select)
                    {
                        SetShips();
                    }
                    else
                    {
                        game.PlaceRandom();
                    }
                    Console.SetCursorPosition(0, BoardRow);
                    DrawBoard();
                    Console.SetCursorPosition(firstCellCol, firstCellRow);
                    System.Threading.Thread.Sleep(100);
                    if (setting.PlaceType == PlaceShips.Select && gameType == GAME_TYPE.HU_VS_HU)
                    {
                        SetShips();
                    }
                    else
                    {
                        game.PlaceRandom();
                    }
                    Console.SetCursorPosition(firstCellCol, firstCellRow);
                }
                Console.SetCursorPosition(0, BoardRow);
                DrawBoard();
                Console.SetCursorPosition(firstCellCol, firstCellRow);
                do
                {
                    if (hasOutcome)
                    {
                        pressedKey = Selector();
                    }
                    else
                    {
                        pressedKey = !game.Turn ? PLAYER1_CONTROLLER() : PLAYER2_CONTROLLER();
                    }
                    if (pressedKey.Modifiers == CTRL)
                    {
                        if (pressedKey.Key == EXIT)
                        {
                            loop = false;
                        }
                        if (pressedKey.Key == NEW)
                        {
                            restart = true;
                            Init();
                            if (setting.PlaceType == PlaceShips.Select)
                            {
                                SetShips();
                            }
                            else
                            {
                                game.PlaceRandom();
                            }
                            Console.SetCursorPosition(0, BoardRow);
                            DrawBoard();
                            Console.SetCursorPosition(firstCellCol, firstCellRow);
                            System.Threading.Thread.Sleep(100);
                            if (setting.PlaceType == PlaceShips.Select && gameType == GAME_TYPE.HU_VS_HU)
                            {
                                SetShips();
                            }
                            else
                            {
                                game.PlaceRandom();
                            }
                            Console.SetCursorPosition(firstCellCol, firstCellRow);
                            Console.SetCursorPosition(0, BoardRow);
                            DrawBoard();
                            Console.SetCursorPosition(firstCellCol, firstCellRow);
                        }
                        //if (pressedKey.Key == UNDO)
                        //    UpdateGameState(false);
                        if (pressedKey.Key == SAVE && gameType == GAME_TYPE.HU_VS_HU)
                        {
                            SaveGame();
                        }
                    }
                    else if (pressedKey.Key == ENTER || pressedKey.Key == ENTER_ALT)
                    {
                        UpdateGameState(true, (Console.CursorTop - firstCellRow) / 2, (Console.CursorLeft - firstCellCol) / (ROW_SEP.Length + CROSS_POINT.Length));
                    }
                } while (loop);

                Console.Clear();
            }
            catch (Exception)
            {
                return;
            }
        }
Example #7
0
 public void GameOver()
 {
     mMainScene.GameOver();
     GameType = GAME_TYPE.OVER;
 }
Example #8
0
 public void GameReady()
 {
     mLandObject.GameReady();
     mBirdObject.GameReady();
     GameType = GAME_TYPE.READY;
 }
Example #9
0
        void InitGameHole(TGAME_MODE gameMode, GAME_TYPE gameType, bool IsRepeted = false, byte Map = 0)
        {
            byte WP;
            byte WD;
            byte P;
            int  x;

            int[] H;
            int[] M;

            if (Map == 0x7F)
            {
                Map = (byte)GetMap();
            }

            if (gameType == GAME_TYPE.HOLE_REPEAT && IsRepeted)
            {
                for (x = 0; x <= 17; x++)
                {
                    WP = (byte)rnd.Next(0, 8);
                    WD = (byte)rnd.Next(255);
                    P  = (byte)rnd.Next(1, 3);

                    this[x].Hole          = (byte)(x + 1);
                    this[x].Weather       = (byte)rnd.Next(0, 3);
                    this[x].WindPower     = WP;
                    this[x].WindDirection = WD;
                    this[x].Map           = Map;
                    this[x].Pos           = P;
                }
                // leave
                return;
            }
            switch (gameMode)
            {
            case TGAME_MODE.GAME_MODE_FRONT:
                for (x = 0; x <= 17; x++)
                {
                    this[x].Hole          = (byte)(x + 1);
                    this[x].Weather       = (byte)rnd.Next(0, 3);
                    this[x].WindPower     = (byte)rnd.Next(0, 8);
                    this[x].WindDirection = (byte)rnd.Next(255);
                    this[x].Map           = Map;
                    this[x].Pos           = (byte)rnd.Next(1, 3);
                }
                break;

            case TGAME_MODE.GAME_MODE_BACK:
                for (x = 0; x <= 17; x++)
                {
                    this[x].Hole          = (byte)(18 - x);
                    this[x].Weather       = (byte)rnd.Next(0, 3);
                    this[x].WindPower     = (byte)rnd.Next(0, 8);
                    this[x].WindDirection = (byte)rnd.Next(255);
                    this[x].Pos           = (byte)rnd.Next(1, 3);
                }
                break;

            case TGAME_MODE.GAME_MODE_SHUFFLE:
            case TGAME_MODE.GAME_MODE_RANDOM:
                H = RandomHole();
                for (x = 0; x <= 17; x++)
                {
                    this[x].Hole          = (byte)H[x];
                    this[x].Weather       = (byte)rnd.Next(0, 3);
                    this[x].WindPower     = (byte)rnd.Next(0, 8);
                    this[x].WindDirection = (byte)rnd.Next(255);
                    this[x].Map           = Map;
                    this[x].Pos           = (byte)rnd.Next(1, 3);
                }
                break;

            case TGAME_MODE.GAME_MODE_SSC:
                H = RandomHole();
                M = RandomMap();
                for (x = 0; x <= 17; x++)
                {
                    this[x].Hole          = (byte)H[x];
                    this[x].Weather       = (byte)rnd.Next(0, 3);
                    this[x].WindPower     = (byte)rnd.Next(0, 8);
                    this[x].WindDirection = (byte)rnd.Next(255);
                    this[x].Map           = (byte)M[x];
                    this[x].Pos           = (byte)rnd.Next(1, 3);
                }
                this.Last().Hole = (byte)(rnd.Next(0, 2) + 1);
                this.Last().Map  = 0x11;
                break;

            default:
                for (x = 0; x <= 17; x++)
                {
                    this[x].Hole          = (byte)(x + 1);
                    this[x].Weather       = (byte)rnd.Next(0, 3);
                    this[x].WindPower     = (byte)rnd.Next(0, 8);
                    this[x].WindDirection = (byte)rnd.Next(255);
                    this[x].Map           = Map;
                    this[x].Pos           = (byte)rnd.Next(1, 3);
                }
                break;
            }
        }
Example #10
0
 public void Init(TGAME_MODE Mode, GAME_TYPE Type, bool Repeted, byte Map, byte holeCount)
 {
     m_holeCount = holeCount;
     InitGameHole(Mode, Type, Repeted, Map);
 }
Example #11
0
        public byte GetEXP(GAME_TYPE GameType, byte Map, byte Rank, byte SumPlayer, byte SumHole)
        {
            byte[] exp_3h;
            byte[] exp_6h;
            byte[] exp_9h;
            byte[] exp_18h;
            switch (GameType)
            {
            case GAME_TYPE.VERSUS_STROKE:
                // Default
                exp_3h  = new byte[] { 0, 0, 0, 0 };
                exp_6h  = new byte[] { 0, 0, 0, 0 };
                exp_9h  = new byte[] { 0, 0, 0, 0 };
                exp_18h = new byte[] { 0, 0, 0, 0 };
                switch (GetDifficulty(Map))
                {
                case 1:
                    // Declare Versus Mode Exp Table
                    switch (SumPlayer)
                    {
                    case 2:
                        exp_3h  = new byte[] { 7, 6, 0, 0 };
                        exp_6h  = new byte[] { 14, 10, 0, 0 };
                        exp_9h  = new byte[] { 20, 15, 0, 0 };
                        exp_18h = new byte[] { 40, 29, 0, 0 };
                        break;

                    case 3:
                        exp_3h  = new byte[] { 9, 8, 7, 0 };
                        exp_6h  = new byte[] { 17, 15, 13, 0 };
                        exp_9h  = new byte[] { 25, 22, 18, 0 };
                        exp_18h = new byte[] { 50, 43, 36, 0 };
                        break;

                    case 4:
                        exp_3h  = new byte[] { 11, 10, 9, 8 };
                        exp_6h  = new byte[] { 21, 19, 17, 15 };
                        exp_9h  = new byte[] { 31, 29, 25, 22 };
                        exp_18h = new byte[] { 62, 56, 49, 42 };
                        break;
                    }
                    break;

                case 2:
                    switch (SumPlayer)
                    {
                    case 2:
                        exp_3h  = new byte[] { 8, 6, 0, 0 };
                        exp_6h  = new byte[] { 14, 11, 0, 0 };
                        exp_9h  = new byte[] { 21, 16, 0, 0 };
                        exp_18h = new byte[] { 41, 30, 0, 0 };
                        break;

                    case 3:
                        exp_3h  = new byte[] { 9, 8, 7, 0 };
                        exp_6h  = new byte[] { 18, 16, 13, 0 };
                        exp_9h  = new byte[] { 26, 23, 19, 0 };
                        exp_18h = new byte[] { 52, 45, 38, 0 };
                        break;

                    case 4:
                        exp_3h  = new byte[] { 12, 11, 9, 8 };
                        exp_6h  = new byte[] { 22, 20, 18, 16 };
                        exp_9h  = new byte[] { 33, 30, 26, 23 };
                        exp_18h = new byte[] { 65, 59, 52, 45 };
                        break;
                    }
                    break;

                case 3:
                    switch (SumPlayer)
                    {
                    case 2:
                        exp_3h  = new byte[] { 8, 6, 0, 0 };
                        exp_6h  = new byte[] { 15, 11, 0, 0 };
                        exp_9h  = new byte[] { 22, 16, 0, 0 };
                        exp_18h = new byte[] { 43, 32, 0, 0 };
                        break;

                    case 3:
                        exp_3h  = new byte[] { 10, 9, 7, 0 };
                        exp_6h  = new byte[] { 19, 16, 14, 0 };
                        exp_9h  = new byte[] { 27, 24, 20, 0 };
                        exp_18h = new byte[] { 54, 47, 40, 0 };
                        break;

                    case 4:
                        exp_3h  = new byte[] { 12, 11, 10, 9 };
                        exp_6h  = new byte[] { 23, 21, 19, 16 };
                        exp_9h  = new byte[] { 34, 31, 28, 24 };
                        exp_18h = new byte[] { 67, 62, 55, 47 };
                        break;
                    }
                    break;

                case 4:
                    switch (SumPlayer)
                    {
                    case 2:
                        exp_3h  = new byte[] { 8, 7, 0, 0 };
                        exp_6h  = new byte[] { 16, 12, 0, 0 };
                        exp_9h  = new byte[] { 23, 18, 0, 0 };
                        exp_18h = new byte[] { 45, 35, 0, 0 };
                        break;

                    case 3:
                        exp_3h  = new byte[] { 11, 9, 8, 0 };
                        exp_6h  = new byte[] { 20, 18, 15, 0 };
                        exp_9h  = new byte[] { 30, 26, 22, 0 };
                        exp_18h = new byte[] { 58, 51, 44, 0 };
                        break;

                    case 4:
                        exp_3h  = new byte[] { 13, 12, 11, 10 };
                        exp_6h  = new byte[] { 25, 23, 21, 18 };
                        exp_9h  = new byte[] { 37, 34, 30, 27 };
                        exp_18h = new byte[] { 72, 67, 60, 53 };
                        break;
                    }
                    break;

                case 5:
                    switch (SumPlayer)
                    {
                    case 2:
                        exp_3h  = new byte[] { 9, 7, 0, 0 };
                        exp_6h  = new byte[] { 17, 14, 0, 0 };
                        exp_9h  = new byte[] { 25, 20, 0, 0 };
                        exp_18h = new byte[] { 49, 39, 0, 0 };
                        break;

                    case 3:
                        exp_3h  = new byte[] { 12, 10, 9, 0 };
                        exp_6h  = new byte[] { 22, 20, 17, 0 };
                        exp_9h  = new byte[] { 33, 29, 25, 0 };
                        exp_18h = new byte[] { 64, 57, 50, 0 };
                        break;

                    case 4:
                        exp_3h  = new byte[] { 14, 13, 12, 11 };
                        exp_6h  = new byte[] { 27, 26, 23, 21 };
                        exp_9h  = new byte[] { 41, 38, 34, 31 };
                        exp_18h = new byte[] { 80, 75, 68, 61 };
                        break;
                    }
                    break;
                }
                switch (SumHole)
                {
                case 3:
                {
                    return(exp_3h[Rank - 1]);
                }

                case 6:
                {
                    return(exp_6h[Rank - 1]);
                }

                case 9:
                {
                    return(exp_9h[Rank - 1]);
                }

                case 18:
                {
                    return(exp_18h[Rank - 1]);
                }

                default:
                {
                    return(0);
                }
                }

            case GAME_TYPE.VERSUS_MATCH:
                break;

            case GAME_TYPE.CHAT_ROOM:
                break;

            case GAME_TYPE.TOURNEY:
                break;

            case GAME_TYPE.TOURNEY_TEAM:
                break;

            case GAME_TYPE.TOURNEY_GUILD:
                break;

            case GAME_TYPE.PANG_BATTLE:
                break;

            case GAME_TYPE.CHIP_IN_PRACTICE:
                break;

            case GAME_TYPE.SSC:
                break;

            case GAME_TYPE.HOLE_REPEAT:
            {
                if (SumHole > 18)
                {
                    return(0);
                }
                return(SumHole);
            }

            case GAME_TYPE.GRANDPRIX:
                break;
            }

            return(0);
        }