コード例 #1
0
ファイル: BattleField.cs プロジェクト: yxpandjay/HalfSLG
        //准备加载战场
        private void PrepareBattleMap()
        {
            if (currentData == null)
            {
                EUtilityHelperL.LogError("Prepare battle map failed. No battle data.");
                return;
            }
            gridUnits = new GridUnit[currentData.mapData.mapWidth, currentData.mapData.mapHeight];

            for (int r = 0; r < currentData.mapData.mapHeight; ++r)
            {
                for (int c = 0; c < currentData.mapData.mapWidth; ++c)
                {
                    GridUnitData gud = currentData.mapData.mapGrids[c, r];
                    if (gud != null)
                    {
                        //创建一个用于显示的格子对象
                        GridUnit gridUnit = CreateGrid();
                        if (gridUnit != null)
                        {
                            gridUnits[c, r] = gridUnit;
                            gridUnit.transform.localPosition = gud.localPosition;
                            gridUnit.name     = string.Format("Grid_{0}_{1}", r, c);
                            gridUnit.gridData = gud;
                            gridUnit.RefreshColor();
                            gridUnit.gameObject.SetActive(true);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: BattleMap.cs プロジェクト: yxpandjay/HalfSLG
        //放置一些障碍格子
        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, reduction);
                if (reduction.Count > 0)
                {
                    foreach (var item in reduction)
                    {
                        randomRange.Remove(item);
                    }
                }
                --count;
            }
        }
コード例 #3
0
ファイル: BattleField.cs プロジェクト: yxpandjay/HalfSLG
        /// <summary>
        /// 测试选中区域
        /// </summary>
        private void TestSelectedRange(int radius)
        {
            //如果点击了鼠标左键
            if (Input.GetMouseButtonDown(0))
            {
                //计算点击位置
                Vector3 clickedWorldPos = BattleCamera.ScreenToWorldPoint(Input.mousePosition);
                clickedWorldPos.z = 0;
                //判断是否有格子被点中?
                GridUnit clicked = GetGridClicked(clickedWorldPos);
                //点中了格子
                if (clicked != null)
                {
                    ClearRendererType();
                    List <GridUnitData> rangeGrids = new List <GridUnitData>();
                    //测试区域
                    currentData.mapData.GetRangeGrids(clicked.gridData.row, clicked.gridData.column, radius, rangeGrids);

                    foreach (var item in rangeGrids)
                    {
                        gridUnits[item.column, item.row].GridRenderType = GridRenderType.Range;
                    }
                }
            }
        }
コード例 #4
0
        //将战斗单位放置入战场
        private void EnterBattleField(bool recordProcess)
        {
            BattleUnit          battleUnit = null;
            List <BattleAction> actions    = null;

            if (recordProcess)
            {
                actions = new List <BattleAction>();
            }

            for (int i = 0; i < teams.Count; ++i)
            {
                for (int j = 0; j < teams[i].battleUnits.Count; ++j)
                {
                    battleUnit = teams[i].battleUnits[j];
                    GridUnit bornUnit = battleMap.GetBornGrid(i, true);
                    if (bornUnit == null)
                    {
                        battleUnit.battleUnitAttribute.hp = 0;
                        UtilityHelper.LogError("Get born unit failed.");
                        continue;
                    }
                    battleUnit.EnterBattleField(this, bornUnit, actions);
                    //生成行动队列
                    actionQueue.Enqueue(battleUnit);
                }
            }

            if (recordProcess)
            {
                AppendBattleActions(actions);
            }
        }
コード例 #5
0
ファイル: BattleUnit.cs プロジェクト: yxpandjay/HalfSLG
        //向目标地点使用技能
        public void UseSkill(List <BattleAction> actions, GridUnit target, BattleSkillAnalysis skillAnalysis)
        {
            if (target == null || skillAnalysis == null)
            {
                UtilityHelper.LogError("Use skill error, none target or skill");
                return;
            }

            List <BattleHeroSkillResult> skillResults = new List <BattleHeroSkillResult>();

            for (int i = 0; i < skillAnalysis.suitableUnits.Count; ++i)
            {
                //范围内的都受到伤害
                if (target.Distance(skillAnalysis.suitableUnits[i].mapGrid) <= skillAnalysis.battleSkill.rangeRadius)
                {
                    skillResults.Add(BattleCalculator.Instance.CalcSingle(this, skillAnalysis.suitableUnits[i], skillAnalysis.battleSkill));
                }
            }

            //产生使用技能的动作
            if (actions != null)
            {
                BattleHeroSkillAction action = new BattleHeroSkillAction(this, skillAnalysis.battleSkill.skillID);
                action.skillResult = skillResults.ToArray();
                actions.Add(action);
            }

            //产生伤害
            for (int i = 0; i < skillResults.Count; ++i)
            {
                skillResults[i].battleUnit.AcceptSkillResult(skillResults[i].syncAttribute, actions);
            }
        }
コード例 #6
0
ファイル: MapNavigator.cs プロジェクト: yxpandjay/HalfSLG
        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);
        }
コード例 #7
0
ファイル: BattleField.cs プロジェクト: yxpandjay/HalfSLG
        //***********************************************

        private GridUnit GetGridClicked(Vector3 clickedWorldPos)
        {
            //转换空间到格子组织节点(GridUnits)的空间
            clickedWorldPos = gridUnitsRoot.transform.InverseTransformPoint(clickedWorldPos);
            //初步判定所在行列
            int row    = Mathf.FloorToInt((clickedWorldPos.y - EGameConstL.Map_GridOffsetY * 0.5f) / -EGameConstL.Map_GridOffsetY);
            int column = Mathf.FloorToInt((clickedWorldPos.x + EGameConstL.Map_GridWidth * 0.5f - ((row & 1) == (EGameConstL.Map_FirstRowOffset ? 1 : 0) ? 0f : (EGameConstL.Map_GridWidth * 0.5f))) / EGameConstL.Map_GridWidth);

            int testRow    = 0;
            int testColumn = 0;
            //二次判定,判定周围格子
            GridUnit clickedGrid = null;
            float    minDis      = Mathf.Infinity;

            for (int r = -1; r <= 1; ++r)
            {
                for (int c = -1; c <= 1; ++c)
                {
                    testRow    = row + r;
                    testColumn = column + c;
                    if (testRow < 0 || testRow >= currentData.mapData.mapHeight ||
                        testColumn < 0 || testColumn >= currentData.mapData.mapWidth)
                    {
                        continue;
                    }
                    float distance = EUtilityHelperL.CalcDistanceInXYAxis(clickedWorldPos, currentData.mapData.mapGrids[testColumn, testRow].localPosition);
                    if (distance < minDis && distance < EGameConstL.Map_HexRadius)
                    {
                        minDis      = distance;
                        clickedGrid = gridUnits[testColumn, testRow];
                    }
                }
            }
            return(clickedGrid);
        }
コード例 #8
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;
            }
        }
コード例 #9
0
ファイル: BattleField.cs プロジェクト: yxpandjay/HalfSLG
        //将战斗单位放置入战场
        private void EnterBattleField(bool recordProcess)
        {
            BattleUnit          battleUnit = null;
            List <BattleAction> actions    = null;

            if (recordProcess)
            {
                actions = new List <BattleAction>();
            }

            for (int i = 0; i < teams.Count; ++i)
            {
                for (int j = 0; j < teams[i].battleUnits.Count; ++j)
                {
                    battleUnit = teams[i].battleUnits[j];
                    GridUnit bornUnit = battleMap.GetBornGrid(i, true);
                    if (bornUnit == null)
                    {
                        UtilityHelper.LogError("Get born unit failed.");
                        continue;
                    }
                    BattleHeroEnterBattleFieldAction action = battleUnit.EnterBattleField(this, bornUnit, recordProcess);
                    if (recordProcess && action != null)
                    {
                        actions.Add(action);
                    }
                }
            }

            if (recordProcess)
            {
                AppendBattleActions(actions.ToArray());
            }
        }
コード例 #10
0
        //点击了地块、战斗单位
        private void OnBattleUnitAndGridTouched(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
#if TEST_NAV
            Test_Nav(gridTouched);
            return;
#endif
#if TEST_RANGE
            Test_Range(gridTouched);
            return;
#endif
#if TEST_REMOTE_RANGE
            Test_RemoteRange(gridTouched);
            return;
#endif
            if (battleUnitTouched != null)
            {
                battleUnitTouched.battleBehaviourSystem.Think();
            }
            if (gridTouched != null || battleUnitTouched != null)
            {
                UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
            }
            else
            {
                UIViewManager.Instance.HideView(UIViewName.BattleFieldUnitInfo);
            }

            //通知helper处理点击反馈逻辑
            manualOperationHelper.OnBattleUnitAndGridTouched(gridTouched, battleUnitTouched);
        }
コード例 #11
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("无效的目标单位");
            }
        }
コード例 #12
0
        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();
                        }
                    }
                }
            }
        }
コード例 #13
0
        //刷新格子
        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);
                        }
                    }
                }
            }
        }
コード例 #14
0
ファイル: BattleUnit.cs プロジェクト: yxpandjay/HalfSLG
        //拾起道具
        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);
            }
        }
コード例 #15
0
        //准备加载战场
        private void PrepareBattleMap()
        {
            if (currentData == null)
            {
                EUtilityHelperL.LogError("Prepare battle map failed. No battle data.");
                return;
            }
            gridUnits = new GridUnit[currentData.mapWidth, currentData.mapHeight];

            for (int row = 0; row < currentData.mapHeight; ++row)
            {
                for (int column = 0; column < currentData.mapWidth; ++column)
                {
                    GridUnitData gud = currentData.mapGrids[column, row];
                    if (gud != null)
                    {
                        //创建一个用于显示的格子对象
                        GridUnit gu = CreateGrid();
                        if (gu != null)
                        {
                            gridUnits[column, row]     = gu;
                            gu.transform.localPosition = gud.localPosition;
                            gu.name     = string.Format("Grid_{0}_{1}", row, column);
                            gu.gridData = gud;
                            gu.Refresh();
                            gu.gameObject.SetActive(true);
                        }
                    }
                }
            }
        }
コード例 #16
0
ファイル: BattleUnit.cs プロジェクト: yxpandjay/HalfSLG
        //进入战场
        public void EnterBattleField(BattleField battleField, GridUnit bornGrid, List <BattleAction> heroActions)
        {
            if (battleField != null && bornGrid != null)
            {
                this.battleField = battleField;

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

                //重置仇恨记录器
                hatredRecorder.Reset(this, enemyTeam);

                EnterGrid(bornGrid);

                if (heroActions != null)
                {
                    BattleUnitAction battleUnitAction = BattleUnitAction.Get(this);
                    battleUnitAction.enterBattleFieldAction                         = BattleUnitEnterBattleFieldAction.Get();
                    battleUnitAction.enterBattleFieldAction.bornGrid                = bornGrid;
                    battleUnitAction.enterBattleFieldAction.attribute               = new BattleUnitSyncAttribute();
                    battleUnitAction.enterBattleFieldAction.attribute.hpChanged     = 0;
                    battleUnitAction.enterBattleFieldAction.attribute.currentHP     = battleUnitAttribute.hp;
                    battleUnitAction.enterBattleFieldAction.attribute.energyChanged = 0;
                    battleUnitAction.enterBattleFieldAction.attribute.currentEnergy = 0;
                    heroActions.Add(battleUnitAction);
                }
            }
        }
コード例 #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();
                //重置bbsys
                battleBehaviourSystem.ResetSystem();

                EnterGrid(bornGrid);

                BattleUnitAction battleUnitAction = BattleUnitAction.Create(this);
                battleUnitAction.enterBattleFieldAction                         = BattleUnitEnterBattleFieldAction.Get();
                battleUnitAction.enterBattleFieldAction.bornGrid                = bornGrid;
                battleUnitAction.enterBattleFieldAction.attribute               = new BattleUnitSyncAttribute();
                battleUnitAction.enterBattleFieldAction.attribute.hpChanged     = 0;
                battleUnitAction.enterBattleFieldAction.attribute.currentHP     = battleUnitAttribute.hp;
                battleUnitAction.enterBattleFieldAction.attribute.energyChanged = 0;
                battleUnitAction.enterBattleFieldAction.attribute.currentEnergy = 0;

                //创建进入战场的消息
                battleField.AppendBattleAction(battleUnitAction);

                //初始化战斗行为系统
                battleBehaviourSystem.Init(this, battleField);
            }
        }
コード例 #18
0
ファイル: BattleUnit.cs プロジェクト: yxpandjay/HalfSLG
 //离开格子
 private void LeaveGrid()
 {
     if (mapGrid != null)
     {
         mapGrid.OnLeave();
         mapGrid = null;
     }
 }
コード例 #19
0
        public int effectedCount;           //这个技能可以影响的人数

        public void Recycle()
        {
            battleSkill      = null;
            targetBattleUnit = null;
            targetGridUnit   = null;
            score            = 0;
            effectedCount    = 0;
        }
コード例 #20
0
 public void UpdatePositionByGrid(GridUnit gridUnit)
 {
     if (battleUnit != null)
     {
         transform.localPosition     = gridUnit.localPosition;
         unitRenderer.sortingOrder   = gridUnit.row * EGameConstL.OrderGapPerRow + EGameConstL.OrderIncrease_BattleUnit;
         battleUnitInfo.sortingOrder = gridUnit.row * EGameConstL.OrderGapPerRow + EGameConstL.OrderIncrease_BattleUnit;
     }
 }
コード例 #21
0
 private void ManualMoveTo(GridUnit grid, GridUnit[] path)
 {
     UtilityObjs.battleActions.Clear();
     //创建动作并追加
     manualBattleUnitRenderer.battleUnit.MoveToTargetGrid(UtilityObjs.battleActions, null, grid, path);
     battleField.AppendBattleActions(UtilityObjs.battleActions);
     UtilityObjs.battleActions.Clear();
     PlayBattle(AfterManualMove);
 }
コード例 #22
0
        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();
            }
        }
コード例 #23
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("目标单位无效");
            }
        }
コード例 #24
0
        //手动选择移动目标
        private void ManualMoveTo(GridUnit grid, GridUnit[] path)
        {
            //添加一个行动
            BattleUnitAction battleUnitAction = BattleUnitAction.Create(manualOperatingBattleUnitRenderer.battleUnit);

            //为行动添加移动数据
            manualOperatingBattleUnitRenderer.battleUnit.MoveToTargetGrid(battleUnitAction, null, grid, path);
            fieldRenderer.battleField.AppendBattleAction(battleUnitAction);
            fieldRenderer.PlayBattle(AfterManualMove);
        }
コード例 #25
0
ファイル: SO_BattleSkill.cs プロジェクト: yxpandjay/HalfSLG
        public float rageLevel      = 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);
        }
コード例 #26
0
        //点击了地块、战斗单位 -- 在当前是选择移动目标的情况下
        private void OnBattleUnitAndGridTouched_StateMove(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //点中了战斗单位
            if (battleUnitTouched != null)
            {
                //显示战斗单位的详情
                UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
            }
            //点中了地图
            else
            {
                //障碍物不能作为移动目标(暂时)
                if (gridTouched.GridType == GridType.Obstacle)
                {
                    UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
                }
                else
                {
                    //点击是否超出了范围
                    GridUnit fromGrid = manualOperatingBattleUnitRenderer.battleUnit.mapGrid;
                    if (fromGrid.Distance(gridTouched) > manualOperatingBattleUnitRenderer.battleUnit.battleUnitAttribute.mobility)
                    {
                        UtilityHelper.Log("超出了移动半径!");
                        UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
                    }
                    else
                    {
                        //判断移动是否可以到达
                        bool result = MapNavigator.Instance.Navigate(
                            fieldRenderer.battleField.battleMap,
                            fromGrid,
                            gridTouched,
                            UtilityObjs.gridUnits,
                            null,
                            manualOperatingBattleUnitRenderer.battleUnit.battleUnitAttribute.mobility
                            );

                        //判断是否可以到达(导航成功且可以可以到达)
                        if (result && UtilityObjs.gridUnits[UtilityObjs.gridUnits.Count - 1].Equals(gridTouched))
                        {
                            //可以到达
                            ManualMoveTo(gridTouched, UtilityObjs.gridUnits.ToArray());
                            UtilityObjs.gridUnits.Clear();
                        }
                        else
                        {
                            //不可以到达
                            UtilityHelper.Log("点击位置不可到达!");
                            UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
                        }
                    }
                }
            }
        }
コード例 #27
0
        //点击了地块、战斗单位
        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);
                }

                Debug.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);
            }
        }
コード例 #28
0
ファイル: BattleUnit.cs プロジェクト: yxpandjay/HalfSLG
        //向目标格子移动
        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);
        }
コード例 #29
0
ファイル: BattleUnit.cs プロジェクト: yxpandjay/HalfSLG
        //进入战场
        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();
                }
            }
        }
コード例 #30
0
ファイル: BattleMap.cs プロジェクト: yxpandjay/HalfSLG
        //获取出生点 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);
        }