protected override void Execute(List <ClientEntity> entities) { foreach (var e in entities) { BattleAction action = e.battleAction.value; BattleActionType type = action.type; int id = action.subject; ClientEntity subject = _context.GetEntityWithBattleUnitId(id); switch (type) { case BattleActionType.Move: BattleActionMove battleActionMove = action as BattleActionMove; subject.ReplaceSpeed(battleActionMove.speed); subject.ReplaceDirection(battleActionMove.dir); break; case BattleActionType.Stop: BattleActionStop battleActionStop = action as BattleActionStop; subject.ReplaceSpeed(0); subject.ReplacePosition(battleActionStop.position); break; default: break; } } }
public BattleAction(BattleSequence bs, Player user, Player[] target, BattleActionType type, Spell spell, Item item) { this.user = user; this.target = target; this.type = type; this.spell = spell; this.item = item; this.battleSequence = bs; }
public BattleContext(BattleActionType actionType) : base() { TurnCancel = new AbortStatus(); this.ActionType = actionType; UsageSlot = BattleContext.DEFAULT_ATTACK_SLOT; SkillUsedUp = -1; StrikeLandTiles = new List <Loc>(); actionMsg = ""; GlobalContextStates = new StateCollection <ContextState>(); }
/// <summary> /// 效果内部创建效果应用,递归深度+1 /// </summary> /// <param name="actionType">效果类型</param> /// <param name="actionArg">效果参数1</param> /// <param name="actionArg2">效果参数2</param> /// <param name="sourceData">效果来源</param> /// <param name="owner">所有者</param> /// <param name="target">目标</param> /// <param name="userdata">携带的自定义参数</param> /// <returns>创建的效果</returns> protected BattleAction Create(BattleActionType actionType, int actionArg, int actionArg2, BattleEffectItemData sourceData, BattlePlayer owner, BattlePlayer target, object userdata) { if (depth > MAX_EXCUTE_DEPTH) { return(Create(BattleActionType.None, 0, 0, null, null, null, null)); } BattleAction battleAction = CreateNew(actionType, actionArg, actionArg2, sourceData, owner, target, userdata); //StackTrace st = new StackTrace(); //执行深度 battleAction.depth = depth + 1; return(battleAction); }
/// <summary> /// 计算战斗数据 /// </summary> private void CalcBattle(CombatVariable atkVal, CombatVariable defVal) { CombatUnit atker = GetCombatUnit(atkVal.position); BattleActionType actionType = GetBattleActionType(atker.weaponType); BattleAction action; if (!m_BattleActionDict.TryGetValue(actionType, out action)) { Debug.LogErrorFormat( "Combat -> StartBattle: BattleActionType.{0} is not found, check the code.", actionType.ToString()); return; } CombatStep step = action.CalcBattle(this, atkVal, defVal); // step.message = action.message; steps.Add(step); // 如果战斗没有结束,交换攻击者与防守者 if (!action.IsBattleEnd(this, step.atkVal, step.defVal)) { if (step.defVal.canAtk) { CalcBattle(step.defVal, step.atkVal); } else { // 如果防守方不可反击 defVal = step.defVal; defVal.action = true; if (!action.IsBattleEnd(this, defVal, step.atkVal)) { CalcBattle(step.atkVal, defVal); } } } else { // TODO 如果死亡,播放死亡动画(我把死亡动画忘记了) // if (step.defVal.isDead) 播放死亡动画 } }
/// <summary> /// 创建新效果应用,新的递归深度 /// </summary> /// <param name="actionType">效果类型</param> /// <param name="actionArg">效果参数1</param> /// <param name="actionArg2">效果参数2</param> /// <param name="sourceData">效果来源</param> /// <param name="owner">所有者</param> /// <param name="target">目标</param> /// <param name="userdata">携带的自定义参数</param> /// <returns>创建的效果</returns> public static BattleAction CreateNew(BattleActionType actionType, int actionArg, int actionArg2, BattleEffectItemData sourceData, BattlePlayer owner, BattlePlayer target, object userdata) { if (dicActionType == null) { Init(); } BattleAction battleAction = Activator.CreateInstance(dicActionType[actionType]) as BattleAction; battleAction.actionArg = actionArg; battleAction.actionArg2 = actionArg2; battleAction.sourceData = sourceData; battleAction.owner = owner; battleAction.target = target; battleAction.battleMgr = Game.BattleManager; battleAction.userdata = userdata; //StackTrace st = new StackTrace(); //执行深度 battleAction.depth = 1; return(battleAction); }
public BattleAction(BattleActionType type, Monster switchTo = null) { Type = type; SwitchTo = switchTo; }
public BattleAction() { Type = BattleActionType.None; SwitchTo = null; WhichMove = -1; }
public BattleActionBase(BattleActionType battleActionType, TargetType Targets) { this.battleActionType = battleActionType; this.Targets = Targets; }
/// <summary> /// 游戏逻辑里面的效果实现 /// </summary> public void ApplyAction(BattleActionType actionType, int actionArg, int actionArg2 = 0) { ApplyAction((int)actionType, actionArg, actionArg2, null, this, this, null); }