예제 #1
0
        //bool sin_active;
        public HexWorld(MVC.View view_,
            int radius_,
            float hex_length__
            )
        {
            view = view_;
            map = new List<List<iTile>>();
            radius = 2 * radius_ - 1;
            cur_team_count = 0;

            tile_size = hex_length__;

            float tR = (float)(Math.Sqrt(3.0f) * tile_size * 1.25);
            float tS = (float)(tile_size * 2.5);
            float tH = (float)(tile_size * 1.25);

            float center_x = (radius_ - 1) * tR * 2 + tR;
            if (radius_ % 2 == 0) center_x += tR;

            float center_y = (radius_ - 1) * (tH + tS) + tS;
            float map_size = tR * (radius_ - 2) * 2;
            float map_outer_r = tR * (radius_ - 1) * 2;

            for (int h = 0; h < radius; h++)
            {
                map.Add(new List<iTile>());
                for (int w = 0; w < radius; w++)
                {

                    Vector3 center;
                    center.X = w * tR * 2 + tR;
                    if (h % 2 == 1) center.X += tR;

                    center.Z = h * (tH + tS) + tS;
                    center.Y = 0.0f;

                    // center tile: map[radius_ - 1][radius_ - 1]

                    float scale_size = (float)2.0 * tile_size;

                    iTile tmp;
                    float dist = (float)Math.Sqrt((Math.Abs(center.X - center_x) * Math.Abs(center.X - center_x))
                                + Math.Abs(center.Z - center_y) * Math.Abs(center.Z - center_y));

                    bool tmp_flag = false;
                    if (dist > map_outer_r)
                    {
                        tmp = new VoidTile();

                    }
                    else if (dist > map_size)
                    {
                        tmp = new BoundaryTile(tile_size, center, new Vector3(scale_size, scale_size, scale_size), w, h);
                        tmp_flag = true;;
                    }
                    else
                    {
                        tmp = new IceTile(tile_size, center, new Vector3(scale_size, scale_size, scale_size), w, h);
                        tmp_flag = true;
                    }

                    map[h].Add(tmp);

                    if (tmp_flag)
                    {
                        view.add_renderable(map[h][w].get_renderable());
                    }

                }
            }
        }
예제 #2
0
 public IceTile(IceTile rhs)
     : base(rhs)
 {
 }
예제 #3
0
        //bool sin_active;
        public World(   MVC.View view_,
		                int width__,
		                int height__,
		                float hex_length__
		        )
        {
            view = view_;
            map = new List< List<iTile> >();
            map_width = width__;
            map_height = height__;
            cur_team_count = 0;

            tile_size = hex_length__;

            float tR = (float)Math.Sqrt(3.0f) * tile_size / 2;
            float tS = tile_size;
            float tH = tile_size / 2;

            tR *= 2.5f;
            tS *= 2.5f;
            tH *= 2.5f;

            Random rand = new Random();

            for (int h = 0; h < map_height; h++)
            {
                map.Add(new List<iTile>());
                for (int w = 0; w < map_width; w++)
                {

                    Vector3 center;
                    center.X = w * tR * 2 + tR;
                    if (h % 2 == 1) center.X += tR;

                    center.Z = h * (tH + tS) + tS;
                    center.Y = 0.0f;

                    /*
                    if((Math.Abs(6 - h) + Math.Abs(7 - w)) < 4){
                        center.Z += 0.6 * tile_size;
                    }
                    else if((Math.Abs(6 - h) + Math.Abs(7 - w)) < 7){
                        center.Z += 0.2 * tile_size;
                    }
                    */

                    float scale_size = (float)2.0 * tile_size;

                    iTile tmp;
                    if (h == 0 || h == map_height - 1 || w == 0 || w == map_width - 1)
                        tmp = new BoundaryTile(tile_size, center, new Vector3(scale_size, scale_size, scale_size), w, h);
                    else
                    {
                        int randint = rand.Next(3);
                        if(randint == 0)
                            tmp = new IceTile(tile_size, center, new Vector3(scale_size, scale_size, scale_size), w, h);
                        else if(randint == 1)
                            tmp = new SoftsnowTile(tile_size, center, new Vector3(scale_size, scale_size, scale_size), w, h);
                        else
                            tmp = new HardsnowTile(tile_size, center, new Vector3(scale_size, scale_size, scale_size), w, h);
                    }

                    map[h].Add(tmp);

                    view.add_renderable(map[h][w].get_renderable());

                }
            }
        }