Exemplo n.º 1
0
    private void Update()
    {
        if (started)
        {
            currentTime.text = FloatToTime.convertFloatToTime(timer);
            //During level
            if (objectivesCompleted < objectiveLines.Count && !playerCtrl.amDead)
            {
                currentObjective.text = objectiveLines[objectivesCompleted];
                timer += Time.unscaledDeltaTime;
            }
            //Completed Level
            else if (!playerCtrl.amDead)
            {
                endScreen();
                currentObjective.text = "You Win!";

                //If we have a new best time
                if (bestTimeFloat > (Mathf.Round(timer * 100f) / 100f))
                {
                    PlayerPrefs.SetFloat("LEVELBESTTIME" + LevelID.ToString(), (Mathf.Round(timer * 100f) / 100f));
                    if (!achivementOnce)
                    {
                        //Submit to leaderboard
                        SubmitTime();
                    }
                }

                if (!achivementOnce)
                {
                    PlayerPrefs.Save();
                    //Achievement Logic
                    GetAchievement();
                }
            }

            //Lost Level
            if (playerCtrl.amDead)
            {
                currentObjective.text = "Game Over";
                //Show Ad
                if (!shownAd)
                {
                    PlayerPrefs.Save();
                    StartCoroutine(showAd());
                    shownAd = true;
                }
            }
        }
        else
        {
            currentTime.text = timer.ToString("F2");
            if (player.GetComponent <NavMeshAgent>().velocity.magnitude > 0.0f)
            {
                started = true;
            }
        }
    }
Exemplo n.º 2
0
    private void Start()
    {
        currentObjective.text = objectiveLines[objectivesCompleted];
        player     = GameObject.FindGameObjectWithTag("Player");
        playerCtrl = player.GetComponent <PlayerController>();

        //Load best time if there is one
        bestTimeFloat = PlayerPrefs.GetFloat("LEVELBESTTIME" + LevelID.ToString());

        achivementOnce = false;

        if (bestTimeFloat > 0.0f)
        {
            bestTime.text = FloatToTime.convertFloatToTime(bestTimeFloat);
            //bestTime.text = (Mathf.Round(bestTimeFloat * 100f) / 100f).ToString();
        }
        else
        {
            bestTimeFloat = Mathf.Infinity;
        }
        //Check for purchase of removal of ads
        adsEnabled = true;

        if (PlayerPrefs.GetInt("noAdsPurchased") == 1)
        {
            adsEnabled = false;
        }

        if (adsEnabled)
        {
            //Start Ad Service
            AdTime.Initialize();
        }

        //DEBUGGER
        if (GameObject.Find("DEBUG_OUTPUT"))
        {
            debugger = GameObject.Find("DEBUG_OUTPUT").GetComponent <Text>();
            Debugger("Best Time: " + bestTimeFloat.ToString());
            Debugger("AD BOOL: " + PlayerPrefs.GetInt("noAdsPurchased").ToString());
        }
    }
Exemplo n.º 3
0
    public void shareOnTwitter()
    {
        //Update best time if it is invalid
        if (bestTimeFloat == Mathf.Infinity)
        {
            bestTimeFloat = timer;
        }

        //Build URL
        string URL = "https://twitter.com/intent/tweet";
        string msg = $"Can you beat my time on level {LevelID} in #SilentEspionage? [{FloatToTime.convertFloatToTime(bestTimeFloat)}]";
        string descriptionParameter = "Silent Espionage";
        string downloadLink         = "https://play.google.com/store/apps/details?id=com.HenryOliver.SilentEspionage";

        //Tweet
        Application.OpenURL($"{URL}?text={WWW.EscapeURL(msg+"\n"+descriptionParameter+"\n"+downloadLink)}");
    }