예제 #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;
        }
    }