/** * Called by the player relic when the relic finishes openening. */ public void RelicOpened(PlayerRelic.RelicConfiguration config) { if (!isLocalPlayer) { return; } /* Update the player's menu */ RelicUIManager playerUI = inventoryMenuObj.GetComponent <RelicUIManager>(); Debug.Assert(playerUI != null); playerUI.SetPlayerInventory(playerInventory.GetInventory()); playerUI.InventoryUpdated(); /* Update the player's bank menu */ BankUIManager bankUI = bankMenuObj.GetComponent <BankUIManager>(); Debug.Assert(bankUI != null); bankUI.SetPlayerBankManager(playerBank); bankUI.BankUpdated(); switch (config) { case PlayerRelic.RelicConfiguration.OpenInventory: /* Reposition the player inventory */ inventoryMenuObj.transform.parent = relic.gameObject.transform; inventoryMenuObj.transform.localPosition = Vector3.zero; inventoryMenuObj.transform.localRotation = Quaternion.identity; /* Show the inventory menu */ ShowMenu(inventory_menu_name); break; case PlayerRelic.RelicConfiguration.OpenBank: /* Reposition the player inventory */ inventoryMenuObj.transform.parent = relic.bankUIRelicPosition.transform; inventoryMenuObj.transform.localPosition = Vector3.zero; inventoryMenuObj.transform.localRotation = Quaternion.identity; /* Reposition the bank inventory */ bankMenuObj.transform.parent = relic.bankUIPosition.transform; bankMenuObj.transform.localPosition = Vector3.zero; bankMenuObj.transform.localRotation = Quaternion.identity; /* Show menues */ ShowMenu(inventory_menu_name); ShowMenu(bank_menu_name); break; } }
/** * Called when this relic piece should move towards it's destination. */ public bool PieceUpdate(PlayerRelic.RelicConfiguration config) { switch (config) { case PlayerRelic.RelicConfiguration.Closed: transform.localPosition = Vector3.Lerp(transform.localPosition, closedPosition, speed * Time.deltaTime); if (Vector3.Distance(transform.localPosition, closedPosition) < distance_allowance) { /* We are at our destination */ transform.localPosition = closedPosition; return(false); } break; case PlayerRelic.RelicConfiguration.OpenInventory: transform.localPosition = Vector3.Lerp(transform.localPosition, inventoryPosition, speed * Time.deltaTime); if (Vector3.Distance(transform.localPosition, inventoryPosition) < distance_allowance) { /* We are at our destination */ transform.localPosition = inventoryPosition; return(false); } break; case PlayerRelic.RelicConfiguration.OpenBank: transform.localPosition = Vector3.Lerp(transform.localPosition, bankPosition, speed * Time.deltaTime); if (Vector3.Distance(transform.localPosition, bankPosition) < distance_allowance) { /* We are at our destination */ transform.localPosition = bankPosition; return(false); } break; default: Debug.LogError("Unsupported state: " + config); break; } /* We're not done moving */ return(true); }