Ejemplo n.º 1
0
 void Start()
 {
     time       = 0.0f;
     mainObject = GameObject.Find("MainObject");
     cManager   = RRConnectionManager.getInstance();
     //RRMessageQueue.getInstance ().AddCallback (Constants.SMSG_AUTH, ResponseLogin);
 }
Ejemplo 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));
                }
            }
        }
Ejemplo 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));
        }
    }
Ejemplo n.º 4
0
        // Use this for initialization
        void Start()
        {
            RRConnectionManager cManager = mainObject.GetComponent <RRConnectionManager> ();

            if (cManager)
            {
                //			cManager.Send(new RequestSpeciesList());
            }
        }
Ejemplo n.º 5
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());
            }
        }
Ejemplo n.º 6
0
        // Use this for initialization
        void Start()
        {
            //Application.LoadLevel("RRLogin");
            RRConnectionManager cManager = gameObject.GetComponent <RRConnectionManager>();

            if (cManager)
            {
                StartCoroutine(RequestHeartbeat(1f));
            }
        }
Ejemplo n.º 7
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;
        }
    }
Ejemplo n.º 8
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));
        }
Ejemplo n.º 9
0
        // 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);
        }
Ejemplo n.º 10
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;
        }
    }
 void Awake()
 {
     sInstance = this;
     mainObject = GameObject.Find ("MainObject");
 }
Ejemplo n.º 12
0
        // 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);
        }
 void Awake()
 {
     sInstance  = this;
     mainObject = GameObject.Find("MainObject");
 }
Ejemplo n.º 14
0
        public float horizontalCollisions(float deltaY, float deltaX, Vector2 p)
        {
            // Check collisions left and right
            movementStopped = false;

            for (int i = 0; i < 3; i++)
            {
                float dir = Mathf.Sign(deltaX);
                float x   = p.x + c.x + s.x / 2 * dir;
                float y   = p.y + c.y - s.y / 2 + s.y / 2 * i;

                ray = new Ray(new Vector2(x, y), new Vector2(dir, 0));
                Debug.DrawRay(ray.origin, ray.direction);

                if (Physics.Raycast(ray, out hit, Mathf.Abs(deltaX) + skin, collisionMask))
                {
                    // Get Distance between player and ground
                    float dst = Vector3.Distance(ray.origin, hit.point);

                    // Stop player's downwards movement after coming within skin width of a collider
                    if (dst > skin)
                    {
                        deltaX = dst * dir - skin * dir;
                    }
                    else
                    {
                        deltaX = 0;
                    }

                    movementStopped = true;
                    break;
                }
                else if (Physics.Raycast(ray, out hit, Mathf.Abs(deltaX) + skin, collectableMask))
                {
                    string name = hit.collider.gameObject.name.Substring(0, 7);
                    //Debug.Log("!!!Try to pass name: " + name);
                    if (running.isHitItem(name))
                    {
                        Animator animator = hit.collider.gameObject.GetComponent <Animator>();
                        animator.SetBool("eaten", true);
                        //GameObject.Destroy(hit.collider.gameObject);
                    }
                }

                else if (Physics.Raycast(ray, out hit, Mathf.Abs(deltaX) + skin, endFlagMask))
                {
                    if (collider.gameObject.ToString().CompareTo("Player_sprite(Clone)") > 0)
                    {
                        PlayerPrefs.SetInt("Win", -1);
                        PlayerPrefs.SetString("Winning Time", "");

                        GameObject          mainObject = GameObject.Find("MainObject");
                        RRConnectionManager cManager;
                        cManager = RRConnectionManager.getInstance();

                        RequestRREndGame requestRREndGame = new RequestRREndGame();
                        requestRREndGame.Send(Running.completed, Running.time.ToString());
                        cManager.Send(requestRREndGame);

                        doPlayerFinish();
                    }
                }
            }

            return(deltaX);
        }
Ejemplo n.º 15
0
 void Start()
 {
     time = 0.0f;
     mainObject = GameObject.Find ("MainObject");
     cManager = RRConnectionManager.getInstance ();
     //RRMessageQueue.getInstance ().AddCallback (Constants.SMSG_AUTH, ResponseLogin);
 }