public void OnTriggerEnter(Collider other) { GiftObject gift = other.GetComponent <GiftObject>(); if (gift != null) { //GameObject.FindGameObjectWithTag("NextButton").GetComponent<Button>().interactable = true; GameObject go = Instantiate(packedGift, new Vector3(transform.parent.position.x, transform.parent.position.y + 2f), Quaternion.identity); GiftObject giftObj = go.AddComponent <GiftObject>(); giftObj.Obj = gift.Obj; giftObj.Wishes = GameObject.FindGameObjectWithTag("WishList").GetComponent <Wishlist>().wishesId; SpawnGift spawnGift = GameObject.FindGameObjectWithTag("GameManager").GetComponent <SpawnGift>(); giftObj.Score = spawnGift.GetScore(); go.transform.rotation = Quaternion.Euler(new Vector3(90f, 0f, 0f)); Destroy(other.gameObject); Destroy(transform.parent.gameObject); } }
public void ResetContent() { List <int> wishesId = Utils.GetItems(grades.Length, subjects.Length, subjects.Length); string finalText = ""; int y = 0; SpawnGift manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <SpawnGift>(); int sum = 0; foreach (int i in wishesId) { int mark = Random.Range(grades[i].ScoreMin, grades[i].ScoreMax); sum += mark; finalText += "<b>" + subjects[y++] + ":</b>" + System.Environment.NewLine + grades[i].Description + " ; " + mark + " / 20" + System.Environment.NewLine + System.Environment.NewLine; } manager.IncreaseScore(((float)sum / wishesId.Count) - 10f); gradeList.text = finalText; }
private void Start() { List <int> wishesId = Utils.GetItems(actions.Length, listSizeMin, listSizeMax); string finalText = ""; SpawnGift manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <SpawnGift>(); List <System.DateTime> dts = new List <System.DateTime>(); for (int i = 0; i < wishesId.Count; i++) { dts.Add(new System.DateTime(2018, Random.Range(1, 13), Random.Range(1, 30))); } foreach (int i in wishesId) { manager.IncreaseScore((int)actions[i].Score); System.DateTime dt = dts.Min(); dts.Remove(dt); finalText += dt.ToString("dd/MM") + ": " + actions[i].Description + System.Environment.NewLine; } actionList.text = finalText; }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Dest")) { Text text = GameObject.FindGameObjectWithTag("Score").GetComponent <Text>(); GiftObject gift = GetComponent <GiftObject>(); float mutliplicator = 1; if (gift.Obj == GiftObject.GObject.Coal) { mutliplicator *= -1f; } float score; if (gift.Obj == GiftObject.GObject.Coal || gift.Wishes.Contains((int)gift.Obj)) { score = gift.Score * 10f * mutliplicator; } else { score = -20f; } if (score > 30f) { score = 30f; } if (score < -30f) { score = -30f; } if (score < 0f) { score *= 3f; } text.text = "Score: " + (int.Parse(text.text.Split(' ').Last()) + Mathf.Round(score)).ToString(); SpawnGift spawnGift = GameObject.FindGameObjectWithTag("GameManager").GetComponent <SpawnGift>(); spawnGift.Spawn(); Destroy(gameObject); } }