Ejemplo n.º 1
0
 private void Awake()
 {
     m_rigidbody = this.GetComponent <Rigidbody2D>();
     m_collider  = this.GetComponent <Collider2D>();
     gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
     enemyKilled = gameManager.EnemyWasKilled;
 }
Ejemplo n.º 2
0
    private void OnCircuitCompletedUpdateServerComplete(ServerData data)
    {
        DebugLog.Trace("OnCircuitCompletedUpdateServerComplete: " + data);

        circuitCompleteAction.RemoveListener(OnCircuitCompletedUpdateServerComplete);
        circuitCompleteAction = null;

        // enable continue until server is completed
        LeanTween.alpha(continueButton, 1f, 0.65f)
        .setDelay(0f)
        .setEase(LeanTweenType.easeOutQuad);

        LeanTween.alpha(leaderboardButton, 1f, 0.65f)
        .setDelay(0f)
        .setEase(LeanTweenType.easeOutQuad);


        leaderboardButton.gameObject.GetComponent <Image>().raycastTarget = true;
        continueButton.gameObject.GetComponent <Image>().raycastTarget    = true;

        Debug.Log("totalAllCircuitsTime: " + data.totalAllCircuitsTime);

        // update current data
        PersistentModel.Instance.ResultData.totalAllCircuitsTime = data.totalAllCircuitsTime;
    }
Ejemplo n.º 3
0
    private void OnGetRecordAttempt(ServerData data)
    {
        DebugLog.Trace("GetRecordTimeByTrackID.data.currentTrackRecordTime:" + data.currentTrackRecordTime);
        PersistentModel.Instance.CurrentTrackRecordTime = data.currentTrackRecordTime;
        PersistentModel.Instance.ResultData             = data;

        getRecordTimeFromServerAttempt.RemoveListener(OnGetRecordAttempt);
        getRecordTimeFromServerAttempt = null;
    }
Ejemplo n.º 4
0
    // called when a challenge is completed
    public void CircuitCompleteUpdate(IntUnityEvent callback)
    {
        if (!IsEnabled)
        {
            return;
        }

        StartCoroutine(OnCircuitCompleteUpdateAttemptForRequest(callback));
    }
Ejemplo n.º 5
0
    // called when a challenge is completed
    public void ChallengeCompleteUpdate(TrackData currentTrackData, IntUnityEvent callback)
    {
        if (!IsEnabled)
        {
            callback?.Invoke(null);
            return;
        }

        StartCoroutine(OnChallengeCompleteUpdateAttemptForRequest(currentTrackData, callback));
    }
Ejemplo n.º 6
0
    // Get Record Time by Circuit
    public void GetRecordTimeByGameMode(string gameMode, IntUnityEvent callback)
    {
        if (!IsEnabled)
        {
            callback?.Invoke(null);

            return;
        }

        StartCoroutine(OnGetRecordTimeByGameModeAttemptForRequest(gameMode, callback));
    }
Ejemplo n.º 7
0
    // Get Record Time by Circuit
    public void GetRecordTimeByTrackID(string trackID, IntUnityEvent callback)
    {
        if (!IsEnabled)
        {
            callback?.Invoke(null);

            return;
        }

        StartCoroutine(OnGetRecordTimeByTrackIDAttemptForRequest(trackID, callback));
    }
Ejemplo n.º 8
0
    private void OnChallengeCompleteUpdateServerComplete(ServerData data)
    {
        DebugLog.Trace("OnChallengeCompleteUpdateServerComplete: " + data);

        challengeCompleteAction.RemoveListener(OnChallengeCompleteUpdateServerComplete);
        challengeCompleteAction = null;

        // enable continue until server is completed
        continueButton.gameObject.GetComponent <Image>().color         = new Color(1, 1, 1, 1);
        continueButton.gameObject.GetComponent <Image>().raycastTarget = true;

        // update current data
        PersistentModel.Instance.ResultData = data;
    }
Ejemplo n.º 9
0
    IEnumerator OnCircuitCompleteUpdateAttemptForRequest(IntUnityEvent callback)
    {
        DebugLog.Trace("OnCircuitCompleteUpdateAttemptForRequest()");

        string requestUrl = "e=" + WWW.EscapeURL(PersistentModel.Instance.Email);

        requestUrl += "&mode=" + PersistentModel.Instance.GameModeID;

        // Debug.Log("CircuitCompleteUpdate.php ?");
        // Debug.Log("requestUrl: " + requestUrl);

        // reset challenge time
        PersistentModel.Instance.ChallengeTime = 0f;

        UnityWebRequest request = ConnectToServer("CircuitCompleteUpdate.php?" + requestUrl);

        yield return(request.SendWebRequest());

        if (request.isNetworkError || request.isHttpError)
        {
            DebugLog.Trace("UnityWebRequest Error: " + request.error);

            // wait a few seconds before retry
            yield return(waitToRefreshServerCall);

            OnCircuitCompleteUpdateAttemptForRequest(callback);
        }
        else
        {
            Debug.Log("downloadHandler.text: " + request.downloadHandler.text);

            ServerData[] resultData = JsonHelper.FromJsonWrapped <ServerData>(request.downloadHandler.text);

            if (resultData[0].success)
            {
                DebugLog.Trace("CircuitCompleteUpdate().success");
            }
            else
            {
                DebugLog.Trace("CircuitCompleteUpdate().error");
            }

            callback.data = resultData[0];
            callback?.Invoke(callback.data);
        }
    }
Ejemplo n.º 10
0
    protected override void TransitionInCompleted()
    {
        // screen draw has been finished, invokes Base.TransitionInCompleteEvent if available
        base.TransitionInCompleted();

        // This screen contains no loader panel, so...
        // the following code is for editor only, when force loading this screen at startup
#if UNITY_EDITOR
        GameObject    progressLoadingPanel = UIManager.Instance.ProgressLoadingPanel;
        RectTransform spinningTire         = progressLoadingPanel.transform.Find("SpinningTire").GetComponent <RectTransform>();
        LeanTween.cancel(spinningTire);
        progressLoadingPanel.transform.SetParent(null, false);
        progressLoadingPanel.transform.SetAsLastSibling();
#endif

        continueButton.gameObject.GetComponent <Button>().onClick.AddListener(OnContinueButtonClick);
        leaderboardButton.gameObject.GetComponent <Button>().onClick.AddListener(OnLeaderboardButtonClick);

        if (UIManager.Instance.PreviousScreenID == UIManager.Instance.GetScreenID(UIManager.Screen.LEADERBOARD))
        {
            // Debug.Log("Coming From Leaderboards, dont update anything");
            // enable continue until server is completed
            LeanTween.alpha(continueButton, 1f, 0.65f)
            .setDelay(0f)
            .setEase(LeanTweenType.easeOutQuad);

            LeanTween.alpha(leaderboardButton, 1f, 0.65f)
            .setDelay(0f)
            .setEase(LeanTweenType.easeOutQuad);
            return;
        }

        // update track completion
        PersistentModel.Instance.UpdateTrackCompletion();


        // mode is completed, save data
        leaderboardButton.gameObject.GetComponent <Image>().raycastTarget = false;
        continueButton.gameObject.GetComponent <Image>().raycastTarget    = false;
        circuitCompleteAction = new IntUnityEvent();
        circuitCompleteAction.AddListener(OnCircuitCompletedUpdateServerComplete);

        PersistentModel.Instance.Server.CircuitCompleteUpdate(circuitCompleteAction);
    }
Ejemplo n.º 11
0
    IEnumerator OnGetRecordTimeByGameModeAttemptForRequest(string gameMode, IntUnityEvent callback)
    {
        DebugLog.Trace("OnGetRecordTimeByGameModeAttemptForRequest()");

        string requestUrl = "g=" + gameMode;

        UnityWebRequest request = ConnectToServer("GetRecordTimeByGameMode.php?" + requestUrl);

        yield return(request.SendWebRequest());

        if (request.isNetworkError || request.isHttpError)
        {
            DebugLog.Trace("UnityWebRequest Error: " + request.error);

            // wait a few seconds before retry
            yield return(waitToRefreshServerCall);

            OnGetRecordTimeByGameModeAttemptForRequest(gameMode, callback);
        }
        else
        {
            ServerData[] resultData = JsonHelper.FromJsonWrapped <ServerData>(request.downloadHandler.text);

            if (resultData[0].success)
            {
                DebugLog.Trace("GetRecordTimeByGameMode().success");
            }
            else
            {
                DebugLog.Trace("GetRecordTimeByGameMode().error");
            }

            DebugLog.Trace("GetRecordTimeByGameMode.resultData[0].currentTrackRecordTime:" + resultData[0].currentTrackRecordTime);
            PersistentModel.Instance.CurrentTrackRecordTime = resultData[0].currentTrackRecordTime;

            callback.data = resultData[0];
            callback?.Invoke(callback.data);
        }
    }
Ejemplo n.º 12
0
    IEnumerator OnGetRecordTimeByTrackIDAttemptForRequest(string trackID, IntUnityEvent callback)
    {
        DebugLog.Trace("OnGetRecordTimeByTrackIDAttemptForRequest()");

        string requestUrl = "trackid=" + trackID;

        UnityWebRequest request = ConnectToServer("GetRecordTimeByTrackID.php?" + requestUrl);

        yield return(request.SendWebRequest());

        if (request.isNetworkError || request.isHttpError)
        {
            DebugLog.Trace("UnityWebRequest Error: " + request.error);

            // wait a few seconds before retry
            yield return(waitToRefreshServerCall);

            OnGetRecordTimeByTrackIDAttemptForRequest(trackID, callback);
        }
        else
        {
            ServerData[] resultData = JsonHelper.FromJsonWrapped <ServerData>(request.downloadHandler.text);

            if (resultData[0].success)
            {
                DebugLog.Trace("GetRecordTimeByTrackID().success");
            }
            else
            {
                DebugLog.Trace("GetRecordTimeByTrackID().error");
            }

            callback.data = resultData[0];
            callback?.Invoke(callback.data);
        }
    }
Ejemplo n.º 13
0
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ public void AddListener(IntUnityEvent listener)
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ unityEventListeners.TryAdd(listener);
/*AUTO SCRIPT*/ }
Ejemplo n.º 14
0
    public override void Initialize(string id)
    {
        base.Initialize(id);

        DebugLog.Trace("SelectSequenceScreen");
        DebugLog.Trace("PersistentModel.Instance.ChallengeTime: " + PersistentModel.Instance.ChallengeTime);

        showProgressLoadingPanel = true;
        elapsedTime = PersistentModel.Instance.ChallengeTime;

        HasTireBeenSubmitted = false;
        TireSelectedIndex    = -1;

        // grab sections and hide scale
        sections            = _screenElements["Sections"];
        sections.localScale = new Vector3(0f, 1f, 1f);

        pauseButton        = _screenElements["PauseButton"];
        superTireSmallLogo = _screenElements["SuperTireSmallLogo"];

        // set submit
        submitButton = _screenElements["SubmitButton"];
        submitButton.GetComponent <Image>().color              = elementShowColor;
        submitButton.Find("Text").GetComponent <Text>().color  = elementShowColor;
        submitButton.GetComponent <CanvasGroup>().alpha        = 0;
        submitButton.GetComponent <CanvasGroup>().interactable = false;

        // set time panel
        timeTopPanel  = _screenElements["TimeTopPanel"];
        timePanelFrom = timeTopPanel.anchoredPosition3D + Vector3.up * timeTopPanel.sizeDelta.y;
        timePanelTo   = timeTopPanel.anchoredPosition3D;
        timeTopPanel.anchoredPosition3D           = timePanelFrom;
        timeTopPanel.GetComponent <Image>().color = elementShowColor;

        // set game time
        gameTimeText       = _screenElements["GameTimeText"].GetComponent <Text>();
        gameTimeText.color = new Color(33f / 255f, 33f / 255f, 33f / 255f, 0f);
        gameTimeText.text  = PersistentModel.Instance.FormatTime(PersistentModel.Instance.ChallengeTime);

        // set clock notification panel
        clockRunningTopMidPanel = _screenElements["ClockRunningTopMidPanel"];
        clockStoppedTopMidPanel = _screenElements["ClockStoppedTopMidPanel"];

        Vector3 orgRunningPos = clockRunningTopMidPanel.anchoredPosition3D;

        clockRunningTopMidPanel.anchoredPosition3D = new Vector3(orgRunningPos.x, sections.anchoredPosition3D.y, orgRunningPos.z);

        Vector3 orgStoppedPos = clockStoppedTopMidPanel.anchoredPosition3D;

        clockRunningTopMidPanel.anchoredPosition3D = new Vector3(orgStoppedPos.x, sections.anchoredPosition3D.y, orgStoppedPos.z);

        clockRMidPanelFrom = clockRunningTopMidPanel.anchoredPosition3D + Vector3.down * clockRunningTopMidPanel.sizeDelta.y;
        clockRMidPanelTo   = clockRunningTopMidPanel.anchoredPosition3D;
        clockSMidPanelFrom = clockStoppedTopMidPanel.anchoredPosition3D + Vector3.down * clockStoppedTopMidPanel.sizeDelta.y;
        clockSMidPanelTo   = clockStoppedTopMidPanel.anchoredPosition3D;
        clockRunningTopMidPanel.anchoredPosition3D = clockRMidPanelFrom;
        clockStoppedTopMidPanel.anchoredPosition3D = clockSMidPanelFrom;

        // top stats info
        Color saveColor = new Color(1f, 0.7686275f, 0f, 1f);

        _screenElements["CurrentCircuitValue"].GetComponent <Text>().color = new Color(saveColor.r, saveColor.g, saveColor.b, 0f);

        // THIS CAN BEDONE BETTER ///////////////////////////////////////////////////////////////
        string currentCircuitLabel = PersistentModel.Instance.GameModeID.ToUpper() + " ";
        // int cIndex = PersistentModel.Instance.ChallengeIndex;
        int cIndex = PersistentModel.Instance.ChallengeCounter;

        if (cIndex == 0)
        {
            cIndex = 1;
        }
        else if (cIndex == PersistentModel.Instance.ChallengeCount)
        {
            cIndex = 5;
        }
        else
        {
            cIndex++;
        }
        /////////////////////////////////////////////////////////////////////////////////

        currentCircuitLabel += cIndex + "/" + PersistentModel.Instance.ChallengeCount;

        if (DebugHandler.isEnabled)
        {
            currentCircuitLabel = "CHALLENGE #" + PersistentModel.Instance.ChallengeUID;
        }
        _screenElements["CurrentCircuitValue"].GetComponent <Text>().text = currentCircuitLabel;

        // tire select section ////////
        customerPreferencesSection = sections.Find("CustomerPreferences").GetComponent <CustomerPreferencesSection>();
        customerPreferencesSection.Initialize();

        tireSelectSection = sections.Find("TireSelect").GetComponent <TireSelectSection>();
        tireSelectSection.Initialize();

        currState = (PersistentModel.Instance.TireOptionSelectedData == null) ? Section.CUST_PREF : Section.TIRESELECT;

        // GET RECORD TIME from SERVER
        getRecordTimeFromServerAttempt = new IntUnityEvent();
        getRecordTimeFromServerAttempt.AddListener(OnGetRecordAttempt);
        PersistentModel.Instance.Server.GetRecordTimeByTrackID(PersistentModel.Instance.ChallengeTrackUID, getRecordTimeFromServerAttempt);
    }
Ejemplo n.º 15
0
/*AUTO SCRIPT*/ public void RemoveListener(IntUnityEvent listener)
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ unityEventListeners.TryRemove(listener);
/*AUTO SCRIPT*/ }
Ejemplo n.º 16
0
    protected override void TransitionInCompleted()
    {
        // screen draw has been finished, invokes Base.TransitionInCompleteEvent if available
        base.TransitionInCompleted();

        // This screen contains no loader panel, so...
        // the following code is for editor only, when force loading this screen at startup
#if UNITY_EDITOR
        GameObject    progressLoadingPanel = UIManager.Instance.ProgressLoadingPanel;
        RectTransform spinningTire         = progressLoadingPanel.transform.Find("SpinningTire").GetComponent <RectTransform>();
        LeanTween.cancel(spinningTire);
        progressLoadingPanel.transform.SetParent(null, false);
        progressLoadingPanel.transform.SetAsLastSibling();
#endif

        continueButton.gameObject.GetComponent <Button>().onClick.AddListener(OnContinueButtonClick);

        DebugLog.Trace("***ChallengeCount:" + PersistentModel.Instance.ChallengeCount);
        DebugLog.Trace("***ChallengeIndex:" + PersistentModel.Instance.ChallengeIndex);
        DebugLog.Trace("***ChallengeCounter:" + PersistentModel.Instance.ChallengeCounter);

        // save Challege Track Data
        TrackData currentTrackData = new TrackData
        {
            track_uid  = PersistentModel.Instance.ChallengeTrackUID,
            track_type = PersistentModel.Instance.GameTrackType,
            track_time = Mathf.RoundToInt(PersistentModel.Instance.CurrentCompletedChallengeTime)
        };

        // Add Completed Challenge Track UID to GameTrackData, we will use this to keep track of the completed challenges
        PersistentModel.Instance.GameTrackData.Add(PersistentModel.Instance.ChallengeTrackUID);

        if (DebugHandler.isEnabled)
        {
            DebugLog.Trace("***DebugHandler.isEnabled");
            // disable continue until server is completed
            continueButton.gameObject.GetComponent <Image>().color         = new Color(1, 1, 1, 0.1f);
            continueButton.gameObject.GetComponent <Image>().raycastTarget = false;
            continueButton.gameObject.GetComponent <Button>().onClick.RemoveListener(OnContinueButtonClick);
            continueButton.gameObject.GetComponent <Button>().interactable = false;
            continueButton.gameObject.GetComponent <Button>().GetComponentInChildren <Text>().raycastTarget = false;
            return;
        }
        else
        {
            // disable continue until server is completed
            continueButton.gameObject.GetComponent <Image>().color         = new Color(1, 1, 1, 0.5f);
            continueButton.gameObject.GetComponent <Image>().raycastTarget = false;

            challengeCompleteAction = new IntUnityEvent();
            challengeCompleteAction.AddListener(OnChallengeCompleteUpdateServerComplete);

            // update challenge counter
            PersistentModel.Instance.ChallengeCounter++;

            // Here we will get a Random Challenge Index
            // PersistentModel.Instance.ChallengeIndex++;
            if (PersistentModel.Instance.RandomizeTracks)
            {
                PersistentModel.Instance.ChallengeIndex = PersistentModel.Instance.GetRandomChallengeIndex();
            }
            else
            {
                PersistentModel.Instance.ChallengeIndex++;
            }

            PersistentModel.Instance.Server.ChallengeCompleteUpdate(currentTrackData, challengeCompleteAction);
        }
    }
Ejemplo n.º 17
0
    IEnumerator OnChallengeCompleteUpdateAttemptForRequest(TrackData currentTrackData, IntUnityEvent callback)
    {
        DebugLog.Trace("OnChallengeCompleteUpdateAttemptForRequest()");

        string requestUrl = "e=" + WWW.EscapeURL(PersistentModel.Instance.Email);

        requestUrl += "&mode=" + PersistentModel.Instance.GameModeID;
        // requestUrl += "&index=" + PersistentModel.Instance.ChallengeIndex;
        requestUrl += "&index=" + PersistentModel.Instance.ChallengeCounter;
        requestUrl += "&uid=" + currentTrackData.track_uid;
        requestUrl += "&type=" + currentTrackData.track_type;
        requestUrl += "&time=" + currentTrackData.track_time;

        Debug.Log("ChallengeCompleteUpdate.php ?");
        Debug.Log("requestUrl: " + requestUrl);

        // reset challenge time
        PersistentModel.Instance.ChallengeTime = 0f;

        UnityWebRequest request = ConnectToServer("ChallengeCompleteUpdate.php?" + requestUrl);

        yield return(request.SendWebRequest());

        if (request.isNetworkError || request.isHttpError)
        {
            DebugLog.Trace("UnityWebRequest Error: " + request.error);

            // wait a few seconds before retry
            yield return(waitToRefreshServerCall);

            OnChallengeCompleteUpdateAttemptForRequest(currentTrackData, callback);
        }
        else
        {
            ServerData[] resultData = JsonHelper.FromJsonWrapped <ServerData>(request.downloadHandler.text);

            if (resultData[0].success)
            {
                DebugLog.Trace("ChallengeCompleteUpdate().success");
            }
            else
            {
                DebugLog.Trace("ChallengeCompleteUpdate().error");
            }

            // update completion and record times
            PersistentModel.Instance.SetTrackCompletion(resultData[0].completion);
            PersistentModel.Instance.SetCircuitTimes(resultData[0].circuitRecordTimes);
            PersistentModel.Instance.CurrentCircuitTime = (resultData[0].currentCircuitTime);

            callback.data = resultData[0];
            callback?.Invoke(callback.data);
        }
    }