예제 #1
0
    SpriteMarker make_sprite(Vector3 pos, ConnectionSprite cs, Vector3 offset)
    {
        pos.z = -3f;
        GameObject   g  = GameObject.Instantiate(MapSpritePrefab);
        SpriteMarker sm = g.GetComponent <SpriteMarker>();

        sm.SetSprite(cs);
        sm.transform.position = pos + offset;

        m_sprites.Add(sm);
        //m_sprites.AddRange(sm.CreateMirrorSprites());

        return(sm);
    }
예제 #2
0
    SpriteMarker make_bridge_sprite(Vector3 pos, ConnectionSprite cs, Vector3 offset, bool force, bool flip_x)
    {
        pos.z = -3f;
        GameObject   g  = GameObject.Instantiate(MapSpritePrefab);
        SpriteMarker sm = g.GetComponent <SpriteMarker>();

        sm.SetSprite(cs);
        sm.SetFlip(force, flip_x);
        sm.transform.position = pos + offset;

        m_sprites.Add(sm);
        m_sprites.AddRange(sm.CreateMirrorSprites(m_forced_max, m_forced_min, m_force_mirror));

        return(sm);
    }
예제 #3
0
    public List <SpriteMarker> PlaceSprites()
    {
        MapSpriteSet set = ArtManager.s_art_manager.GetMapSpriteSet(m_node.ProvinceData.Terrain);

        if (!set.MapSprites.Any())
        {
            return(m_sprites);
        }

        int valid_ct = set.MapSprites.Where(x => m_node.ProvinceData.Terrain.IsFlagSet(x.ValidTerrain)).Count();

        if (valid_ct == 0)
        {
            return(m_sprites);
        }

        while (m_sprite_points.Any())
        {
            Vector3        pos = m_sprite_points[0];
            ProvinceSprite ps  = ArtManager.s_art_manager.GetProvinceSprite(m_node.ProvinceData.Terrain);

            if (ps == null)
            {
                m_sprite_points.Remove(pos);
                continue;
            }

            while (UnityEngine.Random.Range(0f, 1f) > ps.SpawnChance)
            {
                ps = ArtManager.s_art_manager.GetProvinceSprite(m_node.ProvinceData.Terrain);

                if (ps == null)
                {
                    break;
                }
            }

            if (ps == null)
            {
                m_sprite_points.Remove(pos);
                continue;
            }

            List <Vector3> remove = m_sprite_points.Where(x => Vector3.Distance(x, pos) < ps.Size).ToList();

            foreach (Vector3 p in remove)
            {
                m_sprite_points.Remove(p);
            }

            //m_sprite_points.Remove(pos);
            pos.z = -3f;

            GameObject   g  = GameObject.Instantiate(MapSpritePrefab);
            SpriteMarker sm = g.GetComponent <SpriteMarker>();
            sm.SetSprite(ps);
            sm.transform.position = pos;

            m_sprites.Add(sm);
            m_sprites.AddRange(sm.CreateMirrorSprites(Vector3.zero, Vector3.zero));
        }

        return(m_sprites);
    }