Ejemplo n.º 1
0
        /// <summary>
        /// 指挥圈变更通知
        /// </summary>
        /// <param name="_unit"></param>
        private void CommanderRangeUnit(ActivitiesUnit _unit)
        {
            if (_unit == null)
            {
                activitiesManager.ExitCommanderOrSoliderUnit();
                cacheHitRaycastUnit = null;
                return;
            }

            if (!activitiesManager.GetUnitSameCommander(cacheHitRaycastUnit, _unit))
            {
                activitiesManager.ExitCommanderOrSoliderUnit(true);
            }

            if (_unit.GetType() == typeof(CommanderUnit))
            {
                activitiesManager.EnterCommanderOrSoliderUnit(_unit as CommanderUnit);
                LoadInfo.Instance.sceneWindowsCanvas.ShowActivitiesData(_unit as CommanderUnit, false);
            }
            else if (_unit.GetType() == typeof(SoliderUnit))
            {
                activitiesManager.EnterCommanderOrSoliderUnit((_unit as SoliderUnit)?.mineCommanderUnit);
                LoadInfo.Instance.sceneWindowsCanvas.ShowActivitiesData(_unit as SoliderUnit, false);
            }

            cacheHitRaycastUnit = _unit;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_unit"></param>
        /// <param name="_unitCurrentPos"></param>
        /// <param name="_tile"></param>
        /// <param name="_actionScopeType"></param>
        /// <param name="_activitiesAction"> 鼠标左键触发的事件 </param>
        /// <param name="_clickTilePosAction"> 鼠标左键触发的事件 </param>
        /// <param name="_cancelAction"> 鼠标右键触发的事件 </param>
        public void AddStepEvent(ActivitiesUnit _unit, TileSaveData[] _tile, ActionScopeType _actionScopeType, Action <ActivitiesUnit> _activitiesAction, Action <Vector3Int> _clickTilePosAction, Action _cancelAction)
        {
            bool valueNull = _tile == null;

            TileSaveDataCommand[] addStepValue = new TileSaveDataCommand[valueNull ? 1 : _tile.Length];
            if (_tile != null)
            {
                for (int i = 0; i < _tile.Length; i++)
                {
                    addStepValue[i]            = new TileSaveDataCommand();
                    addStepValue[i].aliasName  = _tile[i].aliasName;
                    addStepValue[i].path       = _tile[i].path;
                    addStepValue[i].isChange   = _tile[i].isChange;
                    addStepValue[i].moveEnable = false;
                    addStepValue[i].pos        = _tile[i].widthHeighValue;
                }
            }

            // none 类型在弹出时直接跳过 因为none是角色移动过程
            StepInfo temp = new StepInfo()
            {
                unit               = _unit,
                unitCurrentPos     = _unit == null ? Vector3Int.one : _unit.currentPos,
                tileCommand        = valueNull ? null : addStepValue,
                actionScopeType    = _actionScopeType,
                activitiesAction   = _activitiesAction,
                clickTilePosAction = _clickTilePosAction,
                cancelAction       = _cancelAction,
            };

            stepInfoStack.Push(temp);
        }
Ejemplo n.º 3
0
 private void OnSetActivitiesData(ActivitiesUnit _unit)
 {
     // UnitOtherActionPlane
     roundOverBtn.gameObject.SetActive(false);
     skillBtn.gameObject.SetActive(_unit.skillMastery != 0);
     treatBtn.gameObject.SetActive(true);
     detailPanelBtn.gameObject.SetActive(true);
 }
Ejemplo n.º 4
0
        private void ExecuteClickStepEvent(ActivitiesUnit _unit, Vector3Int _cellPos, bool _gridPlayerLayer)
        {
            if (stepInfoStack.Count == 0)
            {
                if (_unit)
                {
                    // 告诉士兵管理系统
                    activitiesManager.SelectionUnit(_unit);
                }
                else
                {
                    // todo 如果通知的脚本过多不如弄成事件。
                    activitiesManager.ClickTilePos(_cellPos);
                }
            }
            else
            {
                StepInfo temp = stepInfoStack.Peek();
                switch (temp.actionScopeType)
                {
                case ActionScopeType.OnlyOurSoldiers:
                case ActionScopeType.OnlyOurCommanders:
                case ActionScopeType.OnlyOur:
                case ActionScopeType.OnlyFriendSoldiers:
                case ActionScopeType.OnlyFriendCommanders:
                case ActionScopeType.OnlyFriend:
                case ActionScopeType.OnlyOurAndFriendSoldiers:
                case ActionScopeType.OnlyOurAndFriendCommanders:
                case ActionScopeType.OnlyOurAndFriend:
                case ActionScopeType.OnlyEnemySoldiers:
                case ActionScopeType.OnlyEnemyCommanders:
                case ActionScopeType.OnlyEnemy:
                case ActionScopeType.MeAndEnemy:
                case ActionScopeType.AllActivities:
                    if (_unit != null)
                    {
                        temp.activitiesAction(_unit);
                    }
                    break;

                case ActionScopeType.NoActivitiesUnit:
                    temp.clickTilePosAction(_cellPos);
                    break;

                case ActionScopeType.AllUnit:
                    if (_unit != null)
                    {
                        temp.activitiesAction(_unit);
                    }
                    temp.clickTilePosAction(_cellPos);
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        // 第一步 技能施法范围显示
        public override void StartCommand(ActivitiesUnit _unit, GameCursor _cursor, SceneTileMapManager _tileMapManager)
        {
            cacheUnit      = _unit;
            cursor         = _cursor;
            tileMapManager = _tileMapManager;

            TileSaveData[] tileData = _tileMapManager.GetRoundTileSaveData(_unit.currentPos, _unit.skillRangeValue[0] + skillIncrement);
            _tileMapManager.ShowCustomActionGrid(tileData);
            _cursor.AddStepEvent(_unit, tileData, ActionScopeType.AllUnit, null, SkillTriggerClick, () =>
            {
            });
        }
Ejemplo n.º 6
0
        private IEnumerator WaitMoveOn(ActivitiesUnit _unit)
        {
            WaitForSeconds wait = new WaitForSeconds(0.1f);

            while (true)
            {
                if (_unit.isActionOver)
                {
                    break;
                }
                yield return(wait);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 刷新指挥圈
 /// </summary>
 /// <param name="_unit"></param>
 public void RefreshCommanderCircleGird(ActivitiesUnit _unit)
 {
     HideCommanderCircleGrid();
     if (_unit.GetType() == typeof(CommanderUnit))
     {
         var commandUnit = ((CommanderUnit)_unit);
         ShowCommanderCircleGrid(commandUnit.currentPos, commandUnit.commandRangeValue[0], commandUnit.campColor);
     }
     else if (_unit.GetType() == typeof(SoliderUnit))
     {
         var soliderUnit = ((SoliderUnit)_unit);
         ShowCommanderCircleGrid(soliderUnit.mineCommanderUnit.currentPos, soliderUnit.mineCommanderUnit.commandRangeValue[0], soliderUnit.campColor);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 显示移动轨迹
        /// </summary>
        /// <param name="_unit"></param>
        /// <param name="_posArray"></param>
        public void ShowCurrentMovingCorrelationGrid(ActivitiesUnit _unit, Vector3Int[] _posArray)
        {
            asyncBoolValue = false;
            foreach (var v in tileList.Where(x => x.activitiesAllowUnit.moveSpriteRenderer.enabled == false))
            {
                v.activitiesAllowUnit.SetMoveGrid(true);
            }

            cacheSaveData.FirstOrDefault(x => x.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) == 0).activitiesAllowUnit.SetMoveGrid(false);
            for (int i = 0; i < _posArray.Length; i++)
            {
                tileList.FirstOrDefault(x => x.widthHeighValue.Vector3IntRangeValue(_posArray[i]) == 0).activitiesAllowUnit.SetMoveGrid(false);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 显示攻击相关区域与待机区域
        /// </summary>
        /// <param name="_unit"></param>
        public void ShowStandByOrOtherActionGrid(ActivitiesUnit _unit)
        {
            foreach (var v in tileList.Where(x => x.activitiesAllowUnit.moveSpriteRenderer.enabled == false))
            {
                v.activitiesAllowUnit.SetMoveGrid(true);
            }

            ActivitiesUnit[] aroundUnitArray = activitiesManager.GetActivitiesUnit(_unit.currentPos, _unit.attackRangeValue[0]);

            ActivitiesUnit[] enemyArray = aroundUnitArray.Where(x =>
                                                                gameManager.GetCampData(x.managerKeyName).troopType !=
                                                                gameManager.GetCampData(_unit.managerKeyName).troopType).ToArray();

            var stackValue = new List <TileSaveData>();

            if (enemyArray.Length != 0)
            {
                foreach (var v in tileList.Where(x => x.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) <= _unit.attackRangeValue[0]))
                {
                    v.activitiesAllowUnit.SetMoveGrid(false);
                }

                stackValue = tileList.Where(x =>
                                            x.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) <= _unit.attackRangeValue[0]).ToList();
            }
            else
            {
                tileList.FirstOrDefault(x => x.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) == 0).activitiesAllowUnit.SetMoveGrid(false);
                stackValue =
                    tileList.Where(x => x.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) == 0).ToList();
            }

            foreach (var v in enemyArray)
            {
                // 设置单位icon
                //activitiesManager.SetActivitiesUnitIconState(v, "sword");
            }

            LoadInfo.Instance.sceneWindowsCanvas.RefreshActivitiesData();

            cursor.AddStepEvent(_unit, stackValue.ToArray(), ActionScopeType.MeAndEnemy, activitiesManager.StandByOrOtherActionGridCallBack, null,
                                () =>
            {
            });
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 显示可移动相关区域
        /// </summary>
        public async void ShowCanMoveCorrelationGrid(ActivitiesUnit _unit, bool _isAsync)
        {
            // 问题出在这了,底下的方格还没显示完就注册了。
            cursor.AddStepEvent(_unit, cacheSaveData, ActionScopeType.NoActivitiesUnit, null, activitiesManager.ClickTilePos,
                                () =>
            {
                asyncBoolValue = false;
            });

            asyncBoolValue = true;
            foreach (var v in tileList.Where(x => x.activitiesAllowUnit.moveSpriteRenderer.enabled == false))
            {
                v.activitiesAllowUnit.SetMoveGrid(true);
            }

            int ms        = 30;
            int moveValue = _unit.moveRangeValue[0];

            for (int i = 0; i <= moveValue; i++)
            {
                if (cacheSaveData == null || !asyncBoolValue)
                {
                    return;
                }

                foreach (var v in cacheSaveData.Where(
                             x => x.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) == i))
                {
                    v.activitiesAllowUnit.SetMoveGrid(false);
                }
                if (_isAsync)
                {
                    await Task.Delay(ms);
                }
            }

            asyncBoolValue = false;
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 两个Unit是否是相同队伍
 /// </summary>
 /// <param name="_unit1"></param>
 /// <param name="_unit2"></param>
 /// <returns></returns>
 public bool VerifySameTroop(ActivitiesUnit _unit1, ActivitiesUnit _unit2)
 {
     return(_unit1.troopsType == _unit2.troopsType);
 }
Ejemplo n.º 12
0
 public void AttackFighting(ActivitiesUnit _leftUnit, ActivitiesUnit _rightUnit, Action _callBack)
 {
     Debug.Log("left Attack firm to 30 damage");
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 输入一个活动单位,返回该活动单位可以活动的区域。
        /// </summary>
        /// <param name="_unit">单位</param>
        /// <returns></returns>
        public TileSaveData[] CalculateMovingRange(ActivitiesUnit _unit)
        {
            // 初始化
            foreach (var v in tileList.Where(x => x.pixelValue[0] != -1))
            {
                v.SetPixelValue(-1);
                v.InitAliasName();
            }
            // 抓取部分数据
            List <TileSaveData> cacheData = tileList.Where(x => x.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) <= _unit.moveRangeValue[0]).ToList();

            int tempIndex = 1;

            // 地形移动力消耗值
            foreach (var v in cacheData)
            {
                if (v.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) != 0)
                {
                    v.aliasName = string.Concat("T", tempIndex++);
                }
                if (activitiesManager.GetUnitPosContains(v.widthHeighValue) &&
                    !activitiesManager.GetUnitPosContainsOtherTroop(v.widthHeighValue, _unit.managerKeyName))
                {
                    v.SetPixelValue(99);
                }
                else
                {
                    v.SetPixelValue(environmentConfig.GetConsumeValue(_unit.movingType,
                                                                      GetSprite(v.widthHeighValue)));
                }
            }
            // 单位当前位置
            var currentSaveData =
                tileList.FirstOrDefault(x => x.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) == 0);

            currentSaveData.SetPixelValue(0);
            currentSaveData.aliasName = "T0";
            currentSaveData.path      = "T0";
            currentSaveData.isChange  = true;

            if (_unit.movingType != TerrainActionType.瞬行)
            {
                PressureAlgorithm(currentSaveData.widthHeighValue, _unit.moveRangeValue[0]);

                while (cacheData.Any(x => x.pixelValue[0] < _unit.moveRangeValue[0] && x.pixelValue[0] > 0 && x.isChange))
                {
                    foreach (var v in cacheData.Where(x =>
                                                      x.pixelValue[0] < _unit.moveRangeValue[0] && x.pixelValue[0] > 0 && x.isChange))
                    {
                        PressureAlgorithm(v.widthHeighValue, _unit.moveRangeValue[0]);
                    }
                }

                // 去除所有数值低于移动力的方格 与没计算过的方格.
                cacheSaveData = cacheData.Where(x =>
                                                x.pixelValue[0] <= _unit.moveRangeValue[0] && x.isChange).ToArray();
            }
            else
            {
                cacheSaveData = cacheData.Where(x => x.pixelValue[0] <= _unit.moveRangeValue[0]).ToArray();
            }

            // 去除所有 已有单位的方格
            cacheSaveData = cacheSaveData.Where(x =>
                                                (!activitiesManager.GetUnitPosContains(x.widthHeighValue) ||
                                                 x.widthHeighValue.Vector3IntRangeValue(_unit.currentPos) == 0)).ToArray();

            return(cacheSaveData);
        }
Ejemplo n.º 14
0
        void Update()
        {
            // 不懂为什么,将Enable关闭了之后,会出现鼠标经过两次的问题
            if (!isExecute)
            {
                return;
            }

            var        worldPointV3 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector3Int cellPos      = grid.WorldToCell(worldPointV3);

            // 非UI层。
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                var hit2D = Physics2D.Raycast(worldPointV3, Vector2.zero, 10);
                if (hit2D.transform != null)
                {
                    bool           gridPlayerLayer = hit2D.transform.gameObject.layer == LayerMask.NameToLayer("GridPlayer");
                    ActivitiesUnit unit            = hit2D.transform.GetComponent <ActivitiesUnit>();
                    if (gridPlayerLayer)
                    {
                        // Touch Unit
                        if (cacheHitRaycastUnit != null && cacheHitRaycastUnit != unit)
                        {
                            Debug.Log("????");
                            //CommanderRangeUnit(null);
                        }

                        if (cacheHitRaycastUnit == null || cacheHitRaycastUnit != unit)
                        {
                            CommanderRangeUnit(unit);
                        }
                    }
                    else
                    {
                        // Exit Unit
                        if (cacheHitRaycastUnit != null)
                        {
                            Debug.Log("??");

                            CommanderRangeUnit(null);
                        }
                    }

                    if (Input.GetMouseButtonDown(0))
                    {
                        ExecuteClickStepEvent(unit, cellPos, gridPlayerLayer);
                    }
                }
                else
                {
                    // 通知现在没点到士兵
                    if (cacheHitRaycastUnit != null)
                    {
                        Debug.Log("??");
                        CommanderRangeUnit(null);
                    }
                }
            }

            if (Input.GetMouseButtonDown(1))
            {
                CancelStepEvent();
            }
        }
Ejemplo n.º 15
0
 public virtual void StartCommand(ActivitiesUnit _unit, GameCursor _cursor, SceneTileMapManager _tileMapManager)
 {
 }