示例#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);
        }
    }
示例#2
0
    void OnClickSelectItem(int index)
    {
        //Debug.Log("OnClickSelectItem,index=" + index);
        if (holdItem)
        {
            holdItem = false;
            holdItemImage.gameObject.SetActive(false);

            ItemSelectPanel.SetSlotItem((uint)index, blocks[showIndex]);
            RefreshSelectPanel();
        }
        else if (holdSelectItem)
        {
            holdSelectItem = false;
            holdItemImage.gameObject.SetActive(false);

            ItemSelectPanel.SetSlotItem((uint)index, holdItemType, holdItemCount);
            RefreshSelectPanel();
        }
        else if (ItemSelectPanel.dataList[index] != CSBlockType.None)
        {
            holdSelectItem       = true;
            holdItemType         = ItemSelectPanel.dataList[index];
            holdItemCount        = ItemSelectPanel.countList[index];
            holdItemImage.sprite = selectItems[showSelectIndex].icon.sprite;
            holdItemImage.gameObject.SetActive(true);

            ItemSelectPanel.SetSlotItem((uint)index, CSBlockType.None);
            RefreshSelectPanel();
        }
    }
示例#3
0
    public void CreateItemSelectPanel(InteractionPanel interactionPanel, Action targetAction)
    {
        GameObject obj = Instantiate(itemSelectPanelPrefab, transform);

        obj.transform.SetParent(transform);
        obj.transform.position = Input.mousePosition;
        ItemSelectPanel itemSelectPanel = obj.GetComponent <ItemSelectPanel>();

        // Set this panel to close on the close button click
        itemSelectPanel.closeButton.onClick.AddListener(() => { Destroy(obj); });
        // Set parent panel to close select panel on close
        interactionPanel.closeButton.onClick.AddListener(() => { Destroy(obj); });

        // Add the item icons
        List <WorldItem> availableItems = new List <WorldItem> {
            new WorldItem(ItemDatabase.items.resources.Gold, 1), new WorldItem(ItemDatabase.items.resources.Wood, 1), new WorldItem(ItemDatabase.items.resources.Stone, 1)
        };

        foreach (WorldItem item in availableItems)
        {
            Button itemIcon = Instantiate(itemSelectPanel.itemIconButton, transform);
            itemIcon.transform.SetParent(itemSelectPanel.itemIconGridLayout.transform);
            itemIcon.image.sprite = item.itemDefinition.icon;
            // Add function to the icon, adds the world item to the action's effects
            itemIcon.onClick.AddListener(() => { targetAction.AddEffect(item); });
        }
    }
示例#4
0
 void Update()
 {
     if (Physics.Raycast(transform.position + offset, Vector3.down, out RaycastHit hit))
     {
         shadowTrans.position = hit.point + offset;
         shadowColor.a        = maxAlpha * ((maxDistance - Mathf.Min(hit.distance, maxDistance)) / maxDistance);
         shadow.color         = shadowColor;
     }
     if (move2player)
     {
         time += Time.deltaTime;
         transform.position = Vector3.Lerp(startPosition, PlayerController.instance.position + collectOffset, time / moveTime);
         float distance = Vector3.Distance(transform.position, PlayerController.instance.position + collectOffset);
         if (distance < minDistance)
         {
             Destroy(gameObject);
             SoundManager.PlayPopSound();
             ItemSelectPanel.AddItem(type, Count);
         }
     }
     if (transform.position.y < 0)
     {
         Destroy(gameObject);
     }
 }
示例#5
0
    void Start()
    {
        ChunkChecker.Init();
        ChunkRefresher.Init();
        ChunkManager.Init();
        ChunkPool.Init();
        OtherPlayerManager.Init();
        ItemSelectPanel.Show();
        ChatPanel.ShowChatPanel();

        List <Vector2Int> preloadChunks = Utilities.GetSurroudingChunks(PlayerController.GetCurrentChunk());

        ChunkManager.ChunksEnterLeaveViewReq(preloadChunks);
    }
示例#6
0
    void Start()
    {
        SettingsPanel.Init();
        ChunkRefresher.Init();
        ChunkPool.Init();
        ItemSelectPanel.Show();
        ChatPanel.ShowChatPanel();
        InventorySystem.Init();
        GameModeManager.Init();

        // load chunk here
        ChunkChecker.Init();

        PlayerController.Init();
        LocalNavMeshBuilder.Init();
        ChunkRefresher.ForceRefreshAll();
    }
示例#7
0
 public static void Show()
 {
     instance = UISystem.InstantiateUI("ItemSelectPanel").GetComponent <ItemSelectPanel>();
 }
示例#8
0
    void Update()
    {
        DrawWireFrame();

        if (acceptInput)
        {
            RotateView();

            if (Input.GetMouseButtonDown(0))
            {
                handAnimator.SetTrigger("interactTrigger");
                if (WireFrameHelper.render)
                {
                    if (WireFrameHelper.pos.y != 0)
                    {
                        DeleteBlockReq(WireFrameHelper.pos);
                    }
                }
            }

            if (Input.GetMouseButtonDown(1))
            {
                if (WireFrameHelper.render && ItemSelectPanel.curBlockType != CSBlockType.None)
                {
                    Vector3Int pos = WireFrameHelper.pos;
                    if (ChunkManager.HasCollidableBlock(WireFrameHelper.pos.x, WireFrameHelper.pos.y, WireFrameHelper.pos.z))
                    {
                        pos = WireFrameHelper.pos + Vector3Int.RoundToInt(hit.normal);
                    }

                    if (!cc.bounds.Intersects(new Bounds(pos, Vector3.one)) && !ChunkManager.HasNotPlantBlock(pos))
                    {
                        if (ItemSelectPanel.curBlockType == CSBlockType.Torch)
                        {
                            AddBlockReq(Vector3Int.RoundToInt(pos), ItemSelectPanel.curBlockType, WireFrameHelper.pos);
                        }
                        else
                        {
                            CSBlockOrientation orientation = ChunkMeshGenerator.GetBlockOrientation(transform.position, pos, WireFrameHelper.hitPos);
                            AddBlockReq(Vector3Int.RoundToInt(pos), ItemSelectPanel.curBlockType, orientation);
                        }
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Jump();
            }
            if (Input.GetKeyDown(KeyCode.Q))
            {
                ItemSelectPanel.DropCurItem();
            }
        }

        if (needUpdate && Time.realtimeSinceStartup - lastUpdateTime > timeInterval)
        {
            needUpdate     = false;
            lastUpdateTime = Time.realtimeSinceStartup;
            CSHeroMoveReq req = new CSHeroMoveReq
            {
                Position = new CSVector3 {
                    x = transform.position.x, y = transform.position.y, z = transform.position.z
                },
                Rotation = new CSVector3 {
                    x = 0, y = transform.localEulerAngles.y, z = camera.transform.localEulerAngles.x
                }
            };
            NetworkManager.SendPkgToServer(ENUM_CMD.CS_HERO_MOVE_REQ, req);
        }
    }