public SpaceShipData[] GetSourceSpaceShipDatas() { // TEMP //if (m_sourceSpaceShips.Count < (int)MobType.End) //{ // Debug.LogError("The sourc turrets is less than Turret.End"); // return null; //} SpaceShipData[] datas = new SpaceShipData[(int)MobType.End]; for (int i = 0; i < (int)MobType.End; ++i) { string key = EnumToStr((MobType)i); GameObject source = null; if (false == m_sourceSpaceShips.TryGetValue(key, out source)) { datas[i] = null; continue; } SpaceShipCtrl ctrl = source.GetComponent <SpaceShipCtrl>(); datas[i] = ctrl.SpaceShipData; } return(datas); }
private void Awake() { DontDestroyOnLoad(this); instance = this; userData = SaveData.LoadUserData(); currentShipData = GetCurrentShipData(); InstantiateShip(); }
private void InitializeSpaceShipData() { var spaceShip = new SpaceShipData(); spaceShip.Name = "SGS Mijago"; spaceShip.GridPosition = Vector3Int.zero; spaceShip.Position = spaceShip.GridPosition; spaceShip.Engine = new ShipEngine(); var playerData = new PlayerData(); playerData.SpaceShipData = spaceShip; GameState.PlayerData = playerData; }
public bool BuyShip(SpaceShipData shipData) { if (shipData.shipPrice <= userData.playerData.diamond) { //buy ship and return true userData.playerData.ChangeDiamond(-shipData.shipPrice); userData.shipControlData.SetCurrentShipName(shipData.shipName); shipData.isBought = true; SaveUserData(); return(true); } return(false); }
void Start() { spaceShipData = DataManager.Instance.GetShipByName(shipName); if (shipName == null) { Debug.LogError("ship name is null"); } if (buttonControl == null) { Debug.LogError("Button control not initiliazed"); } if (shipName == null) { Debug.LogError("ship name is null"); } SetAmounts(); SetAmountTexts(); GetSpaceShipStates(); UpdateButtons(); SetBuyOrSelectButton(); }