Exemplo n.º 1
0
    public void InitHexObject(int x, int z, float xPos, float zPos, Hex.HexType_e hexType)
    {
        //GameObject goHex = new GameObject("Hex " + x + "_" + z);
        //goHex.transform.parent = chunkObject.transform;
        //goHex.transform.localPosition = new Vector3(xPos, zPos);

        GameObject goHex = new GameObject("Hex " + x + "_" + z);

        goHex.transform.SetParent(goChunk.transform);
        goHex.transform.localPosition = new Vector3(xPos, 0, zPos);
        goHex.transform.rotation      = Quaternion.identity;
        goHex.tag = "Hex";
        goHex.AddComponent <BoxCollider>();

        HexObject hexObject = goHex.AddComponent <HexObject>();

        hexObject.InitializeHexObject(new Hex(x, z, xPos, zPos, hexType));

        if (!grid.ContainsKey(hexObject.hex))
        {
            grid.Add(hexObject.hex, hexObject);
        }
        else
        {
            grid[hexObject.hex] = hexObject;
        }
    }
Exemplo n.º 2
0
    private Material LoadFromHexMaterials(Hex.HexType_e hexType)
    {
        if (dictMaterials.ContainsKey(hexType))
        {
            string sMaterialPath = "";
            dictMaterials.TryGetValue(hexType, out sMaterialPath);

            if (sMaterialPath != "")
            {
                Material material = Resources.Load(sMaterialPath, typeof(Material)) as Material;
                return(material);
            }
        }
        return(null);
    }