Exemplo n.º 1
0
    private void CheckRayCast(Vector2 screenPos)
    {
        Ray        ray = Camera.main.ScreenPointToRay(screenPos);
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo, 100.0f))
        {
            hit = hitInfo.collider.gameObject.transform.parent.gameObject;
            if (hit.tag == "Level")
            {
                levelData  = hit.transform.GetChild(0).GetComponent <LevelData>();
                completion = hit.transform.GetChild(0).transform.GetChild(0).GetComponent <RewardGroup>();
                firstTime  = hit.transform.GetChild(0).transform.GetChild(1).GetComponent <RewardGroup>();
                mastery    = hit.transform.GetChild(0).transform.GetChild(2).GetComponent <RewardGroup>();
                owuic.OnLevelClick(levelData);
                // Get data from PlayFab
                StartCoroutine(PopulateLevelData(levelData));

                // TODO: Set up Loading spinning Icon
                // Get data from PlayerPrefs
                // Set all data
                // TODO: set all the LevelData to the InfoPanel
                return;
            }
        }
        owuic.CloseLevelInfoPanel();
    }
Exemplo n.º 2
0
 private void PopulateRewards(RewardGroup rewardGroup, GameObject parent, string caption, int endSpaces)
 {
     for (int i = 0; i < rewardGroup.size.Count; i++)
     {
         // instantiate prefab
         GameObject lootCard = (GameObject)GameObject.Instantiate(lootCardPrefab,
                                                                  lootCardPrefab.transform.position, lootCardPrefab.transform.rotation);
         // Get, compare, and set the picture according to which item it is
         Image cardImage   = lootCard.transform.GetChild(0).GetComponent <Image>();
         int   spriteIndex = GetSpriteIndex(rewardGroup.size[i], rewardGroup.color[i]);
         cardImage.sprite = resourcesData.rewardSprites[spriteIndex];
         lootCard.transform.GetChild(2).GetComponent <TextMeshProUGUI>().text = rewardGroup.size[i] + " " + rewardGroup.color[i];
         lootCard.transform.GetChild(3).GetComponent <TextMeshProUGUI>().text = rewardGroup.quantity[i] + " ";
         lootCard.transform.SetParent(parent.transform, false);
     }
     //Dummy object to take up space at the end of a reward group to add separation
     if (endSpaces > 0)
     {
         for (int i = 0; i < endSpaces; i++)
         {
             GameObject spacer = (GameObject)GameObject.Instantiate(listSpacerPrefab,
                                                                    listSpacerPrefab.transform.position, listSpacerPrefab.transform.rotation);
             spacer.transform.SetParent(parent.transform, false);
         }
     }
 }
Exemplo n.º 3
0
 void Start()
 {
     ggm               = GlobalGameManager.instance;
     resourcesData     = GameObject.Find("GlobalGameManager/ResourcesData").GetComponent <ResourcesData>();
     completionRewards = GameObject.Find("GlobalGameManager/LevelData/Completion").GetComponent <RewardGroup>();
     firstTimeRewards  = GameObject.Find("GlobalGameManager/LevelData/FirstTime").GetComponent <RewardGroup>();
     masteryRewards    = GameObject.Find("GlobalGameManager/LevelData/Mastery").GetComponent <RewardGroup>();
     scoreMarks        = ggm.GetScoreMarks();
     levelName         = ggm.GetLevelName();
     PopulateRewards(completionRewards, rewardContentC, "Completion", 1);
     PopulateRewards(firstTimeRewards, rewardContentFT, "First Time", 1);
     PopulateRewards(masteryRewards, rewardContentM, "Mastery", 1);
 }
Exemplo n.º 4
0
    private void GiveRewards(RewardGroup rewards)
    {
        string key = string.Empty;

        for (int i = 0; i < rewards.quantity.Count; i++)
        {
            if (rewards.size [i] == "Kin")
            {
                // TODO: set up kin reward here
                continue;
            }
            key = rewards.size [i] + rewards.color [i];
            endRewards [key] += rewards.quantity [i];
        }
    }
Exemplo n.º 5
0
 // TODO: Check which crystals are already collected and populate accordingly.
 void Start()
 {
     ggm                = GlobalGameManager.instance;
     lc                 = GameObject.Find("LevelController").GetComponent <LevelController>();
     rluiController     = GameObject.Find("UI").GetComponent <RLUIController>();
     pfd                = GameObject.Find("GlobalGameManager/PlayFabController/PlayFabDataController").GetComponent <PlayFabData>();
     completionRewards  = GameObject.Find("GlobalGameManager/LevelData/Completion").GetComponent <RewardGroup>();
     firstTimeRewards   = GameObject.Find("GlobalGameManager/LevelData/FirstTime").GetComponent <RewardGroup>();
     masteryRewards     = GameObject.Find("GlobalGameManager/LevelData/Mastery").GetComponent <RewardGroup>();
     levelLength        = ggm.GetLevelLength();
     spellMultiplier    = ggm.GetSpellMultiplier();
     spellMultiplierCap = ggm.GetSpellMultiplierCap();
     speedMultiplierCap = ggm.GetMaxSpeedBonus();
     maxSpeed           = ggm.GetMaxVelocity();
     scoreMarks         = ggm.GetScoreMarks();
     scoreCap           = ggm.GetScoreCap();
     freeMovement       = ggm.GetFreeMovement();
     levelName          = ggm.GetLevelName();
     if (freeMovement)
     {
         levelTime = 0;
     }
     levelPerformance = ggm.GetLevelPerformance();
     if (levelPerformance == null)
     {
         levelPerformance = string.Empty;
     }
     if (levelPerformance.Contains("R"))
     {
         rluiController.OnCrystal("Red");
         lc.CollectRedCrystal();
         OnCrystalCollect("Red");
     }
     if (levelPerformance.Contains("G"))
     {
         rluiController.OnCrystal("Green");
         lc.CollectGreenCrystal();
         OnCrystalCollect("Green");
     }
     if (levelPerformance.Contains("B"))
     {
         rluiController.OnCrystal("Blue");
         lc.CollectBlueCrystal();
         OnCrystalCollect("Blue");
     }
     StartCoroutine(GetCompletionData());
 }
Exemplo n.º 6
0
 // TODO: will need to get the scenery prefab lists, enemy prefab lists
 //          and will need to use an index with a data table to determine what is used per level
 void Awake()
 {
     // Used to create a singleton
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     // There will only be 1 instance of this object, and it transfers to other scenes
     DontDestroyOnLoad(gameObject);
     notification = GetComponentInChildren <Notification>();
     levelData    = GetComponentInChildren <LevelData>();
     playerData   = GetComponentInChildren <PlayerData>();
     spellData    = GetComponentInChildren <SpellData>();
     completion   = transform.GetChild(1).transform.GetChild(0).GetComponent <RewardGroup>();
     firstTime    = transform.GetChild(1).transform.GetChild(1).GetComponent <RewardGroup>();
     mastery      = transform.GetChild(1).transform.GetChild(2).GetComponent <RewardGroup>();
     // ----------------- Test Code ---------------------- //
     // -------------- End Test Code --------------------- //
 }
Exemplo n.º 7
0
	public static void CreateLootDrops(RPGLoot loot, Vector3 fromPoint, int npcLevel)
	{
		// ** Figure out which rewards will be selected from groups
		Dictionary<int, RewardGroup> groups = new Dictionary<int, RewardGroup>();

		for (int i = 0; i < loot.rewards.Count; i++)
		{
			if (loot.rewards[i].group != 0)
			{
				if (!groups.ContainsKey(loot.rewards[i].group))
				{
					RewardGroup rg = new RewardGroup();
					rg.rewards.Add(loot.rewards[i]);
					groups.Add(loot.rewards[i].group, rg);
				}
				else
				{
					groups[loot.rewards[i].group].rewards.Add(loot.rewards[i]);
				}
			}
		}

		if (groups.Count > 0)
		{
			foreach (RewardGroup rg in groups.Values)
			{
				int r = rg.rewards.Count > 1 ? Random.Range(0, rg.rewards.Count) : 0;
				rg.selected = rg.rewards[r];
			}
		}

		// ** Drop a Loot Bag
		if (loot.dropAsBag)
		{
			if (loot.bagPrefab == null)
			{
				Debug.LogError("Create Loot Action Error: The Bag Prefab must be set.");
				return;
			}

			GameObject obj = (GameObject)GameObject.Instantiate(loot.bagPrefab);
			obj.transform.position = fromPoint;

			// make sure the prefab has a LootDrop component on it
			RPGLootDrop drop = obj.GetComponent<RPGLootDrop>();
			if (drop == null) drop = obj.AddComponent<RPGLootDrop>();

			// also make sure it has a trigger so that the player can actually interact with it
			Collider coll = obj.GetComponent<Collider>();
			if (coll == null) coll = obj.AddComponent<BoxCollider>();
			coll.isTrigger = true;

			RPGLoot lt = ScriptableObject.CreateInstance<RPGLoot>();	// create new loot bag which holds the rewards
			for (int i = 0; i < loot.rewards.Count; i++)
			{
				// first check if reward in a group and if it is the one chosen to be used from the group
				if (loot.rewards[i].group != 0)
				{
					if (groups[loot.rewards[i].group].selected != loot.rewards[i]) continue;
				}

				// check if the reward is allowed for specified NPC level
				if (loot.rewards[i].lookatNpcLevel && npcLevel < loot.rewards[i].npcMaxLevel) continue;

				// check the chance of spawning this loot
				if (!CanSpawnOnChance(loot.rewards[i].chance)) continue;

				// add the reward
				lt.rewards.Add(loot.rewards[i]);
			}
			drop.DoDrop(lt);
		}

		// ** Drop individual Loot Items
		else
		{
			for (int i = 0; i < loot.rewards.Count; i++)
			{
				// first check if reward in a group and if it is the one chosen to be used from the group
				if (loot.rewards[i].group != 0)
				{
					if (groups[loot.rewards[i].group].selected != loot.rewards[i]) continue;
				}

				// check if the reward is allowed for specified NPC level
				if (loot.rewards[i].lookatNpcLevel && npcLevel < loot.rewards[i].npcMaxLevel) continue;

				// check the chance of spawning this loot
				if (!CanSpawnOnChance(loot.rewards[i].chance)) continue;

				// CURRENCY
				if (loot.rewards[i].type == Reward.RewardType.Currency)
				{
					if (UniRPGGlobal.DB.currencyDropPrefab == null)
					{
						Debug.LogError("Could not create Currency Loot. The Currency LootDrop Prefab is not set.");
						continue;
					}

					GameObject obj = (GameObject)GameObject.Instantiate(UniRPGGlobal.DB.currencyDropPrefab);
					obj.transform.position = fromPoint;

					// make sure the prefab has a LootDrop component on it
					RPGLootDrop drop = obj.GetComponent<RPGLootDrop>();
					if (drop == null) drop = obj.AddComponent<RPGLootDrop>();

					// also make sure it has a trigger so that the player can actually interact with it
					Collider coll = drop.gameObject.GetComponent<Collider>();
					if (coll == null) coll = drop.gameObject.AddComponent<BoxCollider>();
					coll.isTrigger = true;

					RPGLoot lt = ScriptableObject.CreateInstance<RPGLoot>();	// create new loot
					lt.rewards.Add(loot.rewards[i]);							// which holds the one reward
					drop.DoDrop(lt);
				}

				// ATTRIBUTE
				else if (loot.rewards[i].type == Reward.RewardType.Attribute)
				{
					RPGAttribute att = UniRPGGlobal.DB.GetAttribute(loot.rewards[i].guid);
					if (att == null)
					{
						Debug.LogError("Could not create Attribute Loot. The specified Attribute could not be found.");
						continue;
					}

					if (att.lootDropPrefab == null)
					{
						Debug.LogError("Could not create Attribute Loot. The Attribute's LootDrop Prefab is not set.");
						continue;
					}

					GameObject obj = (GameObject)GameObject.Instantiate(att.lootDropPrefab);
					obj.transform.position = fromPoint;

					// make sure the prefab has a LootDrop component on it
					RPGLootDrop drop = obj.GetComponent<RPGLootDrop>();
					if (drop == null) drop = obj.AddComponent<RPGLootDrop>();

					// also make sure it has a trigger so that the player can actually interact with it
					Collider coll = drop.gameObject.GetComponent<Collider>();
					if (coll == null) coll = drop.gameObject.AddComponent<BoxCollider>();
					coll.isTrigger = true;

					RPGLoot lt = ScriptableObject.CreateInstance<RPGLoot>();	// create new loot
					lt.rewards.Add(loot.rewards[i]);							// which holds the one reward
					drop.DoDrop(lt);
				}

				// ITEM
				else if (loot.rewards[i].type == Reward.RewardType.Item)
				{
					RPGItem item = UniRPGGlobal.DB.GetItem(loot.rewards[i].guid);
					if (item == null)
					{
						Debug.LogError("Could not create Item Loot. The specified Item could not be found.");
						continue;
					}

					if (item.lootDropPrefab == null)
					{	// no loot prefab, spawn item normal
						GameObject obj = (GameObject)GameObject.Instantiate(item.gameObject);
						obj.transform.position = fromPoint;

						RPGItem it = obj.GetComponent<RPGItem>();
						it.IsPersistent = false;
		
						RPGLootDrop drop = obj.AddComponent<RPGLootDrop>();
						drop.DoDrop(null); // no reward link. just play drop animation on the item
					}
					else
					{
						// in the case of item one of each copy must be created and dropped
						for (int j = 0; j < (int)loot.rewards[i].count; j++)
						{
							GameObject obj = (GameObject)GameObject.Instantiate(item.lootDropPrefab);
							obj.transform.position = fromPoint;

							// make sure the prefab has a LootDrop component on it
							RPGLootDrop drop = obj.GetComponent<RPGLootDrop>();
							if (drop == null) drop = obj.AddComponent<RPGLootDrop>();

							// also make sure it has a trigger so that the player can actually interact with it
							Collider coll = drop.gameObject.GetComponent<Collider>();
							if (coll == null) coll = drop.gameObject.AddComponent<BoxCollider>();
							coll.isTrigger = true;

							RPGLoot lt = ScriptableObject.CreateInstance<RPGLoot>();	// create new loot
							lt.rewards.Add(loot.rewards[i]);							// which holds the one reward
							drop.DoDrop(lt);
						}
					}
				}
			}
		}
	}