Пример #1
0
 private IEnumerable<DrawableRectangle> DrawSpawnNode(Haxxit.Maps.Point p, Haxxit.Player player, Haxxit.Programs.ProgramFactory program=null)
 {
     List<DrawableRectangle> rectangles = new List<DrawableRectangle>();
     if (program != null)
     {
         rectangles.AddRange(DrawProgramHeadNode(p, player, program.NewInstance()));
     }
     else
     {
         rectangles.AddRange(DrawAvailableNode(p));
         rectangles.Add(new DrawableRectangle(spawn_overlay, p.ToXNARectangle(map_rectangle_size, map_border_size), Color.Purple));
     }
     return rectangles;
 }
Пример #2
0
 public Rectangle HaxxitPointToXnaRectangle(Haxxit.Maps.Point p)
 {
     return p.ToXNARectangle(map_rectangle_size, map_border_size);
 }
Пример #3
0
 private IEnumerable<DrawableRectangle> DrawSilicoinNode(Haxxit.Maps.Point p)
 {
     List<DrawableRectangle> rectangles = new List<DrawableRectangle>();
     Rectangle square = p.ToXNARectangle(map_rectangle_size, map_border_size);
     Rectangle extra = square.DeepCopy().ScaleBy(0.75).CenterAlignOn(square);
     rectangles.Add(new DrawableRectangle(silicoin_overlay, extra, Color.White));
     return rectangles;
 }
Пример #4
0
 private IEnumerable<DrawableRectangle> DrawProgramTailNode(Haxxit.Maps.Point p, Haxxit.Maps.Point connector_direction,
     Haxxit.Player player, Haxxit.Programs.Program program)
 {
     List<DrawableRectangle> rectangles = new List<DrawableRectangle>();
     Tuple<Color, Color> program_colors;
     if (program.GetType() == typeof(Programs.MonoGameProgram))
     {
         Programs.MonoGameProgram monogame_program = (Programs.MonoGameProgram)program;
         program_colors = new Tuple<Color, Color>(monogame_program.HeadColor, monogame_program.TailColor);
     }
     else if (!players.TryGetValue(player, out program_colors))
         program_colors = new Tuple<Color, Color>(Color.Transparent, Color.Transparent);
     Color node_color = program_colors.Item2;
     rectangles.Add(new DrawableRectangle(rounded_rect_full, p.ToXNARectangle(map_rectangle_size, map_border_size), node_color));
     // Used for drawing connectors between nodes.
     foreach (Haxxit.Maps.Point neighbor in p.GetOrthologicalNeighbors())
     {
         if (Map.NodeIsType<Haxxit.Maps.ProgramNode>(neighbor)
             && Map.GetNode<Haxxit.Maps.ProgramNode>(neighbor).Player == player
             && Object.ReferenceEquals(Map.GetNode<Haxxit.Maps.ProgramNode>(neighbor).Program, program))
             rectangles.AddRange(DrawProgramNodeConnector(p, neighbor - p, node_color));
     }
     return rectangles;
 }
Пример #5
0
 private IEnumerable<DrawableRectangle> DrawProgramNodeConnector(Haxxit.Maps.Point p, Haxxit.Maps.Point connector_direction,
     Color node_color)
 {
     List<DrawableRectangle> rectangles = new List<DrawableRectangle>();
     if (!connector_direction.IsDirectional())
     {
         #if DEBUG
             throw new Exception();
         #else
             return rectangles;
         #endif
     }
     DrawableRectangle connector = new DrawableRectangle(rectangle_texture,
         p.ToXNARectangle(map_rectangle_size, map_border_size), node_color);
     Rectangle area = connector.Area;
     if (connector_direction == new Haxxit.Maps.Point(0, 1)) // Down
     {
         area.Y += map_rectangle_size;
         area.Height /= (map_rectangle_size / map_border_size);
         area.Width /= 2;
         area.X += area.Width / 2;
     }
     else if (connector_direction == new Haxxit.Maps.Point(0, -1)) // Up
     {
         area.Y -= map_border_size;
         area.Height /= (map_rectangle_size / map_border_size);
         area.Width /= 2;
         area.X += area.Width / 2;
     }
     else if (connector_direction == new Haxxit.Maps.Point(1, 0)) // Right
     {
         area.X += map_rectangle_size;
         area.Width /= (map_rectangle_size / map_border_size);
         area.Height /= 2;
         area.Y += area.Height / 2;
     }
     else // Left
     {
         area.X -= map_border_size;
         area.Width /= (map_rectangle_size / map_border_size);
         area.Height /= 2;
         area.Y += area.Height / 2;
     }
     connector.Area = area;
     rectangles.Add(connector);
     return rectangles;
 }
Пример #6
0
 private IEnumerable<DrawableRectangle> DrawProgramHeadNode(Haxxit.Maps.Point p, Haxxit.Player player, Haxxit.Programs.Program program)
 {
     List<DrawableRectangle> rectangles = new List<DrawableRectangle>();
     Tuple<Color, Color> program_colors;
     if (program.GetType() == typeof(Programs.MonoGameProgram))
     {
         Programs.MonoGameProgram monogame_program = (Programs.MonoGameProgram)program;
         program_colors = new Tuple<Color, Color>(monogame_program.HeadColor, monogame_program.TailColor);
     }
     else if (!players.TryGetValue(player, out program_colors))
         program_colors = new Tuple<Color, Color>(Color.Transparent, Color.Transparent);
     Color node_color = program_colors.Item1;
     Rectangle rectangle = p.ToXNARectangle(map_rectangle_size, map_border_size);
     rectangles.Add(new DrawableRectangle(rounded_rect_back, rectangle, node_color));
     rectangles.Add(new DrawableRectangle(rounded_rect_border, rectangle, program_colors.Item2));
     string programTextureName = program.TypeName;
     if (!program_textures.ContainsKey(programTextureName))
         program_textures.Add(programTextureName, content.Load<Texture2D>(programTextureName));
     rectangles.Add(new DrawableRectangle(program_textures[programTextureName],
         p.ToXNARectangle(map_rectangle_size, map_border_size).ScaleBy(0.75).CenterAlignOn(rectangle), Color.White));
     foreach (Haxxit.Maps.Point neighbor in p.GetOrthologicalNeighbors())
     {
         if (Map.NodeIsType<Haxxit.Maps.ProgramNode>(neighbor)
             && Map.GetNode<Haxxit.Maps.ProgramNode>(neighbor).Player == player
             && Object.ReferenceEquals(Map.GetNode<Haxxit.Maps.ProgramNode>(neighbor).Program, program))
             rectangles.AddRange(DrawProgramNodeConnector(p, neighbor - p, program_colors.Item2));
     }
     return rectangles;
 }
Пример #7
0
 private IEnumerable<DrawableRectangle> DrawAvailableNode(Haxxit.Maps.Point p)
 {
     List<DrawableRectangle> rectangles = new List<DrawableRectangle>();
     Rectangle square = p.ToXNARectangle(map_rectangle_size, map_border_size);
     rectangles.Add(new DrawableRectangle(rounded_rect_back, square, new Color(52, 96, 141) * 0.5f));
     rectangles.Add(new DrawableRectangle(rounded_rect_border, square, new Color(24, 202, 230)));
     return rectangles;
 }