public void SpawnNewTarget() { mainTarget = Instantiate <GameObject>(Resources.Load <GameObject>("Soldier")).GetComponent <HostFigure>(); mainTarget.name = "Trump"; Vector3 randomPos = new Vector3(Random.Range(spawnableArea.min.x, spawnableArea.max.x), Random.Range(spawnableArea.min.y, spawnableArea.min.y), 0); int tries = 0; while ((randomPos - player.transform.position).sqrMagnitude < 1300 && tries < 100) { ++tries; randomPos = new Vector3(Random.Range(spawnableArea.min.x, spawnableArea.max.x), Random.Range(spawnableArea.min.y, spawnableArea.min.y), 0); } if (tries == 100) { Debug.LogError("Oh hell"); } mainTarget.transform.localPosition = randomPos; mainTarget.Init(HostFigureType.Trump); targetPointer = (Instantiate(Resources.Load("TargetPointer")) as GameObject).GetComponent <OffscreenPointer> (); targetPointer.transform.parent = transform; targetPointer.Init(mainTarget.transform, player.transform); leaderAnimationShown = true; DisplayLeaderSequence(); }
public void SpawnNewSoldier(Vector3 position) { GameObject hostFigureGO = Instantiate(m_hostFigurePrefab) as GameObject; hostFigureGO.transform.localPosition = position; HostFigure hostFigure = hostFigureGO.GetComponent <HostFigure>(); hostFigure.Init(HostFigureType.Soldier); hostFigures.Add(hostFigure); }