/// <summary> /// 加载该随机事件的触发脚本. /// </summary> /// <param name="owner"></param> public void LoadScript(BattleUnit owner, /*const*/ ref AttackerAttr createrAttr) { if (randEventResource.triggerScript != SkillScriptDef.Invalid) { mScript = SkillScriptFactory.Instance.Allocate(randEventResource.triggerScript, owner); do { if (!checkScript(owner, mScript)) { break; } SkillScriptStartArgument argument = new SkillScriptStartArgument() { buffCreaterAttr = createrAttr, buffRes = fromBuffRes, argument_0 = randEventResource.triggerArgument_0, argument_1 = randEventResource.triggerArgument_1, argument_2 = randEventResource.triggerArgument_2 }; if (!mScript.StartScript(argument)) { break; } return; } while (false); ErrorHandler.Parse(ErrorCode.ConfigError, "加载randevent[" + randEventResource.resID + "]附带的脚本失败"); mScript = null; } }
private static bool IsTarget(AttackerAttr attackerAttr, BattleUnit target, LeagueSelection selection) { // 自身不是Ally关系! if (attackerAttr.AttackerID == target.InstanceID) { return((selection & LeagueSelection.Self) != 0); } // 此时, 攻守双方不相同. LeagueRelationship r = GetRelationship(attackerAttr.AttackerLeague, target.GetLeague()); switch (r) { case LeagueRelationship.Ally: return((selection & LeagueSelection.Ally) != 0); case LeagueRelationship.Enemy: return((selection & LeagueSelection.Enemy) != 0 && !target.IsInviolable()); default: break; } return(false); }
protected override void onDamage(DamageInfo damage, AttackerAttr attackerAttr) { if (mRes.bossHpUnit > 0) { int curHp = GetHP() < 0 ? 0 : GetHP(); BossBloodUIManager.Instance.ChangeHp(mRes.name, mRes.headicon, GetLevel(), curHp, GetMaxHP(), mRes.bossHpUnit, IsFury()); } if (mBloodNode != null && !IsDead() && damage.Value < 0) { mBloodNode.Show(); } Vector3 headPos = this.GetBonePositionByName("head"); if (headPos != Vector3.zero) { headPos = CameraController.Instance.WorldToScreenPoint(headPos); headPos.z = 0.0f; BattleUIEvent evt = new BattleUIEvent(BattleUIEvent.BATTLE_UI_DAMAGE); evt.pos = headPos; evt.damage = damage; evt.dead = IsDead(); EventSystem.Instance.PushEvent(evt); } base.onDamage(damage, attackerAttr); }
/// <summary> /// 战斗过程中, 给battleunit添加伤害(伤害值可正可负, 负值表示增血). /// </summary> /// <returns>单位是否依然活着.</returns> public bool AddDamage(DamageInfo damage, AttackerAttr attackerAttr) { if (GetPropertyValue((int)PropertyTypeEnum.PropertyTypeHP) + damage.Value <= 0) { FatalStrikeEventArg fatalStrikeArg = new FatalStrikeEventArg(); // 致命一击随机事件. ApplyRandEvent(null, RandEventTriggerType.OnFatalStrike, fatalStrikeArg); if (fatalStrikeArg.BlockThisDamage) { return(true); } } ModifyPropertyValue((int)PropertyTypeEnum.PropertyTypeHP, damage.Value); if (GetHP() <= 0) { Die(attackerAttr, damage.DamageType); //return false; } onDamage(damage, attackerAttr); //return true; return(isAlive()); }
/// <summary> /// 单位受到来自attackerAttr的damage伤害. /// </summary> protected virtual void onDamage(DamageInfo damage, AttackerAttr attackerAttr) { if (damage.Value < 0) { if (mBattleUintAI != null) { mBattleUintAI.OnBeHit(attackerAttr.AttackerID, Mathf.Abs(damage.Value)); } //挨打闪烁 StartTwinkle(); if (kCriticalStrikeEffectID != uint.MaxValue && damage.Critical) { if (isAlive()) { AddEffect(kCriticalStrikeEffectID, GameConfig.CriticalStrikeEffectBindPoint); } // 暴击死亡特效不显示. //else // Scene.CreateEffect((int)kCriticalStrikeEffectID, Vector3.one, GetPosition(), GetDirection()); } } Scene.onDamage(this, damage, attackerAttr); }
/// <summary> /// 死亡的前端表现. /// </summary> private void createDeathClientBehaviour(ImpactDamageType damageType, AttackerAttr killerAttr) { // 材质死亡(特效). ErrorHandler.Parse( mOwner.AddMaterialBehaviour(MaterialBehaviourDef.OnMaterialDie, damageType, killerAttr.EffectStartDirection), "failed to add death material effect" ); // 死亡动作. MecanimStateController stateControl = mOwner.GetStateController(); AnimatorProperty animSet = stateControl.AnimSet; if (animSet != null && !string.IsNullOrEmpty(mOwner.GetDeathAnimation())) //animSet.NumOfDie > 0) { AnimActionDeath death = AnimActionFactory.Create(AnimActionFactory.E_Type.Death) as AnimActionDeath; death.dieAnim = mOwner.GetDeathAnimation(); if (stateControl.AnimSet != null) { mDieAnimationHashCode = stateControl.AnimSet.GetStateHash(death.dieAnim); } stateControl.DoAction(death); } //mOwner.SetDeathMaterial("dssipate"); //mOwner.SetDeathMaterial("burn_out"); // 死亡声音. if (mOwner.GetDeadSound() != -1) { SoundManager.Instance.Play(mOwner.GetDeadSound()); } }
/// <summary> /// 以目标选择的对象(而不是资源ID)作为参数, 外界可以通过直接构造该对象, 而非从数据表读取, 从而调用该方法. /// </summary> public static ErrorCode SelectTargetAndAddSkillEffect( AttackerAttr attackerAttr, Vector3 centerPosition, float direction, TargetSelectionTableItem targetSelectionRes, uint skillEffectResID, SkillUtilities.FilterTarget filter = null ) { ArrayList targets = SkillUtilities.SelectTargets(attackerAttr, centerPosition, direction, targetSelectionRes); if (filter != null) { SkillUtilities.FilterTargetsBy(targets, filter, null); } foreach (BattleUnit t in targets) { // 设置效果的起始点. attackerAttr.SetEffectStartLocation(centerPosition, Utility.Vector3ToRadian(t.GetPosition() - attackerAttr.EffectStartPosition, direction) ); ErrorHandler.Parse( AddSkillEffectByResource(attackerAttr, t, skillEffectResID), "failed to add skill effect with SelectTargetAndAddSkillEffect" ); } return(ErrorCode.Succeeded); }
protected override void onDamage(DamageInfo damage, AttackerAttr attackerAttr) { if (!mMainPlayer) { int curHp = GetHP() < 0 ? 0 : GetHP(); BossBloodUIManager.Instance.ChangeHp(mGhostData.name, "touxiang:head" + mGhostData.resId.ToString(), GetLevel(), curHp, GetMaxHP(), GetMaxHP(), IsFury()); } Vector3 headPos = this.GetBonePositionByName("head"); if (headPos != Vector3.zero) { headPos = CameraController.Instance.WorldToScreenPoint(headPos); headPos.z = 0.0f; BattleUIEvent evt = new BattleUIEvent(BattleUIEvent.BATTLE_UI_GHOST_DAMAGE); evt.pos = headPos; evt.damage = damage; evt.dead = IsDead(); EventSystem.Instance.PushEvent(evt); } base.onDamage(damage, attackerAttr); }
/// <summary> /// 为target添加技能效果. /// skillEffectResID为skilleffect.txt的资源ID. /// </summary> public static ErrorCode AddSkillEffectByResource(AttackerAttr attackerAttr, BattleUnit target, uint skillEffectResID) { if (skillEffectResID == uint.MaxValue) { return(ErrorCode.Succeeded); } SkillEffectTableItem effectRes = DataManager.SkillEffectTable[skillEffectResID] as SkillEffectTableItem; if (effectRes == null) { SkillUtilities.ResourceNotFound("skilleffect", skillEffectResID); return(ErrorCode.ConfigError); } System.Type T = effectRes.GetType(); for (uint i = 0; i < SkillEffectTableItem.SkillEffectCount; ++i) { SkillEffectItem item = effectRes.items[i]; if (item.effectType == SkillEffectType.Invalid || item.effectID == uint.MaxValue) { break; } ErrorHandler.Parse( target.AddSkillEffect(attackerAttr, item.effectType, item.effectID), "in AddSkillEffectByResource" ); } return(ErrorCode.Succeeded); }
public override void Explode() { ErrorHandler.Parse( SkillDetails.CreateCreationAround(mBullet.FirerAttr, mBullet.CreationOnArrive, mBullet.GetPosition(), mBullet.GetDirection()), "failed to create creature on bullet arrived" ); // 爆炸特效, 仅在子弹到达终点时播放, 即, 子弹没有命中足够的人. if (mBullet.CurrentHittedCount < mBullet.MaxHitCount) { SkillClientBehaviour.AddSceneEffect(mBullet.ExplodeEffect, mBullet.GetPosition(), mBullet.GetDirection()); } // 用碰撞来模拟爆炸, 从而使得技能效果的方向沿着子弹的飞行方向. if (mBullet.TargetSelectionOnArrive != uint.MaxValue && mBullet.SkillEffectOnArrive != uint.MaxValue) { TargetSelectionTableItem targetSel = DataManager.TargetSelectionTable[mBullet.TargetSelectionOnArrive] as TargetSelectionTableItem; ArrayList targets = SkillUtilities.SelectTargets(mBullet.FirerAttr, mBullet.GetPosition(), mBullet.GetDirection(), targetSel); AttackerAttr other = mBullet.FirerAttr; other.SetEffectStartLocation(mBullet.GetPosition(), mBullet.GetDirection()); foreach (BattleUnit t in targets) { SkillDetails.AddSkillEffectByResource(other, t, mBullet.SkillEffectOnArrive); } } }
/// <summary> /// user使用的技能对targetPosition产生skillRes指定的技能效果. /// </summary> public static ErrorCode SkillTakeEffect(BattleUnit user, SkillCommonTableItem skillRes, Vector3 targetPosition) { AttackerAttr attackerAttr = new AttackerAttr(user, (uint)skillRes.resID); if (skillRes.projectileResID != uint.MaxValue) { createProjectiles(user, (uint)skillRes.resID, skillRes.projectileResID, targetPosition); } // 给技能使用者添加的效果. ErrorHandler.Parse( AddSkillEffectByResource(attackerAttr, user, skillRes.skillEffect2UserInUseState) ); // 向前延伸一定距离, 作为目标选择的中心点. Vector3 centerPosition = Utility.MoveVector3Towards(attackerAttr.AttackerPosition, user.GetDirection(), skillRes.distForward); // 在中心点进行目标选择, 并添加技能效果. SelectTargetAndAddSkillEffect(attackerAttr, centerPosition, user.GetDirection(), skillRes.targetSelection, skillRes.skillEffect2Others); // 创建召唤物. ErrorHandler.Parse( CreateCreationAround(attackerAttr, skillRes.creationID, user.GetPosition(), user.GetDirection()) ); return(ErrorCode.Succeeded); }
public override bool StartScript(SkillScriptStartArgument argument) { creationId = (uint)argument.argument_0; createrAttr = argument.buffCreaterAttr; return(true); }
private void OnPreEnterScene(BaseScene scene, uint instanceid) { if (mRes == null) { return; } if (mRes.bossHpUnit > 0) { CameraController.Instance.ShakeCamera(); } // NPC使用自身的属性添加出生buff. AttackerAttr myAttr = new AttackerAttr(this); if (mRes.bornBuff_0 != uint.MaxValue) { ErrorHandler.Parse( AddBornSkillEffect(myAttr, SkillEffectType.Buff, mRes.bornBuff_0), "in Npc::AddBornBuff" ); } if (mRes.bornBuff_1 != uint.MaxValue) { ErrorHandler.Parse( AddBornSkillEffect(myAttr, SkillEffectType.Buff, mRes.bornBuff_1), "in Npc::AddBornBuff" ); } }
/// <summary> /// 当本单位击杀他人时调用. /// </summary> /// <param name="myAttrWhenKill">表示该battleunit在击杀技能发起时的属性.</param> protected virtual void OnKillOther(AttackerAttr myAttrWhenKill, BattleUnit theDead) { // 如果this, 通过随机事件击杀, 那么不触发击杀随机事件. if (!myAttrWhenKill.StructMadeByRandEvent) { ApplyRandEvent(theDead, RandEventTriggerType.OnKillOthers, null); } }
protected override void OnKillOther(AttackerAttr attr, BattleUnit theDead) { base.OnKillOther(attr, theDead); BattleUIEvent evt = new BattleUIEvent(BattleUIEvent.BATTLE_UI_KILL_OTHER); EventSystem.Instance.PushEvent(evt); }
override public bool Init(ObjectInitParam param) { CropsInitParam cropsParam = (CropsInitParam)param; if (!DataManager.NPCTable.ContainsKey(cropsParam.crops_res_id)) { return(false); } mRes = DataManager.NPCTable[cropsParam.crops_res_id] as NPCTableItem; mModelResID = mRes.model; if (!base.Init(param)) { return(false); } resid = mRes.resID; mBattleUintAI = AIFactory.Instance.CreateAIObject(this, mRes.ai); if (mBattleUintAI == null) { return(false); } if (cropsParam.talk_id >= 0) { mTalkID = cropsParam.talk_id; } else { mTalkID = mRes.talkID; } if (cropsParam.league != LeagueDef.InvalidLeague) { SetLeague(cropsParam.league); } else { SetLeague(mRes.league); } mDestroyWaiting = true; mMaxDisappearTime = mRes.DisappearTime; mMaxWaitDisappearTime = mRes.WaitDisappearTime; mSummonerAttr = cropsParam.summonerAttr; InitProperty(cropsParam); if (mRes.bossHpUnit < 0 && mRes.showHp) { mBloodNode = BloodUIManager.Instance.CreateBloodUI(); } GetCrySound(); return(true); }
//死了 protected override void onDie(AttackerAttr killerAttr, ImpactDamageType impactDamageType) { if (mPaoPao != null) { mPaoPao.Hide(); } HideShadow(); base.onDie(killerAttr, impactDamageType); }
public SkillBuffInitParam(BattleUnit owner, AttackerAttr attr, uint buffResID) : base(owner, attr) { buffResource = DataManager.BuffTable[buffResID] as SkillBuffTableItem; if (buffResource == null) { SkillUtilities.ResourceNotFound("buff", buffResID); } }
protected override void onDie(AttackerAttr killerAttr, ImpactDamageType impactDamageType) { if (!mMainPlayer) { BossBloodUIManager.Instance.ChangeHp(mGhostData.name, "touxiang:head" + mGhostData.resId.ToString(), GetLevel(), 0, GetMaxHP(), GetMaxHP(), IsFury()); } base.onDie(killerAttr, impactDamageType); }
public SkillImpactInitParam(BattleUnit owner, AttackerAttr attr, uint impactResID) : base(owner, attr) { impactResource = DataManager.ImpactTable[impactResID] as SkillImpactTableItem; if (impactResource == null) { SkillUtilities.ResourceNotFound("impact", impactResID); } }
public override bool Init(ObjectInitParam param) { if (!base.Init(param)) { return(false); } mBulletParam = (BulletInitParam)param; if ((mBulletResource = DataManager.BulletTable[mBulletParam.resID] as BulletTableItem) == null) { SkillUtilities.ResourceNotFound("bullet", mBulletParam.resID); return(false); } mCreateDelay = mBulletParam.createDelay; mFirerAttr = mBulletParam.firerAttr; FlySpeed = mBulletResource.flySpeed; StartPosition = mBulletParam.startPosition; TargetPosition = mBulletParam.targetPosition; Vector3 dir3d = TargetPosition - StartPosition; dir3d.y = 0; if (dir3d == Vector3.zero) { // 起始点与终点位置重叠, 取开火者当前朝向. BattleUnit firer = mFirerAttr.CheckedAttackerObject(); float alternative = (firer != null) ? firer.GetDirection() : mFirerAttr.AttackerDirection; dir3d = Utility.RadianToVector3(alternative); } FlyDirection = Quaternion.LookRotation(dir3d); SetRotation(FlyDirection); AccelerateDelay = mBulletResource.accelerateDelay; mFlyTargetSelection = new TargetSelectionTableItem() { resID = -1, desc = "bullet hit", leagueSel = mBulletResource.leagueSelection, //maxTargetCount = mBulletResource.flyThroughCount - (uint)mHitted.Count, shape = ShapeType.ShapeType_Rect, RectLength = mBulletResource.radiusOnCollide * 2 }; SetPosition(StartPosition); return(true); }
protected override void onDie(AttackerAttr killerAttr, ImpactDamageType impactDamageType) { base.onDie(killerAttr, impactDamageType); if (mBloodNode != null) { mBloodNode.Hide(); } int xx = GetHP(); Scene.OnCropsDie(); }
protected override void onDie(AttackerAttr attackerAttr, ImpactDamageType impactDamageType) { SkillDetails.SelectTargetAndAddSkillEffect(mSummonerAttr, GetPosition(), GetDirection(), mTrapResource.targetSelectionOnExplode, mTrapResource.skillEffectOnExplode ); SkillClientBehaviour.AddSceneEffect(mTrapResource._3DEffectOnExplode, GetPosition()); base.onDie(attackerAttr, impactDamageType); }
protected override void onDie(AttackerAttr killerAttr, ImpactDamageType impactDamageType) { base.onDie(killerAttr, impactDamageType); mScene.OnMainPlayerDie(); if (mHeadNode != null) { mHeadNode.Hide(); } }
public void Start(BattleUnit owner, ImpactDamageType damageType, AttackerAttr killerAttr) { if (!IsRunning) { IsRunning = true; mOwner = owner; createDeathClientBehaviour(damageType, killerAttr); onStarted(killerAttr); } }
override public bool Init(ObjectInitParam param) { NpcInitParam npcParam = (NpcInitParam)param; if (!DataManager.NPCTable.ContainsKey(npcParam.npc_res_id)) { return(false); } mRes = DataManager.NPCTable[npcParam.npc_res_id] as NPCTableItem; mModelResID = mRes.model; if (!base.Init(param)) { return(false); } mBattleUintAI = AIFactory.Instance.CreateAIObject(this, mRes.ai); if (mBattleUintAI == null) { return(false); } if (npcParam.talk_id >= 0) { mTalkID = npcParam.talk_id; } else { mTalkID = mRes.talkID; } InitTalk(); SetLeague(mRes.league); mDestroyWaiting = true; mMaxDisappearTime = mRes.DisappearTime; mMaxWaitDisappearTime = mRes.WaitDisappearTime; mLifeTime = npcParam.lifeTime; mSummonerAttr = npcParam.summonerAttr; InitProperty(); if (mRes.bossHpUnit < 0 && mRes.showHp) { mBloodNode = BloodUIManager.Instance.CreateBloodUI(); } GetCrySound(); return(true); }
protected override void onDie(AttackerAttr killerAttr, ImpactDamageType impactDamageType) { AnimActionDeath death = AnimActionFactory.Create(AnimActionFactory.E_Type.Death) as AnimActionDeath; death.dieAnim = "Base Layer." + mRes.die_ani; GetStateController().DoAction(death); DisplayDieEffect(); //DestroyBornEffect(); base.onDie(killerAttr, impactDamageType); }
/// <summary> /// 给当前单位添加技能效果. /// </summary> /// <param name="attackerAttr">为this添加技能效果的单位的属性</param> /// <param name="type">效果类型</param> /// <param name="resID">效果ID</param> /// <returns></returns> public ErrorCode AddSkillEffect(AttackerAttr attackerAttr, SkillEffectType type, uint resID) { // 是否死亡. if (IsDead()) { return(ErrorCode.TargetIsDead); } // 由单位的本身类型, 决定的是否免疫给类型的技能效果. if (SkillEffectImmunity(type)) { return(ErrorCode.AddEffectFailedSkillEffectImmunity); } if (SkillUtilities.IsHarmfulEffect(type, resID) && IsInviolable()) { return(ErrorCode.AddEffectFailedSkillEffectImmunity); } ErrorCode err = ErrorCode.ConfigError; switch (type) { case SkillEffectType.Spasticity: #region Pending err = SkillDetails.StartSpasticity(mActionCenter, attackerAttr, resID, ref mSpasticityCd); #endregion Pending break; case SkillEffectType.Displacement: err = SkillDetails.StartDisplace(mActionCenter, attackerAttr, resID); break; case SkillEffectType.Buff: case SkillEffectType.Impact: err = SkillDetails.StartSkillEffect(attackerAttr, mSkillEffectManager, type, resID); break; default: break; } if (err == ErrorCode.Succeeded && type == SkillEffectType.Buff) { onSkillBuffAdded((uint)resID); } return(err); }
public override void onDamage(BattleUnit damageTo, DamageInfo damage, AttackerAttr attackerAttr) { if (damage.Value < 0) { if (string.Compare(damageTo.GetAlias(), "zhaocaimao") != 0) { return; } if (attackerAttr.AttackerID == PlayerController.Instance.GetControlObj().InstanceID) { mDamage -= damage.Value; } } }
/// <summary> /// 添加技能效果. /// </summary> /// <param name="attackerAttr">添加者的属性</param> /// <param name="effectManager">被添加者的技能效果控制器</param> /// <param name="type">效果类型</param> /// <param name="resID">效果ID</param> /// <returns></returns> public static ErrorCode StartSkillEffect(AttackerAttr attackerAttr, SkillEffectManager effectManager, SkillEffectType type, uint resID ) { if (effectManager == null) { return(ErrorCode.LogicError); } SkillEffect effect = null; SkillEffectInitParam param = null; switch (type) { case SkillEffectType.Buff: effect = effectManager.FindSkillEffectByPredicate(new SkillUtilities.FindBuffByResource(resID)); // 存在相同的buff, 进行叠加. if (effect != null) { return((effect as SkillBuff).AddStack()); } // 不存在相同的buff, 创建buff. param = new SkillBuffInitParam(effectManager.Owner, attackerAttr, resID); // 移除所有与新buff互斥的效果. uint mutex = ((SkillBuffInitParam)param).buffResource.mutex; if (mutex != uint.MaxValue) { effectManager.ForEverySkillEffect(new SkillUtilities.KillMutuallyExclusiveSkillBuff(mutex)); } break; case SkillEffectType.Impact: // 创建impact. param = new SkillImpactInitParam(effectManager.Owner, attackerAttr, resID); break; default: ErrorHandler.Parse(ErrorCode.ConfigError, "invalid skilleffect type " + (uint)type); break; } return(effectManager.CreateSkillEffect(param)); }