public void ReportDeath(CharacterBuildScript build) { if(build.networkView.isMine) //we only report scores for our own player { networkView.RPC("AddDeath", RPCMode.Server, build.build.owner); //GetPlayerScore(build.build.owner).deaths++; Targetable playerHit = build.GetComponent<Targetable>(); if(!playerHit) { Debug.LogError("There is no Targetable on this player to report a score for"); return; } HitStruct lastHit = new HitStruct(-1f); List<HitStruct> hits = playerHit.GetHits(GameSettings.hitAddsToScoreTime); foreach(HitStruct hit in hits) { if(hit.timestamp > lastHit.timestamp) lastHit = hit; } //apply kill/assist points appropriately to all players that had hit the dead player foreach(HitStruct hit in hits) { if(hit.attacker == lastHit.attacker) networkView.RPC("AddKill", RPCMode.Server, lastHit.attacker.build.owner); //GetPlayerScore(lastHit.attacker.build.owner).kills++; else networkView.RPC("AddAssist", RPCMode.Server, hit.attacker.build.owner); //GetPlayerScore(hit.attacker.build.owner).assists++; } } }
HitStruct GetMostRecentHit(CharacterBuildScript player) { HitStruct mostRecent = new HitStruct(-1); foreach(HitStruct hit in hits) { if(hit.attacker == player && hit.timestamp > mostRecent.timestamp) mostRecent = hit; } return mostRecent; }
public static void CreateHPChanger(EntityBase from, EntityBase to, HitStruct hs) { GameObject child = EffectGet("Game/UI/HPChanger"); child.SetParentNormal(GameNode.m_HP); child.GetComponent <HPChanger>().Init(to, hs); if ((((from != null) && from.IsSelf) && (hs.type == HitType.Crit)) && ((hs.sourcetype == HitSourceType.eBullet) || (hs.sourcetype == HitSourceType.eBody))) { GameNode.CameraShake(CameraShakeType.Crit); } }
private static HitStruct GetReboundHitStruct(EntityBase source, HitStruct hs) { int soundid = 0; return(GetHitStruct(source, hs.before_hit, HitType.Rebound, null, hs.sourcetype, EElementType.eNone, 0, soundid)); }
private void OnEntityHittedOnce(HitStruct data) { if ((((base.m_Entity != null) && !base.m_Entity.GetIsDead()) && (base.m_Entity.Type != EntityType.Baby)) && (!base.m_Entity.m_EntityData.GetCanShieldCount() || (data.before_hit >= 0L))) { bool bulletthrough = false; float bulletangle = 0f; if ((data.bulletdata != null) && (data.bulletdata.weapon != null)) { bulletthrough = data.bulletdata.weapon.bThroughEntity; } if ((data.bulletdata != null) && (data.bulletdata.bullet != null)) { bulletangle = data.bulletdata.bullet.transform.eulerAngles.y; } HittedData hittedData = base.m_Entity.GetHittedData(bulletthrough, bulletangle); if (data.type == HitType.Rebound) { data.real_hit = data.before_hit; } else if (data.before_hit >= 0L) { data.real_hit = data.before_hit; } else { if (!hittedData.GetCanHitted()) { return; } switch (data.sourcetype) { case HitSourceType.eBullet: if (((base.m_Entity != null) && (data.bulletdata != null)) && (data.bulletdata.weapon != null)) { float num2 = data.before_hit; num2 *= hittedData.hitratio; if (data.source != null) { float num4 = Vector3.Distance(base.m_Entity.position, data.source.position) / ((float)data.source.m_EntityData.attribute.DistanceAttackValueDis.Value); if (num4 < 1f) { float num5 = (1f - num4) * data.source.m_EntityData.attribute.DistanceAttackValuePercent.Value; num2 *= 1f + num5; } } data.before_hit = (long)num2; data = base.m_Entity.m_EntityData.GetHurt(data); if (data.type != HitType.Rebound) { bool headShot = false; if (!headShot) { headShot = base.m_Entity.m_EntityData.GetHeadShot(); } if (((!headShot && (base.m_Entity.Type != EntityType.Boss)) && ((data.source != null) && (base.m_Entity.m_EntityData.GetHPPercent() < data.source.m_EntityData.attribute.KillMonsterLessHP.Value))) && (GameLogic.Random((float)0f, (float)1f) < data.source.m_EntityData.attribute.KillMonsterLessHPRatio.Value)) { headShot = true; } if (headShot) { data.real_hit = -9223372036854775807L; data.type = HitType.HeadShot; } if (data.source != null) { data.source.m_EntityData.ExcuteHitAdd(); } } break; } return; case HitSourceType.eTrap: data = base.m_Entity.m_EntityData.GetHurt(data); break; case HitSourceType.eBody: data = base.m_Entity.m_EntityData.GetHurt(data); break; case HitSourceType.eBuff: data = base.m_Entity.m_EntityData.GetHurt(data); break; case HitSourceType.eSkill: data = base.m_Entity.m_EntityData.GetHurt(data); break; } } if (data.real_hit == 0L) { if (data.type == HitType.Miss) { GameLogic.CreateHPChanger(data.source, base.m_Entity, data); } } else { if (data.real_hit < 0f) { if (((data.sourcetype == HitSourceType.eBullet) && (data.bulletdata != null)) && ((data.bulletdata.bullet != null) && (data.bulletdata.weapon != null))) { hittedData.AddBackRatio(data.bulletdata.weapon.BackRatio); hittedData.AddBackRatio(base.m_Entity.m_Data.BackRatio); hittedData.SetBullet(data.bulletdata.bullet); hittedData.hittype = data.type; base.m_Entity.SetHitted(hittedData); } if ((((data.sourcetype == HitSourceType.eBullet) || (data.sourcetype == HitSourceType.eTrap)) || (data.sourcetype == HitSourceType.eBody)) && (GameLogic.Hold.BattleData.Challenge_ismainchallenge() && base.m_Entity.IsSelf)) { GameLogic.Hold.BattleData.AddHittedCount(GameLogic.Release.Mode.RoomGenerate.GetCurrentRoomID()); } long shieldHitValue = base.m_Entity.m_EntityData.GetShieldHitValue(-data.real_hit); data.real_hit += shieldHitValue; if (base.m_Entity.OnHitted != null) { base.m_Entity.OnHitted(data.source, data.real_hit); } if (((data.sourcetype == HitSourceType.eBullet) || (data.sourcetype == HitSourceType.eBody)) && (((data.source != null) && (data.real_hit < 0L)) && (data.type != HitType.Rebound))) { int num7 = 0; if (base.m_Entity.m_EntityData.attribute.ReboundHit.Value > 0L) { num7 += (int)base.m_Entity.m_EntityData.attribute.ReboundHit.Value; } if ((base.m_Entity.m_EntityData.attribute.ReboundTargetPercent.Value > 0f) && (data.source.Type != EntityType.Boss)) { num7 += (int)(data.source.m_EntityData.MaxHP * base.m_Entity.m_EntityData.attribute.ReboundTargetPercent.Value); } if (num7 > 0) { data.before_hit = -num7; GameLogic.SendHit_Rebound(data.source, base.m_Entity, data); } } } if ((base.m_Entity.IsSelf && (data.real_hit < 0f)) && ((base.m_Entity.m_EntityData.mDeadRecover > 0) && (base.m_Entity.m_EntityData.CurrentHP <= 10L))) { base.m_Entity.m_EntityData.UseDeadRecover(); } else { if ((GameLogic.Hold.BattleData.Challenge_RecoverHP() && (data.real_hit > 0L)) || (data.real_hit < 0L)) { GameLogic.CreateHPChanger(data.source, base.m_Entity, data); } if (((data.type == HitType.Crit) && (data.source != null)) && (data.source.OnCrit != null)) { data.source.OnCrit(MathDxx.Abs(data.real_hit)); } if (((data.sourcetype == HitSourceType.eBullet) || (data.sourcetype == HitSourceType.eBody)) || ((data.sourcetype == HitSourceType.eSkill) || (data.sourcetype == HitSourceType.eTrap))) { if (data.real_hit < 0L) { base.m_Entity.PlayEffect(base.m_Entity.m_Data.HittedEffectID); } if ((data.real_hit < 0L) && (data.bulletdata != null)) { if ((((data.source != null) && data.source.m_EntityData.GetLight45()) && ((data.bulletdata != null) && (data.bulletdata.bullet != null))) && !data.bulletdata.bullet.GetLight45()) { if (data.source.OnLight45 != null) { data.source.OnLight45(base.m_Entity); } } else { base.m_Entity.PlayEffect(data.bulletdata.weapon.HittedEffectID, base.m_Entity.m_Body.EffectMask.transform.position, Quaternion.Euler(0f, 90f - Utils.getAngle(base.m_Entity.GetHittedDirection()), 0f)); } } base.m_Entity.PlaySound(data.soundid); } if (data.buffid > 0) { base.m_Entity.ChangeHPMust(data.source, data.real_hit); } else { base.m_Entity.ChangeHP(data.source, data.real_hit); } } } } }
public void Init(EntityBase entity, HitStruct hs) { this.mHitType = hs.type; this.curve_pos = GameLogic.GetHPChangerAnimation(this.mHitType, 0); this.curve_scale = GameLogic.GetHPChangerAnimation(this.mHitType, 1); this.curve_alpha = GameLogic.GetHPChangerAnimation(this.mHitType, 2); this.starttime = Updater.AliveTime; this.OffsetX = GameLogic.Random((float)-50f, (float)50f); this.OffsetY = GameLogic.Random((float)0f, (float)30f); this.MovePer.x = this.OffsetX / 14f; this.MovePer.y = this.OffsetY / 14f; this.CurrentMoveCount = 14; this.MoveAll = Vector3.zero; this.m_Entity = entity; this.entitypos = entity.position; this.entitybodypos = entity.m_Body.HPMask.transform.localPosition; if (hs.element != EElementType.eNone) { this.text.set_color(EntityData.ElementData[hs.element].color); this.text.text = hs.real_hit.ToString(); } else { switch (this.mHitType) { case HitType.Crit: { object[] args = new object[] { hs.real_hit }; this.text.text = Utils.FormatString("{0}!", args); this.text.set_color(Color.red); this.text.fontSize = (int)(this.FontSize * this.CritFontScale); return; } case HitType.HeadShot: this.text.text = GameLogic.Hold.Language.GetLanguageByTID("爆头", Array.Empty <object>()); this.text.set_color(Color.red); this.text.fontSize = (int)(this.FontSize * this.HeadShotFontScale); return; case HitType.Add: { object[] args = new object[] { hs.real_hit }; this.text.text = Utils.FormatString("+{0}", args); this.text.set_color(Color.green); return; } case HitType.Block: this.text.text = hs.real_hit.ToString(); this.text.set_color(Color.gray); return; case HitType.Miss: this.text.text = "Miss"; this.text.set_color(Color.yellow); return; case HitType.HPMaxChange: { string languageByTID = GameLogic.Hold.Language.GetLanguageByTID("生命上限", Array.Empty <object>()); object[] args = new object[] { languageByTID, MathDxx.GetSymbolString(hs.real_hit), MathDxx.Abs(hs.real_hit) }; this.text.text = Utils.FormatString("{0}{1}{2}", args); this.text.set_color((hs.real_hit < 0L) ? Color.red : Color.green); return; } } this.text.text = hs.real_hit.ToString(); this.text.set_color(Color.white); this.text.fontSize = this.FontSize; } }