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 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; }