Example #1
0
    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);
    }
Example #2
0
 private void Awake()
 {
     DontDestroyOnLoad(this);
     instance        = this;
     userData        = SaveData.LoadUserData();
     currentShipData = GetCurrentShipData();
     InstantiateShip();
 }
Example #3
0
        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;
        }
Example #4
0
    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);
    }
Example #5
0
    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();
    }