Пример #1
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Default GameObject constructor
 /// </summary>
 public Actor(GameLevelManager gameLevelMgr)
 {
     _gameLevelMgr = gameLevelMgr;
     _position     = Vector2.Zero;
     _scale        = new Vector2(1.0f);
     _rotation     = 0.0f;
 }
Пример #2
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// KeyDown input event handler function.
        /// </summary>
        /// <param name="e">KeyEvent arguments.</param>
        /// <returns>True if handled.</returns>
        public override bool injectKeyDown(KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Keys.W:
                MoveDirection += GameLevelManager.directionVectorFromView(Direction.DIR_N);
                break;

            case Keys.A:
                MoveDirection += GameLevelManager.directionVectorFromView(Direction.DIR_W);
                break;

            case Keys.S:
                MoveDirection += GameLevelManager.directionVectorFromView(Direction.DIR_S);
                break;

            case Keys.D:
                MoveDirection += GameLevelManager.directionVectorFromView(Direction.DIR_E);
                break;

            case Keys.Space:
                _character.jump();
                break;
            }

            return(base.injectKeyDown(e));
        }
Пример #3
0
 //-------------------------------------------------------------------------
 public Camera2D(GameLevelManager gameLevelMgr)
     : base(gameLevelMgr)
 {
     _rotationZ       = 0.0f;
     _rotationX       = (float)(Math.PI / 6.0f);
     _zoom            = 0.5f;
     _originIsometric = Vector2.Zero;
     update(0.0f);
 }
Пример #4
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// GameNode constructor.
 /// </summary>
 /// <param name="gameLevelMgr">GameLevelManager containing this GameNode.</param>
 /// <param name="name">Name of this GameNode.</param>
 /// <param name="active">Initial active status.</param>
 public GameNode(GameLevelManager gameLevelMgr, String name)
     : base(gameLevelMgr)
 {
     _name              = name;
     _parent            = null;
     _children          = new Dictionary <string, GameNode>();
     _positionIsometric = Vector3.Zero;
     _entity            = null;
 }
Пример #5
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Initialize this GameEditorScreen.
        /// </summary>
        /// <returns>False if failed</returns>
        public override bool init()
        {
            _gameLevelMgr      = new GameLevelManager(_gameContentMgr, _screenMgr.GraphicsDevice);
            Tool               = EditorTool.TOOL_NONE;
            _selection         = new List <GameTile>();
            _grabbingSelection = false;
            _colorSelect       = new Color(0.5f, 1.0f, 0.25f, 0.75f);
            _colorDeselect     = Color.White;

            _elevating = false;
            _snapping  = false;

            return(base.init());
        }
Пример #6
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Initialize this GamePlayScreen by loading an initial level and all defaults.
        /// </summary>
        /// <param name="gameLevel">Relative path to the GameLevel file to be loaded</param>
        /// <returns>False if init has already been called</returns>
        public virtual bool init(String gameLevel)
        {
            // Check if this GamePlayScreen has already been initialized
            if (_gameLevelMgr != null)
            {
                return(false);
            }

            // Load the level passed in
            _gameLevelMgr = new GameLevelManager(_gameContentMgr, _screenMgr.GraphicsDevice);
            _gameLevelMgr.loadLevel("levels\\" + gameLevel);

            // Initialize the user
            initUser();

            return(true);
        }
Пример #7
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Update this Entity's view direction, which will indicate how it's drawn.
        /// </summary>
        public void updateDirectionView(Vector3 directionVector)
        {
            // Project as unit vector onto XZ plane
            directionVector.Y = 0.0f;
            directionVector   = Vector3.Normalize(directionVector);

            // Grab cosine of angle between vector and -Z axis (north/south axis)
            float cosTheta = Vector3.Dot(-Vector3.UnitZ, directionVector);

            if (Math.Abs(cosTheta) < 0.0005f)
            {
                cosTheta = 0.000f;
            }

            // Find angle and update direction
            float theta = (float)Math.Acos(cosTheta);

            if (directionVector.X > 0.0f)
            {
                theta = (float)(Math.PI + (Math.PI - theta));
            }
            _directionView = GameLevelManager.directionViewFromAngle(theta);
        }
Пример #8
0
        /// <summary>
        /// KeyUp input event handler function.
        /// </summary>
        /// <param name="e">KeyEvent arguments.</param>
        /// <returns>True if handled.</returns>
        public override bool injectKeyUp(KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Keys.W:
                MoveDirection -= GameLevelManager.directionVectorFromView(Direction.DIR_N);
                break;

            case Keys.A:
                MoveDirection -= GameLevelManager.directionVectorFromView(Direction.DIR_W);
                break;

            case Keys.S:
                MoveDirection -= GameLevelManager.directionVectorFromView(Direction.DIR_S);
                break;

            case Keys.D:
                MoveDirection -= GameLevelManager.directionVectorFromView(Direction.DIR_E);
                break;
            }

            return(base.injectKeyUp(e));
        }
Пример #9
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Update the direction enum, which indicates where the camera
 /// is pointing
 /// </summary>
 protected void updateDirection()
 {
     _dir = GameLevelManager.directionViewFromAngle(_rotationZ);
 }