Esempio n. 1
0
        private void UnitEventHappened(object sender, UnitEventArgs e)
        {
            switch (e.EventType)
            {
            // Unit movement animation event was raised
            case UnitEventType.MoveCommand:
            {
                //if (IsActiveUnitOutsideMapView) // Update map view if unit is outside visible map
                //{
                //    ReturnCoordsAtMapViewChange(new int[] { Game.ActiveUnit.X, Game.ActiveUnit.Y });
                //    drawPanel.Update(new Rectangle(0, 0, drawPanel.Width, drawPanel.Height));
                //}
                StartAnimation(AnimationType.UnitMoving);
                break;
            }

            case UnitEventType.Attack:
            {
                animationFrames = GetAnimationFrames.UnitAttack(e);
                StartAnimation(AnimationType.Attack);
                break;
            }

            case UnitEventType.StatusUpdate:
            {
                if (IsActiveUnitOutsideMapView)
                {
                    ReturnCoordsAtMapViewChange(new int[] { Game.GetActiveUnit.X, Game.GetActiveUnit.Y });                                     // Update map view if unit is outside visible map
                }
                else
                {
                    StartAnimation(AnimationType.Waiting);
                }
                break;
            }

            case UnitEventType.NewUnitActivated:
            {
                if (IsActiveUnitOutsideMapView)
                {
                    MapViewChange(new int[] { Game.GetActiveUnit.X, Game.GetActiveUnit.Y });
                }
                else
                {
                    StartAnimation(AnimationType.Waiting);
                }
                break;
            }
            }
        }
Esempio n. 2
0
        private void StartAnimation(AnimationType anim)
        {
            switch (anim)
            {
            case AnimationType.UpdateMap:
                animationTimer.Stop();
                animationCount = 0;
                drawPanel.Invalidate();
                break;

            case AnimationType.Waiting:
                animType = AnimationType.Waiting;
                animationTimer.Stop();
                animationFrames         = GetAnimationFrames.Waiting(Map.ActiveXY);
                animationCount          = 0;
                animationTimer.Interval = 0.2;        // sec
                animationTimer.Start();
                break;

            case AnimationType.UnitMoving:
                animType        = AnimationType.UnitMoving;
                animationFrames = GetAnimationFrames.UnitMoving(Game.GetActiveUnit);
                animationTimer.Stop();
                animationCount          = 0;
                animationTimer.Interval = 0.01;        // sec
                animationTimer.Start();
                break;

            case AnimationType.Attack:
                animType = AnimationType.Attack;
                animationTimer.Stop();
                animationCount          = 0;
                animationTimer.Interval = 0.07;        // sec
                animationTimer.Start();
                break;
            }
        }
Esempio n. 3
0
 public MoveAnimation(MovementEventArgs args, Sound sound)
     : base(GetAnimationFrames.UnitMoving(args.Unit).ToArray(), 6, 7, 0.02, args.Location[0])
 {
     _sound = sound;
 }