Esempio n. 1
0
    private void checkIfItsTimeToClaim()
    {
        if (GameStorage.Exists(Application.persistentDataPath + savePath))
        {
            lastClaimTime = GameStorage.Load <Clock>(Application.persistentDataPath + savePath);
            lastLoginDate = lastClaimTime.convertToDateTime();
            DateTime rightNow          = DateTime.Now;
            TimeSpan lastLoginUntilNow = rightNow.Subtract(lastLoginDate);

            if (lastLoginUntilNow.Minutes >= elapsedMinuteRequired)
            {
                treasureShouldBeOpen = true;
                PlayerSaveData psd = bagController.getCurrentSaveData();
                psd.ClaimReward(treasureReward);
                lastClaimTime.SetDataFromDateTime(rightNow);
                lastLoginDate = lastClaimTime.convertToDateTime();
                GameStorage.Save <Clock>(lastClaimTime, Application.persistentDataPath + savePath);
            }
        }
        else
        {
            lastLoginDate = DateTime.Now;
            lastClaimTime = new Clock(Application.persistentDataPath + savePath, lastLoginDate);
            GameStorage.Save <Clock>(lastClaimTime, Application.persistentDataPath + savePath);
        }
    }
Esempio n. 2
0
 protected override void Start()
 {
     base.Start();
     if (GameStorage.Exists(Application.persistentDataPath + SaveKey.LOGINTIME_KEY))
     {
         lastLoginTime = GameStorage.Load <Clock>(Application.persistentDataPath + SaveKey.LOGINTIME_KEY);
         DateTime lastLoginDate     = lastLoginTime.convertToDateTime();
         DateTime rightNow          = DateTime.Now;
         TimeSpan lastLoginUntilNow = rightNow.Subtract(lastLoginDate);
         if (lastLoginUntilNow.Days >= 1)
         {
             if (lastLoginUntilNow.Days > 1)
             {
                 currentSaveData.ResetStreak();
                 currentSaveData.ClaimReward(streakRewards[currentSaveData.getLoginStreak()]);
                 //reset reward
                 //get reward
             }
             else
             {
                 currentSaveData.ClaimReward(streakRewards[currentSaveData.getLoginStreak()]);
                 currentSaveData.AddStreak();
                 //get reward
                 //reward increment
             }
             lastLoginTime.SetDataFromDateTime(rightNow);
             GameStorage.Save <Clock>(lastLoginTime, Application.persistentDataPath + SaveKey.LOGINTIME_KEY);
         }
     }
     else
     {
         lastLoginTime = new Clock(Application.persistentDataPath + SaveKey.LOGINTIME_KEY, DateTime.Now);
         //baru main
     }
 }
Esempio n. 3
0
    // Use this for initialization

    protected virtual void Start()
    {
        GameObject so = Resources.Load("Settings Object") as GameObject;
        GameObject op = Resources.Load("Object Pool") as GameObject;

        op          = Instantiate(op);
        objectPool  = op.GetComponent <ObjectPool>();
        menuButtons = new List <MenuButton>(FindObjectsOfType <MenuButton>());


        if (GameStorage.Exists(Application.persistentDataPath + SaveKey.PLAYERDATA_KEY))
        {
            currentSaveData = GameStorage.Load <PlayerSaveData>(Application.persistentDataPath + SaveKey.PLAYERDATA_KEY);
            Debug.Log(currentSaveData.getCompanionData().mySkills.Count);
            for (int i = 0; i < menuButtons.Count; i++)
            {
                menuButtons[i].NotifyThatPlayerHasSavedBefore();
            }
        }
        else
        {
            currentSaveData       = new PlayerSaveData(Application.persistentDataPath + SaveKey.PLAYERDATA_KEY);
            playerShouldBeTutored = true;
        }

        SceneNavigation.singleton.saveGameContent += SaveGameData;

        settingsObject = objectPool.registerObject <SettingsObject>(so);
        objectPool.activateObject(settingsObject);
    }
Esempio n. 4
0
 // Update is called once per frame
 void LateUpdate()
 {
     if (!initTree)
     {
         if (!GameStorage.Exists(Application.persistentDataPath + SaveKey.SKILLTREEDATA_KEY))
         {
             root.recursivelyChangeStatus(2);
             current = root;
         }
         else
         {
             List <int> nodeStatusData = GameStorage.Load <List <int> >(Application.persistentDataPath + SaveKey.SKILLTREEDATA_KEY);
             for (int i = 0; i < nodeStatusData.Count; i++)
             {
                 nodes[i].status = nodeStatusData[i];
                 if (nodes[i].status == 2)
                 {
                     current = nodes[i];
                 }
                 Debug.Log(nodeStatusData[i]);
             }
         }
         initTree = true;
     }
 }
Esempio n. 5
0
    private void reportCumulativeScore()
    {
        GameStorage <int> cumulativeScoreStorage = GameStorageKeys.CumulativeScore;
        int previousScore = cumulativeScoreStorage.Exists() ? cumulativeScoreStorage.Get() : 0;
        int currentScore  = previousScore + points.Points;

        cumulativeScoreStorage.Set(currentScore);
        reportScore(SocialLeaderboards.GetCumulativeLeaderboard(), currentScore);
    }
Esempio n. 6
0
    private void restoreSavedSoundState()
    {
        bool enableSound = DefaultEnabled;

        if (soundDisabledStorage.Exists())
        {
            enableSound = !soundDisabledStorage.Get();
        }
        setSound(enableSound);
    }
    // Helpers
    private static GameType getGameType()
    {
        GameType gameType = GameType.Offline;

        GameStorage <GameType> selectedGameTypeStorage = GameStorageKeys.SelectedGameType;

        if (selectedGameTypeStorage.Exists())
        {
            gameType = selectedGameTypeStorage.Get();
        }

        return(gameType);
    }
    private static MultiplayerRole getMultiplayerRole()
    {
        MultiplayerRole role = MultiplayerRole.Server;

        GameStorage <MultiplayerRole> selectedMultiplayerRoleStorage = GameStorageKeys.SelectedMultiplayerRole;

        if (selectedMultiplayerRoleStorage.Exists())
        {
            role = selectedMultiplayerRoleStorage.Get();
        }

        return(role);
    }
Esempio n. 9
0
 // Use this for initialization
 void Start()
 {
     audioSources = new List <AudioSource>(FindObjectsOfType <AudioSource>());
     if (GameStorage.Exists(Application.persistentDataPath + SaveKey.SETTINGSDATA_KEY))
     {
         settingsData = GameStorage.Load <Settings>(Application.persistentDataPath + SaveKey.SETTINGSDATA_KEY);
         foreach (AudioSource asrc in audioSources)
         {
             if (asrc.gameObject.tag.Equals("AudioSource - Music"))
             {
                 asrc.volume = settingsData.musicVolume;
             }
             else if (asrc.gameObject.tag.Equals("AudioSource - SFX"))
             {
                 asrc.volume = settingsData.sfxVolume;
             }
         }
     }
     else
     {
         settingsData = new Settings();
     }
 }
Esempio n. 10
0
    void Start()
    {
        gui          = new GuiManager();
        movements    = new List <MovementManager>();
        timeCounters = new List <TimeCounter>();

        GameStorage <NetworkEntityPlaying> networkEntityPlayingStorage = GameStorageKeys.NetworkEntityPlaying;

        if (networkEntityPlayingStorage.Exists())
        {
            network = networkEntityPlayingStorage.Get();
            networkEntityPlayingStorage.Delete();
            network.LocalMapLoaded();
        }

        input = new InputManager(NextStationSelector, network);

        GuiPlayersPointsElement playersPoints = new GuiPlayersPointsElement();

        gui.AddElement(playersPoints);

        LocalTrainSetuper localTrainSetuper = TrainSetuperFactory.On(this.gameObject).Local();

        localTrainSetuper.Setup();
        Train train = localTrainSetuper.Get();

        movements.Add(getMovementFor(train, isLocalTrain: true, networkPlayer: null, playersPoints: playersPoints, network: network));

        NetworkTrainSetuper networkTrainSetuper = TrainSetuperFactory.On(this.gameObject).Network();

        networkTrainSetuper.Setup();
        NetworkTrainPlayer[] networkPlayers = networkTrainSetuper.Get();
        foreach (NetworkTrainPlayer networkPlayer in networkPlayers)
        {
            movements.Add(getMovementFor(networkPlayer.Train, isLocalTrain: false, networkPlayer: networkPlayer, playersPoints: playersPoints, network: network));
        }
    }
Esempio n. 11
0
    protected override void Start()
    {
        base.Start();

        if (GameStorage.Exists(Application.persistentDataPath + SaveKey.PLAYERDATA_KEY))
        {
            mySaveData      = GameStorage.Load <PlayerSaveData>(Application.persistentDataPath + SaveKey.PLAYERDATA_KEY);
            gameObject.name = mySaveData.name;
            myCoin          = mySaveData.getGold();
            myCrystal       = mySaveData.getCrystal();
        }

        if (GameStorage.Exists(Application.persistentDataPath + SaveKey.LASTPLAYERCHECKPOINT_KEY))
        {
            Vector3 checkpointPosition = GameStorage.Load <Vector3>(Application.persistentDataPath + SaveKey.LASTPLAYERCHECKPOINT_KEY);
            transform.position = checkpointPosition;
        }
        else
        {
            transform.position = startingPosition;
        }
        body      = GetComponent <Rigidbody2D>();
        JumpPower = 2;
        readyToAccomplishTheMission = true;

        sceneBackgrounds = new List <Background>(FindObjectsOfType <Background>());

        registerObserver(GameObject.Find("Player Attribute UI").GetComponent <PlayerAttributeView>());
        registerObserver(GameObject.Find("Player View Rect").GetComponent <PlayerViewRect>());

        notifyObservers();
        notifyObserversAboutUnderwaterStatus();
        mySpriteController = GetComponent <SpriteAnimationController>();
        animate(PlayerMovementStatus.IDLE, 0.5f, true);
        followPoint = transform.FindChild("Follow Point");
    }
Esempio n. 12
0
    private string[] networkTrainsNames()
    {
        GameStorage <NetworkTrainPlayers> networkTrainsStorage = GameStorageKeys.NetworkTrains;

        return(networkTrainsStorage.Exists() ? networkTrainsStorage.Get().TrainNames : new string[0]);
    }
Esempio n. 13
0
    private string selectedTrainName()
    {
        GameStorage <string> selectedTrainStorage = GameStorageKeys.SelectedTrain;

        return(selectedTrainStorage.Exists() ? selectedTrainStorage.Get() : "");
    }
Esempio n. 14
0
 public GamePoints GetMaxPoints()
 {
     return(new GamePoints(map, maxPointsStorage.Exists() ? maxPointsStorage.Get() : DEFAULT_MAX_POINTS));
 }
Esempio n. 15
0
 protected override bool exists()
 {
     return(selectedTrainStorage.Exists());
 }
Esempio n. 16
0
 protected override bool exists()
 {
     return(networkTrainsStorage.Exists());
 }
Esempio n. 17
0
	public void Init()
	{
		if (!socialUserStorage.Exists() || socialUserStorage.Get() == true) {
			Authenticate();
		}
	}