Initialize() public méthode

public Initialize ( ) : void
Résultat void
Exemple #1
0
    public void Update()
    {
        while (BufferKVP.Count > 0)
        {
            PlanetSquare ps = BufferKVP [BufferKVP.Count - 1].Value;
            BufferKVP.RemoveAt(BufferKVP.Count - 1);

            if (ps != null)
            {
                ps.Initialize();
                return;
            }
        }
    }
Exemple #2
0
    public void Subdivide(bool usePlanetManager, float priority)
    {
        if (this.childDepth != 0)
        {
            return;
        }

        if (this.subDegree == this.planet.maxSubDegree)
        {
            return;
        }

        this.childDepth = 1;
        if (this.parent != null)
        {
            this.parent.childDepth = 2;
        }
        this.children = new PlanetSquare [4];

        for (int a = 0; a < 2; a++)
        {
            for (int b = 0; b < 2; b++)
            {
                GameObject g = GameObject.Instantiate <GameObject> (this.planet.squareTemplate);
                g.transform.parent        = this.transform;
                g.transform.localPosition = Vector3.zero;
                g.transform.localRotation = Quaternion.identity;
                g.transform.localScale    = Vector3.one;
                PlanetSquare ps = g.GetComponent <PlanetSquare> ();
                ps.subDegree = this.subDegree + 1;

                if ((this.kPos == 0) || (this.kPos == this.indexSize))
                {
                    ps.iPos = 2 * this.iPos - a;
                    ps.jPos = 2 * this.jPos - b;
                    ps.kPos = this.kPos;
                    if (ps.kPos != 0)
                    {
                        ps.kPos = Mathf.FloorToInt(Mathf.Pow(2f, ps.subDegree)) + 1;
                    }
                }
                else if ((this.jPos == 0) || (this.jPos == this.indexSize))
                {
                    ps.iPos = 2 * this.iPos - a;
                    ps.jPos = this.jPos;
                    if (ps.jPos != 0)
                    {
                        ps.jPos = Mathf.FloorToInt(Mathf.Pow(2f, ps.subDegree)) + 1;
                    }
                    ps.kPos = 2 * this.kPos - b;
                }
                else if ((this.iPos == 0) || (this.iPos == this.indexSize))
                {
                    ps.iPos = this.iPos;
                    if (ps.iPos != 0)
                    {
                        ps.iPos = Mathf.FloorToInt(Mathf.Pow(2f, ps.subDegree)) + 1;
                    }
                    ps.jPos = 2 * this.jPos - b;
                    ps.kPos = 2 * this.kPos - a;
                }

                ps.parent = this;
                ps.planet = this.planet;
                this.children [b + 2 * a] = ps;
                ps.name = "Square " + ps.subDegree + "." + ps.iPos + ":" + ps.jPos + ":" + ps.kPos;

                if (usePlanetManager)
                {
                    StellarSystem.Manager.Add(ps, priority);
                }
                else
                {
                    ps.Initialize();
                }
            }
        }
    }