Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class
        /// </summary>
        public Game()
        {
            // Set default value for all settings
            Vsync              = false;
            TargetFramerate    = -1;
            FixedTimestep      = false;
            ResolutionInternal = new Vector2(1280, 720);

            // Instantiate lists
            updateReceivers = new List <IUpdatable>();
            drawReceivers   = new List <IDrawable>();

            // Create platform
            Platform = new Platform(this);

            // Create graphics manager
            Graphics = new GraphicsManager(this, Platform);

            // Create input managers
            Controllers = new DeviceManager(this);
            Keyboard    = new KeyboardManager(this);
            Mouse       = new MouseManager(this);

            // Create Content Manager
            Content = new ContentManager(this);

            // Create sprites
            Sprites = new SpriteList(Graphics, this);

            Actions = new SpriteEvents(Sprites);

            // Create camera manager
            Cameras = new CameraManager(this);
        }
Beispiel #2
0
        private void AddSpriteState(SpriteEvents a_event)
        {
            SpriteState state = new SpriteState();
            if(a_event.m_state != null)
                state.Init(m_actor, a_event.m_name, a_event.m_frameHeight, a_event.m_frameWidth, a_event.m_frameCount, a_event.m_frameColStart, a_event.m_frameRowStart , a_event.m_animSpeed, a_event.m_textures, a_event.m_state);
            else
                state.Init(m_actor, a_event.m_name, a_event.m_frameHeight, a_event.m_frameWidth, a_event.m_frameCount, a_event.m_frameColStart, a_event.m_animSpeed, a_event.m_textures);            

            m_spriteStates.Add(state);
        }
Beispiel #3
0
        /// <summary>
        /// if the transition state has had it's end frame reached it calls the "switch"
        /// else the transition adds the command back onto the command stack to check again
        /// next frame
        /// </summary>
        /// <param name="a_name">name of sprite</param>
        /// <param name="a_state">name of state</param>
        private void TransitionSpriteStates(string a_name, string a_state)
        {
            bool endFrameFound = false;

            for (int i = m_spriteStates.Count - 1; i >= 0; i--) //traverse in reverse for element removal         
            {                
                if(m_spriteStates[i].m_currentFrame == m_spriteStates[i].m_frameCount - 2)//runs one loop extra, end on last frame
                {
                    //Console.WriteLine("found the end frame for state: " + 
                    //    m_spriteStates[i].m_animState + " switching state to: " + a_state);
                    
                    SpriteEvents eventToAdd = new SpriteEvents(SpriteManager.SpriteCommands.SWITCH, a_name, a_state);
                    m_secondryEvents.Add(eventToAdd);

                    endFrameFound = true;
                }
            }



            if(!endFrameFound)
            {
                //if the end frame is not found add the command to the secondry process for
                //the next frame
                SpriteEvents eventToAdd = new SpriteEvents(SpriteManager.SpriteCommands.TRANSITION, a_name, a_state);
                m_secondryEvents.Add(eventToAdd);
                //Console.WriteLine("checking again");
            }

        }
Beispiel #4
0
        /// <summary>
        /// overloaded cmd - used for switching states on an actor
        /// </summary>
        /// <param name="a_cmd"></param>
        /// <param name="a_name"></param>
        /// <param name="a_state"></param>
        public void Cmd(SpriteCommands a_cmd, string a_name, string a_state)
        {
            SpriteEvents newEvent = new SpriteEvents(a_cmd, a_name, a_state);           

            //add event to the command stack, not active until processed
            m_events.Add(newEvent);
        }
Beispiel #5
0
        public void Cmd(SpriteCommands a_cmd, string a_name, List<Texture2D> a_textures,
            int a_frameCount, int a_frameWidth, int a_frameColStart, int a_frameRowStart, int a_frameHeight, float a_animSpeed, string a_state)
        {
            SpriteEvents newEvent = new SpriteEvents(a_cmd, a_name, a_frameCount, a_frameColStart, a_frameRowStart,
                a_frameWidth, a_frameHeight, a_animSpeed, a_textures, a_state);

            //add event to the command stack, not active until processed
            m_events.Add(newEvent);
        }