void animateReward(TreasureContents reward, Vector3 startLoc) { for (int i = 0; i < reward.treasureQualifier; i++) { animateRewardSub(reward, startLoc); } }
void animateRewardSub(TreasureContents reward, Vector3 startLoc) { GameObject prefabToUse; switch (reward.contentType) { case "money": prefabToUse = moneyRewardPrefab; break; case "gem": prefabToUse = gemRewardPrefab; break; case "laser": prefabToUse = laserRewardPrefab; break; default: return; } GameObject go = (GameObject)GameObject.Instantiate(prefabToUse, startLoc, Quaternion.identity); Vector3 p1 = startLoc; Vector3 p4 = new Vector3(0, 0.7f, 0); float scale = 2.0f; Vector3 p2 = ((p1 + p4) * 3 / 4) + (Vector3.up * 3.0f) + new Vector3(UnityEngine.Random.Range(-scale, scale), UnityEngine.Random.Range(-scale, scale), UnityEngine.Random.Range(-scale, scale)); Vector3 p3 = ((p1 + p4) * 1 / 4) + (Vector3.up * 3.0f) + new Vector3(UnityEngine.Random.Range(-scale, scale), UnityEngine.Random.Range(-scale, scale), UnityEngine.Random.Range(-scale, scale)); LeanTween.move(go, new LTBezierPath(new Vector3[] { p1, p2, p3, p4 }), 2.0f).setDestroyOnComplete(true);; }
// Use this for initialization void Start() { health = 2; markedForDeletion = false; int treasureNum = Random.Range(1, 7); if (treasureNum < 5) { treasureNum = 1; } else if (treasureNum < 6) { treasureNum = 2; } else { treasureNum = 3; } treasureNum = treasureNum * 2; for (int i = 0; i < treasureNum; i++) { var tc = new TreasureContents(); tc.contentQuantity = tc.contentQuantity * 2; contents.Add(tc); } goFast = true; }
// awards a chestContents object public static void awardChestContentObj(TreasureContents contentsIn) { switch (contentsIn.contentType) { case "none": break; case "money": moneyCount += contentsIn.contentQuantity; break; case "gem": gemCount += contentsIn.contentQuantity; break; case "laser": laserCount += contentsIn.contentQuantity; break; } }
public void set(TreasureContents contentsIn) { // set the reward contents contents = contentsIn; }