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; } }