Scriptum/Assets/Scripts/DungeonItemsFiller.cs

45 lines
1.3 KiB
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DungeonItemsFiller : MonoBehaviour
{
public GameObject itemOriginalOne;
public GameObject itemOneContainer;
private bool wasBuilt = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (!wasBuilt)
{
PlaceItems(20);
}
}
private void PlaceItems(int numberOfItems)
{
Vector3 coords;
for (int i = 0; i < numberOfItems; i++)
{
//GameObject CoinClone = Instantiate(itemOriginalOne);
//GameObject CoinClone = Instantiate(itemOriginalOne, new Vector3(i * 0.6f, itemOriginalOne.transform.position.y, i * 0.75f), itemOriginalOne.transform.rotation);
coords = GameObject.FindObjectOfType<TileMapGenerator>().gameObject.GetComponent<TileMapGenerator>().randomCoordsForStanding();
var CoinClone = Instantiate(itemOriginalOne, coords, Quaternion.identity);
CoinClone.name = "ItemClone-" + (i + 1);
CoinClone.transform.parent = itemOneContainer.transform;
if (i == numberOfItems - 1)
{
wasBuilt = true;
}
}
}
}