Exemple #1
0
        /// <summary>
        /// 动作结束后处理
        /// </summary>
        public IEnumerator ActionOverNext()
        {
            if (battleMode == BattleMode.moving)
            {
                currentVCharacter.action = ActionType.idle;
            }
            yield return(AppManager.CurrentScene.StartCoroutine(ActionEndSkillsRun()));

            currentVCharacter.actionOver = true;
            currentMCharacter.roadLength = 0;
            tilesManager.ClearCurrentTiles();
            Global.battleEvent.DispatchEventCharacterPreview(null);
            battleMode = BattleMode.none;
            Belong belong = currentMCharacter.belong;

            this.currentMCharacter = null;
            this.currentVCharacter = null;
            if (!Global.charactersManager.mCharacters.Exists(c => c.hp > 0 && !c.isHide && c.belong == belong && !c.actionOver))
            {
                ChangeBelong(belong);
            }
            else
            {
                Global.battleEvent.DispatchEventOperatingMenu(false);
            }
        }
Exemple #2
0
        public void ClickNoneNode(Vector2Int coordinate)
        {
            MCharacter mCharacter = Global.charactersManager.GetCharacter(coordinate);

            if (mCharacter != null)
            {
                currentVCharacter                 = Global.charactersManager.GetVCharacter(mCharacter);
                this.currentMCharacter            = mCharacter;
                this.currentMCharacter.roadLength = 0;
                tilesManager.ShowCharacterMovingArea(mCharacter);
                tilesManager.ShowCharacterSkillArea(mCharacter);
                Global.battleEvent.DispatchEventCharacterPreview(mCharacter);
                _oldCoordinate.x = mCharacter.coordinate.x;
                _oldCoordinate.y = mCharacter.coordinate.y;
                ActionType action    = currentVCharacter.action;
                float      x         = currentVCharacter.X;
                Direction  direction = currentVCharacter.direction;
                if (mCharacter.belong == Belong.self)
                {
                    Global.battleEvent.DispatchEventOperatingMenu(true);
                }
                returnAction = () =>
                {
                    this.currentMCharacter.coordinate.y = _oldCoordinate.y;
                    this.currentMCharacter.coordinate.x = _oldCoordinate.x;
                    currentVCharacter.X         = x;
                    currentVCharacter.direction = direction;
                    currentVCharacter.action    = action;
                };
            }
        }
Exemple #3
0
        private void SetActionCharacterList(VCharacterBase actionCharacter, VCharacterBase targetCharacter, bool canCounter)
        {
            int count     = this.calculateManager.SkillCount(actionCharacter.mCharacter, targetCharacter.mCharacter);
            int countBack = count;

            while (count-- > 0)
            {
                actionCharacterList.Add(actionCharacter);
            }
            if (!canCounter || !this.calculateManager.CanCounterAttack(actionCharacter.mCharacter, targetCharacter.mCharacter, actionCharacter.mCharacter.coordinate, targetCharacter.mCharacter.coordinate))
            {
                return;
            }
            count = this.calculateManager.CounterAttackCount(actionCharacter.mCharacter, targetCharacter.mCharacter);
            while (count-- > 0)
            {
                actionCharacterList.Add(targetCharacter);
            }
            //反击后反击
            if (actionCharacter.mCharacter.currentSkill.master.effect.special == Model.SkillEffectSpecial.attack_back_attack)
            {
                while (countBack-- > 0)
                {
                    actionCharacterList.Add(actionCharacter);
                }
            }
        }
 /// <summary>
 /// 行动中武将移除
 /// </summary>
 /// <param name="vCharacter">V character.</param>
 public void RemoveDynamicCharacter(VCharacterBase vCharacter)
 {
     dynamicCharacters.Remove(vCharacter);
     if (!HasDynamicCharacter())
     {
         Global.battleEvent.DispatchEventActionEnd();
     }
 }
Exemple #5
0
        public static void ToShowNpc(int npcId, string message, System.Action onComplete = null)
        {
            VCharacterBase vCharacter = Global.charactersManager.vCharacters.Find(chara => chara.mCharacter.id == npcId);

            Model.Character.MCharacter mCharacter = vCharacter.mCharacter;
            Request req = Request.Create("mCharacter", mCharacter, "message", message, "closeEvent", onComplete);

            AppManager.CurrentScene.StartCoroutine(Global.AppManager.ShowDialog(Util.Dialog.TalkDialog, req));
        }
 /// <summary>
 /// 行动中武将挂起
 /// </summary>
 /// <param name="vCharacter">V character.</param>
 public void AddDynamicCharacter(VCharacterBase vCharacter)
 {
     if (dynamicCharacters.Contains(vCharacter))
     {
         return;
     }
     //Debug.LogError("行动中武将 " + vCharacter.ViewModel.Action.Value + ","+vCharacter.ViewModel.Name.Value + ","+vCharacter.ViewModel.Belong.Value);
     dynamicCharacters.Add(vCharacter);
 }
Exemple #7
0
 /// <summary>
 /// 开始动作
 /// </summary>
 /// <returns><c>true</c>, if start run was actioned, <c>false</c> otherwise.</returns>
 /// <param name="vCharacter">Current character.</param>
 private void ActionStartRun(VCharacterBase vCharacter)
 {
     Debug.LogError("ActionStartRun");
     System.Action actionStartEvent = () =>
     {
         //cBattlefield.MapMoveToPosition(currentCharacter.CoordinateX, currentCharacter.CoordinateY);
         //vCharacter.direction = (vCharacter.mCharacter.coordinate.x > vCharacter.mCharacter.target.coordinate.x ? Direction.left : Direction.right);
         vCharacter.direction = Global.mapSearch.GetDirection(vCharacter.mCharacter.coordinate, vCharacter.mCharacter.target.coordinate);
         vCharacter.action    = ActionType.attack;
         App.Model.Master.MSkill skillMaster = vCharacter.mCharacter.currentSkill.master;
         if (!string.IsNullOrEmpty(skillMaster.animation))
         {
             VTile vTile = Global.mapSearch.GetTile(vCharacter.mCharacter.target.coordinate);
             //this.cBattlefield.CreateEffect(skillMaster.animation, vTile.transform);
         }
     };
     if (vCharacter.mCharacter.currentSkill.master.effect.special == SkillEffectSpecial.back_thrust)
     {
         //回马枪
         VTile     currentTile = Global.mapSearch.GetTile(vCharacter.mCharacter.coordinate);
         VTile     targetTile  = Global.mapSearch.GetTile(vCharacter.mCharacter.target.coordinate);
         Direction direction   = Global.mapSearch.GetDirection(targetTile, currentTile);
         VTile     backTile    = Global.mapSearch.GetTile(currentTile, direction);
         if (Global.charactersManager.GetCharacter(backTile.coordinate) != null)
         {
             actionStartEvent();
             return;
         }
         Sequence   sequence   = new Sequence();
         TweenParms tweenParms = new TweenParms()
                                 .Prop("X", backTile.transform.localPosition.x, false)
                                 .Prop("Y", backTile.transform.localPosition.y, false)
                                 .Ease(EaseType.Linear);
         TweenParms tweenParmsTarget = new TweenParms()
                                       .Prop("X", currentTile.transform.localPosition.x, false)
                                       .Prop("Y", currentTile.transform.localPosition.y, false)
                                       .Ease(EaseType.Linear);
         Holoville.HOTween.Core.TweenDelegate.TweenCallback moveComplete = () =>
         {
             vCharacter.mCharacter.coordinate.y        = backTile.coordinate.y;
             vCharacter.mCharacter.coordinate.x        = backTile.coordinate.x;
             vCharacter.mCharacter.target.coordinate.y = currentTile.coordinate.y;
             vCharacter.mCharacter.target.coordinate.x = currentTile.coordinate.x;
             actionStartEvent();
         };
         tweenParms.OnComplete(moveComplete);
         VCharacterBase vTarget = Global.charactersManager.GetVCharacter(vCharacter.mCharacter.target);
         sequence.Insert(0f, HOTween.To(vCharacter, 0.5f, tweenParms));
         sequence.Insert(0f, HOTween.To(vTarget, 0.5f, tweenParmsTarget));
         sequence.Play();
     }
     else
     {
         actionStartEvent();
     }
 }
Exemple #8
0
        public void OnDamage(VCharacterBase vCharacter)
        {
            Manager.BattleCalculateManager  calculateManager  = Global.battleManager.calculateManager;
            Manager.BattleCharactersManager charactersManager = Global.charactersManager;
            MCharacter            mCharacter  = vCharacter.mCharacter;
            MCharacter            targetModel = mCharacter.target;
            VCharacterBase        target      = charactersManager.GetVCharacter(targetModel);
            List <VCharacterBase> characters  = charactersManager.GetTargetCharacters(vCharacter, target, mCharacter.currentSkill.master);
            VTile tile = Global.mapSearch.GetTile(mCharacter.coordinate);

            foreach (VCharacter child in characters)
            {
                MCharacter childModel = child.mCharacter;
                bool       hit        = calculateManager.AttackHitrate(mCharacter, childModel);
                if (!hit)
                {
                    child.SendMessage(CharacterEvent.OnBlock.ToString());
                    continue;
                }
                Model.Battle.MDamageParam arg = new App.Model.Battle.MDamageParam(-calculateManager.Hert(mCharacter, childModel, tile));
                child.SendMessage(CharacterEvent.OnDamage.ToString(), arg);
                if (child.mCharacter.characterId != targetModel.characterId)
                {
                    continue;
                }
                if (mCharacter.currentSkill.master.effect.enemy.time == SkillEffectBegin.enemy_hert)
                {
                    if (mCharacter.currentSkill.master.effect.special == SkillEffectSpecial.vampire)
                    {
                        Model.Master.MStrategy strategy = Cacher.StrategyCacher.Instance.Get(mCharacter.currentSkill.master.effect.enemy.strategys[0]);

                        int addHp = -UnityEngine.Mathf.FloorToInt(arg.value * strategy.hert * 0.01f);
                        Model.Battle.MDamageParam arg2 = new Model.Battle.MDamageParam(addHp);
                        vCharacter.SendMessage(CharacterEvent.OnHealWithoutAction.ToString(), arg2);
                    }
                }
                else if (mCharacter.currentSkill.master.effect.enemy.time == SkillEffectBegin.attack_end)
                {
                    if (mCharacter.currentSkill.master.effect.special == SkillEffectSpecial.status)
                    {
                        int specialValue = mCharacter.currentSkill.master.effect.special_value;
                        if (specialValue > 0 && UnityEngine.Random.Range(0, 50) > specialValue)
                        {
                            continue;
                        }
                        childModel.attackEndEffects.Add(mCharacter.currentSkill.master.effect.enemy);
                    }
                }
            }
        }
Exemple #9
0
 /// <summary>
 /// 动作结束时,判断是否继续进行
 /// </summary>
 public void OnActionComplete()
 {
     Debug.LogError("OnActionComplete");
     if (actionCharacterList.Count > 0)
     {
         VCharacterBase vCharacter = actionCharacterList[0];
         actionCharacterList.RemoveAt(0);
         bool isContinue = ActionStart(vCharacter);
         if (isContinue)
         {
             return;
         }
     }
     Global.battleEvent.ActionEndHandler -= OnActionComplete;
     AppManager.CurrentScene.StartCoroutine(ActionOver());
 }
Exemple #10
0
        /// <summary>
        /// 开始动作
        /// </summary>
        /// <returns><c>true</c>, if start was actioned, <c>false</c> otherwise.</returns>
        /// <param name="vCharacter">Current character.</param>
        private bool ActionStart(VCharacterBase vCharacter)
        {
            Debug.LogError("ActionStart");
            if (vCharacter.mCharacter.hp > 0)
            {
                //目标已死
                if (vCharacter.mCharacter.target.hp == 0)
                {
                    return(false);
                }
                ActionStartRun(vCharacter);
                return(true);
            }
            actionCharacterList.Clear();
            if (Global.charactersManager.IsSameCharacter(vCharacter.mCharacter, currentMCharacter))
            {
                return(true);
            }
            //是否引导攻击
            bool continueAttack = (currentMCharacter.currentSkill.master.effect.special == Model.SkillEffectSpecial.continue_attack);

            if (continueAttack)
            {
                VTile      vTile      = Global.mapSearch.GetTile(currentMCharacter.coordinate);
                MCharacter mCharacter = Global.charactersManager.mCharacters.Find((c) => {
                    if (c.hp == 0)
                    {
                        return(false);
                    }
                    if (Global.charactersManager.IsSameBelong(currentMCharacter.belong, c.belong))
                    {
                        return(false);
                    }
                    bool canAttack = Global.charactersManager.IsInSkillDistance(c.coordinate, vTile.coordinate, currentMCharacter);
                    return(canAttack);
                });
                if (mCharacter != null)
                {
                    Global.battleEvent.ActionEndHandler -= OnActionComplete;
                    VTile tile = Global.mapSearch.GetTile(mCharacter.coordinate);
                    ClickSkillNode(tile.coordinate);
                    return(true);
                }
            }
            return(false);
        }
Exemple #11
0
        public void ClickSkillNode(Vector2Int coordinate)
        {
            MCharacter mCharacter = Global.charactersManager.GetCharacter(coordinate);

            if (mCharacter == null || !Global.charactersManager.IsInSkillDistance(mCharacter, currentMCharacter))
            {
                CharacterReturnNone();
                return;
            }
            bool sameBelong = Global.charactersManager.IsSameBelong(mCharacter.belong, currentMCharacter.belong);
            bool useToEnemy = currentMCharacter.currentSkill.useToEnemy;

            if (!(useToEnemy ^ sameBelong))
            {
                Controller.Dialog.CAlertDialog.Show("belong不对");
                return;
            }
            currentMCharacter.target = mCharacter;
            mCharacter.target        = currentMCharacter;

            VCharacterBase vCharacter = Global.charactersManager.GetVCharacter(mCharacter);

            if (useToEnemy)
            {
                bool forceFirst = (mCharacter.currentSkill != null && mCharacter.currentSkill.master.effect.special == Model.SkillEffectSpecial.force_first);
                if (forceFirst && Global.charactersManager.IsInSkillDistance(currentMCharacter, mCharacter))
                {
                    //先手攻击
                    SetActionCharacterList(vCharacter, currentVCharacter, true);
                }
                else
                {
                    SetActionCharacterList(currentVCharacter, vCharacter, true);
                }
            }
            else
            {
                SetActionCharacterList(currentVCharacter, vCharacter, false);
            }
            this.tilesManager.ClearCurrentTiles();
            Global.battleEvent.DispatchEventOperatingMenu(false);
            Global.battleEvent.DispatchEventCharacterPreview(null);
            battleMode = Model.BattleMode.actioning;
            Global.battleEvent.ActionEndHandler += OnActionComplete;
            OnActionComplete();
        }
        /// <summary>
        /// 获取攻击到的所有敌人
        /// </summary>
        /// <returns>The damage characters.</returns>
        /// <param name="vCharacter">攻击方</param>
        /// <param name="targetView">攻击目标</param>
        /// <param name="skill">Skill.</param>
        public List <VCharacterBase> GetTargetCharacters(VCharacterBase vCharacter, VCharacterBase targetView, Model.Master.MSkill skill)
        {
            Search.TileMap        mapSearch = Global.mapSearch;
            List <VCharacterBase> result    = new List <VCharacterBase>()
            {
                targetView
            };

            if (skill.radiusType == RadiusType.point)
            {
                return(result);
            }
            List <VCharacterBase> characters;

            if (Array.Exists(skill.types, s => s == SkillType.heal))
            {
                characters = vCharacters.FindAll(c => c.hp > 0 &&
                                                 IsSameBelong(c.mCharacter.belong, vCharacter.mCharacter.belong) &&
                                                 !IsSameCharacter(targetView.mCharacter, c.mCharacter));
            }
            else
            {
                characters = vCharacters.FindAll(c => c.hp > 0 &&
                                                 IsSameBelong(c.mCharacter.belong, targetView.mCharacter.belong) &&
                                                 !IsSameCharacter(targetView.mCharacter, c.mCharacter));
            }
            VTile targetTile;

            if (skill.effect.special == SkillEffectSpecial.attack_all_near)
            {
                targetTile = mapSearch.GetTile(vCharacter.mCharacter.coordinate);
            }
            else
            {
                targetTile = mapSearch.GetTile(targetView.mCharacter.coordinate);
            }
            if (skill.radiusType == RadiusType.range)
            {
                foreach (VCharacter child in characters)
                {
                    VTile tile = mapSearch.GetTile(child.mCharacter.coordinate);
                    if (targetTile.coordinate.Equals(tile.coordinate) && mapSearch.GetDistance(targetTile, tile) <= skill.radius)
                    {
                        result.Add(child);
                    }
                }
                bool quantity_plus = skill.effect.special == SkillEffectSpecial.quantity_plus;
                if (quantity_plus)
                {
                    List <VCharacterBase> resultPlus = new List <VCharacterBase>();
                    while (result.Count > 1 && resultPlus.Count < skill.effect.special_value)
                    {
                        int            index    = UnityEngine.Random.Range(1, result.Count - 1);
                        VCharacterBase plusView = result[index];
                        resultPlus.Add(plusView);
                        result.RemoveAt(index);
                    }
                    resultPlus.Add(targetView);
                    return(resultPlus);
                }
            }
            else if (skill.radiusType == RadiusType.direction)
            {
                VTile tile     = mapSearch.GetTile(vCharacter.mCharacter.coordinate);
                int   distance = mapSearch.GetDistance(targetTile, tile);
                if (distance > 1)
                {
                    return(result);
                }
                var direction = mapSearch.GetDirection(tile, targetTile);
                var radius    = skill.radius;
                while (radius-- > 0)
                {
                    tile = mapSearch.GetTile(targetTile, direction);
                    VCharacterBase child = GetCharacter(tile.coordinate, characters);
                    if (child == null)
                    {
                        break;
                    }
                    result.Add(child);
                    targetTile = tile;
                }
            }
            return(result);
        }