void goToRunnerScene()
        {
            //		int temp = selectSpecies;
            //		PlayerPrefs.SetInt ("species1", temp);

            RequestRRSpecies rs = new RequestRRSpecies();

            rs.send(selectedSpecies);


            if (cManager)
            {
                cManager.Send(rs);
            }


            RequestRRStartGame request = new RequestRRStartGame();

            request.Send(Constants.USER_ID);
            cManager.Send(request);
            //		Application.LoadLevel("CountdownScene");

            // Give the client a message about waiting for the other player to finish selecting.  Hide the PLAY button so
            // player can't send another RequestRRStartGame.  It is cruicial only one RequestRRstartGame is sent from each
            // player.
        }
Esempio n. 2
0
        public void Submit()
        {
            user_id  = user_id.Trim();
            password = password.Trim();

            if (user_id.Length == 0)
            {
                Debug.Log("User ID Required");
                GUI.FocusControl("username_field");
            }
            else if (password.Length == 0)
            {
                Debug.Log("Password Required");
                GUI.FocusControl("password_field");
            }
            else
            {
                //			Debug.Log(mainObject.GetInstanceID());
                RRConnectionManager cManager = mainObject.GetComponent <RRConnectionManager> ();

                if (cManager)
                {
                    cManager.Send(RequestLogin(user_id, password));
                }
            }
        }
Esempio n. 3
0
    public void Submit()
    {
        user_id  = user_id.Trim();
        password = password.Trim();

        if (user_id.Length == 0)
        {
            //			mainObject.GetComponent<Main>().CreateMessageBox("User ID Required");
            GUI.FocusControl("username_field");
        }
        else if (password.Length == 0)
        {
            //			mainObject.GetComponent<Main>().CreateMessageBox("Password Required");
            GUI.FocusControl("password_field");
        }
        else
        {
            NetworkManager.Send(
                LoginProtocol.Prepare(user_id, password),
                ProcessLogin
                );

            CW.NetworkManager.Send(CW.LoginProtocol.Prepare(user_id, password));

            RR.RRConnectionManager cManager = RR.RRConnectionManager.getInstance();
            cManager.Send(RR_RequestLogin(user_id, password));
        }
    }
Esempio n. 4
0
        // Join makes an attempt to create and or join an online game.
        public void Join()
        {
            RRConnectionManager cManager = mainObject.GetComponent <RRConnectionManager> ();

            if (cManager)
            {
                cManager.Send(RequestRaceInit());
            }
        }
Esempio n. 5
0
        // comunication with server
        private IEnumerator Delay()
        {
            flag = false;
            yield return(new WaitForSeconds(4f));

            if (cManager)
            {
                RequestRRPostion rp = new RequestRRPostion();
                rp.send((player1.transform.position.x).ToString(), (player1.transform.position.y).ToString());
                cManager.Send(rp);
            }

            flag = true;
        }
Esempio n. 6
0
    public void OnPairResult(NetworkResponse response)
    {
        ResponsePair args   = response as ResponsePair;
        int          userID = GameState.account.account_id;

        if (args.status == 0)
        {
            Debug.Log("All players are ready to play [room id=" + args.id + "]");
            this.room_id = args.id;

            this.enableRRButton = true;
            this.enableCWButton = true;

            var room = RoomManager.getInstance().getRoom(args.id);
            if (!room.containsPlayer(userID))
            {
                room.addPlayer(userID);
            }

            // switch scene
            if (args.gameID == Constants.MINIGAME_RUNNING_RHINO)
            {
                RR.RRConnectionManager cManager = RR.RRConnectionManager.getInstance();
                cManager.Send(RR_RequestRaceInit());

                Game.SwitchScene("RRReadyScene");
            }
            else if (args.gameID == Constants.MINIGAME_CARDS_OF_WILD)
            {
                CW.GameManager.matchID = args.id;
                CW.NetworkManager.Send(CW.MatchInitProtocol.Prepare
                                           (GameState.player.GetID(), args.id),
                                       ProcessMatchInit);
            }
        }
        else
        {
            Debug.Log("New room allocated [room id=" + args.id + "]");
            var room = RoomManager.getInstance().addRoom(args.id, args.gameID);
            room.host = GameState.player.GetName();
            room.addPlayer(userID);

            this.enableRRButton = false;
            this.enableCWButton = false;
            this.waiting        = true;
        }
    }
Esempio n. 7
0
        public IEnumerator RequestHeartbeat(float time)
        {
            yield return(new WaitForSeconds(time));

            RRConnectionManager cManager = gameObject.GetComponent <RRConnectionManager>();

            if (cManager)
            {
                RequestHeartbeat request = new RequestHeartbeat();
                request.Send();

                cManager.Send(request);
            }

            //originially 1f changed to .1f
            StartCoroutine(RequestHeartbeat(1f));
        }
        // Use this for initialization
        void Start()
        {
            //Canvas Initialization
            gObj      = new GameObject();
            gObj.name = "SelectionCanvas";
            Canvas canvas = gObj.AddComponent <Canvas> ();

            canvas.renderMode = RenderMode.ScreenSpaceOverlay;
            CanvasScaler cs = gObj.AddComponent <CanvasScaler> ();

            cs.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
            GraphicRaycaster gRay = gObj.AddComponent <GraphicRaycaster> ();

            //Button stored by position
            spot1 = 0;
            spot2 = 1;

            //Initialize Buttons
            initButtons();

            mainObject = GameObject.Find("MainObject");

            cManager = RRConnectionManager.getInstance();


            //		NetworkRequestTable.init();
            //		NetworkResponseTable.init();

            RRMessageQueue.getInstance().AddCallback(Constants.SMSG_RRSTARTGAME, ResponseRRStartGame);
            RRMessageQueue.getInstance().AddCallback(Constants.SMSG_RRGETMAP, ResponseRRGetMap);

            RequestRRGetMap reqmap = new RequestRRGetMap();

            reqmap.Send();
            cManager.Send(reqmap);
        }
Esempio n. 9
0
    public void OnPairResult(NetworkResponse response)
    {
        ResponsePair args   = response as ResponsePair;
        int          userID = GameState.account.account_id;

        if (args.status == 0)
        {
            Debug.Log("All players are ready to play [room id=" + args.id + "]");
            this.room_id = args.id;

            this.enableRRButton = true;
            this.enableCWButton = true;
            // DH change
            this.enableMCButton = true;

            var room = RoomManager.getInstance().getRoom(args.id);
            if (!room.containsPlayer(userID))
            {
                room.addPlayer(userID);
            }

            // switch scene
            if (args.gameID == Constants.MINIGAME_RUNNING_RHINO)
            {
                RR.RRConnectionManager cManager = RR.RRConnectionManager.getInstance();
                cManager.Send(RR_RequestRaceInit());

                Game.SwitchScene("RRReadyScene");
            }
            else if (args.gameID == Constants.MINIGAME_CARDS_OF_WILD)
            {
                CW.GameManager.matchID = args.id;
                CW.NetworkManager.Send(CW.MatchInitProtocol.Prepare
                                           (GameState.player.GetID(), args.id),
                                       ProcessMatchInit);
            }
            else if (args.gameID == Constants.MINIGAME_MULTI_CONVERGENCE)
            {
                // DH change
                MultiConvergeGame.matchID = args.id; // game id
                short host = 0;                      // Default - not the host
                if (GameState.player.GetName() == room.host)
                {
                    host = 1;                      // this is the host
                }
                NetworkManager.Send(MCMatchInitProtocol.Prepare
                                        (GameState.player.GetID(), args.id, host, GameState.player.GetName()),
                                    MCProcessMatchInit);
                Debug.Log("MC notice sent to server(game id, player id): " + args.id + " " + GameState.player.GetID());
                Debug.Log("player id/name: " + userID + " " + GameState.player.GetName());
                Debug.Log("This player host value is: " + host);
            }
        }
        else
        {
            Debug.Log("New room allocated [room id=" + args.id + "]");
            var room = RoomManager.getInstance().addRoom(args.id, args.gameID);
            room.host = GameState.player.GetName();
            room.addPlayer(userID);

            this.enableRRButton = false;
            this.enableCWButton = false;
            // DH change
            this.enableMCButton = false;
            this.waiting        = true;
        }
    }
        // Use this for initialization
        void Start()
        {
            //Canvas Initialization
            gObj = new GameObject ();
            gObj.name = "SelectionCanvas";
            Canvas canvas = gObj.AddComponent<Canvas> ();
            canvas.renderMode = RenderMode.ScreenSpaceOverlay;
            CanvasScaler cs = gObj.AddComponent<CanvasScaler> ();
            cs.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
            GraphicRaycaster gRay = gObj.AddComponent<GraphicRaycaster> ();

            //Button stored by position
            spot1 = 0;
            spot2 = 1;

            //Initialize Buttons
            initButtons ();

            mainObject = GameObject.Find ("MainObject");

            cManager = RRConnectionManager.getInstance ();

            //		NetworkRequestTable.init();
            //		NetworkResponseTable.init();

            RRMessageQueue.getInstance ().AddCallback (Constants.SMSG_RRSTARTGAME, ResponseRRStartGame);
            RRMessageQueue.getInstance ().AddCallback (Constants.SMSG_RRGETMAP, ResponseRRGetMap);

            RequestRRGetMap reqmap = new RequestRRGetMap ();
            reqmap.Send ();
            cManager.Send (reqmap);
        }