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(); } } } }
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); }
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(); }
// 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; } }
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); } }
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)); } }
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; }
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(); } }
private void Start() { cb = GetComponent <CatBehaviour>(); }
public void UpdateCatUI() { CatBehaviour updateCat = cats[catFollowIndex]; _cccUI.UpdateUI(updateCat.GetComponent <CatPortrait>(), updateCat.getLapCount(), updateCat.getTotalLapCount()); }
// Start is called before the first frame update void Start() { state = GetComponentInParent <CatBehaviour>(); playerRb = player.GetComponent <Rigidbody2D>(); audioSour = player.GetComponent <AudioSource>(); }
public void setMyCat(CatBehaviour newCat) { myCat = newCat; }