public override void Update(AxiosGameScreen gameScreen, GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameScreen, gameTime, otherScreenHasFocus, coveredByOtherScreen);

            if (ApplyConstantVelocity)
            {
                if (Math.Abs(BodyPart.LinearVelocity.X) > ConstantVelocity.X || Math.Abs(BodyPart.LinearVelocity.X) < ConstantVelocity.X)
                {
                    //Figure which direction it's going and adjust

                    if (Math.Abs(BodyPart.LinearVelocity.X) > BodyPart.LinearVelocity.X) //negative
                        BodyPart.LinearVelocity = new Vector2(-ConstantVelocity.X, BodyPart.LinearVelocity.Y);
                    else
                        BodyPart.LinearVelocity = new Vector2(ConstantVelocity.X, BodyPart.LinearVelocity.Y);

                }

                if (Math.Abs(BodyPart.LinearVelocity.Y) > ConstantVelocity.Y || Math.Abs(BodyPart.LinearVelocity.Y) < ConstantVelocity.Y)
                {
                    //Figure which direction it's going and adjust

                    if (Math.Abs(BodyPart.LinearVelocity.Y) > BodyPart.LinearVelocity.Y) //negative
                        BodyPart.LinearVelocity = new Vector2(BodyPart.LinearVelocity.X, -ConstantVelocity.Y);
                    else
                        BodyPart.LinearVelocity = new Vector2(BodyPart.LinearVelocity.X, ConstantVelocity.Y);
                }
            }
        }
 public void CreateBodyFromTexture(AxiosGameScreen gameScreen)
 {
     if (this.Texture != null)
     {
         uint[] data = new uint[this.Texture.Width * this.Texture.Height];
         this.Texture.GetData<uint>(data);
         Vertices vertices = PolygonTools.CreatePolygon(data, this.Texture.Width, false);
         Vector2 vector = -vertices.GetCentroid();
         vertices.Translate(ref vector);
         this.Origin = -vector;
         List<Vertices> list = BayazitDecomposer.ConvexPartition(SimplifyTools.ReduceByDistance(vertices, 4f));
         this._scale = 1f;
         Vector2 vector2 = (Vector2)(new Vector2(ConvertUnits.ToSimUnits(1)) * this._scale);
         foreach (Vertices vertices2 in list)
         {
             vertices2.Scale(ref vector2);
         }
         this.BodyPart = BodyFactory.CreateCompoundPolygon(gameScreen.World, list, 1f, BodyType.Dynamic);
         this.BodyPart.BodyType = BodyType.Dynamic;
         this.BodyPart.Position = this.Position;
         this.BodyPart.UserData = this;
         this.BodyPart.CollidesWith = Category.All;
         this.BodyPart.CollisionCategories = Category.All;
     }
 }
Пример #3
0
        public override void LoadContent(AxiosGameScreen gameScreen)
        {
            base.LoadContent(gameScreen);
            int xcount, ycount;
            List<Texture2D> walksheets = new List<Texture2D>();
            for(int i = 1; i < 12; i++)
                walksheets.Add( gameScreen.ScreenManager.Game.Content.Load<Texture2D>("tiles/character/walk/walk00" + i.ToString("D2")));
            //_playersheet =
            /*Texture2D[] tmpsheets = _playersheet.SplitFlat(192, 32, out xcount, out ycount);
            Texture2D[] tmpsheetsdown = tmpsheets[0].SplitFlat(24, 32, out xcount, out ycount);
            Texture2D[] tmpsheetsup = tmpsheets[1].SplitFlat(24, 32, out xcount, out ycount);
            Texture2D[] tmpsheetsleft = tmpsheets[2].SplitFlat(24, 32, out xcount, out ycount);
            Texture2D[] tmpsheetsright = tmpsheets[3].SplitFlat(24, 32, out xcount, out ycount);*/
            //_characterdown = walksheets.GetRange(0, 1);
            _characterup = walksheets.GetRange(0, 1);
            _characterleft = walksheets;
            _characterright = walksheets;

            Texture = walksheets[0];
            //offset the width by a little
            BodyPart = BodyFactory.CreateRectangle(gameScreen.World, ConvertUnits.ToSimUnits(Texture.Width - 5), ConvertUnits.ToSimUnits(Texture.Height), 2f);
            this.Origin = new Vector2(Texture.Width / 2f, Texture.Height / 2f);
            BodyPart.Mass = 1f;
            BodyPart.Position = initialpos;
            BodyPart.FixedRotation = true;
            BodyPart.UserData = this;
            BodyPart.BodyType = FarseerPhysics.Dynamics.BodyType.Dynamic;
            BodyPart.OnCollision += new FarseerPhysics.Dynamics.OnCollisionEventHandler(BodyPart_OnCollision);
            BodyPart.Friction = 1f;
            BodyPart.Restitution = 0f;
        }
Пример #4
0
        public override void HandleInput(AxiosGameScreen gameScreen, InputState input, GameTime gameTime)
        {
            base.HandleInput(gameScreen, input, gameTime);
            //if (gameScreen.Console != null && gameScreen.Console.Active)
            //    return;
            PlayerIndex p;
            Animate = false;

            if (input.IsKeyPressed(Keys.A, PlayerIndex.One, out p))
            {
                Move(Direction.Left);
            }

            if (input.IsKeyPressed(Keys.W, PlayerIndex.One, out p) && !jumping)
            {
                Move(Direction.Up);
                jumping = true;
            }
            //else if (input.IsKeyPressed(Keys.S, PlayerIndex.One, out p))
            //{
            //    Move(Direction.Down);
            //}
            if (input.IsKeyPressed(Keys.D, PlayerIndex.One, out p))
            {
                Move(Direction.Right);
            }
            else
            {
                //BodyPart.LinearVelocity = Vector2.Zero;
            }
        }
Пример #5
0
        public override void Update(AxiosGameScreen gameScreen, GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            // Issue here: if you add a timer later on and use the algorithm of
            // gameTime.TotalGameTime - lastTick >= interval
            // The timer will always run
            // What we should do is have an offset of the time it was added like this:
            // ((gameTime.TotalGameTime - offset) - lastTick)  >= interval
            if (gameScreen.ScreenManager.Game.IsActive) //only "tick" if the window has focus - otherwise the Timer will play catchup
            {
                if (offset == null)
                {
                    offset = gameTime.TotalGameTime;
                    return;
                }
                if (_enabled)
                {
                    if (((gameTime.TotalGameTime - offset) - lastTick) >= interval)
                    {
                        if (Tick != null)
                        {
                            //EventArgs e = new EventArgs();
                            //System.Diagnostics.Debugger.Break();
                            Tick(this, null);
                        }

                        lastTick = gameTime.TotalGameTime;
                    }
                }
                else
                {
                    lastTick = gameTime.TotalGameTime;
                }
            }
        }
        public override void Update(AxiosGameScreen gameScreen, Microsoft.Xna.Framework.GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameScreen, gameTime, otherScreenHasFocus, coveredByOtherScreen);

            if (!_calledBodyBroken)
            {
                if (Body.Broken == true)
                    OnBodyBreak(this);
            }
        }
        public override void LoadContent(AxiosGameScreen gameScreen)
        {
            base.LoadContent(gameScreen);

            CreateObjects(gameScreen);

            foreach (SimpleAxiosGameObject obj in GameObjects)
            {
                gameScreen.AddGameObject(obj);
            }
        }
 public void Draw(AxiosGameScreen gameScreen, Microsoft.Xna.Framework.GameTime gameTime)
 {
     if (_isbroken)
     {
         if (BodyParts.Count > 0 && BodyParts[0] is IDrawableAxiosGameObject)
         {
             foreach (SimpleAxiosGameObject b in BodyParts)
                 ((IDrawableAxiosGameObject)b).Draw(gameScreen, gameTime);
         }
     }
     else
     {
         if (BodyPart != null && BodyPart is IDrawableAxiosGameObject)
             ((IDrawableAxiosGameObject)BodyPart).Draw(gameScreen, gameTime);
     }
 }
 public virtual void Draw(AxiosGameScreen gameScreen, GameTime gameTime)
 {
     /*for(int i = 0; i < Body.Parts.Count; i++)
     {
         if (_relativetocamera)
             gameScreen.ScreenManager.SpriteBatch.Begin(0, null, null, null, null, null, gameScreen.Camera.View);
         else
             gameScreen.ScreenManager.SpriteBatch.Begin();
         if (_adjustunits)
             DrawObject(gameScreen.ScreenManager.SpriteBatch, Textures[i], Body.Parts[i].Body, Origins[i], true);
         else
             DrawObject(gameScreen.ScreenManager.SpriteBatch, Textures[i], Body.Parts[i].Body, Origins[i]);
         gameScreen.ScreenManager.SpriteBatch.End();
     }*/
     if (_isbroken)
         if (BodyParts.Count > 0)
             foreach (SimpleDrawableAxiosGameObject obj in BodyParts)
                 obj.Draw(gameScreen, gameTime);
         else
             if (BodyPart != null)
                 BodyPart.Draw(gameScreen, gameTime);
 }
Пример #10
0
 private void OnEvent(AxiosHandler e, AxiosGameScreen gameScreen, InputState input)
 {
     AxiosHandler handle = e;
     if (handle != null)
         handle(this, gameScreen, input);
 }
Пример #11
0
 public virtual void OnValueChange(AxiosGameScreen gameScreen, InputState input)
 {
     this.OnEvent(ValueChange, gameScreen, input);
 }
Пример #12
0
 public virtual void Update(AxiosGameScreen gameScreen, Microsoft.Xna.Framework.GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
 {
 }
Пример #13
0
 public virtual void UnloadContent(AxiosGameScreen gameScreen)
 {
     RemoveEvents();
 }
 //The developer will have to define the BodyParts creation in an overriden method
 public abstract void CreateBodyParts(AxiosGameScreen gameScreen);
Пример #15
0
 public AxiosCommandConsole(AxiosGameScreen gameScreen)
     : base(gameScreen.ScreenManager.Game)
 {
     GameScreen = gameScreen;
     Keyboard = gameScreen.ScreenManager.InputState;
 }
Пример #16
0
 public virtual void OnMouseHover(AxiosGameScreen gameScreen, InputState input)
 {
     this.OnEvent(MouseHover, gameScreen, input);
 }
 public abstract void CreateObjects(AxiosGameScreen gameScreen);
Пример #18
0
 public override void LoadContent(AxiosGameScreen gameScreen)
 {
     base.LoadContent(gameScreen);
     CreateBodyFromTexture(gameScreen);
     this.BodyPart.BodyType = BodyType.Static;
 }
        public override void LoadContent(AxiosGameScreen gameScreen)
        {
            base.LoadContent(gameScreen);

            Body = new BreakableBody();
        }
        public override void LoadContent(AxiosGameScreen gameScreen)
        {
            base.LoadContent(gameScreen);

            BodyParts = new List<SimpleAxiosGameObject>();

            CreateBodyPart(gameScreen);
            CreateBodyParts(gameScreen);

            gameScreen.AddGameObject(BodyPart);
            BodyPart.BodyPart.Enabled = true;
            foreach (SimpleAxiosGameObject obj in BodyParts)
            {
                gameScreen.AddGameObject(obj);
                obj.BodyPart.Enabled = false;
            }
        }
Пример #21
0
 public virtual void OnFocusEnter(AxiosGameScreen gameScreen, InputState input)
 {
     this.HasFocus = true;
     this.OnEvent(FocusEnter, gameScreen, input);
 }
Пример #22
0
 public override void UnloadContent(AxiosGameScreen gameScreen)
 {
     AxiosLog.Instance.AddLine("[Axios Engine] - Unloading SimpleAxiosGameObject " + Name, LoggingFlag.DEBUG);
     base.UnloadContent(gameScreen);
     gameScreen.World.RemoveBody(BodyPart);
 }
Пример #23
0
 public virtual void OnFocusLeave(AxiosGameScreen gameScreen, InputState input)
 {
     this.HasFocus = false;
     this.OnEvent(FocusLeave, gameScreen, input);
 }
Пример #24
0
 public virtual void HandleInput(AxiosGameScreen gameScreen, InputState input, GameTime gameTime)
 {
 }
Пример #25
0
 public GameConsole(AxiosGameScreen gameScreen)
     : base(gameScreen)
 {
     //LoadDefault();
 }
Пример #26
0
 public virtual void LoadContent(AxiosGameScreen gameScreen)
 {
 }
Пример #27
0
 public AxiosCommandConsole(AxiosGameScreen gameScreen, SpriteFont font)
     : base(gameScreen.ScreenManager.Game, font)
 {
     GameScreen = gameScreen;
     Keyboard = gameScreen.ScreenManager.InputState;
 }
 public override void Update(AxiosGameScreen gameScreen, Microsoft.Xna.Framework.GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
 {
     base.Update(gameScreen, gameTime, otherScreenHasFocus, coveredByOtherScreen);
 }
 public override void LoadContent(AxiosGameScreen gameScreen)
 {
     base.LoadContent(gameScreen);
 }
Пример #30
0
 public virtual void HandleCursor(AxiosGameScreen gameScreen, InputState input)
 {
 }