Ejemplo n.º 1
0
 public override void Release()
 {
     base.Release();
     for (int i = 0; i < 4; ++i)
     {
         if (children[i] != null)
         {
             children[i].Release();
         }
     }
     MapEntityFactory.Destroy(groundObject);
 }
Ejemplo n.º 2
0
 public override void ClearGameObject()
 {
     if (groundObject)
     {
         MapEntityFactory.Destroy(groundObject);
     }
     for (int i = 0; i < 4; ++i)
     {
         if (children[i] != null)
         {
             children[i].ClearGameObject();
         }
     }
 }
Ejemplo n.º 3
0
    private IEnumerator RenderCR(RenderInfo info)
    {
        Vector3    pos             = info.globalPosition;
        Vector3Int center          = info.playerPosition;
        float      sqrDist         = Mathf.Pow(pos.x - center.x, 2f) + Mathf.Pow(pos.z - center.z, 2f);
        int        desiredLODScale = (int)Mathf.Pow(2f, lodDistance.Index(sqrDist));

        //        Render(offset, desiredLODScale);
        if (LODScale <= desiredLODScale)
        {
            if (groundObject == null)
            {
                groundObject = MapEntityFactory.Instantiate(MapEntityFactory.shared.groundPrefab);
            }
            float LODOffset = LODScale * 0.5f;
            groundObject.transform.position   = new Vector3(pos.x + LODOffset, size.y * 0.5f, pos.z + LODOffset) * MapRenderer.scale;
            groundObject.transform.localScale = new Vector3(size.x * LODScale, size.y, size.z * LODScale);

            for (int i = 0; i < 4; ++i)
            {
                PlacedMapEntity child = children[i];
                if (child != null)
                {
                    child.ClearGameObject();
                }
            }
        }
        else
        {
            if (groundObject)
            {
                ClearGameObject();
            }
            for (int z = 0; z < 2; ++z)
            {
                for (int x = 0; x < 2; ++x)
                {
                    PlacedMapEntity child = children[z * 2 + x];
                    if (child != null)
                    {
                        int childLODScale = (int)LODScale / 2;
                        child.Render(info.globalPosition + new Vector3Int(x * childLODScale, 0, z * childLODScale), center);
                    }
                }
                yield return(null);
            }
        }
    }
Ejemplo n.º 4
0
 private void Awake()
 {
     shared = this;
 }