示例#1
0
文件: Entity.cs 项目: endy/IvyXNA
        public void ChangeZone(WorldZone zone, Point position)
        {
            ///@todo need 'ExitZone' method?
            WorldZone = zone;

            LastPosition = Position;
            Position = position;
        }
示例#2
0
文件: IvyGame.cs 项目: endy/IvyXNA
 public void SetCurrentZone(WorldZone room)
 {
     m_currentZone = room;
 }
示例#3
0
文件: IvyGame.cs 项目: endy/IvyXNA
        private void HandleChangeZoneMsg(ChangeZoneMsg msg)
        {
            // Pause, Transition Room, Then Pass Message onto both rooms

            if (m_currentZone != null)
            {
                MessageDispatcher.Get().SendMessage(
                    new ChangeZoneMsg(this, m_currentZone, msg.Entity, msg.DestZone, msg.DestPosition, 1));
            }

            if (msg.Entity == m_cameraTarget)
            {
                WorldZone destZone = new WorldZone(msg.DestZone);

                destZone.SetEscapeMode(GetCurrentZone().EscapeMode);

                SetCurrentZone(destZone);
                Camera.SetZoneBounds(destZone.Bounds);

                Camera.SetTarget(msg.Entity);

                if (msg.DestZone != null)
                {
                    MessageDispatcher.Get().SendMessage(
                        new ChangeZoneMsg(this, destZone, msg.Entity, msg.DestZone, msg.DestPosition, 1));
                }
            }
        }
示例#4
0
文件: Ceres.cs 项目: endy/IvyXNA
        protected override void Initialize()
        {
            base.Initialize();

            WorldZone shaftZone = new WorldZone(@"levels/shaft");

            // Add player

            // TODO: Find out if components need to be individually initialized here,
            //       XNA may provide a way of doing this.
            m_playerOne = new Player(this);
            m_playerOne.Initialize();
            ChangeZoneMsg addEntityMsg = new ChangeZoneMsg(this, shaftZone, m_playerOne, shaftZone.ZoneName, new Point(112, 16), 0);
            MessageDispatcher.Get().SendMessage(addEntityMsg);

            SetCurrentZone(shaftZone);

            SetCameraTarget(m_playerOne);

            // Create Camera
            Rectangle screenRect = new Rectangle(0, 0, 800, 600);

            int cameraHeight = 192;
            int cameraWidth = 256;
            Rectangle cameraBounds = new Rectangle(0, 0, cameraWidth, cameraHeight);
            Camera.Initialize(shaftZone.Bounds, cameraBounds, screenRect);

            CameraGel = Content.Load<Texture2D>(@"art/bg_layer_blueaura");
            GelTint = new Color(0.0f, 0.0f, 1.0f, 0.0f);

            EscapeTimer = new Timer(1000 * 60);  // One minute to escape
            EscapeTimer.OnTimeExpired += OnEscapeTimeExpired;

            #region Register Input Handlers
            // Movement
            InputMgr.Get().RegisterGamePadButton(Buttons.LeftThumbstickLeft, OnGamePadDirectionEvent);
            InputMgr.Get().RegisterGamePadButton(Buttons.LeftThumbstickRight, OnGamePadDirectionEvent);
            InputMgr.Get().RegisterGamePadButton(Buttons.LeftThumbstickUp, OnGamePadDirectionEvent);
            InputMgr.Get().RegisterGamePadButton(Buttons.LeftThumbstickDown, OnGamePadDirectionEvent);

            InputMgr.Get().RegisterGamePadButton(Buttons.DPadLeft, OnGamePadDirectionEvent);
            InputMgr.Get().RegisterGamePadButton(Buttons.DPadRight, OnGamePadDirectionEvent);
            InputMgr.Get().RegisterGamePadButton(Buttons.DPadUp, OnGamePadDirectionEvent);
            InputMgr.Get().RegisterGamePadButton(Buttons.DPadDown, OnGamePadDirectionEvent);

            InputMgr.Get().RegisterKey(Keys.Up, OnKeyboardDirectionEvent);
            InputMgr.Get().RegisterKey(Keys.Down, OnKeyboardDirectionEvent);
            InputMgr.Get().RegisterKey(Keys.Left, OnKeyboardDirectionEvent);
            InputMgr.Get().RegisterKey(Keys.Right, OnKeyboardDirectionEvent);

            // Actions
            InputMgr.Get().RegisterGamePadButton(Buttons.A, OnGamePadButtonEvent); // Run/Alt
            InputMgr.Get().RegisterGamePadButton(Buttons.B, OnGamePadButtonEvent); // Jump
            InputMgr.Get().RegisterGamePadButton(Buttons.Y, OnGamePadButtonEvent); // Fire Weapon

            // Keyboard Actions
            InputMgr.Get().RegisterKey(Keys.F, OnKeyboardEvent);                    // Fire
            InputMgr.Get().RegisterKey(Keys.Space, OnKeyboardEvent);                // Jump

            // Debug Actions
            InputMgr.Get().RegisterGamePadButton(Buttons.X, DebugOnGamePadButtonEvent);
            #endregion
        }