示例#1
0
        public LevelPortal(World nWorld, Level nLevel, ContentManager nContentManager, Color nColor, Vector2 nPos, OnLevelPortalCollision nDelegate, Hashtable nConfig)
        {
            string nTextureName = "SpriteMaps/Portal";

            base.Init(nWorld, nLevel, nContentManager, nTextureName, nColor, nPos);

            //Populate the Hashtable SpriteMap with the values for the player spritemap
            AddFrame(SpriteState.Portal, 0, 0, 100, 100);
            AddFrame(SpriteState.Portal, 100, 0, 100, 100);
            AddFrame(SpriteState.Portal, 200, 0, 100, 100);

            //Default SpriteState
            SetState(SpriteState.Portal);

            //Manually step the animation to update the sprite Source rectangle
            StepAnimation();

            //Set callback for collisions
            Body.OnCollision += OnCollision;
            Body.OnSeparation += OnSeparation;

            //Other physical properties
            Body.BodyType = BodyType.Static;
            Body.IsSensor = true;
            Body.CollidesWith = Category.All;
            Body.CollisionCategories = Category.Cat30;
            Body.CollisionGroup = 30;
            Body.SleepingAllowed = false;
            Body.Position = nPos;

            OnPortalCollision = nDelegate;

            mLevelId = (int)nConfig["LevelId"];
        }
        protected void Init(World nWorld, Level nLevel, ContentManager nContentManager, string nTextureName, Color nColor, Vector2 nStartPos)
        {
            base.Init(nContentManager, nLevel.ScreenManager.SpriteBatch, nTextureName, nColor, nStartPos);

            mWorld = nWorld;
            mLevel = nLevel;
            mStartPos = nStartPos;
        }
示例#3
0
        public Player(World nWorld, Level nLevel, ContentManager nContentManager, Color nColor, Vector2 nStartPos)
        {
            //Get player information (I.e. class, race, etc) here and make any modifications needed.
            //This information will determine the texture name
            //For now just use the burrito
            string nTextureName = "SpriteMaps/Naked Guy";

            //Create the camera body that follows the player around
            CamBody = BodyFactory.CreateBody(nWorld);
            CamBody.BodyType = BodyType.Kinematic;
            CamBody.IsSensor = true;
            CamBody.CollisionCategories = Category.Cat31;
            CamBody.CollidesWith = Category.None;
            CamBody.CollisionGroup = 31;
            CamBody.IgnoreGravity = true;
            CamBody.IgnoreCCD = true;
            CamBody.SleepingAllowed = false;
            CamBody.LinearDamping = 3.0f;

            //Initialize base classes - sets up physical bodies, animation, etc
            base.Init(nWorld, nLevel, nContentManager, nTextureName, nColor, nStartPos);

            //Populate the Hashtable SpriteMap with the values for the player spritemap
            AddFrame(SpriteState.Standing, 0, 0, 100, 100);
            AddFrame(SpriteState.Standing, 0, 0, 100, 100);
            AddFrame(SpriteState.Standing, 0, 0, 100, 100);

            AddFrame(SpriteState.Walking, 100, 0, 100, 100);
            AddFrame(SpriteState.Walking, 500, 0, 100, 100);
            AddFrame(SpriteState.Walking, 200, 0, 100, 100);
            AddFrame(SpriteState.Walking, 500, 0, 100, 100);
            AddFrame(SpriteState.Walking, 300, 0, 100, 100);
            AddFrame(SpriteState.Walking, 500, 0, 100, 100);
            AddFrame(SpriteState.Walking, 400, 0, 100, 100);
            AddFrame(SpriteState.Walking, 500, 0, 100, 100);

            AddFrame(SpriteState.Falling, 200, 100, 100, 100);
            AddFrame(SpriteState.Falling, 200, 100, 100, 100);
            AddFrame(SpriteState.Falling, 200, 100, 100, 100);

            AddFrame(SpriteState.Jumping, 200, 100, 100, 100);
            AddFrame(SpriteState.Jumping, 200, 100, 100, 100);
            AddFrame(SpriteState.Jumping, 200, 100, 100, 100);

            AddFrame(SpriteState.Crouching, 0, 100, 100, 100);
            AddFrame(SpriteState.Crouching, 0, 100, 100, 100);
            AddFrame(SpriteState.Crouching, 0, 100, 100, 100);

            //Default SpriteState
            SetState(SpriteState.Standing);

            //Manually step the animation to update the sprite Source rectangle
            StepAnimation();

            //Set callback for collisions
            Body.OnCollision += OnCollision;
            Body.OnSeparation += OnSeparation;
        }