public override void OnGetBuffEffect() { base.OnGetBuffEffect(); Actor actor = ActorManager.Singleton.Lookup(TargetID); if (null == actor) { Debug.LogWarning("actor is not exist! actor id=" + TargetID.ToString()); return; } BuffInfo info = GameTable.BuffTableAsset.Lookup(BuffID); if (info == null) { Debug.LogWarning("buff is not exist! buff id=" + BuffID.ToString()); return; } IsNeedResultPass = true; if (actor.Type == ActorType.enNPC) {//npc不能潜行 Debug.LogWarning("npc can not sneak"); return; } //开始潜行 actor.StartSneak(BuffID); }
public override void OnRemoved(IResultControl control) { base.OnRemoved(control); Actor actor = ActorManager.Singleton.Lookup(TargetID); if (null == actor) { Debug.LogWarning("OnGetBuffEffect failed! actor is not exist! actor id=" + TargetID.ToString()); return; } BuffInfo info = GameTable.BuffTableAsset.Lookup(BuffID); if (info == null) { Debug.LogWarning("OnGetBuffEffect failed! buff is not exist! buff id=" + BuffID.ToString()); return; } if (actor.Type == ActorType.enNPC) {//此buff效果只对npc生效 foreach (var item in info.BuffResultList) { if (item.ID == (int)ClassID) { switch ((ENFearType)item.ParamList[0]) { case ENFearType.enEscape: { //更改ai actor.SelfAI = m_selfAI; } break; } } } } }
public override void OnGetBuffEffect() { base.OnGetBuffEffect(); BuffInfo info = GameTable.BuffTableAsset.Lookup(BuffID); if (info == null) { Debug.LogWarning("buff is not exist! buff id=" + BuffID.ToString()); return; } FindSneak(true); }
public override void OnGetResult(IResult result, IResultControl control) { base.OnGetResult(result, control); if (result.ClassID == (int)ENResult.Dead) { m_self = ActorManager.Singleton.Lookup(TargetID); if (m_self == null) { Debug.LogWarning("actor is not exist, actor id is " + TargetID); return; } BuffInfo info = GameTable.BuffTableAsset.Lookup(BuffID); if (info == null) { Debug.LogWarning("buff is not exist! buff id=" + BuffID.ToString()); return; } foreach (var item in info.BuffResultList) { if (item.ID == (int)ClassID) { switch ((ENPlagueType)item.ParamList[0]) { case ENPlagueType.enInfect: { m_target = null; ActorManager.Singleton.ForEach(FindFriend); if (m_target != null) { //给友方添加buff IResult r = BattleFactory.Singleton.CreateResult(ENResult.AddBuff, TargetID, m_target.ID, 0, 0, new float[1] { item.ParamList[2] }); if (r != null) { r.ResultExpr(new float[1] { item.ParamList[2] }); BattleFactory.Singleton.DispatchResult(r); } } } break; } } } } }
public override void OnGetBuffEffect() { base.OnGetBuffEffect(); Actor actor = ActorManager.Singleton.Lookup(TargetID); if (null == actor) { Debug.LogWarning("OnGetBuffEffect failed! actor is not exist! actor id=" + TargetID.ToString()); return; } BuffInfo info = GameTable.BuffTableAsset.Lookup(BuffID); if (info == null) { Debug.LogWarning("OnGetBuffEffect failed! buff is not exist! buff id=" + BuffID.ToString()); return; } if (actor.Type == ActorType.enNPC) { //此buff效果只对npc生效 actor.CurrentTarget = null; //重新选择目标 actor.TempType = ActorType.enNPC_AllEnemy; } }
public override void OnGetBuffEffect() { base.OnGetBuffEffect(); BuffInfo info = GameTable.BuffTableAsset.Lookup(BuffID); if (info == null) { Debug.LogWarning("buff is not exist! buff id=" + BuffID.ToString()); return; } foreach (var item in info.BuffResultList) { if (item.ID == (int)ClassID) { switch ((ENPlagueType)item.ParamList[0]) { case ENPlagueType.enInfect: { //给自己添加buff IResult r = BattleFactory.Singleton.CreateResult(ENResult.AddBuff, TargetID, TargetID, 0, 0, new float[1] { item.ParamList[1] }); if (r != null) { r.ResultExpr(new float[1] { item.ParamList[1] }); BattleFactory.Singleton.DispatchResult(r); } } break; } } } IsNeedResultPass = true; }
void NotifySkillSilence(bool isSilence) { Actor actor = ActorManager.Singleton.Lookup(TargetID); if (null == actor) { Debug.LogWarning("actor is not exist! actor id=" + TargetID.ToString()); return; } BuffInfo info = GameTable.BuffTableAsset.Lookup(BuffID); if (info == null) { Debug.LogWarning("buff is not exist! buff id=" + BuffID.ToString()); return; } foreach (var item in info.BuffResultList) { if (item.ID == (int)ClassID) { actor.NotifySkillSilence((int)item.ParamList[0], (int)item.ParamList[1], isSilence); } } }
public void getPlayers(StreamWriter sw) { // Initialize list of Serialized Player List <SerializedPlayer> playerList = new List <SerializedPlayer>(); // Loop over every players foreach (Player player in Main.player.Where(player => player.active).ToArray()) { // Create a serializedPlayer object SerializedPlayer serializedPlayer = new SerializedPlayer(); serializedPlayer.name = player.name; serializedPlayer.health = player.statLife; serializedPlayer.mana = player.statMana; // Create Inventory Map foreach (Item item in player.inventory.Where((item, index) => item.Name != "" && index < 50).ToArray()) { if (item.prefix != 0) { string prefix = PrefixID.GetUniqueKey(item.prefix); prefix = prefix.Replace("Terraria ", "") + " "; serializedPlayer.inventory.Add(prefix + item.Name, item.stack); } else { serializedPlayer.inventory.Add(item.Name, item.stack); } } // Create Ammunitions List foreach (Item item in player.inventory.Where((item, index) => item.Name != "" && index > 53).ToArray()) { serializedPlayer.ammunitions.Add(item.Name, item.stack); } // Create Coins List foreach (Item item in player.inventory.Where((item, index) => item.Name != "" && index > 49 && index < 54).ToArray()) { serializedPlayer.coins.Add(item.Name, item.stack); } // Create Piggy Bank Map foreach (Item item in player.bank.item.Where(item => item.Name != "").ToArray()) { if (item.prefix != 0) { string prefix = PrefixID.GetUniqueKey(item.prefix); prefix = prefix.Replace("Terraria ", "") + " "; serializedPlayer.piggyBank.Add(prefix + item.Name, item.stack); } else { serializedPlayer.piggyBank.Add(item.Name, item.stack); } } // Create Safe Map foreach (Item item in player.bank2.item.Where(item => item.Name != "").ToArray()) { if (item.prefix != 0) { string prefix = PrefixID.GetUniqueKey(item.prefix); prefix = prefix.Replace("Terraria ", "") + " "; serializedPlayer.safe.Add(prefix + item.Name, item.stack); } else { serializedPlayer.safe.Add(item.Name, item.stack); } } // Create Defender Forge Map foreach (Item item in player.bank3.item.Where(item => item.Name != "").ToArray()) { if (item.prefix != 0) { string prefix = PrefixID.GetUniqueKey(item.prefix); prefix = prefix.Replace("Terraria ", "") + " "; serializedPlayer.defenderForge.Add(prefix + item.Name, item.stack); } else { serializedPlayer.defenderForge.Add(item.Name, item.stack); } } // Get List of Armor Items foreach (Item item in player.armor.Where((item, index) => item.Name != "" && index < 3).ToArray()) { Dictionary <string, string> itemInfos = new Dictionary <string, string>(); if (item.prefix != 0) { string prefix = PrefixID.GetUniqueKey(item.prefix); prefix = prefix.Replace("Terraria ", "") + " "; itemInfos.Add("Prefix", prefix); } int index = Array.FindIndex(player.armor, (c => c.Name == item.Name)); if (player.dye[index].Name != "") { itemInfos.Add("Dye", player.dye[index].Name); } serializedPlayer.armor.Add(item.Name, itemInfos); } // Get List of Accessories foreach (Item item in player.armor.Where((item, index) => item.Name != "" && index > 2).ToArray()) { Dictionary <string, string> itemInfos = new Dictionary <string, string>(); if (item.prefix != 0) { string prefix = PrefixID.GetUniqueKey(item.prefix); prefix = prefix.Replace("Terraria ", "") + " "; itemInfos.Add("Prefix", prefix); } int index = Array.FindIndex(player.armor, (c => c.Name == item.Name)); if (player.dye[index].Name != "") { itemInfos.Add("Dye", player.dye[index].Name); } serializedPlayer.accessories.Add(item.Name, itemInfos); } // Create Equipments List foreach (Item item in player.miscEquips.Where(item => item.Name != "").ToArray()) { Dictionary <string, string> itemInfos = new Dictionary <string, string>(); int index = Array.FindIndex(player.miscEquips, (c => c.Name == item.Name)); if (player.miscDyes[index].Name != "") { itemInfos.Add("Dye", player.miscDyes[index].Name); } serializedPlayer.equipments.Add(item.Name, itemInfos); } // Create Buff Map foreach (int buff in player.buffType.Where(buff => buff != 0)) { // Getting the buff Name with some Regex string buffName = BuffID.GetUniqueKey(buff); buffName = buffName.Replace("Terraria ", ""); buffName = Regex.Replace(buffName, "(\\B[A-Z])", " $1"); serializedPlayer.buffs.Add(buffName); } // Add Serialized Player to List playerList.Add(serializedPlayer); } // Convert the list to an array then return it sw.WriteLine(JsonConvert.SerializeObject(playerList)); }