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 virtual void onDie(AttackerAttr killerAttr, ImpactDamageType impactDamageType) { MaterialTableItem material = null; uint materialID = GetMaterialResourceID(); if (materialID != uint.MaxValue) { material = DataManager.MaterialTable[materialID] as MaterialTableItem; } bool operate = false; //根据材质修正尸体的存在时间 if (impactDamageType < ImpactDamageType.Count) { if (material != null) { MaterialItem item = material.items[(int)impactDamageType]; if (item.deatdelay >= 0) { mWaitTime = item.deatdelay; mDisappearTime = 0; operate = true; } } } if (!operate) { mWaitTime = mMaxWaitDisappearTime; mDisappearTime = mMaxDisappearTime; } // 检查击杀的随机事件. BattleUnit killer = killerAttr.CheckedAttackerObject(); // 检查是否是自杀. if (killer != null && InstanceID != killerAttr.AttackerID) { killer.OnKillOther(killerAttr, this); } // 系统回收不触发死亡事件, 自杀依然触发. // 如果凶手通过随机事件杀死this, 那么不触发this的随机事件. if (killerAttr.AttackerID != uint.MaxValue && !killerAttr.StructMadeByRandEvent) { ApplyRandEvent(killer, RandEventTriggerType.OnBeKilled, new OnBeKilledEventArg(killerAttr)); } // 通知skilleffect的清理. SkillDetails.OnSkillEffectOwnerEvent(mSkillEffectManager, SkillEffectOwnerEventDef.OwnerDie); if (material != null && impactDamageType < ImpactDamageType.Count) { MaterialItem item = material.items[(int)impactDamageType]; if (item.mtl) { ////火死亡 if (impactDamageType == ImpactDamageType.Fire) { SetDeathMaterial("burn_out"); } ////毒死亡 if (impactDamageType == ImpactDamageType.Poison) { SetDeathMaterial("poison"); } //冰死亡 if (impactDamageType == ImpactDamageType.Frost) { SetDeathMaterial("iceimpact"); } } } // 死亡特效, 声音, 动作等. // 当所有的效果, 动作都结束时, 开始死亡动作. if (mActionCenter != null) { ErrorHandler.Parse( mActionCenter.StartAction(new ActionDieInitParam() { attackerAttr = killerAttr, damageType = impactDamageType }), "failed to create action die" ); } DieAward(killerAttr.AttackerID); }