/// <summary> /// 技能触发特效,一个技能对应多个特效 /// </summary> /// <param name="skillID"></param> public void PlaySfx(int skillID) { SkillAction skillData = SkillAction.GetByID(skillID); if (skillData == null) { Debuger.LogError("not exist spell data:" + skillID); return; } // 从技能表中获取 sfx 配置 // 逐个, 按序, 按时触发特效 //key 特效id value 延时启动时间 Dictionary <int, float> sfx = skillData.sfx; SfxHandler cueHandler = theOwner.sfxHandler; if (sfx != null && sfx.Count > 0) { if (!sfxTimerIDDic.ContainsKey(skillID)) { sfxTimerIDDic.Add(skillID, new List <uint>()); } foreach (var pair in sfx) { sfxTimerIDDic[skillID].Add(FrameTimerHeap.AddTimer((uint)(1000 * pair.Value), 0, TriggerCues, cueHandler, pair.Key)); } } return; }
public void Process(EntityParent theOwner, params Object[] args) { if (theOwner is EntityDummy) { theOwner.animator.applyRootMotion = true; } if (args.Length != 1) { Debug.LogError("error spell id"); return; } int spellID = (int)(args[0]); SkillData s = SkillData.dataMap[spellID]; theOwner.motor.speed = 0; theOwner.motor.targetSpeed = 0; int baseTime = 0; for (int i = 0; i < s.skillAction.Count; i++) { SkillAction action = SkillAction.dataMap[s.skillAction[i]]; List <object> args1 = new List <object>(); args1.Add(s.skillAction[0]); args1.Add(theOwner.Transform.localToWorldMatrix); args1.Add(theOwner.Transform.rotation); args1.Add(theOwner.Transform.forward); args1.Add(theOwner.Transform.position); if (i == 0) { ProcessHit(theOwner, spellID, args1); if (theOwner is EntityMyself) { theOwner.motor.enableStick = action.enableStick > 0; } } if (i + 1 == s.skillAction.Count) { break; } uint tid = 0; List <object> args2 = new List <object>(); args2.Add(s.skillAction[i + 1]); args2.Add(theOwner.Transform.localToWorldMatrix); args2.Add(theOwner.Transform.rotation); args2.Add(theOwner.Transform.forward); args2.Add(theOwner.Transform.position); if (action.actionTime > 0) { tid = TimerHeap.AddTimer((uint)((baseTime + action.actionTime) / theOwner.aiRate), 0, ProcessHit, theOwner, spellID, args2); baseTime += action.actionTime; } if (action.nextHitTime > 0) { tid = TimerHeap.AddTimer((uint)((baseTime + action.nextHitTime) / theOwner.aiRate), 0, ProcessHit, theOwner, spellID, args2); baseTime += action.nextHitTime; } theOwner.hitTimer.Add(tid); } }
public CastTask(Skill skill, Unit caster, SkillAction casterAction, BaseUnit target, SkillAction targetAction) : base(skill) { _caster = caster; _casterAction = casterAction; _target = target; _targetAction = targetAction; }
void AttackTo(BaseHero from, BaseHero hero) { from.ReduceHP(expend, true); hero.ReduceHP(attackHP); UnityTools.Log(from.name + " 使用 " + name + " 攻击 " + hero.name + " 造成 " + attackHP + " 点伤害,消耗 " + expend + "点血量"); HeroAction treatAction = new HeroAction(); treatAction.action = HeroActionType.Skill; SkillAction skillAction = new SkillAction(); skillAction.action = SkillActionType.MiniHP; skillAction.args = new object[] { expend }; treatAction.args = new object[] { from, hero, this, skillAction }; from.AddAction(treatAction); HeroAction treatAction1 = new HeroAction(); treatAction1.action = HeroActionType.Skill; SkillAction skillAction1 = new SkillAction(); skillAction1.action = SkillActionType.MiniHP; skillAction1.args = new object[] { attackHP }; treatAction1.args = new object[] { from, hero, this, skillAction1 }; hero.AddAction(treatAction1); }
public void AttackEffect(int hitActionID, Matrix4x4 ltwm, Quaternion rotation, Vector3 forward, Vector3 position) { SkillAction s = SkillAction.dataMap[hitActionID]; List <uint> list = GetHitEntities(hitActionID, ltwm, rotation, forward, position); List <uint> monsterList = new List <uint>(); List <uint> playerList = new List <uint>(); for (int i = 0; i < list.Count; i++) { if (GameWorld.Entities[list[i]].IsDead()) { continue; } if (GameWorld.Entities[list[i]] is EntityMonster) { monsterList.Add(list[i]); } if (GameWorld.Entities[list[i]] is EntityMyself) { playerList.Add(list[i]); } } if (owner is EntityMyself && monsterList.Count > 0) { AttackMonster(hitActionID, monsterList); } if (owner is EntityMonster && playerList.Count > 0) { //TODU怪攻击玩家 AttackMonster(hitActionID, playerList); } }
public void RegisterSkill(SkillAction NewAction, int slot) { //get rid of old skill SkillSlots[slot] -= SkillSlots[slot]; //register new skill SkillSlots[slot] += NewAction; }
protected override void onInit(Unit unit) { mUnit.sendUnitEvent((int)UnitEvent.SkillBegin, null, true); setUnitState(mGS.state, true); if (mGS.pointType != Skill.PointType.None) { mUnit.forward(mUnit.skill.targetPos); } if (!string.IsNullOrEmpty(mGS.anim)) { mUnit.anim.sendEvent(AnimPlugin.PlayAnim, mGS.anim); } for (int i = 0, max = mGS.actions.Count; i < max; ++i) { SkillAction act = mGS.actions[i]; TimeMgr.Action a = timer.AddAction(new TimeMgr.Action()); a.doTime = act.time; a.onAction = onAction; a.userData = act; } state = 1; //lua call if (mGS.lua != null) { mTB.lua = mGS.lua; base.onInit(mUnit); } }
public string GetString() { if (action == null) { return(string.Empty); } StringBuilder info = new StringBuilder(); info.Append("<b><size=45>").Append(action.SkillName).Append("</size></b>").Append("\n"); info.Append(action.Description).Append("\n"); info.Append("<size=30>Range: ").Append(action.Range).Append(" tile(s)\n"); if (action is SkillAction) { SkillAction skillAction = (SkillAction)action; info.Append(skillAction.DamageDescription).Append("\n"); info.Append("Knockback: ").Append(skillAction.KnockbackDescription).Append("\n"); info.Append("Cooldown: ").Append(skillAction.CoolDown).Append(" turn(s) \n"); } if (!action.IsUnlocked()) { info.Append("COST: ").Append(action.ExperiencePointsToUnlocked).Append(" Kills"); } info.Append("</size>"); return(info.ToString()); }
public bool Check(Unit caster, SkillAction casterAction, BaseUnit target, SkillAction targetAction) { var res = true; switch (Kind) { case PlotConditionType.Distance: //var dist = MathUtil.CalculateDistance(caster.Position, target.Position); var dist = 10; res = dist >= Param1 && dist <= Param2; break; case PlotConditionType.BuffTag: // TODO res = target.Effects.CheckBuffs(SkillManager.Instance.GetBuffsByTagId((uint)Param1)); break; case PlotConditionType.Unk6: res = false; //TODO break; case PlotConditionType.Unk7: res = false; //TODO break; } return(NotCondition ? !res : res); }
void AttackTo(BaseHero from, BaseHero hero) { from.ReduceMP(expend); hero.ReduceHP(attackHP); UnityTools.Log(from.name + " 使用 " + name + " 攻击 " + hero.name + " 造成 " + attackHP + " 点伤害,眩晕" + dizzDuration + "毫秒,消耗 " + expend + "点MP"); HeroAction treatAction = new HeroAction(); treatAction.action = HeroActionType.Skill; SkillAction skillAction = new SkillAction(); skillAction.action = SkillActionType.MiniMP; skillAction.args = new object[] { expend }; treatAction.args = new object[] { from, hero, this, skillAction }; from.AddAction(treatAction); HeroAction treatAction1 = new HeroAction(); treatAction1.action = HeroActionType.Skill; SkillAction skillAction1 = new SkillAction(); skillAction1.action = SkillActionType.MiniHP; skillAction1.args = new object[] { attackHP }; treatAction1.args = new object[] { from, hero, this, skillAction1 }; hero.AddAction(treatAction1); Buff buff = new Buff(); buff.type = BuffType.Dizzy; buff.start = now; buff.duration = dizzDuration; hero.AddBuff(buff); }
public override void Execute(SkillAction action, GameObject go) { const float Distance = 5f; // Doesnt do much. If player is trade packing then we want to turn it in. if (isTradepacking) { if ((Mathf.Abs(startLocation.x - transform.position.x) >= Distance) && (Mathf.Abs(startLocation.y - transform.position.y) >= Distance)) { // Check that player still has the pack // if (validPack) { // Valid location to turn in tradepack. Turn in trade pack // Remove pack from player and give reward AddXpToSkill(SkillType.Tradepacking, pack.xp); // } } else { // If it's the same location as start, send player an ugly message that he sucks // They keep tradepack and they can go somewhere else. } } else { // Create tradepack and remove resources if (Inventory.instance.Contains(pack.materials)) { foreach (int id in pack.materials) { Inventory.instance.Contains(id); } isTradepacking = true; } } }
public SCUnitDamagedPacket(CastAction castAction, SkillAction skillAction, uint casterId, uint targetId, int damage) : base(0x0a0, 1) { _castAction = castAction; _skillAction = skillAction; _casterId = casterId; _targetId = targetId; _damage = damage; }
public void NetworkAttack(SkillAction sk) { var cmd = new ObjectCommand(ObjectCommand.ENUM_OBJECT_COMMAND.OC_USE_SKILL); cmd.skillId = sk.SkillId; Log.GUI("Other Player Attack LogicCommand"); gameObject.GetComponent <LogicCommand> ().PushCommand(cmd); }
public SCSkillStartedPacket(uint id, ushort tl, SkillAction caster, SkillAction target, Skill skill) : base(0x09a, 1) { _id = id; _tl = tl; _caster = caster; _target = target; _skill = skill; }
public ApplySkillTask(Skill skill, Unit caster, SkillAction casterAction, BaseUnit target, SkillAction targetAction) { _skill = skill; _caster = caster; _casterAction = casterAction; _target = target; _targetAction = targetAction; }
private void Awake() { button = GetComponent <Button>(); xp = GetComponentInChildren <TextMeshProUGUI>(); unit = GetComponentInParent <Unit>(); action = (SkillAction)unit.ActionsHandler.GetActions()[actionIndex]; experiencePointsToUnlock = action.ExperiencePointsToUnlocked; }
/// <summary> /// 播放特效 /// </summary> protected void AttackingFx(SkillAction skillData) { owner.PlaySfx(skillData.id); if (skillData.cameraTweenId > 0) { ////有震屏,调用震屏接口 TimerHeap.AddTimer <int, float>((uint)(skillData.cameraTweenSL), 0, MogoMainCamera.Instance.Shake, skillData.cameraTweenId, (float)skillData.cameraTweenST / 1000f); } }
public PlotTask(Skill skill, Unit caster, SkillAction casterAction, BaseUnit target, SkillAction targetAction, PlotNextEvent nextEvent) : base(skill) { _caster = caster; _casterAction = casterAction; _target = target; _targetAction = targetAction; _nextEvent = nextEvent; }
private void ProcessHit(EntityParent theOwner, int spellID, List <object> args) { int actionID = (int)args[0]; UnityEngine.Matrix4x4 ltwm = (UnityEngine.Matrix4x4)args[1]; UnityEngine.Quaternion rotation = (UnityEngine.Quaternion)args[2]; UnityEngine.Vector3 forward = (UnityEngine.Vector3)args[3]; UnityEngine.Vector3 position = (UnityEngine.Vector3)args[4]; SkillAction action = SkillAction.dataMap[actionID]; SkillData s = SkillData.dataMap[spellID]; // 回调,基于计时器。 在duration 后切换回 idle 状态 int duration = action.duration; if (duration <= 0 && s.skillAction.Count > 1)// && theOwner.hitActionIdx >= (s.skillAction.Count - 1)) { if (SkillAction.dataMap[s.skillAction[0]].duration <= 0) { theOwner.Actor.AddCallbackInFrames <int, EntityParent>( (_actionID, _theOwner) => { //_theOwner.TriggerUniqEvent<int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID); }, actionID, theOwner); } } else if (duration > 0 && action.action > 0) { TimerHeap.AddTimer <int, EntityParent>( (uint)duration, 0, (_actionID, _theOwner) => { //_theOwner.TriggerUniqEvent<int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID); //_theOwner.ChangeMotionState(MotionState.IDLE); }, actionID, theOwner); } // 回调,基于计时器。 在removeSfxTime 后关闭持久的sfx if (action.duration > 0) { TimerHeap.AddTimer <int, EntityParent>( (uint)action.duration, 0, (_actionID, _theOwner) => { _theOwner.RemoveSfx(_actionID); }, actionID, theOwner); } OnAttacking(actionID, ltwm, rotation, forward, position); }
private static Example.SkillAction ExportSkillAction(SkillAction action, List <Example.SkillAction> actions) { Example.SkillAction skillAction = new Example.SkillAction(); skillAction.actionType = action.actionType; skillAction.StartTime = action.startFrame; skillAction.Duration = action.duration; skillAction.Args = ArrayToList(action.arguments); actions.Add(skillAction); return(skillAction); }
public Skill(string name, SkillIcon icon, SkillAction action, int stamina, int cooldown) { this.Name = name; this.SAction = action; this.Icon = icon; this.Stamina = stamina; this.CooldownDuration = cooldown; this.CooldownTime = 0; SkillManager.Instance.Add(this); }
private void DelayExtraMove(int hitActionID) { SkillAction action = SkillAction.dataMap[hitActionID]; MotorParent theMotor = owner.Motor; float extraSpeed = action.extraSpeed; theMotor.SetExrtaSpeed(extraSpeed); theMotor.SetMoveDirection(owner.transform.forward); TimerHeap.AddTimer <MotorParent>((uint)action.extraSl, 0, (m) => { m.SetExrtaSpeed(0); }, theMotor); }
/// <summary> /// 技能的朝向 /// 攻击目标由服务器决定 /// </summary> /// <param name="skillId"></param> /// <param name="skillLevel"></param> public static void FastUseSkill(int skillId, int skillLevel) { Log.Sys("FastUseSkill: " + skillId + " lev " + skillLevel); var sc = WorldManager.worldManager.GetActive(); if (sc.IsNet && sc.CanFight) { var me = ObjectManager.objectManager.GetMyPlayer(); var pos = me.transform.position; var dir = (int)me.transform.localRotation.eulerAngles.y; /* * var tower = me.GetComponent<TankPhysicComponent>().tower; * if (tower == null) * { * return; * } * var dir = (int)tower.transform.eulerAngles.y; */ var cg = CGPlayerCmd.CreateBuilder(); var skInfo = SkillAction.CreateBuilder(); skInfo.Who = ObjectManager.objectManager.GetMyServerID(); skInfo.SkillId = skillId; skInfo.SkillLevel = skillLevel; var ip = NetworkUtil.ConvertPos(pos); skInfo.X = ip[0]; skInfo.Y = ip[1]; skInfo.Z = ip[2]; skInfo.Dir = dir; /* * if (skillId == 1) * { * var attribute = me.GetComponent<NpcAttribute>(); * skInfo.IsStaticShoot = attribute.GetStaticShootBuff(); * } */ var target = SkillLogic.FindNearestEnemy(me); var targetId = 0; if (target != null) { targetId = target.GetComponent <NpcAttribute>().GetNetView().GetServerID(); } skInfo.Target = targetId; cg.SkillAction = skInfo.Build(); cg.Cmd = "Skill"; //sc.BroadcastMsg(cg); sc.BroadcastKCP(cg); } }
protected void EndAttackAction(SkillAction skillAction) { isCanSkill = true; isSkillPlaying = false; owner.SetAction(0); owner.ClearSkill(); if (owner is EntityMyself) { Mogo.Util.EventDispatcher.TriggerEvent(GUIEvent.START_JOYSTICK_TURN); } }
public void AttackEffect(int hitActionID, Matrix4x4 ltwm, Quaternion rotation, Vector3 forward, Vector3 position) { SkillAction s = SkillAction.dataMap[hitActionID]; if (s.damageFlag == 0) {//等于1才有伤害 return; } // dummyList, MonsterList, PlayerList, MercenaryList List <List <uint> > list = GetHitEntities(hitActionID, ltwm, rotation, forward, position); List <Transform> hitContainers = GetHitContainers(hitActionID); if (list.Count != 4) { return; } if (theOwner is EntityMyself && list[0].Count > 0) { // 客户端导向技能 AttackDummy(hitActionID, list[0]); } if (theOwner is EntityMyself && list[3].Count > 0) { AttackMercenary(hitActionID, list[3]); } if (theOwner is EntityDummy && list[2].Count > 0) { AttackPlayer(hitActionID, list[2]); } if (theOwner is EntityDummy && list[3].Count > 0) { AttackMercenary(hitActionID, list[3]); } if (theOwner is EntityMercenary && theOwner.m_factionFlag > 0 && list[0].Count > 0) { // 客户端导向技能 AttackDummy(hitActionID, list[0]); } if (hitContainers.Count > 0) { AttackContainers(theOwner, hitActionID, hitContainers); } #region 技能触发机关 if (theOwner is EntityDummy && s.triggerEvent != 0) { AttackTriggerGearEvent(s.triggerEvent); } #endregion }
public void useSkill() { if (this.isCding) { return; } SkillAction skillAction = new SkillAction(this._map).init(this._data, this._person); this._person.addAction(skillAction); this._cdTime.reset(); }
private void TryActNext(int currentIndex) { if (nextAction) { return; } if (currentskillActions.Count > 0) { nextAction = currentskillActions.Dequeue(); PlayerAnimator.SetInteger(animaAttackIndexNameHash, currentIndex + 1); } }
public virtual void SetCurrentSkillAction(int index) { if (CurrentSkill == null) { return; } DestroyCurrentSkillAction(); SkillAction currentSkillActionInstance = Instantiate <SkillAction> (SkillActions [index], instantiationPosition, Quaternion.identity); CurrentSkillAction = currentSkillActionInstance; CurrentSkillAction.PlayerCharacter = this; }
public Skill(string name, int cooldown, int range, int castTime, Keys key, bool shouldCastOnCreeps, List<SkillProperty> type, SkillAction action) { Name = name; Cooldown = cooldown; Range = range; Properties = type; Key = key; ShouldCastOnCreeps = shouldCastOnCreeps; SkillCastTime = castTime; AfterSkillUseAction = action; }
public Skill(string name, int cooldown, int range, int castTime, Keys key, bool shouldCastOnCreeps, List <SkillProperty> type, SkillAction action) { Name = name; Cooldown = cooldown; Range = range; Properties = type; Key = key; ShouldCastOnCreeps = shouldCastOnCreeps; SkillCastTime = castTime; AfterSkillUseAction = action; }
public override void Apply(Unit caster, SkillAction casterObj, BaseUnit target, SkillAction targetObj, CastAction castObj, Skill skill, DateTime time) { if (RequireBuffId > 0 && !target.Effects.CheckBuff(RequireBuffId)) { return; //TODO send error? } if (target.Effects.CheckBuffImmune(Id)) { return; //TODO error of immune? } target.Effects.AddEffect(new Effect(target, caster, casterObj, this, skill, time)); }
private void HitBuff(SkillAction action) { if (action.targetAddBuff != null) { foreach (int id in action.targetAddBuff) { theOwner.ClientAddBuff(id); } } if (action.targetDelBuff != null) { foreach (int id in action.targetDelBuff) { theOwner.ClientDelBuff(id); } } }
private void AttackBuff(SkillAction action) { if (action.casterAddBuff != null) { foreach (int id in action.casterAddBuff) { theOwner.ClientAddBuff(id); } } if (action.casterDelBuff != null) { foreach (int id in action.casterDelBuff) { theOwner.ClientDelBuff(id); } } }
private void AttackingMove(SkillAction action) { MogoMotor theMotor = theOwner.motor; if (theMotor == null) { return; } float extraSpeed = action.extraSpeed; if (extraSpeed != 0) { if (action.extraSt <= 0) { theMotor.SetExrtaSpeed(extraSpeed); theMotor.SetMoveDirection(theOwner.Transform.forward); TimerHeap.AddTimer<MogoMotor>((uint)action.extraSl, 0, (m) => { m.SetExrtaSpeed(0); }, theMotor); } else { TimerHeap.AddTimer<int>((uint)action.extraSt, 0, DelayExtraMove, action.id); } } else { theMotor.SetExrtaSpeed(0); } // 是否允许,在技能过程中使用 摇杆改变方向 //if (theOwner is EntityMyself) //{ // theMotor.enableStick = action.enableStick > 0; //} if (action.teleportDistance > 0 && extraSpeed <= 0) { Vector3 dst = Vector3.zero; dst = theOwner.Transform.position + theOwner.Transform.forward * action.teleportDistance; theMotor.TeleportTo(dst); } }
private void AttackingFx(SkillAction action) { if (!MogoWorld.showSkillFx) { return; } // 播放特效 theOwner.PlaySfx(action.id); if (action.cameraTweenId > 0) {//有震屏,调用震屏接口 TimerHeap.AddTimer<int, float>((uint)(action.cameraTweenST * 1000), 0, MogoMainCamera.Instance.Shake, action.cameraTweenId, action.cameraTweenSL); } if (action.sound != "") {//有技能释放音效 //TimerHeap.AddTimer<string>(skill.soundST * 1000, 0, soundplayInterface, skill.sound); } }