123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using UnityEngine;
- using DataTools;
- using WebTools.Phone;
- public class QuestGigs : RandomGigs
- {
- protected override void Start()
- {
- base.Start();
- GameGlobal.Instance.OnGigChanged += OnGigChanged;
- OnGigChanged(GameGlobal.Instance.GigID);
- }
- private void OnGigChanged(string id)
- {
- if (id == string.Empty)
- {
- return;
- }
- currentGig = data.GameData.GetGigById(id, GameGlobal.Instance.CurrentChapter);
- if (dataUser.UserData.ActualGigId != currentGig.Id)
- {
- if (dataUser.UserData.StarsEarned > 0)
- {
- Debug.LogWarning("Something weird happens and StarsEarned value not 0 at the start of gig");
- dataUser.UserData.StarsEarned = 0;//To prevent starting gig with filled completion bar
- }
- dataUser.UserData.ActualGigId = currentGig.Id;
- dataUser.OnGigTimestampReceived += OnTimeReceived;
- dataUser.UpdateGigStartTime();
- SaveDataUser();
- }
- else
- {
- OnTimeReceived();
- }
- if((currentGig.StarsNeeded - dataUser.UserData.StarsEarned) > 0)
- {
- RandomizeGigs(currentGig.StarsNeeded, currentGig.Type, currentGig.Location);
- }
- else
- {
- Invoke("OnFinishTask", 2f);
- }
- }
- private void SaveDataUser()
- {
- dataUser.UpdateDataUser();
- }
- protected override void OnLocationChanged(Location location)
- {
- base.OnLocationChanged(location);
- if(currentGig != null)
- {
- SetLocationButtons(currentGig.Location);
- }
- }
- protected override void OnFinishTask()
- {
- DataTools.Gig gig = currentGig;
- dataUser.UserData.ActualGigId = string.Empty;
- FinishGig();
- base.OnFinishTask();
- if (gig.Type != DataTools.GigType.Practice)
- {
- AddTweetReward(gig);
- }
- }
- protected override void Update()
- {
- base.Update();
- }
- private void AddTweetReward()
- {
- ChirpTimerAndFollowers chirpTimerAndFollow = gigsGigActionsData.GetChirpTimerAndFollowers(currentGig.Type, currentGig.Duration);
- TweetBehaviour.Instance.GigTweet(currentGig, chirpTimerAndFollow, pointsBar);
- return;
- }
- private void AddTweetReward(DataTools.Gig gig)
- {
- if(gig.Id == "Your First Gig")//This is stupid. Need to find another way to not showing tweet after first gig in game.
- {
- return;
- }
- ChirpTimerAndFollowers chirpTimerAndFollow = gigsGigActionsData.GetChirpTimerAndFollowers(gig.Type, gig.Duration);
- TweetBehaviour.Instance.GigTweet(gig, chirpTimerAndFollow, pointsBar);
- return;
- }
- protected override void ShowTweetOnGigFinish()
- {
- AddTweetReward();
- dataUser.UserData.ActualGigId = string.Empty;
- }
- }
|