예제 #1
0
    public static void SpawnResourcesOnly(Transform target)
    {
        GameObject LootCrateObj = Instantiate(GameManager.Instance.LootCratePrefab);

        // LootCrateObj.transform.position = new Vector3(target.transform.position.x, LootCrateObj.transform.position.y, target.transform.position.z);
        LootCrateObj.transform.position = target.transform.position;
        LootCrate crate = LootCrateObj.GetComponent <LootCrate>();

        crate.AmtGold  = Random.Range(0, 9);
        crate.AmtWood  = Random.Range(0, 9);
        crate.AmtStone = Random.Range(0, 9);
        crate.AmtFood  = Random.Range(0, 9);

        crate.Init();
    }
예제 #2
0
    public static void SpawnLootcrateOn(Transform target)
    {
        GameObject LootCrateObj = Instantiate(GameManager.Instance.LootCratePrefab);

        LootCrateObj.transform.position = new Vector3(target.transform.position.x, LootCrateObj.transform.position.y, target.transform.position.z);
        LootCrate crate = LootCrateObj.GetComponent <LootCrate>();
        Inventory myInv = target.GetComponent <Inventory>();

        crate.AmtGold  = myInv.GetAmtResource(Inventory.ResourceType.Gold);
        crate.AmtWood  = myInv.GetAmtResource(Inventory.ResourceType.Wood);
        crate.AmtStone = myInv.GetAmtResource(Inventory.ResourceType.Stone);
        crate.AmtFood  = myInv.GetAmtResource(Inventory.ResourceType.Food);

        myInv.ItemHolder.transform.SetParent(crate.ItemHolder.transform);
        crate.ItemHolder.transform.GetChild(0).localRotation = new Quaternion(0, 0, 0, 0);
        crate.ItemHolder.transform.GetChild(0).localScale    = new Vector3(1, 1, 1);
        crate.ItemHolder.transform.GetChild(0).localPosition = new Vector3(0, 0, 0);
        crate.ItemHolder.GetComponent <ScrollRect>().content =
            crate.ItemHolder.transform.GetChild(0).GetComponent <Image>().rectTransform;

        crate.Init();
    }