示例#1
0
 public void ChangeColor()
 {
     int noHits = Mathf.Min(boardScript.counter / 20 + 1, boardScript.maxNoHits);
     if (!alternate)
     {
         if (boardScript.noHits % noHits == 0)
             color = boardScript.currentColor;
         else
             color = (HomerColor)(random.Next() % 6);
     }
     else
     {
         color = (HomerColor)(random.Next() % 6);
         if (color == boardScript.currentColor)
             color = (HomerColor)(((int)color + 1) % 6);
     }
     Renderer homerRenderer = homer.GetComponent<Renderer>();
     if (((boardScript.counter > goldStart && random.NextDouble() < goldProbability) || boardScript.goldTimer > 0))
     {
         color = HomerColor.ORO;
         homerRenderer.material = gold;
         if (boardScript.goldTimer == 0)
             GetComponent<AudioSource>().PlayOneShot(whistle);
     }
     else
     {
         homerRenderer.material = regular;
         homerRenderer.material.mainTexture = textures[(int)color];
         homer.GetComponent<Renderer>().material.mainTexture = textures[(int)color];
         /*
         arrow.GetComponent<Renderer>().material.SetColor("_Color", boardScript.colors[(int)color]);
         arrow.transform.Find("part").GetComponent<Renderer>().material.SetColor("_Color", boardScript.colors[(int)color]);
         */
     }
     if (color == boardScript.currentColor && boardScript.counter < 14)
         hammer.SetActive(active);
     else
         hammer.SetActive(false);
 }
 public void ChangeColor(int points = 0, bool gold = false)
 {
     if (points != 0)
     {
         counter += points;
         if (counter < 0)
             counter = 0;
         hitsText.color = points > 0 ? new Color(.3f, 1, .3f) : new Color(1, .3f, .3f);
     }
     homerId = -1;
     if (gold)
     {
         if (goldTimer == 0)
         {
             goldTimer = .1e-5f;
             mainSound.clip = goldSoundtrack;
             mainSound.Play();
         }
         colorArea.SetActive(true);
         colorArea.GetComponent<Renderer>().material.SetColor("_EmissionColor", colors[(int)HomerColor.AMARILLO]);
         colorLight.SetActive(true);
         colorLight.GetComponent<Light>().color = colors[(int)HomerColor.AMARILLO];
         changeHomerTimer = .2f;
     }
     else
     {
         changeHomerTimer = 0;
         colorTimer = colorTimerLength;
         if (points >= 0)
         {
             currentColor = (HomerColor)(random.Next() % 6);
             while (currentColor == previousColor)
                 currentColor = (HomerColor)(random.Next() % 6);
             previousColor = currentColor;
             colorArea.SetActive(false);
             colorArea.GetComponent<Renderer>().material.SetColor("_EmissionColor", colors[(int)currentColor]);
             colorLight.SetActive(false);
             colorLight.GetComponent<Light>().color = colors[(int)currentColor];
         }
         newColor = true;
     }
     noHits = 0;
     if (!boardTracked)
         return;
 }
    void Start()
    {
        random = new System.Random();
        changeHomerTimer = 0;
        gameTimer = gameTimerLenght;
        colorTimer = colorTimerLength;
        prevHomerId = -1;
        counter = 0;
        finishedGame = false;
        previousColor = HomerColor.AMARILLO;
        noHits = 0;
        boardTracked = false;
        goldTimer = 0;
        gotGold = false;

        ChangeColor();

        GetComponent<TrackableBehaviour>().RegisterTrackableEventHandler(this);
        ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
        tracker.PersistExtendedTracking(true);
    }