Exemple #1
0
        //实例化一个hexGrid-
        public void AchieveHexGrid(HexGridItem HexGrid)
        {
            this.modelInfo = HexGrid.modelInfo;
            foreach (KeyValuePair <HexCoordinates, HexCellItem> keyValuePair in HexGrid.cellMap)
            {
                HexCellItem hexCellItem = keyValuePair.Value;
                int         x           = hexCellItem.X;
                int         z           = hexCellItem.Z;
                Vector3     position    = new Vector3();
                //格子中心坐标
                position = HexMetrics.erectPosition(position, x, z, this.modelInfo.arrayMode);
                //创建一个格子实例
                HexCellView cell = Instantiate <HexCellView>(cellPrefab);
                cell.transform.SetParent(transform, false);
                cell.transform.localPosition = position;
                cell.hexCellItem             = hexCellItem;
                TextMeshProUGUI HexCellLabel = UtilityHelper.FindChild <TextMeshProUGUI>(cell.transform, "HexCellLabel");
                HexCellLabel.text = hexCellItem.coordinates.ToStringOnSeparateLines();
                cellViewMap.Add(keyValuePair.Key, cell);

                //Text label = Instantiate<Text>(cellLabelPrefab);
                //label.rectTransform.SetParent(gridCanvas.transform, false);
                //label.rectTransform.anchoredPosition =
                //    new Vector2(position.x, position.y);
                //label.text = hexCellItem.coordinates.ToStringOnSeparateLines();
            }
            //渲染需要放在格子生成完毕后
            hexMesh.Triangulate(cellViewMap, this.modelInfo.arrayMode);
        }
Exemple #2
0
 //更新地图内容
 public void UpdateHexGrid(HexGridItem HexGrid)
 {
     foreach (KeyValuePair <HexCoordinates, HexCellItem> keyValuePair in HexGrid.cellMap)
     {
         cellViewMap[keyValuePair.Key].LoadHexCellItem(keyValuePair.Value, this);
     }
     hexMesh.Triangulate(cellViewMap, this.modelInfo.arrayMode);
 }
Exemple #3
0
        //添加一个生物实例展示
        public void AchieveOneMinion(CardEntry minionCellItem, HexGridItem hexGridItem, MinionGridMediator minionGridMediator)
        {
            Vector3        position           = new Vector3();
            HexCoordinates showHexCoordinates = HexCoordinates.ReverseFromOffsetCoordinates(minionCellItem.nowIndex.X, minionCellItem.nowIndex.Z, hexGridItem.modelInfo.arrayMode);

            position   = MinionMetrics.erectPosition(position, showHexCoordinates.X, showHexCoordinates.Z, hexGridItem.modelInfo.arrayMode);
            position.y = 1f;
            //创建一个生物实例
            MinionCellView cell = minionCellPool.Pop();

            cell.transform.SetParent(transform, false);
            cell.transform.localPosition = position;
            cell.minionCellItem          = minionCellItem;
            cell.playerCode = minionGridMediator.playerCode;
            TextMeshProUGUI atkAndDef = UtilityHelper.FindChild <TextMeshProUGUI>(cell.transform, "MinionCellLabel");

            atkAndDef.text = minionCellItem.atk.ToString() + "-" + minionCellItem.def.ToString();
            //添加绑定信息
            cell.OnPointerEnter = () =>
            {
                minionGridMediator.SendNotification(
                    UIViewSystemEvent.UI_VIEW_CURRENT,
                    cell,
                    StringUtil.GetNTByNotificationTypeAndUIViewNameAndOtherTypeAndDelayedProcess(
                        UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW,
                        UIViewConfig.getNameStrByUIViewName(UIViewName.OneCardAllInfo),
                        "MinionCellView",
                        "N"
                        )
                    );
            };
            cell.OnPointerExit = () =>
            {
                minionGridMediator.SendNotification(
                    UIViewSystemEvent.UI_VIEW_CURRENT,
                    UIViewConfig.getNameStrByUIViewName(UIViewName.OneCardAllInfo),
                    StringUtil.GetNTByNotificationTypeAndDelayedProcess(
                        UIViewSystemEvent.UI_VIEW_CURRENT_CLOSE_ONE_VIEW,
                        "N"
                        )
                    );
            };
            cell.OnPointerDown = (CardEntry downMinionCellItem) =>
            {
                minionGridMediator.SendNotification(
                    OperateSystemEvent.OPERATE_SYS,
                    downMinionCellItem,
                    OperateSystemEvent.OPERATE_SYS_POINTER_DOWN_ONE_MINION
                    );
            };
            cell.OnPointerUp = (CardEntry upMinionCellItem) =>
            {
            };
            minionCellViews.Add(minionCellItem.nowIndex, cell);
            MinionCellMaterialChange(cell, minionCellItem);
            UtilityLog.Log("生成一个生物:" + minionCellItem.cardInfo.name, LogUtType.Operate);
        }
Exemple #4
0
 //初始化
 public void AchieveMinionGrid(MinionGridItem minionGridItem, HexGridItem hexGridItem, MinionGridMediator minionGridMediator)
 {
     Dictionary <HexCoordinates, CardEntry> .KeyCollection keyCol = minionGridItem.minionCells.Keys;
     foreach (HexCoordinates key in keyCol)
     {
         CardEntry minionCellItem = minionGridItem.minionCells[key];
         AchieveOneMinion(minionCellItem, hexGridItem, minionGridMediator);
     }
     //渲染需要放在格子生成完毕后
     //minionMesh.Triangulate(minionCellViews, hexGridItem.modelInfo.arrayMode);
 }
Exemple #5
0
        public override void HandleNotification(INotification notification)
        {
            //处理公共请求
            HandleNotificationCommon(notification);
            switch (notification.Name)
            {
            case HexSystemEvent.HEX_VIEW_SYS:
                switch (notification.Type)
                {
                case HexSystemEvent.HEX_VIEW_SYS_SHOW:
                    HexGridItem hexGrid = notification.Body as HexGridItem;
                    //初始化地图区域
                    hexGridView.AchieveHexGrid(hexGrid);
                    //给每一个单元格绑定上单击事件
                    foreach (KeyValuePair <HexCoordinates, HexCellView> keyValuePair in hexGridView.cellViewMap)
                    {
                        keyValuePair.Value.OnClick += () =>
                        {
                            SendNotification(OrderSystemEvent.ONCLICK, keyValuePair.Value.hexCellItem, "CLICK");
                        };
                    }
                    break;

                case HexSystemEvent.HEX_VIEW_RENDER_CAN_CALL_OVER:
                    HexGridItem hexGridItem = notification.Body as HexGridItem;
                    hexGridView.UpdateHexGrid(hexGridItem);
                    break;

                case HexSystemEvent.HEX_VIEW_RENDER_CAN_CALL_CANCEL_OVER:
                    HexGridItem hexGridItemCancel = notification.Body as HexGridItem;
                    hexGridView.UpdateHexGrid(hexGridItemCancel);
                    break;
                }
                break;
            }
        }