Beispiel #1
0
    public static Popup Create(IntRect triggerArea, IntRect revealArea, int revealMainIndex)
    {
        var gameObject = new GameObject("Popup " + revealMainIndex);

        gameObject.transform.position = Iso.MapTileToWorld(triggerArea.xMin, triggerArea.yMax);
        var popup = gameObject.AddComponent <Popup>();

        popup.triggerArea     = triggerArea;
        popup.revealArea      = revealArea;
        popup.revealMainIndex = revealMainIndex;
        var collider = gameObject.AddComponent <PolygonCollider2D>();

        collider.points    = Iso.CreateTileRectPoints(triggerArea.width, triggerArea.height);
        collider.isTrigger = true;
        return(popup);
    }
Beispiel #2
0
    public GameObject Instantiate(Vector2i offset)
    {
        var root = new GameObject(name);

        if (info != null)
        {
            var collider = root.AddComponent <PolygonCollider2D>();
            collider.offset    = Iso.MapTileToWorld(offset);
            collider.points    = Iso.CreateTileRectPoints(info.sizeX, info.sizeY);
            collider.isTrigger = true;

            var level = root.AddComponent <Level>();
            level.info = info;

            SelectMonsterTypes();
        }

        int i = 0;

        for (int y = 0; y < gridHeight; ++y)
        {
            for (int x = 0; x < gridWidth; ++x, ++i)
            {
                var ds1     = grid[i];
                int offsetX = offset.x + x * gridX;
                int offsetY = offset.y + y * gridY;
                if (ds1 != null)
                {
                    Instantiate(ds1, offsetX, offsetY, root.transform);
                    InstantiateMonsters(offsetX, offsetY, root.transform);
                }
                else if (info != null && info.drlgType == 3)
                {
                    FillGap(offset, x, y, root.transform);
                    InstantiateMonsters(offsetX, offsetY, root.transform);
                }
            }
        }

        InstantiateDebugGrid(offset, root.transform);

        return(root);
    }
Beispiel #3
0
        public GameObject Instantiate(Vector2i offset)
        {
            UnityEngine.Profiling.Profiler.BeginSample("LevelBuilder.Instantiate");
            var root = new GameObject(name);

            if (info != null)
            {
                var collider = root.AddComponent <PolygonCollider2D>();
                collider.offset    = Iso.MapTileToWorld(offset);
                collider.points    = Iso.CreateTileRectPoints(info.sizeX, info.sizeY);
                collider.isTrigger = true;

                var level = root.AddComponent <Level>();
                level.info = info;

                SelectMonsterTypes();
            }

            InstantiateGrid(offset, root.transform);
            InstantiateDebugGrid(offset, root.transform);

            UnityEngine.Profiling.Profiler.EndSample();
            return(root);
        }