Example #1
0
    void PickARandomMaterial()
    {
        Material matToTryThisTime = PossibleMaterials[Random.Range(0, PossibleMaterials.Length)];

        //theMesh.material = matToTryThisTime;

        /*if (usedMats.Contains(matToTryThisTime.name))
         * {
         *  return;
         * }
         *
         * usedMats = usedMats + matToTryThisTime.name;
         */
        hasPickedMaterial = true;
        //UIName.GetComponent<TextMeshProUGUI>().color = myColor;
        //oddsGui.color = myColor;
        //oddsGui.text = oddsReturner(myOdds);
        //UIOddsTitle.GetComponent<TextMeshProUGUI>().color = myColor;
        OverHeadName.GetComponent <TextMeshProUGUI>().color = myColor;
        OverHeadName.GetComponent <TextMeshProUGUI>().text  = gameObject.name;
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        percentFinished = transform.position.z / RaceManagerScriptRef.FinishLineLocator.transform.position.z;
        if (!hasPickedMaterial)         //To pick a random color
        {
            Material matToTryThisTime = PossibleMaterials[Random.Range(0, PossibleMaterials.Length)];
            theMesh.material = matToTryThisTime;
            if (usedMats.Contains(matToTryThisTime.name))
            {
                return;
            }
            usedMats          = usedMats + matToTryThisTime.name;
            hasPickedMaterial = true;
            UIName.GetComponent <TextMeshProUGUI>().color = matToTryThisTime.color;
            oddsGui.color = matToTryThisTime.color;
            //oddsGui.text = oddsReturner(myOdds);

            UIOddsTitle.GetComponent <TextMeshProUGUI>().color  = matToTryThisTime.color;
            OverHeadName.GetComponent <TextMeshProUGUI>().color = matToTryThisTime.color;
            OverHeadName.GetComponent <TextMeshProUGUI>().text  = gameObject.name;
        }

        if (!RaceManagerScriptRef.hasRaceStarted)
        {
            if (idleCounter < Time.time)
            {
                myAnimator.SetTrigger("Play Idle");
                idleCounter = Time.time + Random.Range(10, 20);
            }

            //calculate odds
            if (howMuchIsBetOnMe > 0)
            {
                myRealOdds = Mathf.RoundToInt((OddsDisplay.CurrentTotalPot / howMuchIsBetOnMe));


                //oddsGui.text = oddsReturner(myRealOdds);
                //int oX = Mathf.RoundToInt( myRealOdds * 100);
                //Fraction showtheseOdds = RealToFraction(oX,0);

                //print("odds = "+myRealOdds+ " betonme= "+ howMuchIsBetOnMe + " total= " + OddsDisplay.CurrentTotalPot );

                //oddsGui.text =myRealOdds.ToString()+"/1";
                //oddsGui.text =  System.Math.Round(myRealOdds,2).ToString();
                //print("My real odds" + myRealOdds + " total pot" + OddsDisplay.CurrentTotalPot + " on me " + howMuchIsBetOnMe);
            }
            else
            {
                myRealOdds = OddsDisplay.CurrentTotalPot;
            }
            oddsGui.text = myRealOdds.ToString() + "/1";
        }

        if (RaceManagerScriptRef.hasRaceStarted)
        {
            myAnimator.SetTrigger("Start Walking");
            myAnimator.SetFloat("MoveAnimSpeed", BaseSpeed / BaseSpeedAnimMultiplier);
            transform.Translate(Vector3.forward * BaseSpeed * Time.deltaTime);
        }
        if (Time.time >= SpeedChangeTimer && RaceManagerScriptRef.hasRaceStarted)
        {
            if (percentFinished < 0.8f)
            {
                SpeedChangeTimer = Time.time + SpeedChangeTickRate;
                BaseSpeed       += Random.Range(-50, 50) * .001f;
                if (BaseSpeed <= 0.83f)
                {
                    BaseSpeed = 1.5f;
                    print(gameObject.name + " got a second wind!");
                    ShoulderCam.Priority += 2;
                    secondWindTimer       = Time.time;
                    GameObject     bottomToaster  = GameObject.Find("Toaster");
                    ToasterManager toastScriptRef = bottomToaster.GetComponent <ToasterManager>();
                    toastScriptRef.ShowAToaster(gameObject.name, "Got a second wind!");
                }
                if (ShoulderCam.Priority != 10)
                {
                    if (secondWindTimer + 3 < Time.time)
                    {
                        ShoulderCam.Priority = 10;
                    }
                }
                if (BaseSpeed <= 1.45 && ShoulderCam.Priority > 10)
                {
                    ShoulderCam.Priority = 10;
                }
            }
            if (percentFinished > 1)           //we passed the finish line
            {
                if (BaseSpeed > 0.01f)
                {
                    BaseSpeed -= 0.002f;
                }
            }

            //print ("Changed speeds" + Time.time + "   " +SpeedChangeTimer + "   " + SpeedChangeTickRate);
        }
        //float dist = Vector3.Distance (FinishLineLocator.transform.position, transform.position);
        //print(gameObject.name + dist);
        if (gameObject.transform.position.z > RaceManagerScriptRef.FinishLineLocator.transform.position.z && !didIFinish)
        {
            //record race result.
            RaceResultData aSingleResult = new RaceResultData();
            aSingleResult.TurtleName     = gameObject.transform.name;
            aSingleResult.FinishingPlace = HowManyTurtlesFinished + 1;
            //aSingleResult.odds = myRealOdds;
            //aSingleResult.totalPool = howMuchIsBetOnMe;
            GuestManager.CurrentRaceresults.Add(aSingleResult);
            RaceResultsColumn1 += (HowManyTurtlesFinished + 1) + ")<nobr>" + gameObject.name + " \n";
            RaceResultsColumn2 += myRealOdds.ToString() + "/1\n";
            RaceResultsColumn3 += howMuchIsBetOnMe.ToString() + "\n";
            //RaceResults += "</nobr>" + (HowManyTurtlesFinished+1) + ". " + gameObject.name + " - Total Pool: " + howMuchIsBetOnMe + " Odds: " +myRealOdds +"</nobr> \n ";
            HowManyTurtlesFinished++;
            //print(RaceResults);
            didIFinish = true;
        }
    }