Ejemplo n.º 1
0
        public bool PlaceBack(byte ID, int x, int y, bool Self = false)
        {
            if (!InBounds(x, y) || (ID == 0))
            {
                return(false);
            }
            Mod.Tile Tile  = Mod.Back[ID];
            Point    Point = new Point(x, y);

            if (Tiles[x, y].Back == ID)
            {
                return(false);
            }
            if (Tile.Frames > 0)
            {
                Tiles[x, y].BackAnimation = new Animation(("Tiles.Back." + ID + "-"), Tile.Frames, true, Tile.Speed);
            }
            else
            {
                Tiles[x, y].BackAnimation = null;
            }
            Tiles[x, y].Back = ID;
            if (Self && (MultiPlayer.Peer() != null))
            {
                MultiPlayer.Send(MultiPlayer.Construct(Game.Packets.PlaceBack, ID, (ushort)x, (ushort)y));
            }
            return(true);
        }
Ejemplo n.º 2
0
        public bool ClearFore(int x, int y, bool Self = false)
        {
            if (!InBounds(x, y) || !Tiles[x, y].HasFore)
            {
                return(false);
            }
            Mod.Tile Tile  = Mod.Fore[Tiles[x, y].Fore];
            Point    Point = new Point(x, y);

            Pathfinder.SetNode(Point, new Pathfinder.Node(true));
            if (Tile.Waypoint.HasValue)
            {
                Waypoints[Tile.Waypoint.Value].Remove(Point);
            }
            if (Tile.Spawn.HasValue)
            {
                Spawns[Tile.Spawn.Value].Remove(Point);
            }
            Tiles[x, y].Fore          = 0;
            Tiles[x, y].Angle         = 0;
            Tiles[x, y].ForeAnimation = null;
            if (Self && (MultiPlayer.Peer() != null))
            {
                MultiPlayer.Send(MultiPlayer.Construct(Game.Packets.ClearFore, (ushort)x, (ushort)y));
            }
            return(true);
        }
Ejemplo n.º 3
0
 public bool ClearBack(int x, int y, bool Self = false)
 {
     if (!InBounds(x, y) || !Tiles[x, y].HasBack)
     {
         return(false);
     }
     Mod.Tile Tile = Mod.Back[Tiles[x, y].Back];
     Tiles[x, y].Back          = 0;
     Tiles[x, y].BackAnimation = null;
     if (Self && (MultiPlayer.Peer() != null))
     {
         MultiPlayer.Send(MultiPlayer.Construct(Game.Packets.ClearBack, (ushort)x, (ushort)y));
     }
     return(true);
 }
Ejemplo n.º 4
0
 public void Draw(Batch Batch, Vector2 Position, float LayerOffset)
 {
     if (Back > 0)
     {
         Mod.Tile Tile = Mod.Back[Back];
         if (!Tile.Invisible || (Game.State == Game.States.MapEditor))
         {
             if (Textures.Exists("Tiles.Back." + Back))
             {
                 Batch.Draw(Textures.Get("Tiles.Back." + Back), Position, null, Color.White, 0, Origin.Center, 1, SpriteEffects.None, (.8f + LayerOffset));
             }
             if (BackAnimation != null)
             {
                 Batch.Draw(BackAnimation.Texture(), Position, null, Color.White, 0, Origin.Center, 1, SpriteEffects.None, (.75f + LayerOffset));
             }
         }
     }
     if (Fore > 0)
     {
         Mod.Tile Tile = Mod.Fore[Fore];
         if (!Tile.Invisible || (Game.State == Game.States.MapEditor))
         {
             float Layer = ((Mod.Fore[Fore].Type == Mod.Tile.Types.Wall) ? .4f : (Mod.Fore[Fore].Type == Mod.Tile.Types.Platform) ? .5f : .6f);
             if (Textures.Exists("Tiles.Fore." + Fore))
             {
                 Batch.Draw(Textures.Get("Tiles.Fore." + Fore), Position, null, Color.White, MathHelper.ToRadians((Angle / 128f) * 360), Origin.Center, 1, SpriteEffects.None, (Layer + LayerOffset));
             }
             if (ForeAnimation != null)
             {
                 Batch.Draw(ForeAnimation.Texture(), Position, null, Color.White, MathHelper.ToRadians((Angle / 128f) * 360), Origin.Center, 1, SpriteEffects.None, (Layer - .05f + LayerOffset));
             }
             if (Mod.Fore[Fore].Border)
             {
                 Batch.Draw(Textures.Get("Tiles.Fore." + Fore + "b"), Position, null, Color.Black, MathHelper.ToRadians((Angle / 128f) * 360), Origin.Center, 1, SpriteEffects.None, (Layer + .05f + LayerOffset));
             }
         }
     }
     //Batch.Draw(Pixel(Color.Black, true), new Rectangle((int)(Position.X - (Width / 2f)), (int)(Position.Y - (Height / 2f)), Width, Height), null, (Color.White * (1 - (Light / 255f))), 0, Origin.None);
     //Batch.DrawString(Light.ToString(), Fonts.Get("Default/Tiny"), (Position - new Vector2(0, 5)), Origin.Center, Color.White, null, 0, .85f);
     //Batch.DrawString(Max.ToString(), Fonts.Get("Default/Tiny"), (Position + new Vector2(0, 5)), Origin.Center, Color.White, null, 0, .85f);
     //Batch.DrawString(State.ToString(), Fonts.Get("Default/Tiny"), Position, Origin.Center, Color.White, null, 0, .85f);
 }
Ejemplo n.º 5
0
        public bool PlaceFore(byte ID, int x, int y, byte?Angle = null, bool Self = false)
        {
            if (!InBounds(x, y) || (ID == 0))
            {
                return(false);
            }
            Mod.Tile Tile  = Mod.Fore[ID];
            Point    Point = new Point(x, y);

            if (Tile.Type == (Mod.Tile.Types.Platform | Mod.Tile.Types.Wall))
            {
                Pathfinder.SetNode(Point, new Pathfinder.Node(false));
            }
            else
            {
                Pathfinder.SetNode(Point, new Pathfinder.Node(true));
            }
            if (Tile.Waypoint.HasValue && !Waypoints[Tile.Waypoint.Value].Contains(Point))
            {
                Waypoints[Tile.Waypoint.Value].Add(Point);
            }
            if (Tile.Spawn.HasValue && !Spawns[Tile.Spawn.Value].Contains(Point))
            {
                Spawns[Tile.Spawn.Value].Add(Point);
            }
            if (!Angle.HasValue)
            {
                if (Tile.ClipToFore)
                {
                    Angle = 128;
                    ushort RFore = this.RFore(Point), BFore = this.BFore(Point), LFore = this.LFore(Point), AFore = this.AFore(Point);
                    if ((RFore > 0) && Mod.Fore[RFore].Type == (Mod.Tile.Types.Platform | Mod.Tile.Types.Wall))
                    {
                        Angle = 0;
                    }
                    else if ((BFore > 0) && Mod.Fore[BFore].Type == (Mod.Tile.Types.Platform | Mod.Tile.Types.Wall))
                    {
                        Angle = 32;
                    }
                    else if ((LFore > 0) && Mod.Fore[LFore].Type == (Mod.Tile.Types.Platform | Mod.Tile.Types.Wall))
                    {
                        Angle = 64;
                    }
                    else if ((AFore > 0) && Mod.Fore[AFore].Type == (Mod.Tile.Types.Platform | Mod.Tile.Types.Wall))
                    {
                        Angle = 96;
                    }
                    if (Angle.Value == 128)
                    {
                        return(false);
                    }
                }
                else
                {
                    Angle = 0;
                }
            }
            if ((Tiles[x, y].Fore == ID) && (Tiles[x, y].Angle == Angle.Value))
            {
                return(false);
            }
            if (Tile.Frames > 0)
            {
                Tiles[x, y].ForeAnimation = new Animation(("Tiles.Fore." + ID + "-"), Tile.Frames, true, Tile.Speed);
            }
            else
            {
                Tiles[x, y].ForeAnimation = null;
            }
            Tiles[x, y].Fore  = ID;
            Tiles[x, y].Angle = Angle.Value;
            if (Self && (MultiPlayer.Peer() != null))
            {
                MultiPlayer.Send(MultiPlayer.Construct(Game.Packets.PlaceFore, ID, (ushort)x, (ushort)y, Angle));
            }
            return(true);
        }