protected override void SetCurrent(int amount) { if (amount < min) { Empty(); if (Prependage != null) { int excess = min - amount; Prependage.Subtract(excess); } } else if (amount > max) { Fill(); if (Appendage != null) { int excess = max - amount; Appendage.Add(excess); } } else { current = amount; } }
public void AttachAppendage(Appendage attachment, string linkPointID) { if (!_linkPoints.ContainsKey(linkPointID)) { Debug.LogError($"'{linkPointID}' is not a valid attachment point!"); return; } if (attachment == null) { RemoveAppendage(linkPointID); return; } if (_linkPoints[linkPointID].AttachedItem != null) { RemoveAppendage(linkPointID); } LinkPoint linkPoint = _linkPoints[linkPointID]; attachment.transform.SetParent(linkPoint.transform, false); attachment.transform.localPosition = Vector3.zero; attachment.transform.localRotation = Quaternion.Euler(0, Random.Range(0, 360f), 0); linkPoint.SetAttachedItem(attachment); attachment.OnAttached(_rigidbody); }
void AutoAppendagesButton() { if (GUILayout.Button("Auto Add Appendages (this might take a second)")) { string regexPattern = "\\s\\(\\d.*\\)\\z"; string folderName = Regex.Replace(target.name, regexPattern, ""); if (!AssetDatabase.IsValidFolder(path + "/" + folderName)) { string guid = AssetDatabase.CreateFolder(path, folderName); string folderPath = AssetDatabase.GUIDToAssetPath(guid); Debug.Log("Created: " + folderPath); AutoAddAppendages(); } else if (thisTarget.appendages.Count == 0) { Object[] assets = AssetDatabase.LoadAllAssetsAtPath(folderName); foreach (Object asset in assets) { Appendage newAppendage = thisTarget.gameObject.AddComponent <Appendage>(); newAppendage.baseAppendageData = (AppendageData)asset; int collindex = colliderNames.FindIndex(x => x == newAppendage.baseAppendageData.limbName); newAppendage.collider = colliders[collindex]; thisTarget.appendages.Add(newAppendage); } } } }
public override void Fill() { current = max; if (Appendage != null) { Appendage.Fill(); } }
void OnTriggerEnter(Collider other) { // call stopArrow in this function rather than in the update of the arrow manager. Performance Appendage appendage = AppendageFactory.createAppendage(other.gameObject.name); if (appendage != null) { print(appendage.Damage); ArrowManager.Instance.StopArrow(); } AttachArrow(); }
public void SetPartsData(List <PartsData> parts) { for (int i = 0; i < parts.Count; i++) { Appendage newPart = null; if (!string.IsNullOrEmpty(parts[i].PartID)) { newPart = Instantiate(PartsManager.Instance.GetPartPrefab(parts[i].PartID)); } AttachAppendage(newPart, parts[i].SlotName); } }
//fills in the appendage info given inputs void DealWithAppendage(string appName, AppendageData.AppendageType type, int index) { Appendage newAppendage = thisTarget.gameObject.AddComponent <Appendage>(); newAppendage.baseAppendageData = ScriptableObject.CreateInstance <AppendageData>(); newAppendage.baseAppendageData.limbName = appName; newAppendage.baseAppendageData.appendageType = type; newAppendage.collider = colliders[index]; thisTarget.appendages.Add(newAppendage); AssetDatabase.CreateAsset(newAppendage.baseAppendageData, path + "/" + target.name + "/" + appName + ".asset"); AssetDatabase.SaveAssets(); }
Transform FindBestAppendage(Vector3 inputDirection) { try { List <Appendage> appendages = target.GetComponent <BaseEntity>().appendages; Appendage best = targettedAppendageScript; float boundsSize = Mathf.Max(target.gameObject.GetComponentInChildren <Renderer>().bounds.max.x, target.gameObject.GetComponentInChildren <Renderer>().bounds.max.y, target.gameObject.GetComponentInChildren <Renderer>().bounds.max.z); //max allowed angle + the max possible modified distance (45 + 45) float bestVal = 45 + boundsSize * 45; float angle; float relativeDistance; float value; if (appendages.Count > 1) { for (int i = 0; i < appendages.Count; i++) { if (targettedAppendageScript == appendages[i]) { continue; } angle = Vector3.Angle(inputDirection, appendages[i].collider.transform.position - targettedAppendage.position); relativeDistance = (targettedAppendage.position - appendages[i].collider.transform.position).magnitude / boundsSize; //if they're basically the same part don't allow for change if (relativeDistance < 0.01) { continue; } //distance / boundsSize should be in [0,1], so we want to multiply this so that 1 is roughly the max angle value = angle + 90 * relativeDistance; if (angle < 45 && value < bestVal) { best = appendages[i]; bestVal = value; } } targettedAppendageScript = best; return(best.collider.gameObject.transform); } else { return(null); } } catch { Debug.LogWarning("not implemented"); return(null); } }
public void SetAttachedItem(Appendage attachment) { if (_attachedItem != null) { Destroy(_attachedItem.gameObject); } _attachedItem = attachment; if (_icon != null) { _icon.gameObject.SetActive(_attachedItem != null); } }
void UpdateSprite() { if (Appendages.Count == 0) { Dynamic._sprite = menuIcons; ((Animate) ~Dynamic).ChangeAnimation(ItemInfo.AnimationIndex); } else { Appendage orbAppendage = (Appendage)Dynamic._orbAppendage; orbAppendage.AnchorOffset = new Point(-4, -36); //TODO fix glow position ((Animate)Dynamic._orbAppendage).AsDynamic()._sprite = menuIcons; ((Animate)Dynamic._orbAppendage).ChangeAnimation(ItemInfo.AnimationIndex); } }
public void SetSelectedPart(UIBuildPartIcon part) { if (part == _selectedPart) { part = null; } _selectedPart = part; if (_selectedPart != null) { Appendage newPart = Instantiate(PartsManager.Instance.GetPartPrefab(part.PartID)); Core.Instance.AttachAppendage(newPart, _linkPointID); _partIcon.gameObject.SetActive(true); _partIcon.sprite = newPart.Icon; } else { Core.Instance.RemoveAppendage(_linkPointID); _partIcon.gameObject.SetActive(false); } }
private void Awake() { _instance = this; LinkPoint[] points = GetComponentsInChildren <LinkPoint>(); for (int i = 0; i < points.Length; i++) { _linkPoints.Add(points[i].ID, points[i]); Appendage attached = points[i].GetComponentInChildren <Appendage>(); if (attached != null) { AttachAppendage(attached, points[i].ID); } } if (LevelManager.Instance != null && LevelManager.Instance.PartsList != null) { SetPartsData(LevelManager.Instance.PartsList); } }
void RebuildScreen() { Dynamic.ChangeAnimation(23); var particles = new PassiveBuffSparkleParticleSystem(Level.GCM.TxParticleEnergy, 10); Dynamic._sparkleParticles = particles; ((List <ParticleSystem>)Dynamic._particleSystems).Add(particles); var appendage = new Appendage((Animate)TypedObject, new Point(10, 17), Point.Zero, Level, Dynamic._sprite) { FollowType = EAppendageFollowType.AnchorLocked, AnchorOffset = new Point(0, -25), DrawPriority = 1, IsGlowing = true, GlowBase = 3.5f, }; appendage.AsDynamic().GlowColor = new Color(0.8f, 0.85f, 0.9f, 0.6f); appendage.ChangeAnimation(24); Dynamic._screenAppendage = appendage; ((List <Appendage>)Dynamic._appendages).Add(appendage); var glowTexture = GlowTextureType.CreateInstance(true, Level); var dynamicGlowTexture = glowTexture.AsDynamic(); dynamicGlowTexture.GlowSpriteSheet = Dynamic._sprite; dynamicGlowTexture.FrameIndex = 24; dynamicGlowTexture.GlowCircleCount = 6; dynamicGlowTexture.Center = new Point(TypedObject.Position.X, TypedObject.Position.Y - 36); dynamicGlowTexture.GlowCircleWidth = 32; dynamicGlowTexture.GlowCircleHeight = 32; Dynamic._glowTexture = glowTexture; Dynamic._isUsable = true; }
Transform FindRootBone() { try { BaseEntity targetInfo = target.GetComponent <BaseEntity>(); List <Appendage> appendages = targetInfo.appendages; if (appendages.Count > 0) { targettedAppendageScript = appendages.Find(x => x.baseAppendageData.appendageType == AppendageData.AppendageType.TorsoU); return(targettedAppendageScript.collider.gameObject.transform); } else { return(null); } } catch { Debug.LogWarning("This target is missing appendage information"); return(null); } }
public void _RecvHandler(ProxySocket Socket, uint Serial, NewProxy Proxy, ref MemoryStream Buffer) { Packet Packet = new Packet(Buffer.ToArray()); try { switch ((ServerAction)Packet.Action) { #region Location case ServerAction.Location: { PlayerLocation Loc = Packet.Read <PlayerLocation>(0); Clients[Serial].Aisling.Location.X = Loc.X; Clients[Serial].Aisling.Location.Y = Loc.Y; Clients[Serial].Aisling.LastRefresh = DateTime.Now; } break; #endregion #region Map Info case ServerAction.MapInfo: { MapInfo Info = Packet.Read <MapInfo>(0); Clients[Serial].Aisling.Location.Map = Info.MapNumber; //if (Clients[Serial].Aisling.Map.Number != Info.MapNumber) Clients[Serial].Aisling.Map.Entities.Clear(); Clients[Serial].Aisling.Map.Number = Info.MapNumber; Clients[Serial].Aisling.Map.Width = Info.TileX; Clients[Serial].Aisling.Map.Height = Info.TileY; new System.Threading.Thread(new System.Threading.ThreadStart(Clients[Serial].WaitForMapLoad)).Start(); Clients[Serial].Aisling.LastRefresh = DateTime.Now; } break; #endregion #region Animation case ServerAction.Animation: { string PString = Packet.GetPacketString(Packet.Data); Net.ServerStructs.Animation AnimationStruct = Packet.Read <Net.ServerStructs.Animation>(0); Types.Animation Animation = new Types.Animation(AnimationStruct.ToWho, AnimationStruct.FromWho, AnimationStruct.Number, AnimationStruct.Speed); Clients[Serial].Aisling.Map.Entities[Animation.ToWho].Animations.Add(Animation); if (Clients[Serial].Aisling.Map.Entities[Animation.ToWho].Animations.Count > 30) { Clients[Serial].Aisling.Map.Entities[Animation.ToWho].Animations = new List <Types.Animation>( from var in Clients[Serial].Aisling.Map.Entities[Animation.ToWho].Animations where var.TimeElapsed < new TimeSpan(0, 5, 0) select var ); } if (AnimationStruct.ToWho == Clients[Serial].Aisling.Serial) { Clients[Serial].Aisling.Animations.Add(Animation); } else { if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Animation.ToWho) && Clients[Serial].Aisling.Map.Entities.ContainsKey(Animation.FromWho)) { if (Clients[Serial].Aisling.Map.Entities[Animation.FromWho].EntityType == MapEntity.Type.Player) { if (Clients[Serial].Aisling.Map.Entities[Animation.ToWho].EntityType == MapEntity.Type.Monster) { if (!(Clients[Serial].Aisling.Map.Entities[Animation.FromWho] as AislingEntity).Targets.Contains(Animation.ToWho)) { (Clients[Serial].Aisling.Map.Entities[Animation.FromWho] as AislingEntity).Targets.Add(Animation.ToWho); } } foreach (MapEntity Entity in Clients[Serial].Aisling.Map.FindEntities((MapEntity MapEnt) => MapEnt.EntityType == MapEntity.Type.Monster && MapEnt.Serial == Animation.ToWho)) { (Entity as Monster).Animations.Add(Animation); } (Clients[Serial].Aisling.Map.Entities[Animation.FromWho] as AislingEntity).Targets = new List <uint> ( from var in (Clients[Serial].Aisling.Map.Entities[Animation.FromWho] as AislingEntity).Targets where Clients[Serial].Aisling.Map.Entities.ContainsKey(var) select var ); } } } } break; #endregion #region Skill Slot Info case ServerAction.SkillSlotInfo: { SkillSlotInfo Info = Packet.Read <SkillSlotInfo>(0); if (Info.Slot <= 36) { Clients[Serial].Aisling.TemSkills[(int)(Info.Slot - 1)] = new SkillSlot() { Icon = Info.Icon, Name = Info.Name }; } else if (Info.Slot <= 72) { Clients[Serial].Aisling.MedSkills[(int)(Info.Slot - 37)] = new SkillSlot() { Icon = Info.Icon, Name = Info.Name }; } else if (Info.Slot <= 90) { Clients[Serial].Aisling.WorldSkills[(int)(Info.Slot - 73)] = new SkillSlot() { Icon = Info.Icon, Name = Info.Name }; } } break; #endregion #region Spell Slot Info case ServerAction.SpellSlotInfo: { SpellSlotInfo Info = Packet.Read <SpellSlotInfo>(0); if (Info.Slot <= 36) { Clients[Serial].Aisling.TemSpells[Info.Slot - 1] = new SpellSlot() { Lines = Info.Lines, Name = Info.Name, Prompt = Info.Prompt, TargetType = Info.TargetType }; } else if (Info.Slot <= 72) { Clients[Serial].Aisling.MedSpells[Info.Slot - 37] = new SpellSlot() { Lines = Info.Lines, Name = Info.Name, Prompt = Info.Prompt, TargetType = Info.TargetType }; } else if (Info.Slot <= 90) { Clients[Serial].Aisling.WorldSpells[Info.Slot - 73] = new SpellSlot() { Lines = Info.Lines, Name = Info.Name, Prompt = Info.Prompt, TargetType = Info.TargetType }; } } break; #endregion #region Remove Slot case ServerAction.RemoveItem: { RemoveSlot Info = Packet.Read <RemoveSlot>(0); Clients[Serial].Aisling.Inventory[Info.Slot - 1] = null; } break; case ServerAction.RemoveSpell: { RemoveSlot Info = Packet.Read <RemoveSlot>(0); if (Info.Slot <= 36) { Clients[Serial].Aisling.TemSpells[(int)(Info.Slot - 1)] = null; } else if (Info.Slot <= 72) { Clients[Serial].Aisling.MedSpells[(int)(Info.Slot - 37)] = null; } else if (Info.Slot <= 90) { Clients[Serial].Aisling.WorldSpells[(int)(Info.Slot - 73)] = null; } } break; case ServerAction.RemoveSkill: { RemoveSlot Info = Packet.Read <RemoveSlot>(0); if (Info.Slot <= 36) { Clients[Serial].Aisling.TemSkills[(int)(Info.Slot - 1)] = null; } else if (Info.Slot <= 72) { Clients[Serial].Aisling.MedSkills[(int)(Info.Slot - 37)] = null; } else if (Info.Slot <= 90) { Clients[Serial].Aisling.WorldSkills[(int)(Info.Slot - 73)] = null; } } break; #endregion #region Spell Bar case ServerAction.SpellBar: { PlayerSpellBar PlayerBar = Packet.Read <PlayerSpellBar>(0); Types.SpellBar SpellBar = new SpellBar(PlayerBar.Icon, PlayerBar.Color); if (!Clients[Serial].Aisling.SpellBar.ContainsKey(PlayerBar.Icon)) { Clients[Serial].Aisling.SpellBar.Add(PlayerBar.Icon, SpellBar); } if (SpellBar.Color == PlayerSpellBar.SpellIconColor.Gone) { Clients[Serial].Aisling.SpellBar.Remove(SpellBar.Icon); } } break; #endregion #region Client Walk case ServerAction.ClientWalk: { ClientSpriteWalk WalkingDirection = Packet.Read <ClientSpriteWalk>(0); Clients[Serial].Aisling.Location.AbsX = WalkingDirection.X; Clients[Serial].Aisling.Location.AbsY = WalkingDirection.Y; switch (WalkingDirection.Direction) { case FaceDirection.Down: Clients[Serial].Aisling.Location.AbsY++; break; case FaceDirection.Up: Clients[Serial].Aisling.Location.AbsY--; break; case FaceDirection.Left: Clients[Serial].Aisling.Location.AbsX--; break; case FaceDirection.Right: Clients[Serial].Aisling.Location.AbsX++; break; } Clients[Serial].Aisling.Location.AbsLocation = WalkingDirection.Direction; Clients[Serial].Aisling.LastBattle = DateTime.Now; } break; #endregion #region HPBar Display case ServerAction.DisplayHPBAR: { HPBAR EntityBar = Packet.Read <HPBAR>(0); Console.WriteLine(EntityBar.Percent); if (Clients[Serial].Aisling.Map.Entities.ContainsKey(EntityBar.Serial)) { Clients[Serial].Aisling.Map.Entities[EntityBar.Serial].HPPercent = EntityBar.Percent; } if (EntityBar.Serial == Clients[Serial].Aisling.Serial) { Clients[Serial].HPPercent = EntityBar.Percent; } foreach (MapEntity Entity in Clients[Serial].Aisling.Map.FindEntities((MapEntity MapEnt) => MapEnt.EntityType == MapEntity.Type.Monster && MapEnt.Serial == EntityBar.Serial)) { try { if (EntityBar.Percent < 100) { (Entity as Monster).WasHit = true; } (Clients[Serial].EntityFromSerial(EntityBar.Serial) as Monster).WasPramhed = false; (Clients[Serial].EntityFromSerial(EntityBar.Serial) as Monster).HPPercent = EntityBar.Percent; } catch { } } //if we hit our target, reset hit count to zero if (Clients[Serial].Aisling.testSer == EntityBar.Serial) { Clients[Serial].Aisling.test = 0; //we hit it, so it's not pramhed Clients[Serial].Aisling.Map.Entities[EntityBar.Serial].WasPramhed = false; } } break; #endregion #region Adding Sprites / Monsters / Npcs / Items case ServerAction.AddSprites: { AddSprites Sprites = AddSprites.FromPacket(Packet); foreach (AddSprites.MonsterSprite Monster in Sprites.Monsters) { if (!Clients[Serial].Aisling.Map.Entities.ContainsKey(Monster.Serial)) { Clients[Serial].Aisling.Map.Entities.Add(Monster.Serial, new Monster() { Icon = Monster.Icon, IsPet = Monster.IsPet, HPPercent = 100, Date = DateTime.Now, Location = new Location() { X = Monster.X, Y = Monster.Y, Direction = Monster.Direction, Map = Clients[Serial].Aisling.Location.Map }, Serial = Monster.Serial } ); } } foreach (AddSprites.NPCSprite NPC in Sprites.NPCs) { if (Clients[Serial].Aisling.Map.Entities.ContainsKey(NPC.Serial)) { Clients[Serial].Aisling.Map.Entities.Remove(NPC.Serial); } Clients[Serial].Aisling.Map.Entities.Add(NPC.Serial, new NPC() { Icon = NPC.Icon, Location = new Location() { X = NPC.X, Y = NPC.Y, Direction = NPC.Direction, Map = Clients[Serial].Aisling.Location.Map }, Name = NPC.Name, Serial = NPC.Serial } ); } foreach (AddSprites.ItemSprite Item in Sprites.Items) { if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Item.Serial)) { Clients[Serial].Aisling.Map.Entities.Remove(Item.Serial); } Clients[Serial].Aisling.Map.Entities.Add(Item.Serial, new Item() { Icon = Item.Icon, Location = new Location() { X = Item.X, Y = Item.Y, Direction = (FaceDirection)FaceDirection.Up, Map = Clients[Serial].Aisling.Location.Map, }, Serial = Item.Serial } ); } } break; #endregion #region Adding Players case ServerAction.AddPlayer: { if (Packet.Data[11] == 0x00 && Packet.Data[12] == 0x00 && Packet.Data[13] == 0x00 && Packet.Data[14] == 0x00) { Packet.Data[13] = 0x50; } if (Packet[11] == 0xFF && Packet[12] == 0xFF) { ShowPlayerForm Info = Packet.Read <ShowPlayerForm>(0); if (Packet.Data[11] == 0x00 && Packet.Data[12] == 0x00 && Packet.Data[13] == 0x00 && Packet.Data[14] == 0x00) { Info.Name = "icube"; } if (!(new Location() { X = Info.X, Y = Info.Y }.OnScreenOf(Clients[Serial].Aisling.Location))) { break; } if (Info.Serial == Clients[Serial].Aisling.Serial) { Clients[Serial].Aisling.Location.X = Info.X; Clients[Serial].Aisling.Location.Y = Info.Y; } else { if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Info.Serial)) { Clients[Serial].Aisling.Map.Entities.Remove(Info.Serial); } Clients[Serial].Aisling.Map.Entities.Add(Info.Serial, new AislingEntity() { LegendInfo = new LegendInfo.Entry[0], Location = new Location() { X = Info.X, Y = Info.Y, Map = Clients[Serial].Aisling.Location.Map, Direction = Info.Direction }, Name = Info.Name.value, Serial = Info.Serial, HoverMessage = Info.HoverMessage.value } ); } } else { ShowPlayer Info = null; Info = Packet.Read <ShowPlayer>(0); Console.WriteLine(Info.Name); if (!(new Location() { X = Info.X, Y = Info.Y }.OnScreenOf(Clients[Serial].Aisling.Location))) { break; } if (Packet.Data[11] == 0x00 && Packet.Data[12] == 0x00 && Packet.Data[13] == 0x00 && Packet.Data[14] == 0x00) { Info.Name = "icube"; } if (Info.Serial == Clients[Serial].Aisling.Serial) { Clients[Serial].Aisling.Location.X = Info.X; Clients[Serial].Aisling.Location.Y = Info.Y; } else { if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Info.Serial)) { Clients[Serial].Aisling.Map.Entities.Remove(Info.Serial); } Clients[Serial].Aisling.Map.Entities.Add(Info.Serial, new AislingEntity() { LegendInfo = new LegendInfo.Entry[0], Location = new Location() { X = Info.X, Y = Info.Y, Map = Clients[Serial].Aisling.Location.Map, Direction = Info.Direction }, Name = Info.Name.value, Serial = Info.Serial, HoverMessage = Info.HoverMessage.value } ); } } } break; #endregion #region Remove Sprite case ServerAction.RemoveSprite: { uint EntitySerial = Packet.Read <RemoveSprite>(0).ID; if (Clients[Serial].Aisling.Map.Entities.ContainsKey(EntitySerial)) { Clients[Serial].Aisling.Map.Entities.Remove(EntitySerial); } } break; #endregion #region Stats Updated case ServerAction.StatsUpdated: { bool[] Bools = Packet.Read <StatsUpdate>(0).BitMaskValues(); int Index = 3; if (Bools[2]) { StatsStructA StructA = Packet.Read <StatsStructA>(Index); Clients[Serial].Aisling.Stats.STR = StructA.STR; Clients[Serial].Aisling.Stats.INT = StructA.INT; Clients[Serial].Aisling.Stats.WIS = StructA.WIS; Clients[Serial].Aisling.Stats.CON = StructA.CON; Clients[Serial].Aisling.Stats.DEX = StructA.DEX; Clients[Serial].Aisling.Stats.Points = StructA.Points; Clients[Serial].Aisling.Stats.MaxHP = StructA.HPMax; Clients[Serial].Aisling.Stats.MaxMP = StructA.MPMax; Clients[Serial].Aisling.Stats.WeightCurr = StructA.WeightCurr; Clients[Serial].Aisling.Stats.WeightMax = StructA.WeightMax; Clients[Serial].Aisling.Stats.Ability = StructA.Ability; Clients[Serial].Aisling.Stats.Level = StructA.Level; Index += 28; } if (Bools[3]) { StatsStructB StructB = Packet.Read <StatsStructB>(Index); Clients[Serial].Aisling.Stats.CurHP = StructB.HPCurr; Clients[Serial].Aisling.Stats.CurMP = StructB.MPCurr; Index += 8; } if (Bools[4]) { StatsStructC StructC = Packet.Read <StatsStructC>(Index); Clients[Serial].Aisling.Stats.AbilityExperience = StructC.AExp; Clients[Serial].Aisling.Stats.LevelExperience = StructC.EXP; Clients[Serial].Aisling.Stats.Gold = StructC.Gold; Clients[Serial].Aisling.Stats.GP = StructC.GP; Clients[Serial].Aisling.Stats.NextLevel = StructC.NextLev; Clients[Serial].Aisling.Stats.NextAbility = StructC.NextAB; Index += 24; } if (Bools[5]) { StatsStructD StructD = Packet.Read <StatsStructD>(Index); Clients[Serial].Aisling.Stats.AC = StructD.AC; Clients[Serial].Aisling.Stats.MR = StructD.MR; Clients[Serial].Aisling.Stats.HIT = StructD.HIT; Clients[Serial].Aisling.Stats.DAM = StructD.DAM; Clients[Serial].Aisling.Stats.AttackElement = StructD.AEle; Clients[Serial].Aisling.Stats.DefenseElement = StructD.DEle; Index += 13; } } break; #endregion #region Entity Walked case ServerAction.EntityWalked: { SpriteWalk EntityWalk = Packet.Read <SpriteWalk>(0); ushort XDIFF = EntityWalk.X, YDIFF = EntityWalk.Y; switch (EntityWalk.Direction) { case FaceDirection.Down: YDIFF++; break; case FaceDirection.Left: XDIFF--; break; case FaceDirection.Right: XDIFF++; break; case FaceDirection.Up: YDIFF--; break; } if (Clients[Serial].Aisling.Map.Entities.ContainsKey(EntityWalk.Serial)) { if (Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].EntityType == MapEntity.Type.Monster) { (Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial] as Monster).WasHit = false; } Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].WasHit = false; Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].Location.X = XDIFF; Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].Location.Y = YDIFF; Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].Location.Direction = EntityWalk.Direction; } if (Clients[Serial].AttackTargetSerial == EntityWalk.Serial) { Clients[Serial].Aisling.AttackLoops = 0; Clients[Serial].Aisling.test2 = false; } } break; #endregion #region Appendage case ServerAction.Appendage: { Appendage BodyItems = Packet.Read <Appendage>(0); Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)BodyItems.Slot] = new Aisling.SpriteBody.Appendage(BodyItems.Icon, BodyItems.Name); Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)BodyItems.Slot].Icon = BodyItems.Icon; } break; #endregion #region Entity Turned case ServerAction.EntityTurn: { EntityDirection EntityDir = Packet.Read <EntityDirection>(0); if (Clients[Serial].Aisling.Map.Entities.ContainsKey(EntityDir.Serial)) { Clients[Serial].Aisling.Map.Entities[EntityDir.Serial].Location.Direction = EntityDir.FaceDirection; if (Clients[Serial].Aisling.Map.Entities[EntityDir.Serial].EntityType == MapEntity.Type.Monster) { (Clients[Serial].Aisling.Map.Entities[EntityDir.Serial] as Monster).WasSuained = false; } } } break; #endregion #region Body Animation case ServerAction.BodyAnimation: { SpriteAnimation EntityAnimation = Packet.Read <SpriteAnimation>(0); if (Clients[Serial].Aisling.Serial == EntityAnimation.ID) { Clients[Serial].Aisling.AttackLanded = true; } else { Clients[Serial].Aisling.AttackLanded = false; } //we enganged attacking if (EntityAnimation.ID == Clients[Serial].Aisling.Serial) { if (EntityAnimation.Animation == 1 || EntityAnimation.Animation == 129 || EntityAnimation.Animation == 139 || EntityAnimation.Animation == 132) { Clients[Serial].Aisling.Swings++; Clients[Serial].Aisling.EngagedCombat = true; } else { Clients[Serial].Aisling.EngagedCombat = false; } } else { Clients[Serial].Aisling.EngagedCombat = false; if (Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID].EntityType == MapEntity.Type.Player) { var v = from var in Clients[Serial].Aisling.Map.EntityList where var.Location.X == Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID].Location.InfrontOf.X && var.Location.Y == Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID].Location.InfrontOf.Y select var; if (v.Count() > 0) { foreach (var ent in v) { if (!(Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID] as AislingEntity).Targets.Contains(ent.Serial)) { (Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID] as AislingEntity).Targets.Add(ent.Serial); } } } (Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID] as AislingEntity).Targets = new List <uint> ( from var in (Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID] as AislingEntity).Targets where Clients[Serial].Aisling.Map.Entities.ContainsKey(var) select var ); } } } break; #endregion #region Sound Played case ServerAction.SoundPlay: { PlaySound SoundNumber = Packet.Read <PlaySound>(0); Clients[Serial].Aisling.LastSound = new Sounds() { Number = SoundNumber.Number }; if (Clients[Serial].AttackTargetSerial > 0) { Clients[Serial].Aisling.testSer = Clients[Serial].AttackTargetSerial; } } break; #endregion #region Chat Messages case ServerAction.Chat: { Chat ChatMessage = Packet.Read <Chat>(0); Clients[Serial].Aisling.ChatMessages.Add(new Aisling.ChatMessage(Convert.ToBoolean(ChatMessage.Type), ChatMessage.Serial, ChatMessage.Message)); } break; #endregion #region Bar Messages case ServerAction.Bar: { BarMessage BarMessage = Packet.Read <BarMessage>(0); Clients[Serial].Aisling.BarMessages.Add(new Aisling.BarMessage((Aisling.BarMessage.MessageType)BarMessage.Type, BarMessage.Message)); if (BarMessage.Message.value.ToLower().StartsWith("these items are cursed")) { if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Clients[Serial].ItemTargetSerial)) { (Clients[Serial].Aisling.Map.Entities[Clients[Serial].ItemTargetSerial] as Item).IsBanned = true; } } } break; #endregion #region Group case ServerAction.GroupRequest: { GroupRequest Request = Packet.Read <GroupRequest>(0); } break; #endregion #region Remove Appendage case ServerAction.RemoveAppendage: { if (Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)Packet[2]] != null) { string ItemRemoved = Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)Packet[2]].Name; } Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)Packet[2]] = null; } break; #endregion default: { } break; } if (Clients[Serial].Aisling.EngagedCombat) { Clients[Serial].Aisling.test++; Clients[Serial].Aisling.EngagedCombat = false; } } catch { } }
public void hit(Appendage appendage) { _health -= appendage.Damage; }