public override void HandleInput(BaseTower entity, InputEvent inputEvent) { if (entity.Locked) { return; } // Will only check to be picked up if not the tower is not locked // Check if tower is broken and filter input if (entity.TowerStateMachine.IsInState(Broken)) { return; } if (!(inputEvent is InputEventMouseButton eventMouseButton) || !inputEvent.IsActionPressed("picked_up")) { return; } if (entity.GetRect().HasPoint(entity.ToLocal(eventMouseButton.Position))) { entity.TowerStateMachine.ChangeState(entity.Purchased ? PickedUp : Buying); } }
public override void HandleInput(BaseTower entity, InputEvent inputEvent) { if (!(inputEvent is InputEventMouseButton) || !inputEvent.IsActionReleased("picked_up")) { return; } var canPlace = entity.CanPlaceTower(); if (canPlace) { var purchased = GameInfo.GameCurrency.PurchaseTower(entity); if (purchased) { entity.TowerStateMachine.ChangeState(Idle); } else { entity.SetForDeletion(); } } else { entity.SetForDeletion(); } }
public override void HandleInput(BaseTower entity, InputEvent inputEvent) { if (!(inputEvent is InputEventMouseButton) || !inputEvent.IsActionReleased("picked_up")) { return; } entity.TowerStateMachine.ChangeState(Idle); }
/// <summary> /// Checks if the tower is overlapping another tower /// </summary> /// <param name="tower">the tower to check</param> /// <param name="padding">optional padding to add to collision rectangles. default is 4</param> /// <returns>true if both tower's bounding rectangles are intersecting</returns> private bool CollidesWithTower(BaseTower tower, int padding = 4) { //GD.Print(Name,GetGlobalRect(), tower.Name,tower.GetGlobalRect()); var paddedRect = GetGlobalRect().Grow(padding); var paddedTargetRect = tower.GetGlobalRect().Grow(padding); return(tower != this && paddedRect.Intersects(paddedTargetRect)); }
public override void OnExit(BaseTower entity) { entity.Update(); entity.ZIndex = 3; entity.PlayerCollision.Disabled = false; if (!entity.CanPlaceTower()) { entity.ResetToDragStart(); } }
public override void Update(BaseTower entity, float delta) { var mousePos = entity.GetGlobalMousePosition(); entity.Update(); entity.DragTo(mousePos); entity.ZIndex = 4; var canPlace = entity.CanPlaceTower(); entity.AttackColour = canPlace ? GameInfo.ValidColour : GameInfo.InvalidColour; entity.DragStart = canPlace ? entity.Position : entity.DragStart; }
public override void Update(BaseTower entity, float delta) { entity.Targets = entity.Targets.Where(enemy => !enemy.IsDead()).ToList(); entity.CurrentTarget = entity.Targets.Count == 0 ? null : entity.Targets.First(); if (entity.CurrentTarget == null && entity.Targets.Count == 0) { entity.TowerStateMachine.ChangeState(Idle); } else { entity.TrackNextTarget(delta); entity.Shoot(entity.CurrentTarget, delta); } }
public override void Update(BaseTower entity, float delta) { if ((entity.CurrentTarget != null || entity.Targets.Count != 0) && entity.Purchased) { entity.TowerStateMachine.ChangeState(Attacking); } else { if (entity.TowerGun.RotationDegrees < 0) { entity.TowerGun.RotationDegrees += 1; } if (entity.TowerGun.RotationDegrees > 0) { entity.TowerGun.RotationDegrees -= 1; } } }
public override void OnEnter(BaseTower entity) { entity.PlayAttackAnimation(); }
public override void OnEnter(BaseTower entity) { entity.PlayIdleAnimation(); entity.CurrentTarget = null; }
public override void OnExit(BaseTower entity) => PickedUp.OnExit(entity);
public override void Draw(BaseTower entity) => PickedUp.Draw(entity);
public override void Update(BaseTower entity, float delta) { PickedUp.Update(entity, delta); entity.ZIndex = 10; }
public override void OnEnter(BaseTower entity) { entity.DragStart = entity.Position; entity.PlayerCollision.Disabled = true; }
public override void Draw(BaseTower entity) { entity.DrawAttackRadius(); }
public override void OnEnter(BaseTower entity) { entity.DragStart = entity.Position; entity.PlayerCollision.Disabled = true; // TODO : show gui sell menu }