GAM456-SpaceInvaders / SpaceInvaders / 3_Timer / Commands / AnimateGrid.cs
AnimateGrid.cs
Raw
using System;
using System.Diagnostics;


namespace SpaceInvaders
{
    public class AnimateGrid : Command
    {
        //-------------------------------------------------------------------
        //  FIELDS
        //-------------------------------------------------------------------

        private readonly GameObject pGrid;
        private readonly float x;


        //-------------------------------------------------------------------
        //  CONSTRUCTION
        //-------------------------------------------------------------------

        public AnimateGrid(GameObject pAlienGrid, float x)
        {
            Debug.Assert(pAlienGrid != null);
            pGrid = pAlienGrid;

            this.x = x;
        }


        //-------------------------------------------------------------------
        //  PUBLIC METHOD
        //-------------------------------------------------------------------

        public override void Execute(float deltaTime)
        {
            //move grid
            pGrid.Move(x, 0.0f);

            //add event back to man
            float delta = ((State_Play)GameContext.GetCurrState()).GetCurrDelta();
            TimerEventMan.AddEvent(TimerEvent.EventName.AnimateGrid, this, delta);
        }


    } // end class

} // end namespace