123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System;
- namespace YLBattle
- {
- /// <summary>
- /// 战场技能
- /// </summary>
- public partial class BattleManager : IBattleGlobalOper
- {
- /// <summary>
- /// 释放技能
- /// </summary>
- /// <param name="who"></param>
- /// <param name="skillTid"></param>
- /// <param name="_type">0=普攻 1=技能</param>
- /// <param name="triggerParm">触发参数</param>
- public void OnCastBullet(string who, string skillTid, string trg = "", bool ismarktrg = false)
- {
- if (string.IsNullOrEmpty(who) || string.IsNullOrEmpty(skillTid))
- {
- this.Env().DebugHelper().Warning("错误:对象:" + who + "模板id:" + who + "释放技能id:" + skillTid);
- return;
- }
- //Debug.Log(who + " castBullet " + skillTid);
- //this.mBulletModel.OnCastSkill(who, skillTid, trg, ismarktrg);
- }
- /// <summary>
- /// 释放技能 (带动作)
- /// </summary>
- /// <param name="who"></param>
- /// <param name="skillId"></param>
- /// <param name="target"></param>
- public void OnCastSkill(string who, string skillId, bool ismark = false)
- {
- if (skillId == string.Empty || skillId.Trim().Length <= 0)
- {
- return;
- }
- /// 需优化对象创建
- FieldEvent ev = this.Env().EventDisp().MakeEvent(EFieldEventType.EFIELD_EVENT_CASTSKILL);
- ev.PutValue("caster", who);
- ev.PutValue("skill", skillId);
- ev.PutValue("isskill", "true");
- ev.PutValue("ismarktrg", ismark.ToString());
- //LogHelper.Log(who + " skill=" + skillId);
- this.Env().EventDisp().PostEvent(ev);
- }
- /// <summary>
- /// 触发被动技能
- /// </summary>
- /// <param name="triggerType">当前事件类型</param>
- /// <param name="triggerParm">事件参数</param>
- /// <param name="casterId">释放者</param>
- /// <param name="targetIds">受影响ID列</param>
- public void OnTriggerPassiveSkill(int triggerType, string triggerParm = "", string casterId = "", string targetIds = "")
- {
- FieldEvent ev = this.Env().EventDisp().MakeEvent(EFieldEventType.EFIELD_EVENT_PASSIVE);
- ev.PutValue("markType", triggerType.ToString());
- /**
- * caster=单项时为事件当前触发者。
- */
- ev.PutValue("caster", casterId);
- /**
- * targets=所有受影响的角色
- */
- ev.PutValue("targets", targetIds);
- ev.PutValue("parm", triggerParm);
- /**
- * 这里不采用事件,主要是为了解决被动技能可以及时触发,否则如果压栈到事件里,会慢半拍~~
- */
- //------------------------2017-09-04关闭被动技能触发
- //this.Env().mSkillManagerOpr.OnTrigger(ev);
- //
- }
- ///// <summary>
- ///// 对象向目标【释放】技能
- ///// </summary>
- ///// <param name="who">释放者</param>
- ///// <param name="_skillId">技能Id</param>
- //public void OnCastSkillByConsumePower(string who,bool ismark=false)
- //{
- // LogicFighter fighter = this.Env().mLogicFighterOper.FindFighter(who);
- // if (BattleSwitch.IsConsumePower)
- // {
- // ///能量消失
- // fighter.SetProperty(EBattleProperty.NPOWER, 0);
- // }
- // //Debug.LogError(who + " OnCastSkillByConsumePower " + fighter.ManuSkill1());
- // this.OnCastSkill(who, fighter.ManuSkill1(),ismark);
- //}
- /// <summary>
- /// 是否可释放技能
- /// </summary>
- /// <param name="who"></param>
- /// <returns></returns>
- public bool ToCheckCouldCastSkill(string who)
- {
- if (this.mFieldModule.CurrentPoilcy() == null ||
- this.mFieldModule.CurrentPoilcy().Type() != EBattleStaus.EBATTLE_STATUS_FIGHTING)
- {
- return false;
- }
- if (this.mFieldModule.CurrentSubPolicy() != null)
- {
- //己方通过UI释放技能时,待技能释放(bomb)完毕后,才可再次点击,敌方才可以继续轮询
- return false;
- }
- LogicFighter fighter = this.Env().mLogicFighterOper.FindFighter(who);
- if (fighter == null || fighter.IsDead())
- {
- return false;
- }
- List<LogicFighter> targets = this.Env().mLogicFighterOper.FindTeamAliveFighter(fighter.Team() == EBattleTeam.BLUETEAM ? EBattleTeam.REDTEAM : EBattleTeam.BLUETEAM);
- if (targets == null || targets.Count <= 0)
- {
- LogHelper.Log("无法释放技能:" + (fighter.Team() == EBattleTeam.BLUETEAM ? "红对" : "蓝队") + "敌方全部死亡,战斗结束");
- return false;
- }
- if (fighter.GetBuffEffectProperty(EBuffEffect.EBUFF_EFFECT_Silent) != 0)
- {
- return false;
- }
- if (fighter.GetBuffEffectProperty(EBuffEffect.EBUFF_EFFECT_Stun) != 0)
- {
- return false;
- }
- return true;
- }
- #region UI_TipWindow
- /// <summary>
- /// [UI]角色释放必杀技能准备【提示】
- /// </summary>
- /// <param name="who">释放者</param>
- /// <param name="_skillId">技能Id</param>
- public void OnManualSkillTipFromUnity(string who)
- {
- if (!ToCheckCouldCastSkill(who))
- {
- return;
- }
- LogicFighter fighter = this.Env().mLogicFighterOper.FindFighter(who);
- if (BattleSwitch.IsConsumePower)
- {
- if (fighter.RoleType() == 0)
- {
- fighter.SetProperty(EBattleProperty.NPOWER, 0);
- }
- else
- {
- this.Env().BattleBlueTeamSkillPower -= long.Parse(fighter.GetProperty(EBattleProperty.NMAXPOWER).ToString());
- }
- }
- if (fighter.Team() == EBattleTeam.BLUETEAM && this.Env().levelMode != 2 && this.Env().levelMode != 4)
- {
- this.Env().BattleCOMBOPower += this.Env().IncreasePowerByCastSkill;
- }
- this.Env().mBlueSkillFighterId = who;
- }
- #endregion
- #region bullet 实时位置 碰撞事件 死亡
- /// <summary>
- /// [Bullet=>ProjectileBase-Update]修改子弹当前位置
- /// </summary>
- /// <param name="id">子弹实例ID</param>
- /// <param name="pos">坐标</param>
- public void ModifyBulletPostion(string id, Vector3 pos)
- {
- //CBullet bullet = this.mBulletModel.FindBullet(id);
- //if (null == bullet)
- //{
- // return;
- //}
- //bullet.ModifyCurrentPos(pos);
- }
- /// <summary>
- /// [SkillControl.createSkillExplode]子弹碰撞事件
- /// </summary>
- /// <param name="id">子弹实例ID</param>
- /// <param name="target">碰撞到的目标实例ID, 没有则传递string.Empty</param>
- public void OnBulletCollideEvent(string id, string target)
- {
- //CBullet bullet = this.mBulletModel.FindBullet(id);
- //if (null == bullet)
- //{
- // this.Env().DebugHelper().Error("无法查找到指定子弹:" + id);
- // return;
- //}
- //int delay = int.Parse(this.Env().SkillAdapter().GetSkillProperty(bullet.TID(), ESkillProperty.ESKILL_PROPERTY_BOMBTIME));
- //BulletCollideEvent bce = new BulletCollideEvent();
- //bce.id = id;
- //bce.time = this.Env().TimeCenter().Now();
- //bce.bombtime = bce.time + delay;
- //bce.target = target;
- //bce.postion = bullet.CurrentPos();
- //bullet.EnqueueCollideEvent(bce);
- }
- /// <summary>
- /// 标记子弹为消亡状态
- /// </summary>
- /// <param name="id">子弹实例ID</param>
- public void MarkBulletDead(string id)
- {
- //CBullet bullet = this.mBulletModel.FindBullet(id);
- //if (null == bullet)
- //{
- // this.Env().DebugHelper().Warning("无法查找到指定子弹:" + id);
- // return;
- //}
- //this.Env().mBattleGlobalOper.ConfirmSkillBombComplete(bullet.Owner(), bullet.TID());
- //bullet.MarkBulletDead();
- }
- #endregion
- }
- }
|