Exemplo n.º 1
0
    IEnumerator GenPart(int xPart, int yPart)
    {
        bool alreadyExists = false;

        for (int i = 0; i < terainList.Count; i++)
        {
            if (terainList[i].StartX == xPart && terainList[i].StartY == yPart)
            {
                alreadyExists = true;
            }
        }
        if (!alreadyExists)
        {
            //Debug.Log("xPart: "+xPart+" yPart: "+yPart);

            TerainGen newTerain = ((GameObject)GameObject.Instantiate(baseTerain.gameObject, Vector3.zero, Quaternion.identity)).GetComponent <TerainGen>();


            newTerain.StartX = xPart;
            newTerain.StartY = yPart;
            newTerain.MapX   = (terainSize + 1);
            newTerain.MapY   = (terainSize + 1);
            newTerain.Generate();
            terainList.Add(newTerain);
            newTerain.transform.parent = transform;
            newTerain.gameObject.AddComponent <MeshCollider>();

            yield return(null);
        }
    }
Exemplo n.º 2
0
    bool GenPart(int newPartX, int newPartY)
    {
        bool alreadyExists = false;

        for (int i = 0; i < tileCount; i++)
        {
            if (terainList[i].startX == newPartX && terainList[i].startY == newPartY)
            {
                alreadyExists = true;
                return(false);
            }
        }
        if (!alreadyExists)
        {
            TerainGen newTerain = ((GameObject)GameObject.Instantiate(baseTerain.gameObject, Vector3.zero, Quaternion.identity)).GetComponent <TerainGen>();

            newTerain.SetStartX = newPartX;
            newTerain.SetStartY = newPartY;
            newTerain.Generate();
            terainList[tileCount]      = newTerain;
            newTerain.transform.parent = transform;

            tileCount++;

            return(true);
        }
        return(false);
    }
    /// <summary>
    /// generates a tain tile
    /// </summary>
    /// <param name="newPartX">X position of new tile</param>
    /// <param name="newPartY">Y position of new tile</param>
    void GenPart(int newPartX, int newPartY)
    {
        TerainGen newTerain = ((GameObject)GameObject.Instantiate(baseTerain.gameObject, Vector3.zero, Quaternion.identity)).GetComponent <TerainGen>();

        newTerain.SetStartX = newPartX;
        newTerain.SetStartY = newPartY;

        newTerain.Generate();
        terainList.Add(newTerain);
        newTerain.transform.parent = transform;
    }