Ejemplo n.º 1
0
            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);
                }
            }
Ejemplo n.º 2
0
            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();
                }
            }
Ejemplo n.º 3
0
 public override void HandleInput(BaseTower entity, InputEvent inputEvent)
 {
     if (!(inputEvent is InputEventMouseButton) || !inputEvent.IsActionReleased("picked_up"))
     {
         return;
     }
     entity.TowerStateMachine.ChangeState(Idle);
 }
Ejemplo n.º 4
0
        /// <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));
        }
Ejemplo n.º 5
0
 public override void OnExit(BaseTower entity)
 {
     entity.Update();
     entity.ZIndex = 3;
     entity.PlayerCollision.Disabled = false;
     if (!entity.CanPlaceTower())
     {
         entity.ResetToDragStart();
     }
 }
Ejemplo n.º 6
0
            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;
            }
Ejemplo n.º 7
0
 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);
     }
 }
Ejemplo n.º 8
0
 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;
         }
     }
 }
Ejemplo n.º 9
0
 public override void OnEnter(BaseTower entity)
 {
     entity.PlayAttackAnimation();
 }
Ejemplo n.º 10
0
 public override void OnEnter(BaseTower entity)
 {
     entity.PlayIdleAnimation();
     entity.CurrentTarget = null;
 }
Ejemplo n.º 11
0
 public override void OnExit(BaseTower entity) => PickedUp.OnExit(entity);
Ejemplo n.º 12
0
 public override void Draw(BaseTower entity) => PickedUp.Draw(entity);
Ejemplo n.º 13
0
 public override void Update(BaseTower entity, float delta)
 {
     PickedUp.Update(entity, delta);
     entity.ZIndex = 10;
 }
Ejemplo n.º 14
0
 public override void OnEnter(BaseTower entity)
 {
     entity.DragStart = entity.Position;
     entity.PlayerCollision.Disabled = true;
 }
Ejemplo n.º 15
0
 public override void Draw(BaseTower entity)
 {
     entity.DrawAttackRadius();
 }
Ejemplo n.º 16
0
 public override void OnEnter(BaseTower entity)
 {
     entity.DragStart = entity.Position;
     entity.PlayerCollision.Disabled = true;
     // TODO : show gui sell menu
 }