private IEnumerator DropLootCoroutine(GridObject gridObject, Vector3 dropLocation, float delayAppear = 1.0f) { LootHandler lh = gridObject.gameObject.GetComponent <LootHandler>(); if (lh != null) { GameObject lootObjectToDrop = lh.RequestLootDrop(dropLocation, forced: true); if (lootObjectToDrop != null) { MeshRenderer renderer = lootObjectToDrop.GetComponentInChildren <MeshRenderer>(); renderer.enabled = false; gm.AddObjectToGrid(lootObjectToDrop, gm.WorldToGrid(dropLocation)); gridObjectsInPlay.Add(lootObjectToDrop.GetComponent <Loot>()); Rotator lootRotator = lootObjectToDrop.GetComponent <Rotator>(); lootRotator.enabled = true; lootRotator.ApplyRotation("Left"); yield return(new WaitForSeconds(delayAppear)); renderer.enabled = true; } } }
// METHODS public virtual void Init(string spawnBorder) { currentMode = GridObject.Mode.Spawn; Health hp = GetComponent <Health>(); if (hp != null) { hp.ToggleInvincibility(true); } MovePattern movement = GetComponent <MovePattern>(); if (movement != null) { switch (spawnBorder) { case "Bottom": movement.SetMovePatternUp(); break; case "Top": if (spawnRules.requiresOrientation) { transform.rotation = Quaternion.Euler(0.0f, 0.0f, 180.0f); spawnWarningObject.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 180.0f); } movement.SetMovePatternDown(); break; case "Right": if (spawnRules.requiresOrientation) { transform.rotation = Quaternion.Euler(0.0f, 0.0f, 90.0f); spawnWarningObject.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 270.0f); } movement.SetMovePatternLeft(); break; case "Left": if (spawnRules.requiresOrientation) { transform.rotation = Quaternion.Euler(0.0f, 0.0f, 270.0f); spawnWarningObject.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 90.0f); } movement.SetMovePatternRight(); break; } } Rotator r = GetComponent <Rotator>(); if (r != null) { if (!r.enabled) { r.enabled = true; } r.ApplyRotation(spawnBorder); } //ticksRemainingUntilMove = ticksPerMove; SetGamePlayMode(Mode.Spawn); }