Exemplo n.º 1
0
    private GameObject CreateNewHouse(House house)
    {
        GameObject newHouseObj = Instantiate(housePrefab,
                                             house.position + (Vector3.up * house.shape.offset * houseSize), Quaternion.identity);

        newHouseObj.name = "House " + existingHouseObjs.Count;
        HouseManager newHouseManager = newHouseObj.GetComponent <HouseManager>();

        newHouseObj.GetComponent <MeshFilter>().mesh             = house.shape.shape;
        newHouseObj.GetComponent <MeshRenderer>().material.color = house.color.color;
        newHouseManager.house            = house;
        newHouseObj.transform.localScale = Vector3.one * houseSize;
        newHouseObj.transform.GetChild(0).localPosition = Vector3.up * (-house.shape.offset + 0.25f);  //position collider
        newHouseObj.GetComponent <Rigidbody>().AddForce(Vector3.up * bounceForce);
        newHouseManager.InitializeHouse();

        existingHouseObjs.Add(newHouseObj);
        UpdateHeaderText();
        return(newHouseObj);
    }