Esempio n. 1
0
        //点击了地块、战斗单位
        public void OnBattleUnitAndGridTouched(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //对应当前地图的操作状态
            switch (manualOperationState)
            {
            case ManualOperationState.Waiting:
                //当前为等待中
                UtilityHelper.Log("当前为等待中...");
                break;

            case ManualOperationState.Select:
                //当前为允许操作待选择
                OnBattleUnitAndGridTouched_StateSelect(gridTouched, battleUnitTouched);
                break;

            case ManualOperationState.Move:
                //当前为选择移动目标
                OnBattleUnitAndGridTouched_StateMove(gridTouched, battleUnitTouched);
                break;

            case ManualOperationState.Skill:
                //当前为技能使用判断
                OnBattleUnitAndGridTouched_StateSkill(gridTouched, battleUnitTouched);
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        //查找一定范围内的敌人
        public List <BattleUnit> SearchBattleUnits(GridUnit centerGridUnit, int range)
        {
            List <BattleUnit> battleUnits = new List <BattleUnit>();
            BattleMap         battleMap   = centerGridUnit.battleMap;

            bool[,] flag = new bool[battleMap.mapWidth, battleMap.mapHeight];
            flag[centerGridUnit.column, centerGridUnit.row] = true;
            Queue <GridUnit> checkList   = new Queue <GridUnit>();
            GridUnit         currentUnit = centerGridUnit;

            checkList.Enqueue(currentUnit);
            while (checkList.Count > 0)
            {
                currentUnit = checkList.Dequeue();
                List <GridUnit> gridUnitList = battleMap.GetNearbyGrid(currentUnit);
                foreach (GridUnit gridUnit in gridUnitList)
                {
                    if (range < centerGridUnit.Distance(gridUnit))
                    {
                        continue;
                    }
                    if (!flag[gridUnit.column, gridUnit.row])
                    {
                        flag[gridUnit.column, gridUnit.row] = true;
                        if (gridUnit.battleUnit != null)
                        {
                            battleUnits.Add(gridUnit.battleUnit);
                        }
                        checkList.Enqueue(gridUnit);
                    }
                }
            }
            return(battleUnits);
        }
Esempio n. 3
0
        //获取某格子周围的格子
        public List <GridUnit> GetNearbyGrid(GridUnit gridUnit)
        {
            int             row          = gridUnit.row;
            int             column       = gridUnit.column;
            List <GridUnit> gridUnitList = new List <GridUnit>();
            GridUnit        tempGridUnit = GetGridData(row, column - 1);

            if (tempGridUnit != null)
            {
                gridUnitList.Add(tempGridUnit);
            }
            //tempGridUnit = GetGridData(row + 1, ((row & 1) == (EGameConstL.Map_FirstRowOffset ? 1 : 0)) ? column - 1 : column);
            tempGridUnit = GetGridData(row + 1, column);
            if (tempGridUnit != null)
            {
                gridUnitList.Add(tempGridUnit);
            }
            //tempGridUnit = GetGridData(row + 1, ((row & 1) == (EGameConstL.Map_FirstRowOffset ? 1 : 0)) ? column : column + 1);
            //if (tempGridUnit != null) gridUnitList.Add(tempGridUnit);
            tempGridUnit = GetGridData(row, column + 1);
            if (tempGridUnit != null)
            {
                gridUnitList.Add(tempGridUnit);
            }
            //tempGridUnit = GetGridData(row - 1, ((row & 1) == (EGameConstL.Map_FirstRowOffset ? 1 : 0)) ? column : column + 1);
            tempGridUnit = GetGridData(row - 1, column);
            if (tempGridUnit != null)
            {
                gridUnitList.Add(tempGridUnit);
            }
            //tempGridUnit = GetGridData(row - 1, ((row & 1) == (EGameConstL.Map_FirstRowOffset ? 1 : 0)) ? column - 1 : column);
            //if (tempGridUnit != null) gridUnitList.Add(tempGridUnit);
            return(gridUnitList);
        }
        //刷新格子
        private void RefreshBattleMapGrids()
        {
            if (battleField == null)
            {
                UtilityHelper.LogError("Prepare battle map failed. No battle data.");
                return;
            }

            for (int r = 0; r < battleField.battleMap.mapHeight; ++r)
            {
                for (int c = 0; c < battleField.battleMap.mapWidth; ++c)
                {
                    GridUnit gridUnitData = battleField.battleMap.mapGrids[c, r];
                    if (gridUnitData != null)
                    {
                        //创建一个用于显示的格子对象
                        GridUnitRenderer gridUnitRenderer = GetUnusedGridUnitRenderer();
                        if (gridUnitRenderer != null)
                        {
                            gridUnitData.ConnectRenderer(gridUnitRenderer);
                        }
                    }
                }
            }
        }
        public void RefreshRenderer()
        {
            for (int r = 0; r < battleField.battleMap.mapHeight; ++r)
            {
                for (int c = 0; c < battleField.battleMap.mapWidth; ++c)
                {
                    GridUnit gridUnitData = battleField.battleMap.mapGrids[c, r];
                    if (gridUnitData != null && gridUnitData.gridUnitRenderer != null)
                    {
                        gridUnitData.gridUnitRenderer.RefreshRenderer();
                    }
                }
            }

            for (int i = 0; i < battleField.teams.Count; ++i)
            {
                BattleTeam team = battleField.teams[i];
                if (team.battleUnits != null)
                {
                    foreach (var battleUnitData in team.battleUnits)
                    {
                        if (battleUnitData.battleUnitRenderer != null)
                        {
                            battleUnitData.battleUnitRenderer.RefreshRenderer();
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        private NavigationData GetEmptyNavigationData(GridUnit _thisGrid, NavigationData _preGrid, int _G, int _H)
        {
            //优先从池子里取出
            NavigationData nd = null;

            if (curUsedIdx < navigationDataPool.Count)
            {
                nd = navigationDataPool[curUsedIdx];
            }
            else
            {
                nd = new NavigationData();
                navigationDataPool.Add(nd);
            }

            ++curUsedIdx;

            nd.thisGrid         = _thisGrid;
            nd.preGrid          = _preGrid;
            nd.G                = _G;
            nd.H                = _H;
            nd.F                = _G + _H;
            nd.open             = true;
            nd.thisGrid.tempRef = nd;

            return(nd);
        }
Esempio n. 7
0
        //拾起道具
        public void PickupItemFromGrid(GridUnit fromGrid)
        {
            if (fromGrid == null || fromGrid.gridItem == null || package == null)
            {
                return;
            }

            int  itemID     = fromGrid.gridItem.item.itemID;
            int  itemCount  = fromGrid.gridItem.count;
            int  finalCount = 0;
            bool result     = package.TryAddItem(itemID, itemCount, ref finalCount);

            //成功捡起道具
            if (result)
            {
                //先生成道具格子的事件
                if (fromGrid != null)
                {
                    fromGrid.OnItemPicked();
                }

                BattleUnitPickupItemAction action = BattleUnitActionEvent.CreateEvent <BattleUnitPickupItemAction>(BattleUnitActionType.PickupItem, this);
                action.itemID     = itemID;
                action.addCount   = itemCount;
                action.finalCount = finalCount;
                battleField.AppendBattleAction(action);
            }
        }
Esempio n. 8
0
        //放置一些障碍格子
        private void GenerateObstacle(int obstacleCount, int gap)
        {
            //随机范围
            List <GridUnit> randomRange = new List <GridUnit>();
            //减掉不能随机的格子
            List <GridUnit> reduction = new List <GridUnit>();

            //将普通格子放入
            foreach (var grid in mapGrids)
            {
                if (grid.GridType == GridType.Normal)
                {
                    randomRange.Add(grid);
                }
            }

            int count = obstacleCount;

            while (count > 0 && randomRange.Count > 0)
            {
                int      randIdx    = Random.Range(0, randomRange.Count);
                GridUnit randomGrid = randomRange[randIdx];
                randomGrid.GridType = GridType.Obstacle;
                //排除格子周围的格子
                GetCircularGrids(randomGrid.row, randomGrid.column, gap, 0, true, reduction);
                if (reduction.Count > 0)
                {
                    foreach (var item in reduction)
                    {
                        randomRange.Remove(item);
                    }
                }
                --count;
            }
        }
Esempio n. 9
0
        //点击了技能,在单体目标技能情况下
        private void OnBattleUnitAndGridTouched_StateSkill_SingleBattleUnitTarget(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //没有点中战斗单位
            if (battleUnitTouched == null)
            {
                return;
            }

            //点中了可以被使用技能的单位
            if (usedManualReleaseAnalysisor.suitableUnits.Contains(battleUnitTouched))
            {
                ManualSkill(battleUnitTouched);
            }

            //点中了超出距离的
            else if (usedManualReleaseAnalysisor.distanceLimit.Contains(battleUnitTouched))
            {
                UtilityHelper.Log("目标超出攻击范围");
            }

            //同一个队伍
            else if (usedManualReleaseAnalysisor.teamLimit.Contains(battleUnitTouched))
            {
                UtilityHelper.Log("不能对同一个队伍的单位使用这个技能");
            }

            else
            {
                UtilityHelper.Log("无效的目标单位");
            }
        }
Esempio n. 10
0
 //离开格子
 private void LeaveGrid()
 {
     if (mapGrid != null)
     {
         mapGrid.OnLeave();
         mapGrid = null;
     }
 }
Esempio n. 11
0
        //点击了技能,在单体带环绕的技能情况下
        private void OnBattleUnitAndGridTouched_StateSkill_SurroundBattleUnit(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //没有点中战斗单位
            if (battleUnitTouched == null)
            {
                return;
            }

            //是否是有效单位
            if (usedManualReleaseAnalysisor.suitableUnits.Contains(battleUnitTouched))
            {
                //重复点击同一个有效的战斗单位,则释放技能
                if (battleUnitTouched.battleUnitRenderer.Equals(selectedBattleUnitRenderer))
                {
                    ManualSkill(battleUnitTouched);
                    return;
                }
                else if (selectedBattleUnitRenderer != null)
                {
                    //取消选中
                    selectedBattleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Normal);
                }
                //显示新的范围
                selectedBattleUnitRenderer = battleUnitTouched.battleUnitRenderer;
                //范围内战斗单位设置为选中
                for (int i = 0; i < usedManualReleaseAnalysisor.suitableUnits.Count; ++i)
                {
                    if (usedManualReleaseAnalysisor.suitableUnits[i].mapGrid.Distance(gridTouched) <= usedManualReleaseAnalysisor.battleSkill.effectRadius)
                    {
                        usedManualReleaseAnalysisor.suitableUnits[i].battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Selected);
                    }
                }
                SetCircularRangeRenderStateActive(
                    true,
                    GridRenderType.SkillEffectRange,
                    gridTouched.row,
                    gridTouched.column,
                    usedManualReleaseAnalysisor.battleSkill.effectRadius);
            }
            //不是有效单位
            else if (usedManualReleaseAnalysisor.distanceLimit.Contains(battleUnitTouched))
            {
                UtilityHelper.Log("目标超出攻击范围");
            }

            //队伍不符合
            else if (usedManualReleaseAnalysisor.teamLimit.Contains(battleUnitTouched))
            {
                UtilityHelper.Log("不能对同一个队伍的单位使用这个技能");
            }

            else
            {
                UtilityHelper.Log("目标单位无效");
            }
        }
        public void Test_RemoteRange(GridUnit gridUnit)
        {
            if (releaserGrid == null)
            {
                releaserGrid = gridUnit;
                releaserGrid.gridUnitRenderer.AppendGridRenderType(GridRenderType.Start);

                battleField.battleMap.GetCircularGrids(releaserGrid.row, releaserGrid.column,
                                                       motionRadius, 0, true, releaseRange);

                foreach (var item in releaseRange)
                {
                    item.gridUnitRenderer.AppendGridRenderType(GridRenderType.SkillReleaseRange);
                }
            }
            else if (targetGrid == null)
            {
                UtilityHelper.TimerStart();

                targetGrid = gridUnit;
                targetGrid.gridUnitRenderer.AppendGridRenderType(GridRenderType.End);

                for (int i = 0; i < 1000; ++i)
                {
                    battleField.battleMap.GetCircularGrids(releaserGrid.row, releaserGrid.column,
                                                           motionRadius, 0, true, skillRange, delegate(GridUnit _gridUnit)
                    {
                        return(_gridUnit.Distance(targetGrid) <= effectRadius);
                    });
                }

                foreach (var item in skillRange)
                {
                    item.gridUnitRenderer.AppendGridRenderType(GridRenderType.SkillEffectRange);
                }

                UtilityHelper.Log("Test_RemoteRange cost:" + UtilityHelper.TimerEnd());
            }
            else
            {
                releaserGrid.gridUnitRenderer.ResetGridRenderType();
                targetGrid.gridUnitRenderer.ResetGridRenderType();
                foreach (var item in releaseRange)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
                foreach (var item in skillRange)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
                releaserGrid = null;
                targetGrid   = null;
                releaseRange.Clear();
                skillRange.Clear();
            }
        }
Esempio n. 13
0
 public void UpdatePositionByGrid(GridUnit gridUnit)
 {
     if (battleUnit != null)
     {
         transform.localPosition     = gridUnit.localPosition;
         unitRenderer.sortingOrder   = gridUnit.row * EGameConstL.OrderGapPerRow + EGameConstL.OrderIncrease_BattleUnit;
         frameRenderer.sortingOrder  = gridUnit.row * EGameConstL.OrderGapPerRow + EGameConstL.OrderIncrease_BattleUnit + 1;
         battleUnitInfo.sortingOrder = gridUnit.row * EGameConstL.OrderGapPerRow + EGameConstL.OrderIncrease_BattleUnit + 2;
     }
 }
Esempio n. 14
0
        public float technicModulus = 0.0f;         //技巧补正系数

        public int GetReleaseRadius(GridUnit gridUnit)
        {
            int addition = 0;

            if (gridUnit != null && gridUnit.gridUnitBuff != null && gridUnit.gridUnitBuff.buffType == GridUnitBuffType.Range)
            {
                addition = gridUnit.gridUnitBuff.addition;
            }

            return(releaseRadius + addition);
        }
        //点击了地块、战斗单位
        private void Test_Nav(GridUnit gridTouched)
        {
            if (start == null)
            {
                start = gridTouched;
                start.gridUnitRenderer.AppendGridRenderType(GridRenderType.Start);
            }
            else if (end == null)
            {
                end = gridTouched;
                end.gridUnitRenderer.AppendGridRenderType(GridRenderType.End);

                //Nav

                UtilityHelper.TimerStart();
                for (int i = 0; i < 1000; i++)
                {
                    //SetCircularRangeRenderStateActive(true, GridRenderType.SkillEffectRange, start.row, start.column, 3);
                    MapNavigator.Instance.Navigate(battleField.battleMap,
                                                   start,
                                                   end,
                                                   lastPath, null, -1, 2);
                }

                UtilityHelper.Log("TimeCost:" + UtilityHelper.TimerEnd());
                //foreach (var item in lastSearched)
                //{
                //    item.gridUnitRenderer.AppendGridRenderType(GridRenderType.Searched);
                //}
                foreach (var item in lastPath)
                {
                    item.gridUnitRenderer.AppendGridRenderType(GridRenderType.Path);
                }
            }
            else
            {
                start.gridUnitRenderer.ResetGridRenderType();
                end.gridUnitRenderer.ResetGridRenderType();
                foreach (var item in lastPath)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
                foreach (var item in lastSearched)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
                start = null;
                end   = null;
                SetCircularRangeRenderStateActive(false, GridRenderType.SkillEffectRange);
            }
        }
Esempio n. 16
0
        //向目标格子移动
        public void MoveToTargetGrid(BattleUnit targetUnit, GridUnit targetGrid, GridUnit[] gridPath)
        {
            BattleUnitMotionAction action = BattleUnitActionEvent.CreateEvent <BattleUnitMotionAction>(BattleUnitActionType.MoveToTarget, this);

            action.targetUnit = targetUnit;
            action.fromGrid   = mapGrid;
            action.gridPath   = gridPath;
            action.moveRange  = battleUnitAttribute.mobility;

            battleField.AppendBattleAction(action);

            //进入格子,直接设置数据
            EnterGrid(targetGrid);
        }
Esempio n. 17
0
        //进入战场
        public void EnterBattleField(BattleField battleField, GridUnit bornGrid)
        {
            if (battleField != null && bornGrid != null)
            {
                this.battleField = battleField;

                //设置敌方队伍
                enemyTeam = battleField.GetBattleTeam(this, false);

                //重置属性
                battleUnitAttribute.RandomAttributes();
                battleUnitAttribute.Reset();

                //创建背包
                if (package == null)
                {
                    package = BattleUnitPackage.CreateInstance(this, 2);
                }

                package.Clear();

                //进入战场
                BattleUnitEnterBattleFieldAction enterBattleFieldAction = BattleUnitActionEvent.CreateEvent <BattleUnitEnterBattleFieldAction>(BattleUnitActionType.EnterBattleField, this);
                enterBattleFieldAction.battleField             = battleField;
                enterBattleFieldAction.bornGrid                = bornGrid;
                enterBattleFieldAction.attribute               = new BattleUnitSyncAttribute();
                enterBattleFieldAction.attribute.hpChanged     = 0;
                enterBattleFieldAction.attribute.currentHP     = battleUnitAttribute.hp;
                enterBattleFieldAction.attribute.energyChanged = 0;
                enterBattleFieldAction.attribute.currentEnergy = 0;
                battleField.AppendBattleAction(enterBattleFieldAction);

                //进入格子
                EnterGrid(bornGrid);

                //初始化战斗行为系统
                if (battleBehaviourSystem != null)
                {
                    battleBehaviourSystem.Init(this, battleField);
                }

                //重置bbsys
                if (battleBehaviourSystem != null)
                {
                    battleBehaviourSystem.ResetSystem();
                }
            }
        }
Esempio n. 18
0
        //获取出生点 0:上方 1:下方
        public GridUnit[] GetBornGrid(int side, int bornCount, bool rand)
        {
            if (rand)
            {
                return(GetRandomBornGrid(bornCount));
            }

            side      = side > 0 ? 1 : 0;
            bornCount = Mathf.Min(bornCount, BornCount);

            int start = side * bornCount;

            GridUnit[] grids = new GridUnit[bornCount];
            bornGrids.CopyTo(start, grids, 0, bornCount);
            return(grids);
        }
Esempio n. 19
0
            public void Reset()
            {
                open = true;

                F = 0;
                G = 0;
                H = 0;

                //清空关联
                if (thisGrid != null)
                {
                    thisGrid.tempRef = null;
                    thisGrid         = null;
                }

                preGrid = null;
            }
        //播放战场动作
        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.battleUnitActionType != BattleUnitActionType.EnterBattleField)
                    {
                        hotPointGridUnit   = actionEvent.actionUnit.mapGrid;
                        hotPointBattleUnit = actionEvent.actionUnit;
                    }

                    //有对应的战斗单位,且这个战斗单位已经连接了战斗单位渲染器
                    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();
            }
        }
Esempio n. 21
0
        //手动释放技能(对具体的地块)
        private void ManualSkill(GridUnit targetGrid)
        {
            if (targetGrid == null)
            {
                return;
            }

            //添加一个行动
            manualOperatingBattleUnitRenderer.battleUnit.UseSkill(usedManualReleaseAnalysisor.battleSkill, null, targetGrid);

            //取消范围高亮显示
            SetCircularRangeRenderStateActive(false, GridRenderType.SkillReleaseRange);
            SetCircularRangeRenderStateActive(false, GridRenderType.SkillEffectRange);

            //行动结束
            ManualOperationComplete();
        }
Esempio n. 22
0
        protected override void UpdateArguments(params object[] args)
        {
            if (args.Length == 0)
            {
                ErrorClose("Args error");
                return;
            }

            focusGridUnit   = args[0] as GridUnit;
            FocusBattleUnit = args[1] as BattleUnit;

            if (focusGridUnit == null && focusBattleUnit == null)
            {
                Close();
                return;
            }
        }
Esempio n. 23
0
 //点击了技能,在以自身为原点的技能情况下
 private void OnBattleUnitAndGridTouched_StateSkill_SurroundSelf(GridUnit gridTouched, BattleUnit battleUnitTouched)
 {
     //当前选定的战斗单位为空,表示还没有显示攻击范围
     if (selectedBattleUnitRenderer == null)
     {
         selectedBattleUnitRenderer = battleUnitTouched.battleUnitRenderer;
         //展示攻击区域
         SetCircularRangeRenderStateActive(
             true,
             GridRenderType.SkillEffectRange,
             selectedBattleUnitRenderer.battleUnit.mapGrid.row,
             selectedBattleUnitRenderer.battleUnit.mapGrid.column,
             usedManualReleaseAnalysisor.battleSkill.effectRadius);
     }
     else
     {
         //点击任意位置判断为释放
         ManualSkill(manualOperatingBattleUnitRenderer.battleUnit.mapGrid);
     }
 }
Esempio n. 24
0
        //从某个格子到目标格
        public GridUnit GetEmptyGrid(GridUnit from, GridUnit to, List <GridUnit> path, int mobility)
        {
            //总需要一个容器来保存
            if (path == null)
            {
                path = new List <GridUnit>();
            }

            path.Clear();

            //发起向终点的一个导航
            if (MapNavigator.Instance.Navigate(this, from, to, path, null, mobility))
            {
                //表示可以到达
                if (path.Count > 1)
                {
                    if (path[path.Count - 1].Equals(to))
                    {
                        //移除最后一个,因为它是目标点
                        path.RemoveAt(path.Count - 1);
                        return(path[path.Count - 1]);
                    }
                    else
                    {
                        return(path[path.Count - 1]);
                    }
                }
                else if (path.Count > 0)
                {
                    //一步之遥,无需移动
                    path.Clear();
                    return(from);
                }
                else
                {
                    return(null);
                }
            }

            return(null);
        }
Esempio n. 25
0
        //点击了地块、战斗单位 -- 在当前是选择技能释放的情况下
        private void OnBattleUnitAndGridTouched_StateSkill(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //技能有问题
            if (usedManualReleaseAnalysisor == null || usedManualReleaseAnalysisor.battleSkill == null)
            {
                UtilityHelper.LogError("OnBattleUnitAndGridTouched_StateSkill failed:None skill...");
                CleanState(true, true);
                return;
            }

            switch (skillOperationType)
            {
            case SkillOperationType.None:
                UtilityHelper.LogError(string.Format("OnBattleUnitAndGridTouched_StateSkill failed:none skill type. Skill id -> {0}", usedManualReleaseAnalysisor.battleSkill.skillID));
                CleanState(true, true);
                return;

            //单个目标
            case SkillOperationType.SingleBattleUnitTarget:
                OnBattleUnitAndGridTouched_StateSkill_SingleBattleUnitTarget(gridTouched, battleUnitTouched);
                break;

            //单个目标,带范围覆盖
            case SkillOperationType.SurroundBattleUnit:
                OnBattleUnitAndGridTouched_StateSkill_SurroundBattleUnit(gridTouched, battleUnitTouched);
                break;

            //以自身为圆心的技能
            case SkillOperationType.SurroundSelf:
                OnBattleUnitAndGridTouched_StateSkill_SurroundSelf(gridTouched, battleUnitTouched);
                break;

            //范围技能,需要选定释放位置
            case SkillOperationType.GridUnitTarget:
                OnBattleUnitAndGridTouched_StateSkill_GridUnitTarget(gridTouched, battleUnitTouched);
                break;

            default:
                break;
            }
        }
Esempio n. 26
0
        //获得全图的随机位置
        private GridUnit[] GetRandomBornGrid(int count)
        {
            List <GridUnit> randomBornGrids = new List <GridUnit>(normalGrids);

            //移除已经包含了玩家的格子
            for (int i = randomBornGrids.Count - 1; i >= 0; --i)
            {
                if (randomBornGrids[i].battleUnit != null)
                {
                    randomBornGrids.RemoveAt(i);
                }
            }
            GridUnit[] grids = new GridUnit[count];
            for (int i = 0; i < count; i++)
            {
                int randomIdx = Random.Range(0, randomBornGrids.Count);
                grids[i] = randomBornGrids[randomIdx];
                randomBornGrids.RemoveAt(randomIdx);
            }
            return(grids);
        }
Esempio n. 27
0
        //战场中铺设格子
        public void Init(
            int width, int height,
            int obstacleCount, int gap,
            int buffCount, int itemCount)
        {
            if (width <= 0 || height <= 0)
            {
                return;
            }

            //记录地图宽高
            mapWidth  = width;
            mapHeight = height;
            //生成格子数组
            mapGrids = new GridUnit[mapWidth, mapHeight];

            this.obstacleCount = obstacleCount;
            this.obstacleGap   = gap;
            this.buffCount     = buffCount;
            this.itemCount     = itemCount;

            //全部生成为普通格子
            for (int r = 0; r < mapHeight; ++r)
            {
                for (int c = 0; c < mapWidth; ++c)
                {
                    GridUnit gridUnitData = new GridUnit(this, r, c);
                    gridUnitData.localPosition = new Vector3(
                        c * EGameConstL.Map_GridWidth,// + ((r & 1) == (EGameConstL.Map_FirstRowOffset ? 0 : 1) ? (EGameConstL.Map_GridWidth * 0.5f) : 0f),
                        -r * EGameConstL.Map_GridOffsetY,
                        0
                        );

                    //保存
                    mapGrids[c, r] = gridUnitData;
                }
            }

            ResetMap();
        }
Esempio n. 28
0
        //战斗表现生命周期
        //释放技能前
        private IEnumerator BeforeReleaseSkill(BattleUnitSkillAction action)
        {
            //将自己显示为行动状态~变身!
            UpdateRenderState(BattleUnitRenderState.Action);

            //仅有范围的技能显示范围呢
            if (action.battleSkill.effectRadius > 0)
            {
                GridUnit centerGrid = null;
                switch (action.battleSkill.targetType)
                {
                case BattleSkillTargetType.BattleUnit:
                case BattleSkillTargetType.Self:
                    centerGrid = action.targetBattleUnit.mapGrid;
                    break;

                case BattleSkillTargetType.GridUnit:
                    centerGrid = action.targetGrid;
                    break;

                default:
                    break;
                }
                if (centerGrid != null)
                {
                    BattleFieldRenderer.Instance.SetCircularRangeRenderStateActive(
                        true,
                        GridRenderType.SkillEffectRange,
                        centerGrid.row, centerGrid.column,
                        action.battleSkill.effectRadius);
                }
            }
            //受到技能影响的单位高亮(暂时)
            for (int i = 0; i < action.skillResult.Length; ++i)
            {
                action.skillResult[i].battleUnit.battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Selected);
            }

            yield return(EGameConstL.WaitForHalfSecond);
        }
        private void Test_Range(GridUnit gridTouched)
        {
            if (lastUnits.Count > 0)
            {
                foreach (var item in lastUnits)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
            }

            UtilityHelper.TimerStart();
            for (int i = 0; i < 100; i++)
            {
                battleField.battleMap.GetCircularGrids(gridTouched.row, gridTouched.column, 3, 0, false, lastUnits);
            }

            UtilityHelper.Log("TimeCost:" + UtilityHelper.TimerEnd());
            foreach (var item in lastUnits)
            {
                item.gridUnitRenderer.AppendGridRenderType(GridRenderType.MoveRange);
            }
        }
Esempio n. 30
0
        //进入格子
        private void EnterGrid(GridUnit grid)
        {
            if (grid == null)
            {
                UtilityHelper.LogError(string.Format("Battle unit {0} enter grid failed, grid is null.", ID));
                return;
            }
            if (mapGrid != null)
            {
                LeaveGrid();
            }

            mapGrid = grid;

            //判断这个格子是否有道具
            if (grid.gridItem != null)
            {
                PickupItemFromGrid(grid);
            }

            //通知格子被自己进入了
            grid.OnEnter(this);
        }