コード例 #1
0
    private void PoopLogic()
    {
        if (GameManager.gameOver)
        {
            poopTimer.Text = " ";
            poopTimer.GenerateText();
            return;
        }

        if (currentCooldown < 1)
        {
            if (!isDisplayingMsg)
            {
                poopTimer.transform.localPosition = new Vector3(10f, 3f, 1);
                poopTimer.Text  = poopMessages[Random.Range(0, poopMessages.Count)];
                isDisplayingMsg = true;
            }
            canPoop         = true;
            currentCooldown = poopCooldown;
        }
        else if (!canPoop)
        {
            timerText = (int)currentCooldown;
            poopTimer.transform.localPosition = new Vector3(-0.2f, 3f, 1);
            poopTimer.Text  = $"{timerText.ToString(CultureInfo.CurrentCulture)}";
            isDisplayingMsg = false;
        }

        poopTimer.GenerateText();
    }
    public void ShowForecast()
    {
        try
        {
            _cityText.text = forecast.info.slug.ToUpper();
            var dataPeriod = forecast.fact;
            if (!curent)
            {
                var day = forecast.forecasts[0];
                if (!today)
                {
                    day = forecast.forecasts[1];
                }

                Day periodOfDay = day.parts.night;

                if (periodOfDayName.Equals("morning"))
                {
                    periodOfDay = day.parts.morning;
                }
                else if (periodOfDayName.Equals("afternoon"))
                {
                    periodOfDay = day.parts.day;
                }
                else if (periodOfDayName.Equals("evening"))
                {
                    periodOfDay = day.parts.evening;
                }

                _dateAndTimeText.text = day.date + " " + periodOfDayName;
                _temperatureText.Text = (periodOfDay.temp_avg > 0 ? "+" : "") + periodOfDay.temp_avg;
                _temperatureText.GenerateText();
                _weatherConditionText.text = periodOfDay.condition.Replace('-', ' ');
                _windDirectionText.text    = "Direction: " + periodOfDay.wind_dir.ToString();
                _windSpeedText.text        = "Speed [m/s]: " + periodOfDay.wind_speed.ToString();
                _pressureText.text         = "Pressure [mm]: " + periodOfDay.pressure_mm.ToString();
            }
            else
            {
                _dateAndTimeText.text = forecast.now_dt.ToLocalTime().ToString();
                _temperatureText.Text = (dataPeriod.temp > 0 ? "+" : "") + dataPeriod.temp.ToString();
                _temperatureText.GenerateText();
                _weatherConditionText.text = dataPeriod.condition.Replace('-', ' ');
                _windDirectionText.text    = "Direction: " + dataPeriod.wind_dir.ToString();
                _windSpeedText.text        = "Speed [m/s]: " + dataPeriod.wind_speed.ToString();
                _pressureText.text         = "Pressure [mm]: " + dataPeriod.pressure_mm.ToString();
            }

            _spawnerWeatherPrefab.InstantiateClouds();
        }catch (Exception e)
        {
            _cityText.text = e.Message;
        }
    }
コード例 #3
0
    private async void UpdateHighscores()
    {
        StringBuilder sb = new StringBuilder();

        Highscores = await ScoreManager.GetAllScores();

        Highscores = Highscores.OrderByDescending(hs => hs.Score).Take(10).ToList(); //change to pull only top 10 by partition of highscore

        sb.AppendLine("High Scores:");
        int i = 1;

        foreach (highscore highscore in Highscores)
        {
            sb.Append(i.ToString());
            sb.Append(". ");
            sb.Append(highscore.Score.ToString());
            sb.Append(" - ");
            sb.AppendLine(highscore.UserName);

            i++;
        }

        HighScoresText.Text = sb.ToString().Replace("\r", "");
        HighScoresText.GenerateText();
    }
コード例 #4
0
 public void SetText(string text)
 {
     textScript.Text = text;
     textScript.GenerateText();
     if (dynamicPosition)
     {
         UpdateTextPosition();
     }
 }
コード例 #5
0
    public override void OnInspectorGUI()
    {
        SimpleHelvetica targetSH = (target as SimpleHelvetica);         // find target component

        if (!targetSH.enabled)
        {
            if (GUILayout.Button("Edit Text", GUILayout.MaxWidth(120)))
            {
                targetSH.EnableSelf();
            }
        }
        else
        {
            GUILayout.Label("Text");
            EditorGUILayout.HelpBox("- WARNING: Changing text will reset individual character transform changes\n- Multiple lines supported\n- Undo not supported for this Text area", MessageType.None);
            targetSH.Text             = EditorGUILayout.TextArea((target as SimpleHelvetica).Text);
            targetSH.CharacterSpacing = EditorGUILayout.FloatField("Character Spacing", (target as SimpleHelvetica).CharacterSpacing);
            targetSH.LineSpacing      = EditorGUILayout.FloatField("Line Spacing", (target as SimpleHelvetica).LineSpacing);
            targetSH.SpaceWidth       = EditorGUILayout.FloatField("Space Width", (target as SimpleHelvetica).SpaceWidth);

            //tell SimpleHelvetica.cs that something has changed (so it runs ManualUpdate() ) when Text | variables are modified
            if (targetSH.Text != PrevFrameText ||
                targetSH.CharacterSpacing != PrevFrameCharacterSpacing ||
                targetSH.LineSpacing != PrevFrameLineSpacing ||
                targetSH.SpaceWidth != PrevFrameSpaceWidth)
            {
                PrevFrameText             = targetSH.Text;
                PrevFrameCharacterSpacing = targetSH.CharacterSpacing;
                PrevFrameLineSpacing      = targetSH.LineSpacing;
                PrevFrameSpaceWidth       = targetSH.SpaceWidth;
                targetSH.GenerateText();
            }

            //DrawDefaultInspector();

            /*
             * if (!targetSH.UpdateInRealtime){
             * if(GUILayout.Button("Update Text", GUILayout.MaxWidth(120))) {
             *              targetSH.GenerateText();
             * }
             * }
             */


            EditorGUILayout.Space();
            if (GUILayout.Button("Apply\nMesh Renderer\nSettings", GUILayout.MaxWidth(120)))
            {
                targetSH.ApplyMeshRenderer();
            }
            EditorGUILayout.HelpBox("Cannot Undo when Applying Mesh Renderer Settings", MessageType.None);
        }
    }
コード例 #6
0
ファイル: GameManager.cs プロジェクト: AIMS20/StickyGame
    // Start is called before the first frame update
    void Awake()
    {
        InstanceCheck();

        pooledObjects = new List <GameObject>();
        StartPooling();

        policeStartSpeed    = PersistentSettings.policeStartSpeed;
        policeIncreaseSpeed = PersistentSettings.policeIncreaseSpeed;
        policeSpawnSeconds  = PersistentSettings.policeSpawnSeconds;

        currentTime = 0f;
        gameStarted = false;
        gameOver    = false;

        //cam
        camTarget = GameObject.Find("CamTarget");

        //initialize timer
        timerText      = gameObject.GetComponentInChildren <SimpleHelvetica>();
        timerText.Text = "0";
        timerText.GenerateText();

        restartText      = Instantiate(timerText);
        restartText.Text = " ";
        restartText.GenerateText();

        //spawn road tiles
        InvokeRepeating(nameof(SpawnRoads), 0f, tileSpawnSeconds);

        //spawn player
        var playerSpawnpos = new Vector3(0, player.transform.GetComponent <BoxCollider>().bounds.size.y, 0);

        player              = Instantiate(player, playerSpawnpos, Quaternion.identity);
        playerRb            = player.GetComponent <Rigidbody>();
        playerRb.useGravity = false;

        // rb.constraints = RigidbodyConstraints.FreezeAll; //TODO: add back in with correct rotation

        //spawn police cars
        policeCars             = new List <GameObject>();
        policeSpawnPosOffset.y = 1; //TODO: magic numbas
        policeSpawnPosOffset   = playerSpawnpos + policeSpawnPosOffset;

        InvokeRepeating(nameof(SpawnPoliceCars), 0f, policeSpawnSeconds);

        //spawn random road block items
        //TODO: fix attaching
        // InvokeRepeating(nameof(SpawnRoadBlockItems), 1f, policeSpawnSeconds*2f);
    }
コード例 #7
0
ファイル: GameManager.cs プロジェクト: AIMS20/StickyGame
    private void UpdateTimer()
    {
        if (gameStarted)
        {
            currentTime   += Time.deltaTime;
            timer          = (int)currentTime;
            timerText.Text = $"{timer.ToString(CultureInfo.CurrentCulture)}";
        }
        else
        {
            var timerBegin = "--";
            timerText.Text = $"{timerBegin.ToString(CultureInfo.CurrentCulture)}";
        }

        timerText.GenerateText();
    }
コード例 #8
0
    public void UpdateScoreText(bool includePrompt)
    {
        StringBuilder sb = new StringBuilder();

        sb.AppendLine("Your Score:");
        sb.AppendLine(ScoreEntering.ToString());

        if (includePrompt)
        {
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine("Press A to enter your name");
        }

        YourScoreText.Text = sb.ToString().Replace("\r", "");
        YourScoreText.GenerateText();
    }
コード例 #9
0
    // Update is called once per frame
    void Update()
    {
        currentDate = System.DateTime.Now.ToString("HH:mm\ndddd,MMMM\bdd");
        if (enabled)
        {
            currentDate = "";
        }

        // Update date text
        Transform       parent          = transform.parent;
        GameObject      blueScreen      = parent.Find("blue_screen").gameObject;
        GameObject      date            = blueScreen.transform.Find("Date").gameObject;
        SimpleHelvetica simpleHelvetica = date.GetComponent <SimpleHelvetica>();

        simpleHelvetica.Text = currentDate;
        simpleHelvetica.GenerateText();
    }
コード例 #10
0
 private void RetriveHighscore()
 {
     try
     {
         HighScoreText.Text = String.Format(
             "1.   {0}{5}" +
             "2.   {1}{5}" +
             "3.   {2}{5}" +
             "4.   {3}{5}" +
             "5.   {4}{5}",
             retriveScore(1), retriveScore(2), retriveScore(3), retriveScore(4), retriveScore(5),
             "\n");
         HighScoreText.ApplyMeshRenderer();
         HighScoreText.GenerateText();
     }
     catch (Exception exp)
     {
     }
 }
コード例 #11
0
    void Start()
    {
        rb = GetComponent <Rigidbody>();
        rb.centerOfMass = centermass;

        if (random_letter)
        {
            Random.InitState((int)System.DateTime.Now.Ticks);
            text.Text = Alphabet[(int)(Random.value * 26f - 0.1f)];
            text.GenerateText();



            letter = text.transform.GetChild(1);

            //letter.localScale = letter.localScale * transform.localScale.x;
            transform.localScale = transform.localScale * scale;

            // rb.centerOfMass = centermass * scale;

            letter_collider        = letter.gameObject.AddComponent(typeof(MeshCollider)) as MeshCollider;
            letter_rigidbody       = letter.gameObject.AddComponent(typeof(Rigidbody)) as Rigidbody;
            letter_collider.convex = true;
            transform.GetComponent <FixedJoint>().connectedBody = letter_rigidbody;
            letter.GetComponent <Renderer>().material.color     = //new Color(0.5f, 1, 1);
                                                                  GoldenColor.GenerateColor(0.6f, 0.95f, 0f);
        }
        else
        {
            Random.InitState((int)System.DateTime.Now.Ticks);
            letter                 = text.transform.GetChild(1);
            letter_collider        = letter.gameObject.AddComponent(typeof(MeshCollider)) as MeshCollider;
            letter_rigidbody       = letter.gameObject.AddComponent(typeof(Rigidbody)) as Rigidbody;
            letter_collider.convex = true;
            transform.GetComponent <FixedJoint>().connectedBody = letter_rigidbody;
        }
    }
コード例 #12
0
 public void SetScore(int score)
 {
     _scoreValueText.Text = score.ToString();
     _scoreValueText.GenerateText();
 }
コード例 #13
0
 public void SetSpeed(float speed)
 {
     _speedValueText.Text = String.Format("{0:N2}", Math.Round(speed, 2)) + " lm/s";
     _speedValueText.GenerateText();
 }
コード例 #14
0
    public override void OnInspectorGUI()
    {
                #if UNITY_EDITOR
        SimpleHelvetica targetSH = (target as SimpleHelvetica);         // find target component

        if (!targetSH.enabled)
        {
            if (GUILayout.Button("Edit Text", GUILayout.MaxWidth(120)))
            {
                targetSH.EnableSelf();
            }
        }
        else
        {
            GUILayout.Label("Text");
            EditorGUILayout.HelpBox("- WARNING: Changing text will reset individual character transform changes\n- Multiple lines supported\n- Undo not supported for this Text area", MessageType.None);
            targetSH.Text             = EditorGUILayout.TextArea((target as SimpleHelvetica).Text);
            targetSH.CharacterSpacing = EditorGUILayout.FloatField("Character Spacing", (target as SimpleHelvetica).CharacterSpacing);
            targetSH.LineSpacing      = EditorGUILayout.FloatField("Line Spacing", (target as SimpleHelvetica).LineSpacing);
            targetSH.SpaceWidth       = EditorGUILayout.FloatField("Space Width", (target as SimpleHelvetica).SpaceWidth);

            //tell SimpleHelvetica.cs that something has changed (so it runs ManualUpdate() ) when Text | variables are modified
            if (targetSH.Text != PrevFrameText ||
                targetSH.CharacterSpacing != PrevFrameCharacterSpacing ||
                targetSH.LineSpacing != PrevFrameLineSpacing ||
                targetSH.SpaceWidth != PrevFrameSpaceWidth)
            {
                PrevFrameText             = targetSH.Text;
                PrevFrameCharacterSpacing = targetSH.CharacterSpacing;
                PrevFrameLineSpacing      = targetSH.LineSpacing;
                PrevFrameSpaceWidth       = targetSH.SpaceWidth;
                targetSH.GenerateText();
            }

            //DrawDefaultInspector();

            /*
             * if (!targetSH.UpdateInRealtime){
             * if(GUILayout.Button("Update Text", GUILayout.MaxWidth(120))) {
             *              targetSH.GenerateText();
             * }
             * }
             */
            EditorGUILayout.Space();

            if (!targetSH.BoxColliderAdded)
            {
                if (GUILayout.Button("+ Box Colliders", GUILayout.MaxWidth(120)))
                {
                    targetSH.AddBoxCollider();
                }
            }

            if (targetSH.BoxColliderAdded)
            {
                if (GUILayout.Button("- Box Colliders", GUILayout.MaxWidth(120)))
                {
                    targetSH.RemoveBoxCollider();
                }
                targetSH.BoxColliderIsTrigger = EditorGUILayout.Toggle("Is Trigger", (target as SimpleHelvetica).BoxColliderIsTrigger);
                //if(GUILayout.Button("Update Box Collider", GUILayout.MaxWidth(120))) {
                targetSH.SetBoxColliderVariables();
                //}
            }

            EditorGUILayout.Space();

            if (!targetSH.RigidbodyAdded)
            {
                if (GUILayout.Button("+ Rigidbody", GUILayout.MaxWidth(120)))
                {
                    targetSH.AddRigidbody();
                }
            }

            if (targetSH.RigidbodyAdded)
            {
                if (GUILayout.Button("- Rigidbody", GUILayout.MaxWidth(120)))
                {
                    targetSH.RemoveRigidbody();
                }
                EditorGUILayout.HelpBox("Press \"Update Rigidbody\" to apply changes\nPress \"Reset Rigidbody\" to revert to default values", MessageType.None);

                DrawDefaultInspector();

                if (GUILayout.Button("Update Rigidbody", GUILayout.MaxWidth(120)))
                {
                    targetSH.SetRigidbodyVariables();
                }

                if (GUILayout.Button("Reset Rigidbody", GUILayout.MaxWidth(120)))
                {
                    targetSH.ResetRigidbodyVariables();
                }
            }


            EditorGUILayout.Space();
            if (GUILayout.Button("Apply\nMesh Renderer\nSettings", GUILayout.MaxWidth(120)))
            {
                targetSH.ApplyMeshRenderer();
            }
            EditorGUILayout.HelpBox("Cannot Undo when Applying Mesh Renderer Settings", MessageType.None);
        }
                #endif
    }