using UnityEngine;
public class ObjectSpawner : MonoBehaviour
{
public GameObject firstObjectPrefab;
public GameObject secondObjectPrefab;
public GameObject thirdObjectPrefab;
public GameObject bombObjectPrefab;
private Vector2 firstPos;
private Vector2 secondPos;
private Vector2 thirdPos;
private Vector2 bombPos;
private void Start()
{
SpawnObjects();
}
private void SpawnObjects()
{
bool validPositions = false;
while (!validPositions)
{
// Generate random positions for all objects
float angle = Random.Range(0f, Mathf.PI * 2f);
float distanceFromCenter = Random.Range(0f, 200f);
firstPos = new Vector2(Mathf.Cos(angle) * distanceFromCenter, Mathf.Sin(angle) * distanceFromCenter);
angle = Random.Range(0f, Mathf.PI * 2f);
distanceFromCenter = Random.Range(0f, 200f);
secondPos = new Vector2(Mathf.Cos(angle) * distanceFromCenter, Mathf.Sin(angle) * distanceFromCenter);
angle = Random.Range(0f, Mathf.PI * 2f);
distanceFromCenter = Random.Range(0f, 200f);
thirdPos = new Vector2(Mathf.Cos(angle) * distanceFromCenter, Mathf.Sin(angle) * distanceFromCenter);
angle = Random.Range(0f, Mathf.PI * 2f);
distanceFromCenter = Random.Range(0f, 256f);
bombPos = new Vector2(Mathf.Cos(angle) * distanceFromCenter, Mathf.Sin(angle) * distanceFromCenter);
// Check if all positions are valid
if (Vector2.Distance(firstPos, secondPos) >= 200f &&
Vector2.Distance(secondPos, thirdPos) >= 200f &&
Vector2.Distance(thirdPos, firstPos) >= 200f &&
Vector2.Distance(firstPos, bombPos) >= 256f &&
Vector2.Distance(secondPos, bombPos) >= 256f &&
Vector2.Distance(thirdPos, bombPos) >= 256f)
{
validPositions = true;
}
}
// Spawn objects at the generated positions
Instantiate(firstObjectPrefab, firstPos, Quaternion.identity);
Instantiate(secondObjectPrefab, secondPos, Quaternion.identity);
Instantiate(thirdObjectPrefab, thirdPos, Quaternion.identity);
Instantiate(bombObjectPrefab, bombPos, Quaternion.identity);
}
}
public int inWordCount;
public int numberInArray = 0;
public int[] wordsCount;
public GameObject[] Letters;
public GameObject[] TakeLetters;
public bool[] IsLetterActive;
private void Start()
{
for (int i = 0; i < IsLetterActive.Length; i++)
{
IsLetterActive[i] = false;
}
}
private void OnTriggerEnter2D(Collider2D col)
{
if (TakeLetters[numberInArray] == null)
{
TakeLetters[numberInArray] = col.gameObject;
}
else
{
while (TakeLetters[numberInArray] != null)
{
numberInArray++;
if (TakeLetters[numberInArray] == null)
{
TakeLetters[numberInArray] = col.gameObject;
}
}
}
if (numberInArray < Letters.Length)
{
numberInArray++;
}
}
private void OnPress(InputValue value)
{
if (value.isPressed)
{
}
else
{
for (int inNumber = 0; inNumber < wordsCount.Length; inNumber++)
{
for (int InLetters = 0; InLetters < TakeLetters.Length; InLetters++)
{
inWordCount = wordsCount[inNumber];
while (inWordCount <= 0)
{
if (TakeLetters[InLetters])
{
}
}
}
}
}
}