Exemplo n.º 1
0
    public void SpawnUnitAt(UnitScript unit, GameObject prefab, int q, int r)
    {
        if (units == null)
        {
            units = new HashSet <UnitScript>();
            unitToGameObjectMap = new Dictionary <UnitScript, GameObject>();
        }

        GameObject myHex_go = hexToGameObjectMap[GetHexAt(q, r)];

        unit.SetHex(GetHexAt(q, r));
        GameObject unitPlumber_go = (GameObject)Instantiate(prefab, new Vector3(myHex_go.transform.position.x, 1, myHex_go.transform.position.z), Quaternion.identity, myHex_go.transform);

        unit.OnUnitMoved  += unitPlumber_go.GetComponent <UnitViewScript>().OnUnitMoved;
        unit.ReceivedName += unitPlumber_go.GetComponent <UnitViewScript>().ReceiveName;
        unit.name          = "PlayerPlumber";
        unit.SetName();

        units.Add(unit);
        unitToGameObjectMap.Add(unit, unitPlumber_go);
    }