public void CreateCharacterSkillUsage(string characterId, CharacterSkillUsage characterSkillUsage) { ExecuteNonQuery("INSERT INTO characterskillusage (id, characterId, type, dataId, coolDownRemainsDuration) VALUES (@id, @characterId, @type, @dataId, @coolDownRemainsDuration)", new SqliteParameter("@id", characterId + "_" + characterSkillUsage.type + "_" + characterSkillUsage.dataId), new SqliteParameter("@characterId", characterId), new SqliteParameter("@type", (byte)characterSkillUsage.type), new SqliteParameter("@dataId", characterSkillUsage.dataId), new SqliteParameter("@coolDownRemainsDuration", characterSkillUsage.coolDownRemainsDuration)); }
public void GetObjectData(System.Object obj, SerializationInfo info, StreamingContext context) { CharacterSkillUsage data = (CharacterSkillUsage)obj; info.AddValue("type", (byte)data.type); info.AddValue("dataId", data.dataId); info.AddValue("coolDownRemainsDuration", data.coolDownRemainsDuration); }
public static CharacterSkillUsage Create(SkillUsageType type, int dataId) { CharacterSkillUsage newSkillUsage = new CharacterSkillUsage(); newSkillUsage.type = type; newSkillUsage.dataId = dataId; newSkillUsage.coolDownRemainsDuration = 0f; return(newSkillUsage); }
public System.Object SetObjectData(System.Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { CharacterSkillUsage data = (CharacterSkillUsage)obj; data.type = (SkillUsageType)info.GetByte("type"); data.dataId = info.GetInt32("dataId"); data.coolDownRemainsDuration = info.GetSingle("coolDownRemainsDuration"); obj = data; return(obj); }
private bool ReadCharacterSkillUsage(MySqlDataReader reader, out CharacterSkillUsage result) { if (reader.Read()) { result = new CharacterSkillUsage(); result.type = (SkillUsageType)reader.GetByte(0); result.dataId = reader.GetInt32(1); result.coolDownRemainsDuration = reader.GetFloat(2); return(true); } result = CharacterSkillUsage.Empty; return(false); }
private bool ReadCharacterSkillUsage(MySQLRowsReader reader, out CharacterSkillUsage result, bool resetReader = true) { if (resetReader) { reader.ResetReader(); } if (reader.Read()) { result = new CharacterSkillUsage(); result.type = (SkillUsageType)reader.GetSByte("type"); result.dataId = reader.GetInt32("dataId"); result.coolDownRemainsDuration = reader.GetFloat("coolDownRemainsDuration"); return(true); } result = CharacterSkillUsage.Empty; return(false); }
private IEnumerator UseSkillRoutine( CharacterSkill characterSkill, Vector3 position, float triggerDuration, float totalDuration, SkillAttackType skillAttackType, CharacterItem weapon, DamageInfo damageInfo, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts) { // Update skill usage states var newSkillUsage = CharacterSkillUsage.Create(SkillUsageType.Skill, characterSkill.dataId); newSkillUsage.Use(this, characterSkill.level); skillUsages.Add(newSkillUsage); yield return(new WaitForSecondsRealtime(triggerDuration)); ApplySkill(characterSkill, position, skillAttackType, weapon, damageInfo, allDamageAmounts); yield return(new WaitForSecondsRealtime(totalDuration - triggerDuration)); }
protected virtual void NetFuncUseGuildSkill(int dataId) { if (IsDead()) { return; } GuildSkill guildSkill; if (!GameInstance.GuildSkills.TryGetValue(dataId, out guildSkill) || guildSkill.skillType != GuildSkillType.Active) { return; } GuildData guild; if (GuildId <= 0 || !gameManager.TryGetGuild(GuildId, out guild)) { return; } short level = guild.GetSkillLevel(dataId); if (level <= 0) { return; } if (this.IndexOfSkillUsage(dataId, SkillUsageType.GuildSkill) >= 0) { return; } // Apply guild skill CharacterSkillUsage newSkillUsage = CharacterSkillUsage.Create(SkillUsageType.GuildSkill, dataId); newSkillUsage.Use(this, level); skillUsages.Add(newSkillUsage); ApplyBuff(dataId, BuffType.GuildSkillBuff, level); }
public void CreateCharacterSkillUsage(MySqlConnection connection, MySqlTransaction transaction, string characterId, CharacterSkillUsage characterSkillUsage) { ExecuteNonQuery(connection, transaction, "INSERT INTO characterskillusage (id, characterId, type, dataId, coolDownRemainsDuration) VALUES (@id, @characterId, @type, @dataId, @coolDownRemainsDuration)", new MySqlParameter("@id", characterId + "_" + characterSkillUsage.type + "_" + characterSkillUsage.dataId), new MySqlParameter("@characterId", characterId), new MySqlParameter("@type", (byte)characterSkillUsage.type), new MySqlParameter("@dataId", characterSkillUsage.dataId), new MySqlParameter("@coolDownRemainsDuration", characterSkillUsage.coolDownRemainsDuration)); }
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 static bool IsEmpty(this CharacterSkillUsage data) { return(data == null || data.Equals(CharacterSkillUsage.Empty)); }
private IEnumerator UseSkillRoutine( Skill skill, short level, AnimActionType animActionType, int skillOrWeaponTypeDataId, int animationIndex, float triggerDuration, float totalDuration, bool isLeftHand, CharacterItem weapon, DamageInfo damageInfo, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, bool hasAimPosition, Vector3 aimPosition) { if (onUseSkillRoutine != null) { onUseSkillRoutine.Invoke(skill, level, animActionType, skillOrWeaponTypeDataId, animationIndex, triggerDuration, totalDuration, isLeftHand, weapon, damageInfo, allDamageAmounts, hasAimPosition, aimPosition); } // Set doing action data isCastingSkillCanBeInterrupted = skill.canBeInterruptedWhileCasting; isCastingSkillInterrupted = false; float castDuration = skill.GetCastDuration(level); if (castDuration > 0f) { // Play casting effects on clients RequestPlayEffect(skill.castEffects.Id); // Tell clients that character is casting RequestSkillCasting(skill.DataId, castDuration); yield return(new WaitForSecondsRealtime(castDuration)); } // If skill casting not interrupted, continue doing action if (!isCastingSkillInterrupted || !isCastingSkillCanBeInterrupted) { // Play animation on clients RequestPlayActionAnimation(animActionType, skillOrWeaponTypeDataId, (byte)animationIndex); // Update skill usage states CharacterSkillUsage newSkillUsage = CharacterSkillUsage.Create(SkillUsageType.Skill, skill.DataId); newSkillUsage.Use(this, level); skillUsages.Add(newSkillUsage); yield return(new WaitForSecondsRealtime(triggerDuration)); // Reduce ammo amount if (skill.skillAttackType != SkillAttackType.None) { Dictionary <DamageElement, MinMaxFloat> increaseDamages; ReduceAmmo(weapon, isLeftHand, out increaseDamages); if (increaseDamages != null) { allDamageAmounts = GameDataHelpers.CombineDamages(allDamageAmounts, increaseDamages); } } ApplySkill(skill, level, isLeftHand, weapon, damageInfo, allDamageAmounts, hasAimPosition, aimPosition); yield return(new WaitForSecondsRealtime(totalDuration - triggerDuration)); } isAttackingOrUsingSkill = false; }