Exemple #1
0
 public new void Update(GameTime gameTime, OWPlayer player)
 {
     base.Update(gameTime, player);
     if (movement.trigger == Movement.Trigger.AUTO)
     {
         RunEventCommand(script, player);
     }
     if (movement.trigger == Movement.Trigger.TOUCH)
     {
         bool touching = (player.travel.X == 0 && player.travel.Y == 0 && player.GetMapPos()[Character.Z] == mapZ && (
                              (player.GetDir() == Tile.Direction.NORTH && player.GetMapPos()[Character.X] == mapX && player.GetMapPos()[Character.Y] == mapY - 1) ||
                              (player.GetDir() == Tile.Direction.SOUTH && player.GetMapPos()[Character.X] == mapX && player.GetMapPos()[Character.Y] == mapY + 1) ||
                              (player.GetDir() == Tile.Direction.EAST && player.GetMapPos()[Character.X] == mapX - 1 && player.GetMapPos()[Character.Y] == mapY) ||
                              (player.GetDir() == Tile.Direction.WEST && player.GetMapPos()[Character.X] == mapX + 1 && player.GetMapPos()[Character.Y] == mapY)));
         if (!touching)
         {
             touching = false;
         }
         if (touching && !touched)
         {
             touched = true;
             RunEventCommand(script, player);
         }
     }
     if (!Global.action.dialog.visible)
     {
         sentRun = false;
     }
     if (!sentRun)
     {
         UpdateMovement(gameTime);
     }
 }
 public void UpdateTrigger(OWPlayer player)
 {
     if (player.GetMapPos()[Character.Z] == mapZ && (((dir == Tile.Direction.NORTH || dir == Tile.Direction.SOUTH) && player.GetMapPos()[Character.X] == mapX) || (dir == Tile.Direction.WEST && player.GetMapPos()[Character.X] + 1 == mapX) || (dir == Tile.Direction.EAST && player.GetMapPos()[Character.X] - 1 == mapX)) && (((dir == Tile.Direction.WEST || dir == Tile.Direction.EAST) && player.GetMapPos()[Character.Y] == mapY) || (dir == Tile.Direction.NORTH && player.GetMapPos()[Character.Y] - 1 == mapY) || (dir == Tile.Direction.SOUTH && player.GetMapPos()[Character.Y] + 1 == mapY)))
     {
         state = 1;
     }
     else
     {
         state = -1;
     }
     if (player.GetMapPos()[Character.X] == mapX && player.GetMapPos()[Character.Y] == mapY && player.GetMapPos()[Character.Z] == mapZ && ((player.GetDir() == Tile.Direction.NORTH && dir == Tile.Direction.SOUTH) || (player.GetDir() == Tile.Direction.SOUTH && dir == Tile.Direction.NORTH) || (player.GetDir() == Tile.Direction.EAST && dir == Tile.Direction.WEST) || (player.GetDir() == Tile.Direction.WEST && dir == Tile.Direction.EAST)))
     {
         state = -1;
         Global.action.SetTileMap(mapDestKey, destPos, (playerDir != Tile.Direction.NONE)?playerDir:player.GetDir());
         player.Move(playerDir);
     }
     if (player.GetDir() == dir && player.GetMapPos()[Character.X] == mapX && player.GetMapPos()[Character.Y] == mapY && player.GetMapPos()[Character.Z] == mapZ)
     {
         state = 1;
     }
 }
 public void UpdateTrigger(OWPlayer player)
 {
     if (player.GetMapPos()[Character.Z] == mapZ && (((dir == Tile.Direction.NORTH || dir == Tile.Direction.SOUTH) && player.GetMapPos()[Character.X] == mapX) || (dir == Tile.Direction.WEST && player.GetMapPos()[Character.X] + 1 == mapX) || (dir == Tile.Direction.EAST && player.GetMapPos()[Character.X] - 1 == mapX)) && (((dir == Tile.Direction.WEST || dir == Tile.Direction.EAST) && player.GetMapPos()[Character.Y] == mapY) || (dir == Tile.Direction.NORTH && player.GetMapPos()[Character.Y] - 1 == mapY) || (dir == Tile.Direction.SOUTH && player.GetMapPos()[Character.Y] + 1 == mapY)))
     {
         state = 1;
     }else{
         state = -1;
     }
     if (player.GetMapPos()[Character.X] == mapX && player.GetMapPos()[Character.Y] == mapY && player.GetMapPos()[Character.Z] == mapZ && ((player.GetDir() == Tile.Direction.NORTH && dir == Tile.Direction.SOUTH) || (player.GetDir() == Tile.Direction.SOUTH && dir == Tile.Direction.NORTH) || (player.GetDir() == Tile.Direction.EAST && dir == Tile.Direction.WEST) || (player.GetDir() == Tile.Direction.WEST && dir == Tile.Direction.EAST)))
     {
         state = -1;
         Global.action.SetTileMap(mapDestKey, destPos, (playerDir != Tile.Direction.NONE)?playerDir:player.GetDir());
         player.Move(playerDir);
     }
     if (player.GetDir() == dir && player.GetMapPos()[Character.X] == mapX && player.GetMapPos()[Character.Y] == mapY && player.GetMapPos()[Character.Z] == mapZ)
     {
         state = 1;
     }
 }
 public new void Update(GameTime gameTime, OWPlayer player)
 {
     base.Update(gameTime, player);
     if (movement.trigger == Movement.Trigger.AUTO){
         RunEventCommand(script, player);
     }
     if (movement.trigger == Movement.Trigger.TOUCH){
         bool touching = (player.travel.X == 0 && player.travel.Y == 0 && player.GetMapPos()[Character.Z] == mapZ && (
             (player.GetDir() == Tile.Direction.NORTH && player.GetMapPos()[Character.X] == mapX && player.GetMapPos()[Character.Y] == mapY - 1) ||
             (player.GetDir() == Tile.Direction.SOUTH && player.GetMapPos()[Character.X] == mapX && player.GetMapPos()[Character.Y] == mapY + 1) ||
             (player.GetDir() == Tile.Direction.EAST && player.GetMapPos()[Character.X] == mapX - 1 && player.GetMapPos()[Character.Y] == mapY) ||
             (player.GetDir() == Tile.Direction.WEST && player.GetMapPos()[Character.X] == mapX + 1 && player.GetMapPos()[Character.Y] == mapY)));
         if (!touching) touching = false;
         if (touching && !touched){
             touched = true;
             RunEventCommand(script, player);
         }
     }
     if (!Global.action.dialog.visible)
         sentRun = false;
     if(!sentRun)
         UpdateMovement(gameTime);
 }
        public void Draw(SpriteBatch spriteBatch)
        {
            GraphicsDevice g = spriteBatch.GraphicsDevice;

            #region EffectMath
            basicEffect.World      = world * Matrix.CreateRotationX(-0.3f);
            basicEffect.View       = Global.view;
            basicEffect.Projection = Global.projection * Global.screenScale;
            alphaEffect.World      = world * Matrix.CreateRotationX(-0.3f);
            alphaEffect.View       = Global.view;
            alphaEffect.Projection = Global.projection * Global.screenScale;
            //maybe next line only on change?
            #endregion
            foreach (Building b in buildings)
            {
                b.Draw(world, basicEffect, nightTime);
            }
            vertexBuffer.SetData <VertexPositionNormalTexture>(vertices);
            g.SetVertexBuffer(vertexBuffer);
            g.RasterizerState = rasterizerState;
            #region TileDraw
            int m = 0;
            for (int i = 0; i < tiles.GetLength(0); i++)
            {
                for (int j = 0; j < tiles.GetLength(1); j++)
                {
                    for (int k = 0; k < tiles.GetLength(2); k++)
                    {
                        if (tiles[i, j, k] != null)
                        {
                            basicEffect.Texture = tiles[i, j, k].GetTexture();
                            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                            {
                                pass.Apply();
                                g.DrawPrimitives(PrimitiveType.TriangleStrip, m * 4, 2);
                            }
                            m++;
                        }
                    }
                }
            }
            #endregion

            m = 0;
            //g.DepthStencilState = new DepthStencilState() { DepthBufferEnable = false };
            g.DepthStencilState = DepthStencilState.Default;
            #region EventDraw
            for (int j = events.GetLength(1) - 1; j >= 0; j--)
            {
                for (int k = events.GetLength(2) - 1; k >= 0; k--)
                {
                    for (int i = events.GetLength(0) - 1; i >= 0; i--)
                    {
                        if ((i == player.GetMapPos()[Character.X]) && (j == player.GetMapPos()[Character.Y]) && k == player.GetMapPos()[Character.Z])
                        {
                            alphaEffect.Texture = player.GetTexture();
                            foreach (EffectPass pass in alphaEffect.CurrentTechnique.Passes)
                            {
                                pass.Apply();
                                g.DrawPrimitives(PrimitiveType.TriangleStrip, charVertsOffset, 2);
                            }
                            player.DebugDraw(spriteBatch);
                        }
                        if (events[i, j, k] != null)
                        {
                            alphaEffect.Texture = events[i, j, k].GetTexture();
                            foreach (EffectPass pass in alphaEffect.CurrentTechnique.Passes)
                            {
                                pass.Apply();
                                g.DrawPrimitives(PrimitiveType.TriangleStrip, eventVertsOffset + m * 4, 2);
                            }
                            events[i, j, k].DebugDraw(spriteBatch);
                            m++;
                        }
                    }
                }
            }
            #endregion
            //g.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
        }