public void Damage(int power, DamageMode mode = DamageMode.NotKill) { if (this.hp <= 0) { return; } hp = hp - power; mOnDamage.OnNext(power); if (this.hp <= 0) { this.hp = 0; } if (mode == DamageMode.NotKill && this.hp <= 0) { this.hp = 1; } if (this.hp <= 0) { mOnDie.OnNext(power); } }
public Spike(Node parent) { this.parent = parent; spikeActivated = true; damageMultiplier = 1f; pushBack = new Toggle <float>(10f, true); stunSeconds = new Toggle <float>(1f, true); damageMode = DamageMode.Players; }
public override void Deserialize(NetworkReader reader) { this.mode = (DamageMode)reader.ReadByte(); this.callDamage = (this.mode & DamageMode.CallDamage) > DamageMode.None; this.callHitEnemy = (this.mode & DamageMode.CallHitEnemy) > DamageMode.None; this.callHitWorld = (this.mode & DamageMode.CallHitWorld) > DamageMode.None; this.target = reader.ReadHurtBoxReference().ResolveHurtBox(); this.damage = ReadDamageInfo(reader); }
/// <summary> /// 减益状态收到伤害 /// </summary> /// <param name="Damage">伤害量</param> /// <param name="source">伤害来源</param> /// <param name="damageMode">伤害类型</param> public void BeDamageOverBuff(int Damage, Buff source, DamageMode damageMode) { if (OnBeingDamageByBuff != null) { DamageBuffEventArgs e = new DamageBuffEventArgs(damageMode, Damage, source); OnBeingDamageByBuff(this, e); Damage = e.Damage; damageMode = e.DamageMode; } //扣血 owner.Abilities.HP.Value -= Damage; }
CreatDamageMode(DamageMode modo) { if (!cache.ContainsKey(modo.ToString())) //命名空间 { string classNameSpace = typeof(SelectorFactory).Namespace; //类名 string attackTypeName = string.Format("{0}AttackMode", modo.ToString()); //反射需要的命名空+类名 attackTypeName = classNameSpace + "." + attackTypeName; //通过反射获取类型 cache.Add(modo.ToString(), Activator.CreateInstance(Type.GetType(attackTypeName)) as ISelectAttackMode); } return(cache[modo.ToString()]); }
public DamageEventArgs(int damage, T source, DamageMode damageMode, int HitValue, Vector3 AttackDiration, Vector3 AttackPosition, bool StrongGPImmuse, bool DamageRateImmuse, bool DownDamage) { h += hd; h(null, null); this.Damage = damage; this.source = source; this.DamageMode = damageMode; this.HitValue = HitValue; this.attackDiration = AttackDiration; this.attackPosition = AttackPosition; this.strongGPImmuse = StrongGPImmuse; this.damageRateImmuse = DamageRateImmuse; cancel = false; this.DownDamage = DownDamage; }
/// <summary> /// 攻击受到技能伤害 /// </summary> /// <param name="Damage">伤害量(初始值)</param> /// <param name="damageMode">伤害类型</param> /// <param name="source">伤害来源</param> /// <param name="HitValue">硬直量</param> /// <param name="AttackDiration">攻击方向,为0向量时为没有攻击方向,该向量为0向量判定为没有攻击方向</param> /// <param name="AttackPosition">攻击身位,自身中心为原点,该向量出现float.NaN判定为没有攻击身位的技能</param> /// <param name="StrongGPImmuse">是否无视强护甲,无视时,即便强护甲为负数带来的增伤也会无视</param> /// <param name="DamageRateImmuse">是否无视收到伤害按比例增加/减少机制</param> public void BeDamageBySkill(int Damage, Skill source, DamageMode damageMode, int HitValue, Vector3 AttackDiration, Vector3 AttackPosition, bool DownDamage = false, bool StrongGPImmuse = false, bool DamageRateImmuse = false) { DamageInfo <Skill> info = new DamageInfo <Skill>(); info.Damage = Damage; info.source = source; info.damageMode = damageMode; info.HitValue = HitValue; info.AttackDirection = AttackDiration; info.AttackPosition = AttackPosition; info.DownDamage = DownDamage; info.StrongGPImmuse = StrongGPImmuse; info.DamageRateImmuse = DamageRateImmuse; BeDamageBySkill(info); }
public static IAttackSelector CreateSelector(DamageMode mode) { //没有缓存则创建 if (!cache.ContainsKey(mode.ToString())) { var nameSpace = typeof(SelectorFactory).Namespace; string classFullName = string.Format("{0}AttackSelector", mode.ToString()); if (!String.IsNullOrEmpty(nameSpace)) { classFullName = nameSpace + "." + classFullName; } Type type = Type.GetType(classFullName); cache.Add(mode.ToString(), Activator.CreateInstance(type) as IAttackSelector); } //从缓存中取得创建好的选择器对象 return(cache[mode.ToString()]); }
public override void Serialize(NetworkWriter writer) { this.mode = DamageMode.None; if (this.callDamage) { this.mode |= DamageMode.CallDamage; } if (this.callHitEnemy) { this.mode |= DamageMode.CallHitEnemy; } if (this.callHitWorld) { this.mode |= DamageMode.CallHitWorld; } writer.Write((Byte)this.mode); HurtBoxReference.FromHurtBox(this.target).Write(writer); Write(writer, this.damage); }
public DamageBuffEventArgs(DamageMode mode, int Damage, Buff Source) { DamageMode = mode; this.Damage = Damage; this.Source = Source; }
private void DrawWeaponProperties() { EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); FireMode fireMode = (FireMode)EditorGUILayout.EnumPopup("Fire Mode", m_Target.fireMode); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Fire Mode"); m_Target.fireMode = fireMode; } EditorGUI.BeginChangeCheck(); ReloadStyle reloadStyle = (ReloadStyle)EditorGUILayout.EnumPopup("Reload Style", m_Target.reloadStyle); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Reload Style"); m_Target.reloadStyle = reloadStyle; } EditorGUI.BeginChangeCheck(); LayerMask cullingMask = EditorTools.LayerMaskField("Culling Mask", m_Target.cullingMask); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Culling Mask"); m_Target.cullingMask = cullingMask; } EditorGUI.BeginChangeCheck(); float fireRate = EditorGUILayout.FloatField("Fire Rate", m_Target.fireRate); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Fire Rate"); m_Target.fireRate = fireRate; } EditorGUI.BeginChangeCheck(); float shotForce = EditorGUILayout.FloatField("Force", m_Target.shotForce); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Fire Force"); m_Target.shotForce = shotForce; } EditorGUI.BeginChangeCheck(); float range = EditorGUILayout.FloatField("Range", m_Target.range); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Fire Range"); m_Target.range = range; } EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); DamageMode damageMode = (DamageMode)EditorGUILayout.EnumPopup("Damage Mode", m_Target.damageMode); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Damage Mode"); m_Target.damageMode = damageMode; } EditorGUILayout.LabelField("Weapon Damage"); EditorGUILayout.BeginHorizontal("box"); EditorGUILayout.BeginHorizontal("TextArea"); GUILayout.Label("Min: " + m_Target.minDamage.ToString("F0")); EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); float minDamage = m_Target.minDamage; float maxDamage = m_Target.maxDamage; EditorGUILayout.MinMaxSlider(ref minDamage, ref maxDamage, 0, 100); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Min/Max Weapon Damage"); m_Target.minDamage = minDamage; m_Target.maxDamage = maxDamage; } EditorGUILayout.BeginHorizontal("TextArea"); GUILayout.Label("Max: " + m_Target.maxDamage.ToString("F0")); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); bool infiniteAmmo = EditorGUILayout.Toggle("Infine Ammo", m_Target.infiniteAmmo); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Disabe/Enable Infine Ammo"); m_Target.infiniteAmmo = infiniteAmmo; } if (m_Target.fireMode == FireMode.ShotgunAuto || m_Target.fireMode == FireMode.ShotgunSemi) { EditorGUI.BeginChangeCheck(); int pelletCount = EditorGUILayout.IntField("Bullets per Shot", m_Target.pelletCount); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Bullets per Shot"); m_Target.pelletCount = pelletCount; } } else if (m_Target.fireMode == FireMode.Burst) { EditorGUI.BeginChangeCheck(); int burstCount = EditorGUILayout.IntField("Burst Shot", m_Target.burstCount); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Burst Shot"); m_Target.burstCount = burstCount; } } EditorGUI.BeginChangeCheck(); int magazineSize = EditorGUILayout.IntField("Bullets per Mag", m_Target.magazineSize); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Bullets per Mag"); m_Target.magazineSize = magazineSize; } EditorGUI.BeginChangeCheck(); int numberOfMags = EditorGUILayout.IntField("Number of Mags", m_Target.numberOfMags); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Number of Mags"); m_Target.numberOfMags = numberOfMags; } EditorGUI.BeginChangeCheck(); int maxNumberOfMags = EditorGUILayout.IntField("Max Number of Mags", m_Target.maxNumberOfMags); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Max Number of Mags"); m_Target.maxNumberOfMags = maxNumberOfMags; } }