예제 #1
0
    public Ground_tile ChanceChoose(int _x, int _y, Vector2 worldPos)
    {
        int         chance = 80;
        Ground_tile ret    = new Ground_tile(worldPos, _x, _y);

        for (int x = -2; x < 1; x++)
        {
            for (int y = -2; y < 1; y++)
            {
                if (x == 0 && y == 0)
                {
                    continue;
                }
                int xt = _x + x;
                int yt = _y + y;
                xt = Mathf.Clamp(xt, 0, world.Border_X - 1);
                yt = Mathf.Clamp(yt, 0, world.Border_Y - 1);

                ground_type temp = (world.map[xt, yt] != null) ? world.map[xt, yt].type: ground_type.world_grass;
                if (temp == ground_type.world_grass)
                {
                    continue;
                }

                int chance_t = random_int(0, 100);
                if (chance_t > chance)
                {
                    chance   = chance_t;
                    ret.type = temp;
                }
            }
        }

        if (ret.type != ground_type.world_grass)
        {
            return(ret);
        }

        chance = random_int(0, 100);
        if (chance < ChanceWood)
        {
            ret.type = ground_type.wood;
            //ret.sprite = wood[random_int(0, wood.Length)];
            //ret.type = ground_type.wood;
        }
        else if (chance < ChanceBlocks + ChanceWood)
        {
            ret.type = ground_type.blocks;
            //ret.type = ground_type.blocks;
            //ret.sprite = blocks[random_int(0, blocks.Length)];
        }
        else if (chance < ChanceBlocks + ChanceWood + ChanceSand)
        {
            ret.type = ground_type.sand;
            //ret.type = ground_type.grass_s;
            //ret.sprite = grass_Special[random_int(0, grass_Special.Length)];
        }
        return(ret);
    }
예제 #2
0
 void CreateX4(float x, float y, Sprite sprite, int pixels, ground_type gt)
 {
     float skip = (pixels / 4 * scale);
     float move = (pixels / 2 * scale) - skip;
     //self.CreateTexture(x - skip, y - skip, sprite, gt);
     //self.CreateTexture(x + move, y - skip, sprite, gt);
     //self.CreateTexture(x + move, y + move, sprite, gt);
     //self.CreateTexture(x - skip, y + move, sprite, gt);
 }
예제 #3
0
    void CreateX8(float x, float y, Sprite sprite, int pixels, ground_type gt)
    {
        float skip = (pixels / 4 * scale);
        float move = (pixels / 2 * scale) - skip;

        CreateX4(x - skip, y - skip, sprite, pixels / 2, gt);
        CreateX4(x + move, y - skip, sprite, pixels / 2, gt);
        CreateX4(x + move, y + move, sprite, pixels / 2, gt);
        CreateX4(x - skip, y + move, sprite, pixels / 2, gt);
    }
예제 #4
0
 public void SelectTileSprite(tile_typ2e type, ground_type gt, Vector2 pos)
 {
     if (gt == ground_type.sand)
     {
         foreach (Sprite s in sand)
         {
             if (s.name.Contains(type.ToString()))
             {
                 CreateTexture(pos, s, gt);
             }
         }
     }
 }
예제 #5
0
    public tile_typ2e GetType(int _x, int _y, ground_type type)
    {
        Dictionary <tile_typ2e, bool> CanBe = new Dictionary <tile_typ2e, bool>();

        foreach (tile_typ2e t in EnumCheck <tile_typ2e> .GetEnumValues())
        {
            CanBe.Add(t, false);
            if (t == tile_typ2e.mid)
            {
                CanBe[t] = true;
            }
        }


        for (int x = -1; x < 2; x++)
        {
            for (int y = -1; y < 2; y++)
            {
                if (x == 0 && y == 0)
                {
                    continue;
                }

                int xt = _x + x;
                int yt = _y + y;
                xt = Mathf.Clamp(xt, 0, world.Border_X - 1);
                yt = Mathf.Clamp(yt, 0, world.Border_Y - 1);
                if (xt == _x && yt == _y)
                {
                    continue;
                }

                ground_type t = world.map[xt, yt].type;
                if (t != type)
                {
                    CanBe[tile_typ2e.mid] = false;
                    continue;
                }

                if (x == -1)
                {
                    if (y == -1)
                    {
                    }
                }
            }
        }

        return(tile_typ2e.eev);
    }
예제 #6
0
    public void CreateTexture(Vector2 pos, Sprite sprite, ground_type gt)
    {
        Transform      child = Instantiate(game_Object).transform;
        SpriteRenderer sr    = child.GetComponent <SpriteRenderer>();

        //child.gameObject.AddComponent<Unselectable>();
        if (gt == ground_type.world_grass)
        {
            sr.sortingLayerName = "wgrass";
        }
        else
        {
            sr.sortingLayerName = "ground";
        }

        sr.sprite = sprite;
        child.SetParent(ground_t);
        child.localPosition = pos;
        child.localScale    = new Vector3(scale, scale, 1);

        //print(gt);
    }