Пример #1
0
        public void OnItemPicked()
        {
            GridUnitRefreshItemsEvent e = GridUnitEvent.CreateEvent <GridUnitRefreshItemsEvent>(GridUnitEventType.RefreshItems, this);

            e.itemID    = gridItem.item.itemID;
            e.itemCount = 0;
            battleMap.battleField.AppendBattleAction(e);

            gridItem = null;
        }
Пример #2
0
        //运行英雄动作
        public IEnumerator RunGridEvent(GridUnitEvent gridUnitEvent)
        {
            if (gridUnitEvent == null)
            {
                yield break;
            }

            switch (gridUnitEvent.gridUnitEventType)
            {
            case GridUnitEventType.RefreshItems:
                RunRefreshItemEvent(gridUnitEvent as GridUnitRefreshItemsEvent);
                break;

            default:
                break;
            }

            yield return(null);
        }
Пример #3
0
        //播放战场动作
        private IEnumerator PlayBattleByCoroutine(System.Action callback)
        {
            if (battleField == null ||
                battleField.battleFieldEvents == null ||
                battleField.battleFieldEvents.Count == 0)
            {
                UtilityHelper.LogError(string.Format("Play battle action failed. -> {0}", battleField.ID));
                yield break;
            }

            //遍历所有战斗动作
            while (currentActionIndex < battleField.battleFieldEvents.Count)
            {
                //一个英雄行动事件
                if (battleField.battleFieldEvents[currentActionIndex] is BattleUnitActionEvent)
                {
                    BattleUnitActionEvent actionEvent = (BattleUnitActionEvent)battleField.battleFieldEvents[currentActionIndex];

                    //有对应的战斗单位,且这个战斗单位已经连接了战斗单位渲染器
                    if (actionEvent.actionUnit != null && actionEvent.actionUnit.battleUnitRenderer != null)
                    {
                        yield return(actionEvent.actionUnit.battleUnitRenderer.RunHeroAction(actionEvent));
                    }
                }
                //一个格子事件
                else if (battleField.battleFieldEvents[currentActionIndex] is GridUnitEvent)
                {
                    GridUnitEvent gridUnitEvent = (GridUnitEvent)battleField.battleFieldEvents[currentActionIndex];
                    if (gridUnitEvent.grid != null && gridUnitEvent.grid.gridUnitRenderer != null)
                    {
                        yield return(gridUnitEvent.grid.gridUnitRenderer.RunGridEvent(gridUnitEvent));
                    }
                }
                ++currentActionIndex;
            }

            if (callback != null)
            {
                callback();
            }
        }