void CmdSpawnPlayerShip(int shipSpawnIndex) { shipAsset = shipAssets[shipSpawnIndex]; //Cancel if ship asset is null if (shipAsset == null) { return; } //Instantiate object for network spawning shipObject = Instantiate(shipAsset.shipPrefab, transform.position, transform.rotation, transform); //Init ship camera InitialiseShipCamera(); //Init components InitialiseComponents(shipObject); //Set the ship controller's parent id and spawn index for newly connecting clients ShipController shipController = shipObject.GetComponent <ShipController>(); shipController.parentNetID = GetComponent <NetworkIdentity>().netId; shipController.shipSpawnIndex = shipSpawnIndex; //Spawn ship on all clients / server NetworkServer.Spawn(shipObject, connectionToClient); //Set the ship spawn data on all clients RpcSetShipSpawnData(shipObject, shipSpawnIndex); }
private void CreatePlayer() { SessionData sessionData = SessionData.instance; ShipAsset asset = GameManager.Instance.playerSettings.shipsList.Where(x => x.instanceID == sessionData.selectedShip.instanceID).First(); GameObject playerObject = Instantiate(asset.shipPrefab, transform.position, Quaternion.identity); player = playerObject.GetComponent <PlayerController>(); }
public void ShowPurchasePopup(string shipID) { this.shipID = shipID; purchasePopup.SetActive(true); ShipAsset asset = GameManager.Instance.playerSettings.shipsList.Where(x => x.instanceID == shipID).First(); purchasedName.text = asset.name; purchaseDescription.text = "Want to purchase this ship for $" + asset.price + "?"; }
public void ShowLockedPopup(string shipID) { this.shipID = shipID; lockedPopup.SetActive(true); ShipAsset asset = GameManager.Instance.playerSettings.shipsList.Where(x => x.instanceID == shipID).First(); lockedName.text = asset.name; lockedDescription.text = "You need to be at level " + asset.requiredLevel + " in order to unlock this ship."; }
void RpcSetShipSpawnData(GameObject ship, int shipSpawnIndex) { //Assign ship spawn index shipAsset = shipAssets[shipSpawnIndex]; //Init ship camera InitialiseShipCamera(); //Init componenents InitialiseComponents(ship); //Set ship position etc. ship.transform.parent = transform; ship.transform.position = transform.position; ship.transform.rotation = transform.rotation; }
public void OpenSelectedShip() { ShipInfo info = SessionData.instance.shipServicer.GetShipItem(stringID); ShipAsset asset = GameManager.Instance.playerSettings.shipsList.Where(x => x.instanceID == stringID).First(); if (info.isUnlocked) { shipSelector.LoadMenuSelection(stringID); hangarActions.RevealEquipmentMenu(); return; } //Revealed when requirement not achieved if (SessionData.instance.userStatus.userLevel < asset.requiredLevel) { shipSelector.OpenMessagePopup(stringID, ShipPopupOptions.Locked); return; } else if (!info.isUnlocked) { shipSelector.OpenMessagePopup(stringID, ShipPopupOptions.Purchase); } }