Example #1
0
    static void OnLoginRes(object data)
    {
        CSLoginRes rsp = NetworkManager.Deserialize <CSLoginRes>(data);

        Debug.Log("OnLoginRes,retcode=" + rsp.RetCode);
        if (rsp.RetCode == 0)
        {
            DataCenter.playerID      = rsp.PlayerData.PlayerID;
            DataCenter.name          = rsp.PlayerData.Name;
            DataCenter.spawnPosition = rsp.PlayerData.Position.ToVector3();
            DataCenter.spawnRotation = rsp.PlayerData.Rotation.ToVector3();
            ItemSelectPanel.Init(rsp.PlayerData.SelectIndex, rsp.PlayerData.SelectItems);
            DataCenter.state        = ClientState.InRoom;
            ChunkManager.blockAttrs = rsp.BlockAttrs;
            LoginPanel.Close();
            MainMenu.Close();
            LoadingUI.Show();
            SceneManager.LoadScene("GameScene");
            ChatPanel.AddLine(DataCenter.name + ", welcome!");
        }
        else
        {
            FastTips.Show(rsp.RetCode);
        }
    }
Example #2
0
    void OnClickSendButton()
    {
        if (inputField.text != "")
        {
            lastSendText = inputField.text;

            if (inputField.text.StartsWith("/"))
            {
                string text = inputField.text;

                inputField.text = "";
                inputField.ActivateInputField();
                HideInput();

                GM.Process(text);
            }
            else
            {
                inputField.text = "";
                inputField.ActivateInputField();
                HideInput();
                AddLine("<Steve> " + inputField.text);
            }
        }
        else
        {
            FastTips.Show(1);
        }
    }
Example #3
0
    static void ChunksEnterLeaveViewRes(object data)
    {
        CSChunksEnterLeaveViewRes rsp = NetworkManager.Deserialize <CSChunksEnterLeaveViewRes>(data);

        //Debug.Log("CSChunksEnterLeaveViewRes," + rsp.EnterViewChunks.Count + "," + rsp.LeaveViewChunks.Count);
        if (rsp.RetCode == 0)
        {
            foreach (CSVector2Int csv in rsp.LeaveViewChunks)
            {
                UnloadChunk(csv.x, csv.y);
            }
            foreach (CSChunk cschunk in rsp.EnterViewChunks)
            {
                LoadChunk(cschunk);
            }
            if (!PlayerController.isInitialized)
            {
                PlayerController.Init();
                LocalNavMeshBuilder.Init();
                ChunkRefresher.ForceRefreshAll();
            }
            ChunkChecker.FinishRefresh();
        }
        else
        {
            FastTips.Show(rsp.RetCode);
        }
    }
Example #4
0
 void PositionCorrection()
 {
     if (transform.localPosition.y < -100)
     {
         Vector3 pos = transform.localPosition;
         transform.localPosition = new Vector3(pos.x, 100, pos.z);
         FastTips.Show("Position has been corrected!");
     }
 }
Example #5
0
 void OnClickRetry()
 {
     if (NetworkManager.Connect())
     {
         Destroy(gameObject);
         SceneManager.LoadScene("StartScene");
     }
     else
     {
         FastTips.Show("connection failed");
     }
 }
Example #6
0
    void AddBlockRes(object data)
    {
        CSAddBlockRes rsp = NetworkManager.Deserialize <CSAddBlockRes>(data);

        //Debug.Log("AddBlockRes,retCode=" + rsp.RetCode);
        if (rsp.RetCode == 0)
        {
            ChunkManager.AddBlock(rsp.block);
            SoundManager.PlayPlaceSound(rsp.block.type, gameObject);
        }
        else
        {
            FastTips.Show(rsp.RetCode);
        }
    }
Example #7
0
    void OnRegisterAccountRes(object data)
    {
        CSRegisterRes rsp = NetworkManager.Deserialize <CSRegisterRes>(data);

        Debug.Log("CSRegisterRes," + rsp.RetCode);
        if (rsp.RetCode == 0)
        {
            FastTips.Show("注册成功");
            Close();
        }
        else
        {
            FastTips.Show(rsp.RetCode);
        }
    }
Example #8
0
    void OnSendMessageRes(object data)
    {
        CSSendMessageRes rsp = NetworkManager.Deserialize <CSSendMessageRes>(data);

        //Debug.Log("OnSendMessageRes,retCode=" + res.RetCode);
        if (rsp.RetCode == 0)
        {
            inputField.text = "";
            inputField.ActivateInputField();
            HideInput();
        }
        else
        {
            FastTips.Show(rsp.RetCode);
        }
    }
Example #9
0
    void DeleteBlockRes(object data)
    {
        CSDeleteBlockRes rsp = NetworkManager.Deserialize <CSDeleteBlockRes>(data);

        //Debug.Log("DeleteBlockRes,retCode=" + rsp.RetCode);
        if (rsp.RetCode == 0)
        {
            Vector3Int  pos  = new Vector3Int(rsp.position.x, rsp.position.y, rsp.position.z);
            CSBlockType type = ChunkManager.GetBlockType(rsp.position.x, rsp.position.y, rsp.position.z);
            ChunkManager.RemoveBlock(rsp.position.x, rsp.position.y, rsp.position.z);
        }
        else
        {
            FastTips.Show(rsp.RetCode);
        }
    }
Example #10
0
    void OnClickOk()
    {
        if (passwordInput.text != passwordRepeatInput.text)
        {
            FastTips.Show("密码不一致");
            return;
        }
        CSRegisterReq req = new CSRegisterReq
        {
            Account  = accountInput.text,
            Name     = nameInput.text,
            Password = passwordInput.text
        };

        NetworkManager.SendPkgToServer(ENUM_CMD.CS_REGISTER_REQ, req, OnRegisterAccountRes);
    }
Example #11
0
    void OnClickOk()
    {
        if (accountInput.text == "")
        {
            FastTips.Show("用户名不能为空!");
            return;
        }
        if (passwordInput.text == "")
        {
            FastTips.Show("密码不能为空!");
            return;
        }

        LoginSystem.LoginReq(accountInput.text, passwordInput.text);
        PlayerPrefs.SetString(AccountKey, accountInput.text);
    }
Example #12
0
 void PositionCorrection()
 {
     if (cc.isGrounded)
     {
         float fallDistance = lastPosOnGround.y - transform.position.y;
         if (fallDistance > 4)
         {
             int fallDamage = (int)fallDistance - 3;
             OnHit(fallDamage);
         }
         lastPosOnGround = transform.position;
     }
     if (transform.position.y < -10)
     {
         transform.position = lastPosOnGround;
         FastTips.Show("Position has been corrected!");
     }
 }
Example #13
0
    void DeleteBlockRes(object data)
    {
        CSDeleteBlockRes rsp = NetworkManager.Deserialize <CSDeleteBlockRes>(data);

        //Debug.Log("DeleteBlockRes,retCode=" + rsp.RetCode);
        if (rsp.RetCode == 0)
        {
            foreach (CSVector3Int pos in rsp.position)
            {
                ChunkManager.RemoveBlock(pos.ToVector3Int());
            }
            ChunkManager.RebuildChunks();
        }
        else
        {
            FastTips.Show(rsp.RetCode);
        }
    }
Example #14
0
    void OnClickSendButton()
    {
        if (inputField.text != "")
        {
            if (inputField.text == "@test")
            {
                // process gm
                GM.Test();

                inputField.text = "";
                inputField.ActivateInputField();
                HideInput();
            }
            else
            {
                SendMessageReq(inputField.text);
            }
        }
        else
        {
            FastTips.Show(1);
        }
    }
Example #15
0
 void OnClickClear()
 {
     LocalServer.ClearData();
     FastTips.Show("Clear Map Data & Player Data Done!");
 }