Ejemplo n.º 1
0
    void Awake()
    {
        if (manager == null)
        {
            manager = this;
        }

        else if (manager != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
        _daily_login           = new daily_login();
        _player_data           = new player_data();
        _menu_data             = new menu_data();
        _match_making_data     = new match_making_data();
        _statistics_data       = new statistics_data();
        _root_match_data       = new root_match_data();
        _root_opponent_data    = new root_opponent_data();
        _root_timer_data       = new root_timer_data();
        _root_friend_data      = new root_friend_data();
        _root_round_data       = new root_round_data();
        _root_new_balance      = new root_new_balance();
        _root_leaderboard_data = new root_leaderboard_data();
        _root_settings_data    = new root_settings_data();
        _root_invite_timer     = new root_invite_timer();
        _root_oa            = new root_oa();
        _get_Ver            = new get_Ver();
        _check_ver          = new check_ver();
        _root_receive_emoji = new root_receive_emoji();

        _timer_data   = new timer_data();
        _striker_data = new striker_data();
        _keeper_data  = new keeper_data();

        Screen.sleepTimeout = (int)SleepTimeout.NeverSleep;
    }
Ejemplo n.º 2
0
    public void OnSocketReceive()
    {
        socket.On("no_money", (data) =>
        {
            root_login_from_device err = new root_login_from_device();
            err = JsonUtility.FromJson <root_login_from_device>(data.ToString());
            Debug.Log(data.ToString());
            errorMsg            = err.error.getMessage();
            invite_finding_game = false;
            problem             = true;
            //Do Something
        });
        socket.On("friend_no_money", (data) =>
        {
            root_login_from_device err = new root_login_from_device();
            err = JsonUtility.FromJson <root_login_from_device>(data.ToString());
            Debug.Log(data.ToString());
            errorMsg            = err.error.getMessage();
            invite_finding_game = false;
            problem             = true;
            //Do Something
        });


        socket.On("receive_emoji", (data) =>
        {
            _root_receive_emoji = JsonUtility.FromJson <root_receive_emoji>(data.ToString());
            Debug.Log(data.ToString());
            spawn_emoji = true;
            //Do Something
        });

        socket.On("rejected_invite", (data) =>
        {
            root_login_from_device err = new root_login_from_device();
            err = JsonUtility.FromJson <root_login_from_device>(data.ToString());
            Debug.Log(data.ToString());
            errorMsg            = err.error.getMessage();
            invite_finding_game = false;
            problem             = true;
            //Do Something
        });
        socket.On("invite_timeout", (data) =>
        {
            root_login_from_device err = new root_login_from_device();
            err = JsonUtility.FromJson <root_login_from_device>(data.ToString());
            Debug.Log(data.ToString());
            errorMsg            = err.error.getMessage();
            invite_finding_game = false;
            problem             = true;
            //Do Something
        });
        socket.On("invite_timer", (data) =>
        {
            Debug.Log(data.ToString());
            _root_invite_timer  = JsonUtility.FromJson <root_invite_timer>(data.ToString());
            friend_match        = true;
            invite_finding_game = true;

            //Do Something
        });
        socket.On("friend_in_game", (data) =>
        {
            root_login_from_device err = new root_login_from_device();
            err = JsonUtility.FromJson <root_login_from_device>(data.ToString());
            Debug.Log(data.ToString());
            errorMsg            = err.error.getMessage();
            invite_finding_game = false;
            problem             = true;
            cantInvite          = true;
            //Do Something
        });
        socket.On("friend_offline", (data) =>
        {
            root_login_from_device err = new root_login_from_device();
            err = JsonUtility.FromJson <root_login_from_device>(data.ToString());
            Debug.Log(data.ToString());
            errorMsg            = err.error.getMessage();
            invite_finding_game = false;
            problem             = true;
            cantInvite          = true;
            //Do Something
        });

        socket.On("queue_full", (data) =>
        {
            root_login_from_device err = new root_login_from_device();
            err = JsonUtility.FromJson <root_login_from_device>(data.ToString());
            Debug.Log(data.ToString());
            errorMsg = err.error.getMessage();
            fail     = true;
            //Do Something
        });

        socket.On("logged_in_another_device", (data) =>
        {
            root_login_from_device err = new root_login_from_device();
            err = JsonUtility.FromJson <root_login_from_device>(data.ToString());
            Debug.Log(data.ToString());
            errorMsg = err.error.getMessage();
            fail     = true;
            //Do Something
        });

        socket.On("pong", (data) =>
        {
            Debug.Log(data.ToString());
            wait_result = true;
            //Do Something
        });
        socket.On("cancelled_match_making", (data) =>
        {
            Debug.Log(data.ToString());
            _root_new_balance = JsonUtility.FromJson <root_new_balance>(data.ToString());
            cancelled_game    = true;
            //Do Something
        });

        socket.On("find_game_status", (data) =>
        {
            Debug.Log(data.ToString());
            _root_new_balance = JsonUtility.FromJson <root_new_balance>(data.ToString());
            //wait_result = true;
            finding_game = true;
            //Do Something
        });

        socket.On("found_game", (data) =>
        {
            Debug.Log(data.ToString());
            _root_match_data       = JsonUtility.FromJson <root_match_data>(data.ToString());
            _timer_data.match_id   = _root_match_data.data.match_id;
            _striker_data.match_id = _root_match_data.data.match_id;
            _keeper_data.match_id  = _root_match_data.data.match_id;
            found_game             = true;
            invite_finding_game    = false;
            //Do Something
        });


        socket.On("timer", (data) =>
        {
            // Debug.Log(data.ToString());
            _root_timer_data = JsonUtility.FromJson <root_timer_data>(data.ToString());
            timer_wait       = true;
            //Do Something
        });

        socket.On("to_keeper_selection", (data) =>
        {
            striker_done = true;
            //Debug.Log(data.ToString());
            //Do Something
        });

        socket.On("to_vs_screen", (data) =>
        {
            //Debug.Log(data.ToString());
            _root_opponent_data = JsonUtility.FromJson <root_opponent_data>(data.ToString());
            keeper_done         = true;
            //Do Something
        });

        socket.On("round_timer", (data) =>
        {
            //  Debug.Log(data.ToString());
            _root_timer_data = JsonUtility.FromJson <root_timer_data>(data.ToString());
            start_round      = true;
            //Do Something
        });
        socket.On("next_round", (data) =>
        {
            Debug.Log(data.ToString());
            _root_round_data = JsonUtility.FromJson <root_round_data>(data.ToString());
            next_round       = true;
            //Do Something
        });
        socket.On("game_over", (data) =>
        {
            friend_match = false;
            next_round   = true;
            game_over    = true;
            Debug.Log(data.ToString());
            _root_round_data = JsonUtility.FromJson <root_round_data>(data.ToString());
            //Do Something
        });
    }