Esempio n. 1
0
    public void Refresh()
    {
        var bounds = GameObjectUtil.GetBoundsWithParent(settings.hex).size;

        tileSize        = new Rect();
        tileSize.width  = bounds.x;
        tileSize.height = bounds.z;

        this.spaces = CalcAllPossibleSpaces();
    }
Esempio n. 2
0
    private void ReGenerate()
    {
        var bounds = GameObjectUtil.GetBoundsWithParent(settings.platform).size;

        tileSize        = new Rect();
        tileSize.width  = bounds.x;
        tileSize.height = bounds.z;

        if (tileSize.width == 0 || tileSize.height == 0)
        {
            return;
        }

        this.spaces = CalcAllPossibleSpaces();
    }
Esempio n. 3
0
    private void SetupGround()
    {
        basePlatformBounds = GameObjectUtil.GetBoundsWithParent(basePlatform).size;

        minXPos = float.MaxValue;
        float maxXPos = float.MinValue;

        minZPos = float.MaxValue;
        float maxZPos = float.MinValue;

        foreach (Transform child in transform)
        {
            float x = child.position.x;
            float z = child.position.z;
            if (minXPos > x)
            {
                minXPos = x;
            }
            if (maxXPos < x)
            {
                maxXPos = x;
            }
            if (minZPos > z)
            {
                minZPos = z;
            }
            if (maxZPos < z)
            {
                maxZPos = z;
            }
        }
        int xLength = (int)((maxXPos - minXPos) / basePlatformBounds.x) + 1;
        int zLength = (int)((maxZPos - minZPos) / basePlatformBounds.z) + 1;

        ground = new GameObject[xLength, zLength];
        foreach (Transform child in transform)
        {
            Vector3 pos = GroundIndexOf(child.gameObject);
            ground[(int)pos.x, (int)pos.z] = child.gameObject;
        }
    }