public void SetupDamage( IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId, float missileDistance, float missileSpeed, IDamageableEntity lockingTarget) { SetupDamage(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); this.missileDistance = missileDistance; this.missileSpeed.Value = missileSpeed; if (missileDistance <= 0 && missileSpeed <= 0) { // Explode immediately when distance and speed is 0 Explode(); NetworkDestroy(destroyDelay); destroying = true; return; } LockingTarget = lockingTarget; launchTime = Time.unscaledTime; missileDuration = missileDistance / missileSpeed; }
protected virtual void ApplySkill(Skill skill, short level, bool isLeftHand, CharacterItem weapon, DamageInfo damageInfo, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, bool hasAimPosition, Vector3 aimPosition) { // Quit function when on apply skill will override default apply skill functionality if (skill.OnApplySkill(this, level, isLeftHand, weapon, damageInfo, allDamageAmounts, hasAimPosition, aimPosition)) { return; } switch (skill.skillType) { case SkillType.Active: ApplySkillBuff(skill, level); ApplySkillSummon(skill, level); if (skill.skillAttackType != SkillAttackType.None) { CharacterBuff debuff = CharacterBuff.Empty; if (skill.isDebuff) { debuff = CharacterBuff.Create(BuffType.SkillDebuff, skill.DataId, level); } // TODO: some skill type will not able to change aim position by controller if (!hasAimPosition && HasAimPosition) { hasAimPosition = true; aimPosition = AimPosition; } LaunchDamageEntity(isLeftHand, weapon, damageInfo, allDamageAmounts, debuff, skill.hitEffects.Id, hasAimPosition, aimPosition, Vector3.zero); } break; } }
public void CreateCharacterBuff(string characterId, CharacterBuff characterBuff) { ExecuteNonQuery("INSERT INTO characterbuff (id, characterId, type, dataId, level, buffRemainsDuration) VALUES (@id, @characterId, @type, @dataId, @level, @buffRemainsDuration)", new SqliteParameter("@id", characterId + "_" + characterBuff.type + "_" + characterBuff.dataId), new SqliteParameter("@characterId", characterId), new SqliteParameter("@type", (byte)characterBuff.type), new SqliteParameter("@dataId", characterBuff.dataId), new SqliteParameter("@level", characterBuff.level), new SqliteParameter("@buffRemainsDuration", characterBuff.buffRemainsDuration)); }
public static CharacterBuff Create(BuffType type, int dataId, short level = 1) { CharacterBuff newBuff = new CharacterBuff(); newBuff.type = type; newBuff.dataId = dataId; newBuff.level = level; newBuff.buffRemainsDuration = 0f; return(newBuff); }
public void GetObjectData(System.Object obj, SerializationInfo info, StreamingContext context) { CharacterBuff data = (CharacterBuff)obj; info.AddValue("type", (byte)data.type); info.AddValue("dataId", data.dataId); info.AddValue("level", data.level); info.AddValue("buffRemainsDuration", data.buffRemainsDuration); }
public void PushMessagePosition(Transform attach_transform, ICreature creature, string message, eBuffColorType color_type, eTextPushType push_type, float add_position = 0f) { if (creature.IsShowText == false) { return; } TextAnimation ta = Message.Push(attach_transform, creature.TextOffset, message, push_type, 1f, add_position); ta.Text.color = CharacterBuff.GetColor(color_type); }
public virtual void SetupDamage( IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId) { this.attacker = attacker; this.weapon = weapon; this.allDamageAmounts = allDamageAmounts; this.debuff = debuff; this.hitEffectsId = hitEffectsId; }
public void PushMessage(ICreature creature, string message, eBuffColorType color_type, eTextPushType push_type, float add_position = 0f) { if (creature.IsShowText == false) { return; } Transform attach_transform = creature.Character.transform; float scale = attach_transform.GetComponent <Character>().Creature.Scale; TextAnimation ta = Message.Push(attach_transform, creature.TextOffset, message, push_type, scale, add_position); ta.Text.color = CharacterBuff.GetColor(color_type); }
public System.Object SetObjectData(System.Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { CharacterBuff data = (CharacterBuff)obj; data.type = (BuffType)info.GetByte("type"); data.dataId = info.GetInt32("dataId"); data.level = info.GetInt16("level"); data.buffRemainsDuration = info.GetSingle("buffRemainsDuration"); obj = data; return(obj); }
private bool ReadCharacterBuff(SqliteDataReader reader, out CharacterBuff result) { if (reader.Read()) { result = new CharacterBuff(); result.type = (BuffType)reader.GetByte(0); result.dataId = reader.GetInt32(1); result.level = reader.GetInt16(2); result.buffRemainsDuration = reader.GetFloat(3); return(true); } result = CharacterBuff.Empty; return(false); }
private bool ReadCharacterBuff(MySqlDataReader reader, out CharacterBuff result) { if (reader.Read()) { result = new CharacterBuff(); result.id = GenericUtils.GetUniqueId(); result.type = (BuffType)reader.GetByte(0); result.dataId = reader.GetInt32(1); result.level = reader.GetInt16(2); result.buffRemainsDuration = reader.GetFloat(3); return true; } result = CharacterBuff.Empty; return false; }
protected Character(string id, GameObject gameObject) { this.id = id; isDisposed = false; m_gameObject = gameObject; m_transform = gameObject.transform; m_helpTransform = m_transform.Find("help_hp"); hashID = gameObject.GetHashCode().ToString(); gameObject.name = hashID; config = Configs.characterConfig.GetCharacterConfig(id); m_center = new CharacterCenter(); m_move = new CharacterMove(transform); m_buff = new CharacterBuff(center); m_audio = new CharacterAduio(gameObject.AddComponent <AudioSource>()); } // end Character
private bool ReadCharacterBuff(MySQLRowsReader reader, out CharacterBuff result, bool resetReader = true) { if (resetReader) { reader.ResetReader(); } if (reader.Read()) { result = new CharacterBuff(); result.type = (BuffType)reader.GetSByte("type"); result.dataId = reader.GetInt32("dataId"); result.level = (short)reader.GetInt32("level"); result.buffRemainsDuration = reader.GetFloat("buffRemainsDuration"); return(true); } result = CharacterBuff.Empty; return(false); }
void SortBuffs(CharacterBuff character_buff) { float Gap = 26f; Vector3 pos = Vector3.zero; for (int i = 0, index = 0; i < BuffIndicator.transform.childCount; ++i) { var go = BuffIndicator.transform.GetChild(i).gameObject; if (go.activeSelf && (character_buff == null || go != character_buff.gameObject)) { pos.x = (index % 3) * Gap; pos.y = (index / 3) * Gap; go.transform.localPosition = pos; ++index; } } }
public void SetupDamage( BaseCharacterEntity attacker, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, int hitEffectsId, float missileDistance, float missileSpeed) { SetupDamage(attacker, allDamageAmounts, debuff, hitEffectsId); this.missileDistance = missileDistance; this.missileSpeed.Value = missileSpeed; if (missileDistance > 0 && missileSpeed > 0) { NetworkDestroy(missileDistance / missileSpeed); } else { NetworkDestroy(); } }
public void SetupDamage( IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId, float missileDistance, float missileSpeed, IDamageableEntity lockingTarget) { SetupDamage(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); this.missileDistance = missileDistance; this.missileSpeed.Value = missileSpeed; if (missileDistance <= 0 && missileSpeed <= 0) { NetworkDestroy(); return; } LockingTarget = lockingTarget; NetworkDestroy(missileDistance / missileSpeed); }
public virtual void ReceiveDamage(IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId) { if (!IsServer || IsDead()) { return; } if (onReceiveDamage != null) { onReceiveDamage.Invoke(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); } }
public void CreateCharacterBuff(MySqlConnection connection, MySqlTransaction transaction, string characterId, CharacterBuff characterBuff) { ExecuteNonQuery(connection, transaction, "INSERT INTO characterbuff (id, characterId, type, dataId, level, buffRemainsDuration) VALUES (@id, @characterId, @type, @dataId, @level, @buffRemainsDuration)", new MySqlParameter("@id", characterId + "_" + characterBuff.type + "_" + characterBuff.dataId), new MySqlParameter("@characterId", characterId), new MySqlParameter("@type", (byte)characterBuff.type), new MySqlParameter("@dataId", characterBuff.dataId), new MySqlParameter("@level", characterBuff.level), new MySqlParameter("@buffRemainsDuration", characterBuff.buffRemainsDuration)); }
public override void ReceiveDamage(IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId) { if (!IsServer || IsDead() || weapon == null) { return; } base.ReceiveDamage(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); BaseCharacterEntity attackerCharacter = attacker as BaseCharacterEntity; // Play hit effect if (hitEffectsId == 0) { hitEffectsId = gameInstance.DefaultHitEffects.Id; } if (hitEffectsId > 0) { RequestPlayEffect(hitEffectsId); } // Apply damages int totalDamage = 0; Item weaponItem = weapon.GetWeaponItem(); HarvestEffectiveness harvestEffectiveness; WeightedRandomizer <ItemDropByWeight> itemRandomizer; if (harvestable.CacheHarvestEffectivenesses.TryGetValue(weaponItem.weaponType, out harvestEffectiveness) && harvestable.CacheHarvestItems.TryGetValue(weaponItem.weaponType, out itemRandomizer)) { totalDamage = (int)(weaponItem.harvestDamageAmount.GetAmount(weapon.level).Random() * harvestEffectiveness.damageEffectiveness); ItemDropByWeight receivingItem = itemRandomizer.TakeOne(); int dataId = receivingItem.item.DataId; short amount = (short)(receivingItem.amountPerDamage * totalDamage); bool droppingToGround = collectType == HarvestableCollectType.DropToGround; if (attackerCharacter.IncreasingItemsWillOverwhelming(dataId, amount)) { droppingToGround = true; } if (!droppingToGround) { attackerCharacter.IncreaseItems(CharacterItem.Create(dataId, 1, amount)); } else { ItemDropEntity.DropItem(this, CharacterItem.Create(dataId, 1, amount), new uint[0]); } } CurrentHp -= totalDamage; ReceivedDamage(attackerCharacter, CombatAmountType.NormalDamage, totalDamage); if (IsDead()) { CurrentHp = 0; CallNetFunction(NetFuncOnHarvestableDestroy, FunctionReceivers.All); DestroyAndRespawn(); } }
public void ReceiveDamage(IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId) { buildingEntity.ReceiveDamage(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); }
protected void DevExtReceiveDamageDemo(IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId) { if (writeAddonLog) { Debug.Log("[" + name + "] MonsterCharacterEntity.ReceiveDamage(" + attacker.gameObject.name + ", " + weapon + ", " + allDamageAmounts.Count + ", " + debuff + ", " + hitEffectsId + ")"); } }
public void AddBuff(CharacterBuff character_buff) { character_buff.transform.SetParent(BuffIndicator.transform, false); SortBuffs(null); }
public void RemoveBuff(CharacterBuff character_buff) { SortBuffs(character_buff); }
public override void ReceiveDamage(IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId) { if (!IsServer || IsDead() || !CanReceiveDamageFrom(attacker)) { return; } base.ReceiveDamage(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); var attackerCharacter = attacker as BaseCharacterEntity; // If character is not dead, try to attack if (!IsDead()) { BaseCharacterEntity targetEntity; if (!TryGetTargetEntity(out targetEntity)) { // If no target enemy, set target enemy as attacker SetAttackTarget(attackerCharacter); } else if (attackerCharacter != targetEntity && Random.value > 0.5f) { // Random 50% to change target when receive damage from anyone SetAttackTarget(attackerCharacter); } } }
public virtual void ReceiveDamage(IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId) { if (!IsServer || IsDead()) { return; } this.InvokeInstanceDevExtMethods("ReceiveDamage", attacker, weapon, allDamageAmounts, debuff, hitEffectsId); }
public static bool IsEmpty(this CharacterBuff data) { return(data == null || data.Equals(CharacterBuff.Empty)); }
public override void ReceiveDamage(BaseCharacterEntity attacker, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, int hitEffectsId) { // Damage calculations apply at server only if (!IsServer || CurrentHp <= 0) { return; } base.ReceiveDamage(attacker, allDamageAmounts, debuff, hitEffectsId); // If no attacker, skip next logics if (attacker == null || !IsEnemy(attacker)) { return; } // If character isn't dead // If character is not dead, try to attack if (CurrentHp > 0) { var gameInstance = GameInstance.Singleton; // If no target enemy and current target is character, try to attack BaseCharacterEntity targetEntity; if (!TryGetTargetEntity(out targetEntity)) { SetAttackTarget(attacker); // If it's assist character call another character for assist if (MonsterDatabase.characteristic == MonsterCharacteristic.Assist) { var foundObjects = new List <Collider>(Physics.OverlapSphere(CacheTransform.position, MonsterDatabase.visualRange, gameInstance.characterLayer.Mask)); foreach (var foundObject in foundObjects) { var monsterCharacterEntity = foundObject.GetComponent <MonsterCharacterEntity>(); if (monsterCharacterEntity != null && IsAlly(monsterCharacterEntity)) { monsterCharacterEntity.SetAttackTarget(attacker); } } } } else if (attacker != targetEntity && Random.value >= 0.5f) { // Random 50% to change target when receive damage from anyone SetAttackTarget(attacker); } } }
public static T DeserializeCharacterData <T>(this T characterData, NetDataReader reader) where T : IPlayerCharacterData { var tempCharacterData = new PlayerCharacterData(); tempCharacterData.Id = reader.GetString(); tempCharacterData.DataId = reader.GetInt(); tempCharacterData.EntityId = reader.GetInt(); tempCharacterData.CharacterName = reader.GetString(); tempCharacterData.Level = reader.GetShort(); tempCharacterData.Exp = reader.GetInt(); tempCharacterData.CurrentHp = reader.GetInt(); tempCharacterData.CurrentMp = reader.GetInt(); tempCharacterData.CurrentStamina = reader.GetInt(); tempCharacterData.CurrentFood = reader.GetInt(); tempCharacterData.CurrentWater = reader.GetInt(); tempCharacterData.StatPoint = reader.GetShort(); tempCharacterData.SkillPoint = reader.GetShort(); tempCharacterData.Gold = reader.GetInt(); tempCharacterData.PartyId = reader.GetInt(); tempCharacterData.GuildId = reader.GetInt(); tempCharacterData.GuildRole = reader.GetByte(); tempCharacterData.SharedGuildExp = reader.GetInt(); tempCharacterData.CurrentMapName = reader.GetString(); tempCharacterData.CurrentPosition = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat()); tempCharacterData.RespawnMapName = reader.GetString(); tempCharacterData.RespawnPosition = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat()); tempCharacterData.LastUpdate = reader.GetInt(); int count = 0; count = reader.GetByte(); for (var i = 0; i < count; ++i) { var entry = new CharacterAttribute(); entry.Deserialize(reader); tempCharacterData.Attributes.Add(entry); } count = reader.GetByte(); for (var i = 0; i < count; ++i) { var entry = new CharacterBuff(); entry.Deserialize(reader); tempCharacterData.Buffs.Add(entry); } count = reader.GetByte(); for (var i = 0; i < count; ++i) { var entry = new CharacterSkill(); entry.Deserialize(reader); tempCharacterData.Skills.Add(entry); } count = reader.GetByte(); for (var i = 0; i < count; ++i) { var entry = new CharacterSkillUsage(); entry.Deserialize(reader); tempCharacterData.SkillUsages.Add(entry); } count = reader.GetByte(); for (var i = 0; i < count; ++i) { var entry = new CharacterSummon(); entry.Deserialize(reader); tempCharacterData.Summons.Add(entry); } count = reader.GetByte(); for (var i = 0; i < count; ++i) { var entry = new CharacterItem(); entry.Deserialize(reader); tempCharacterData.EquipItems.Add(entry); } count = reader.GetShort(); for (var i = 0; i < count; ++i) { var entry = new CharacterItem(); entry.Deserialize(reader); tempCharacterData.NonEquipItems.Add(entry); } count = reader.GetByte(); for (var i = 0; i < count; ++i) { var entry = new CharacterHotkey(); entry.Deserialize(reader); tempCharacterData.Hotkeys.Add(entry); } count = reader.GetByte(); for (var i = 0; i < count; ++i) { var entry = new CharacterQuest(); entry.Deserialize(reader); tempCharacterData.Quests.Add(entry); } var equipWeapons = new EquipWeapons(); equipWeapons.Deserialize(reader); tempCharacterData.EquipWeapons = equipWeapons; DevExtUtils.InvokeStaticDevExtMethods(ClassType, "DeserializeCharacterData", characterData, reader); tempCharacterData.ValidateCharacterData(); tempCharacterData.CloneTo(characterData); return(characterData); }
public void ReceiveDamage(IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId) { List <DamageElement> keys = new List <DamageElement>(allDamageAmounts.Keys); foreach (DamageElement key in keys) { allDamageAmounts[key] = allDamageAmounts[key] * damageRate; } characterEntity.ReceiveDamageFunction(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); }
public override void ReceiveDamage(IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId) { if (!IsServer || IsDead()) { return; } base.ReceiveDamage(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); // TODO: Reduce current hp }