public AbilityAnimationEntity(AbilityHead ability, Entity target, Vector2 source) { this.ability = ability; this.target = target; this.SetScale(0.25f); this.source = source; switch (ability.ID) { case 1: animation = TextureContainer.GetSpriteAtlasByName("FireBall").GetAnimation("travel"); break; default: break; } float deltaX = target.Position.X - source.X; this.SetPosition(source); animator = AddComponent <SpriteAnimator>(); if (deltaX > 0) { animator.FlipX = true; } animator.AddAnimation("travel", animation); animator.Play("travel"); }
public ChannelBarComponent(int startTime, AbilityHead ability, Entity target, Vector2 source) { //SetText(startTime.ToString()); StartTime = startTime; this.ability = ability; this.source = source; this.target = target; }
private void DamageTarget(NetIncomingMessage message, MessageTemplate template) { CharacterPlayer character = MapContainer.FindCharacterByID(message.SenderConnection.RemoteUniqueIdentifier); AbilityHead abi = AbilityContainer.GetAbilityByName(template.JsonMessage); Entity entity = Scene.FindEntity(character._name); PlayerComponent pcomp = entity.GetComponent <PlayerComponent>(); if (pcomp != null && abi != null && pcomp.Target != null) { pcomp.Target.GetComponent <DamageComponent>().DealDamageToEntity(abi.BaseDamage); } }
private void StartChanneling(MessageTemplate template, NetIncomingMessage message) { ChannelTemplate ct = Newtonsoft.Json.JsonConvert.DeserializeObject <ChannelTemplate>(template.JsonMessage); if (ct.ChannelType.Equals(ChannelType.Ability)) { AbilityHead ability = AbilityContainer.GetAbilityByName(ct.ChannelName); CharacterPlayer character = MapContainer.FindCharacterByID(message.SenderConnection.RemoteUniqueIdentifier); Entity entity = Scene.FindEntity(character._name); PlayerComponent pc = entity.GetComponent <PlayerComponent>(); if (pc != null && !pc.isChanneling) { if (ability != null) { entity.AddComponent(new DamageChannelingComponent(pc, ability.ChannelTime, ability)); } else { entity.AddComponent(new ChannelingComponent(pc, 4)); } } } }
public DamageChannelingComponent(PlayerComponent pc, float ChannelTime, AbilityHead ability) : base(pc, ChannelTime) { target = pc.Target; this.ability = ability; }
//TODO: Change to customizable keybindings later private Keys[] KeyboardChange() { KeyboardState newState = Input.CurrentKeyboardState; KeyboardState OldKeyboardState = Input.PreviousKeyboardState; List <Keys> keys = new List <Keys>(); if (AbiliyCoolDown > 1) { foreach (var KeyBind in KeyBindContainer.KeyBinds) { if (newState.IsKeyDown(KeyBind.BindedKey) && OldKeyboardState.IsKeyUp(KeyBind.BindedKey) && KeyBind.BindedAbilitityID != -1 && Scene.GetSceneComponent <ChannelBarComponent>() == null) { AbilityHead ability = KeyBind.GetAbility(); MessageTemplate template; ChannelTemplate ct = new ChannelTemplate(KeyBind.GetAbility().AbilityName, ChannelType.Ability); if ((Scene as MainScene).UICanvas.Stage.FindAllElementsOfType <TargetWindow>() != null) { if (ability.ChannelTime > 0 && targeting) { template = new MessageTemplate(ct.ToJson(), MessageType.StartChanneling); ChannelBarComponent channelBarComponent = new ChannelBarComponent(ability.ChannelTime, ability, Scene.FindEntitiesWithTag(2).ElementAt(0).GetComponent <PlayerComponent>().GetTarget(), Entity.Position); Scene.AddSceneComponent(channelBarComponent); } else { template = new MessageTemplate(ct.ToJson(), MessageType.DamageTarget); } MessageManager.AddToQueue(template); AbiliyCoolDown = 0; } } } } //Generated inventory if (newState.IsKeyDown(Keys.I) && OldKeyboardState.IsKeyUp(Keys.I)) { if (!InventoryWindow.RemoveInventory(Scene)) { UIManager.GenerateInventoryWindow(skin, Scene, new Vector2(-1, -1), -1, -1); } } if (newState.IsKeyDown(Keys.C) && OldKeyboardState.IsKeyUp(Keys.C)) { if (!CharacterWindow.RemoveCharacterWindow(Scene)) { UIManager.GenerateCharacterWindow(skin, Scene, new Vector2(-1, -1), -1, -1); } } if (newState.IsKeyDown(Keys.D1) && !OldKeyboardState.IsKeyDown(Keys.D1)) { } if (newState.IsKeyDown(Keys.S) && !OldKeyboardState.IsKeyDown(Keys.S)) { direction = Direction.Down; IsMoving = true; } if (newState.IsKeyDown(Keys.W) && !OldKeyboardState.IsKeyDown(Keys.W)) { direction = Direction.Up; IsMoving = true; } if (newState.IsKeyDown(Keys.A) && !OldKeyboardState.IsKeyDown(Keys.A)) { direction = Direction.Left; IsMoving = true; } if (newState.IsKeyDown(Keys.D) && !OldKeyboardState.IsKeyDown(Keys.D)) { direction = Direction.Right; IsMoving = true; } if (newState.IsKeyDown(Keys.T) && !OldKeyboardState.IsKeyDown(Keys.T)) { keys.Add(Keys.T); } if (IsMoving) { Scene.RemoveSceneComponent <ChannelBarComponent>(); } return(keys.ToArray()); }
private void SetAbility() { BindedAbility = AbilityContainerClient.GetAbilityByID(BindedAbilitityID); }