Beispiel #1
0
        //改变材质
        public void MinionCellMaterialChange(MinionCellView minionCellView, CardEntry minionCellItem)
        {
            Component minionCellFrameBg = UtilityHelper.FindChild <Component>(minionCellView.transform, "MinionCellFrameBg");
            Image     imageComponent    = minionCellFrameBg.GetComponent <Image>();

            if (minionCellItem.IsEffectTarget == false)
            {
                if (minionCellView.playerCode == minionCellItem.controllerPlayerItem.playerCode)
                {
                    imageComponent.material = originalMyselfMaterial;
                }
                else
                {
                    imageComponent.material = originalEnemyMaterial;
                }
            }
            else
            {
                if (minionCellView.playerCode == minionCellItem.controllerPlayerItem.playerCode)
                {
                    imageComponent.material = effectTargetMyselfMaterial;
                }
                else
                {
                    imageComponent.material = effectTargetEnemyMaterial;
                }
            }
        }
Beispiel #2
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);
        }
Beispiel #3
0
        //确定顶点
        void Triangulate(MinionCellView cell, string arrayMode)
        {
            Vector3 center = cell.transform.localPosition;

            Vector3[] arrayCorners = MinionMetrics.getCornersByArrayMode(arrayMode);
            for (int i = 0; i < 6; i++)
            {
                AddTriangle(
                    center,
                    center + arrayCorners[i],
                    center + arrayCorners[i + 1]
                    );
                AddTriangleColor(Color.green);
            }
        }
Beispiel #4
0
        //暂时先用一段移动的动画代替攻击动画
        //移动某个子节点到某个位置
        public IEnumerator MoveMinionCellShowAttack(MinionCellView minCellView, UnityAction callBack, Vector3 startPosition, Vector3 endPosition)
        {
            bool    isNear   = false;
            Vector3 position = new Vector3();

            position.y = 0;
            int xdirection = endPosition.x - startPosition.x == 0 ? 0 : endPosition.x - startPosition.x > 0 ? 1 : -1;
            int zdirection = endPosition.z - startPosition.z == 0 ? 0 : endPosition.z - startPosition.z > 0 ? 1 : -1;

            position.x = 8 * xdirection;
            position.y = 8 * zdirection;
            //先到达目的点
            while (!isNear)
            {
                minCellView.transform.Translate(position * Time.deltaTime);
                if (Math.Abs(minCellView.transform.position.x - endPosition.x) < 0.5)
                {
                    if (Math.Abs(minCellView.transform.position.z - endPosition.z) < 0.5)
                    {
                        isNear = true;
                    }
                }
                yield return(null);
            }
            //在返回出发点
            isNear     = false;
            position.x = -8 * xdirection;
            position.y = -8 * zdirection;
            while (!isNear)
            {
                minCellView.transform.Translate(position * Time.deltaTime);
                if (Math.Abs(minCellView.transform.position.x - startPosition.x) < 0.5)
                {
                    if (Math.Abs(minCellView.transform.position.z - startPosition.z) < 0.5)
                    {
                        isNear = true;
                    }
                }
                yield return(null);
            }
            //直接设置为目标点,避免有偏差
            Vector3 OverPosition = new Vector3(startPosition.x, minCellView.transform.position.y, startPosition.z);

            minCellView.transform.position = OverPosition;
            callBack();
        }
Beispiel #5
0
        //生物像指定方向发起一次攻击
        public void MinionAttackTargetIndex(CardEntry minionCellItem, HexModelInfo hexModelInfo, UnityAction callBack)
        {
            MinionCellView minCellView        = minionCellViews[minionCellItem.nowIndex];
            Vector3        startPosition      = minCellView.transform.position;
            Vector3        endPosition        = new Vector3();
            HexCoordinates showHexCoordinates = HexCoordinates.ReverseFromOffsetCoordinates(minionCellItem.attackTargetIndex.X, minionCellItem.attackTargetIndex.Z, hexModelInfo.arrayMode);

            endPosition = HexMetrics.erectPosition(
                endPosition,
                showHexCoordinates.X,
                showHexCoordinates.Z, hexModelInfo.arrayMode);

            endPosition = new Vector3(
                startPosition.x + (endPosition.x - startPosition.x) / 4,
                startPosition.y + (endPosition.y - startPosition.y) / 4,
                startPosition.z + (endPosition.z - startPosition.z) / 4
                );
            StartCoroutine(MoveMinionCellShowAttack(minCellView, callBack, startPosition, endPosition));
        }
Beispiel #6
0
        //移动动画
        public IEnumerator MoveMinionCellShowMove(CardEntry minionCellItemNew, MinionCellView minCellView, UnityAction callBack, HexModelInfo hexModelInfo)
        {
            for (int n = 0; n < minionCellItemNew.cellRoute.Count; n++)
            {
                Vector3        startPosition      = minCellView.transform.position;
                HexCoordinates hexCoordinates     = minionCellItemNew.cellRoute[n].coordinates;
                Vector3        endPosition        = new Vector3();
                HexCoordinates showHexCoordinates = HexCoordinates.ReverseFromOffsetCoordinates(hexCoordinates.X, hexCoordinates.Z, hexModelInfo.arrayMode);
                endPosition = HexMetrics.erectPosition(
                    endPosition,
                    showHexCoordinates.X,
                    showHexCoordinates.Z, hexModelInfo.arrayMode);

                bool    isNear   = false;
                Vector3 position = new Vector3();
                position.y = 0;
                int xdirection = endPosition.x - startPosition.x == 0 ? 0 : endPosition.x - startPosition.x > 0 ? 1 : -1;
                int zdirection = endPosition.z - startPosition.z == 0 ? 0 : endPosition.z - startPosition.z > 0 ? 1 : -1;
                position.x = Math.Abs(endPosition.x - startPosition.x) * xdirection;
                position.y = Math.Abs(endPosition.z - startPosition.z) * zdirection;
                //到达目的点
                while (!isNear)
                {
                    minCellView.transform.Translate(position * Time.deltaTime);
                    if (Math.Abs(minCellView.transform.position.x - endPosition.x) < 0.5)
                    {
                        if (Math.Abs(minCellView.transform.position.z - endPosition.z) < 0.5)
                        {
                            isNear = true;
                        }
                    }
                    yield return(null);
                }
                //直接设置为目标点,避免有偏差
                Vector3 OverPosition = new Vector3(endPosition.x, minCellView.transform.position.y, endPosition.z);
                minCellView.transform.position = OverPosition;
            }
            callBack();
        }
Beispiel #7
0
        public void RenderOneMinionCellByMinionCellItem(MinionCellView minionCellView, CardEntry minionCellItem)
        {
            minionCellView.minionCellItem = minionCellItem;
            TextMeshProUGUI atkAndDef = UtilityHelper.FindChild <TextMeshProUGUI>(minionCellView.transform, "MinionCellLabel");

            string atkStr = minionCellItem.cardEntryVariableAttributeMap.CheckCurrentValueIsBetterByCode("Atk");

            if (atkStr == "Good")
            {
                atkStr = "<color=\"green\">" + minionCellItem.cardEntryVariableAttributeMap.GetValueByCodeAndType("Atk", VATtrtype.CalculatedValue);
            }
            else if (atkStr == "Bad")
            {
                atkStr = "<color=\"red\">" + minionCellItem.cardEntryVariableAttributeMap.GetValueByCodeAndType("Atk", VATtrtype.CalculatedValue);
            }
            else if (atkStr == "NoChange")
            {
                atkStr = "<color=\"black\">" + minionCellItem.cardEntryVariableAttributeMap.GetValueByCodeAndType("Atk", VATtrtype.CalculatedValue);
            }
            string defStr = minionCellItem.cardEntryVariableAttributeMap.CheckCurrentValueIsBetterByCode("Def");

            if (defStr == "Good")
            {
                defStr = "<color=\"green\">" + minionCellItem.cardEntryVariableAttributeMap.GetValueByCodeAndType("Def", VATtrtype.CalculatedValue);
            }
            else if (defStr == "Bad")
            {
                defStr = "<color=\"red\">" + minionCellItem.cardEntryVariableAttributeMap.GetValueByCodeAndType("Def", VATtrtype.CalculatedValue);
            }
            else if (defStr == "NoChange")
            {
                defStr = "<color=\"black\">" + minionCellItem.cardEntryVariableAttributeMap.GetValueByCodeAndType("Def", VATtrtype.CalculatedValue);
            }
            atkAndDef.text = atkStr + "<color=\"black\">-" + defStr;
            minionCellView.OnPointerClick = (CardEntry minionCellItemToClick) => { };
            MinionCellMaterialChange(minionCellView, minionCellItem);
        }
Beispiel #8
0
 public void RenderOneMinionCellByMinionCellItemToChooseTarget(MinionCellView minionCellView, CardEntry minionCellItem, SendNotificationConfirmTargetMinion sendNotificationConfirmTargetMinion)
 {
     minionCellView.minionCellItem = minionCellItem;
     minionCellView.OnPointerClick = sendNotificationConfirmTargetMinion;
     MinionCellMaterialChange(minionCellView, minionCellItem);
 }