Ejemplo n.º 1
0
    public GameObject SpawnOccupant(GameObject prefab, IntVector2 pos, bool overrideOccupied = false)
    {
        if (prefab == null || (Occuppied(pos) && !overrideOccupied))
        {
            Debug.LogError("Error adding occupant!");
            return(null);
        }

        GameObject instance = Instantiate(prefab, this.transform);

        instance.name = prefab.name;
        tiles[pos.x, pos.y].occupant = instance;
        instance.transform.position  = (Vector3)pos;

        IntTransform mov = instance.GetComponent <IntTransform>();

        if (mov)
        {
            mov.SetPos(pos);
        }

        PlayerController playerController = instance.GetComponent <PlayerController>();

        if (playerController != null)
        {
            players.Add(playerController);
        }

        return(instance);
    }
Ejemplo n.º 2
0
    public GameObject SpawnCollectable(GameObject prefab, IntVector2 pos)
    {
        if (prefab == null)
        {
            Debug.LogError("Error adding collectable");
            return(null);
        }

        GameObject instance = Instantiate(prefab, this.transform);

        instance.name = prefab.name;
        instance.transform.position = (Vector3)pos;

        IntTransform mov = instance.GetComponent <IntTransform>();

        if (mov)
        {
            mov.SetPos(pos);
        }
        return(instance);
    }