Ejemplo n.º 1
0
    void Update()
    {
        Vector2 mosPos = mainCam.ScreenToWorldPoint(Input.mousePosition);

        transform.position = mosPos;

        if (Input.GetButtonDown("Fire1") && !instagramOverlay.activeSelf && !menuOverlay.activeSelf && !rounderOverOverlay.activeSelf)
        {
            List <GameObject> cats = cameraCollider.getCurrentCat();
            if (cats.Count > 0)
            {
                List <CatBehaviour> catBehavs = new List <CatBehaviour>();
                foreach (var cat in cats)
                {
                    CatBehaviour catBehav = cat.GetComponent <CatBehaviour>();
                    catBehavs.Add(catBehav);
                }
                takePhoto(catBehavs);
                foreach (var cat in catBehavs)
                {
                    cat.pictureTaken();
                }
            }
        }
    }
Ejemplo n.º 2
0
 public void PlaceBet(CatBehaviour cat)
 {
     catBetOn = cat;
     ui_betting.SetActive(false);
     ui_race.SetActive(true);
     ui_countdown.gameObject.SetActive(true);
     ui_countdown.startTimer();
     currentTicketAmount -= amountPerBet;
     ui_ticket.updateTicketAmount(currentTicketAmount);
 }
Ejemplo n.º 3
0
    public void SetupCamera(CatBehaviour[] cats, CatBehaviour fastCat, CatBehaviour slowCat)
    {
        catFollowIndex = Random.Range(0, cats.Length);

        this.cats = (CatBehaviour[])cats.Clone();
        this.cats[catFollowIndex].giveCamera(this);

        fastestCatIndex = System.Array.IndexOf(cats, fastCat);

        UpdateCatUI();
    }
Ejemplo n.º 4
0
 // https://forum.unity.com/threads/randomize-array-in-c.86871/
 void reshuffleCats(CatBehaviour[] cats)
 {
     // Knuth shuffle algorithm :: courtesy of Wikipedia :)
     for (int t = 0; t < cats.Length; t++)
     {
         CatBehaviour tmp = cats[t];
         int          r   = UnityEngine.Random.Range(t, cats.Length);
         cats[t] = cats[r];
         cats[r] = tmp;
     }
 }
Ejemplo n.º 5
0
    public void endRace(CatBehaviour winningCat)
    {
        if (isRaceOn)
        {
            isRaceOn = false;
            _cb.endRace();

            confetti.SetActive(true);
            Time.timeScale      = raceEndTimeMod;
            Time.fixedDeltaTime = this.fixedDeltaTime * Time.timeScale;

            // show standings UI after 1 seconds
            ui_race.SetActive(false);
            Invoke("showStandings", 1f);
        }
    }
Ejemplo n.º 6
0
    public void GetPlayerAction(PlayerActions action)
    {
        Debug.Log("Action triggered: " + action.name);
        behaviour = action.GetBehaviourByMood(mood);

        behaviourText.text = behaviour.description;
        if (behaviour.playClip != null)
        {
            animator.Play(clips.Find(clip => clip.Equals(behaviour.playClip)).name);
        }
        if (behaviour.audio != null)
        {
            AudioSource.PlayClipAtPoint(behaviour.audio, Camera.main.transform.position, 0.5f);
        }
        if (onBehaving == false)
        {
            StartCoroutine(AwaitBeforeNewMood(Time.time + behaviour.lifeTime));
        }
    }
Ejemplo n.º 7
0
    IEnumerator AwaitBeforeNewMood(float time)
    {
        onBehaving = true;
        behaviourSlider.minValue = Time.time;
        behaviourSlider.maxValue = time;
        while (Time.time < time)
        {
            Debug.Log("Waiting...");
            behaviourSlider.value = Time.time;
            yield return(null);
        }
        mood      = behaviour.triggerMood;
        behaviour = behaviour.triggerBehaviour;

        moodText.text      = mood.description;
        behaviourText.text = behaviour.description;

        animator.Play(clips.Find(clip => clip.Equals(behaviour.playClip)).name);
        Debug.Log("Finished");
        onBehaving = false;
    }
Ejemplo n.º 8
0
    private void Update()
    {
        if (isRaceOn)
        {
            // sort out positions
            CatBehaviour[] newStandings = new CatBehaviour[catStandings.Length];
            newStandings = catStandings.OrderBy(cat => cat.getPercentageDone()).ToArray();
            newStandings = newStandings.Reverse().ToArray();

            for (int i = 0; i < newStandings.Length; i++)
            {
                if (catStandings[i] != newStandings[i])
                {
                    // Standings have changed
                    catStandings = (CatBehaviour[])newStandings.Clone();
                    updateCatStandings();
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            pauseGame();
        }
    }
Ejemplo n.º 9
0
 private void Start()
 {
     cb = GetComponent <CatBehaviour>();
 }
Ejemplo n.º 10
0
    public void UpdateCatUI()
    {
        CatBehaviour updateCat = cats[catFollowIndex];

        _cccUI.UpdateUI(updateCat.GetComponent <CatPortrait>(), updateCat.getLapCount(), updateCat.getTotalLapCount());
    }
Ejemplo n.º 11
0
 // Start is called before the first frame update
 void Start()
 {
     state     = GetComponentInParent <CatBehaviour>();
     playerRb  = player.GetComponent <Rigidbody2D>();
     audioSour = player.GetComponent <AudioSource>();
 }
Ejemplo n.º 12
0
 public void setMyCat(CatBehaviour newCat)
 {
     myCat = newCat;
 }