void GenerateWorld() { float width = UnityEngine.Random.Range(world_WidthRange.x, world_WidthRange.y); float height = UnityEngine.Random.Range(world_HeightRange.x, world_HeightRange.y); worldWidth = width; worldHeight = height; Vector3 wVector = new Vector3(0.5f * width, 0f, 0f); Vector3 hVector = new Vector3(0f, 0.5f * height, 0f); tleft.position = CachedTransform.position - wVector; tleft.name = "Left"; tright.position = CachedTransform.position + wVector; tright.name = "Right"; tup.position = CachedTransform.position + hVector; tup.name = "Up"; tdown.position = CachedTransform.position - hVector; tdown.name = "Down"; int wasters = UnityEngine.Random.Range(min_Wasters, max_Wasters); int startupTrash = UnityEngine.Random.Range(min_TrashOnStartup, max_TrashOnStartup); debug_WasterCount = wasters; float offset = GetPadding(); Vector2 groundLevel = tdown.position; CreateGround(); CreateSky(); CreateBackgroundElements(); CreateWorldSegments(); CreateForegroundElements(); TrashHuman.MovementDirection facingDirection; if (UnityEngine.Random.Range(0, 2) == 1) { groundLevel.x = tright.position.x - offset; facingDirection = TrashHuman.MovementDirection.Left; } else { groundLevel.x = tleft.position.x + offset; facingDirection = TrashHuman.MovementDirection.Right; } TrashPlayer player = GameObject.FindObjectOfType <TrashPlayer> (); player.SetStartPosition(groundLevel, facingDirection); GenerateWasters(wasters); GenerateTrash(startupTrash); }
public override void HandleTriggerEnterWithTrashObject(TrashObject trashObject) { if (!isBoundToHuman) { if (trashObject is TrashPlayer) { TrashPlayer player = trashObject as TrashPlayer; player.SetPickupItem(this); } } }
void Initialize() { if (initialized) { return; } initialized = true; player = GameObject.FindObjectOfType <TrashPlayer> (); world = TrashWorld.Instance; currentCameraFocus = CalculatePlayerFocus(); SetCameraZoom(0); player.SetTrashCamera(this); SnapToPlayerPosition(); }