예제 #1
0
    protected override void XMLNodeHandler(string id, IXMLNode xmlNode, Hashtable hashData, string errorMessage)
    {
        ImmutableDataMiniPet data = new ImmutableDataMiniPet(id, xmlNode, errorMessage);

        // store the data
        if (hashData.ContainsKey(id))
        {
            Debug.LogError(errorMessage + "Duplicate keys!");
        }
        else
        {
            hashData.Add(id, data);
        }
    }
예제 #2
0
    /// <summary>
    /// Gets xp required for next level up
    /// </summary>
    /// <returns>The next level up condition. -1 if at max level already</returns>
    private int GetXpNeededForNextLevel(string miniPetID)
    {
        // Get the next level of minipet
        Level currentLevel    = GetCurrentLevel(miniPetID);
        int   currentLevelNum = (int)currentLevel;
        Level nextLevel       = (Level)(currentLevelNum + 1);

        // Get the xp needed for next level
        int xpNeededForNextLevel = -1;

        if ((int)currentLevel < (int)maxLevel)
        {
            ImmutableDataMiniPet data = DataLoaderMiniPet.GetData(miniPetID);
            ImmutableDataMiniPetLevelUpConditions levelUpConditionData = DataLoaderLevelUpConditions.GetData(data.LevelUpConditionID);
            xpNeededForNextLevel = levelUpConditionData.GetXpNeededForLevel(nextLevel);
        }
        return(xpNeededForNextLevel);
    }
예제 #3
0
 /// <summary>
 /// Pass in the immutable data so this specific MiniPet instantiate can be instantiated with the proper information.
 /// </summary>
 /// <param name="minipetData">ImmutableDataMiniPet.</param>
 public void Init(ImmutableDataMiniPet minipetData)
 {
     minipetId = minipetData.ID;
     name      = minipetData.Name;
 }
예제 #4
0
    private void CreateMiniPet(string miniPetId)
    {
        GameObject goMiniPet = null;

        // Unlock in data manager
        DataManager.Instance.GameData.MiniPets.UnlockMiniPet(miniPetId);
        DataManager.Instance.GameData.MiniPetLocations.UnlockMiniPet(miniPetId);
        ImmutableDataMiniPet data   = DataLoaderMiniPet.GetData(miniPetId);
        GameObject           prefab = Resources.Load(data.PrefabName) as GameObject;

        switch (data.Type)
        {
        case MiniPetTypes.Retention:
            // Check if mp needs new locations
            if (isSpawnNewLocations)
            {
                DataManager.Instance.GameData.Wellapad.ResetMissions();
            }

            // Only spawn the retention pet in the bedroom
            if (SceneManager.GetActiveScene().name == SceneUtils.BEDROOM)
            {
                // Calculate the MP location
                LgTuple <Vector3, string> retentionLocation = PartitionManager.Instance.GetBasePositionInBedroom();
                Vector3 locationPosition = retentionLocation.Item1;
                string  locationId       = retentionLocation.Item2;
                int     partitionNumber  = 0;

                DataManager.Instance.GameData.MiniPets.SetIsHatched(miniPetId, true);
                DataManager.Instance.GameData.MiniPetLocations.SaveLocationId(miniPetId, locationId);   // locationId from tuple
                DataManager.Instance.GameData.MiniPets.SaveHunger(miniPetId, true);                     // Set to always full

                goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partitionNumber).gameObject, prefab);
                goMiniPet.transform.localPosition = locationPosition;                   // vector3 from tuple
                goMiniPet.name = prefab.name;

                MiniPetRetentionPet retentionScript = goMiniPet.GetComponent <MiniPetRetentionPet>();
                retentionScript.Init(data);
                retentionScript.FigureOutMissions();
                if (!DataManager.Instance.GameData.Wellapad.CurrentTasks.ContainsKey("DailyInhaler"))
                {
                    retentionScript.GiveOutMission();
                }

                // Add the pet into the dictionary to keep track
                MiniPetTable.Add(miniPetId, goMiniPet);
            }
            break;

        case MiniPetTypes.GameMaster:
            // Check if mp needs new locations
            ImmutableDataGate latestGate = GatingManager.Instance.GetLatestLockedGate();

//			if(latestGate == null)
//				Debug.Log("-----Spawning GameMaster: " + (latestGate == null) + " gate null");
//			else
//				Debug.Log("-----Spawning GameMaster: " + (latestGate.AbsolutePartition - 1 >= 1) + " || latest gate " + latestGate.AbsolutePartition);

            if (latestGate == null || (latestGate.AbsolutePartition - 1 >= 1))
            {
                // NOTE: Besides spawning new locations, there may not be any data for a minipet when coming back to same PP, do or check
                if (isSpawnNewLocations || GetPartitionNumberForMinipet(miniPetId) == -1)
                {
                    // Calculate the MP location
                    MinigameTypes             type = PartitionManager.Instance.GetRandomUnlockedMinigameType();
                    LgTuple <Vector3, string> gameMasterLocation = PartitionManager.Instance.GetPositionNextToMinigame(type);
                    Vector3 locationPosition = gameMasterLocation.Item1;
                    string  locationId       = gameMasterLocation.Item2;
                    int     partitionNumber  = DataLoaderPartitionLocations.GetAbsolutePartitionNumberFromLocationId(locationId);

                    // Save information for minipet
                    DataManager.Instance.GameData.MiniPetLocations.SaveLocationId(miniPetId, locationId);
                    DataManager.Instance.GameData.MiniPets.SaveHunger(miniPetId, false);

                    // Spawn the minipet if it is in current scene
                    if (PartitionManager.Instance.IsPartitionInCurrentZone(partitionNumber))
                    {
                        goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partitionNumber).gameObject, prefab);
                        goMiniPet.transform.localPosition = locationPosition;
                        goMiniPet.name = prefab.name;

                        MiniPetGameMaster gameMasterScript = goMiniPet.GetComponent <MiniPetGameMaster>();
                        gameMasterScript.minigameType = type;
                        gameMasterScript.Init(data);
                        gameMasterScript.isFinishEating = false;

                        // Add the pet into the dictionary to keep track
                        MiniPetTable.Add(miniPetId, goMiniPet);
                    }
                }
                // Spawn based on its saved location
                else
                {
                    // If the saved minipet location is in the current zone
                    if (PartitionManager.Instance.IsPartitionInCurrentZone(GetPartitionNumberForMinipet(miniPetId)))
                    {
                        string locationId = DataManager.Instance.GameData.MiniPetLocations.GetLocationId(miniPetId);

                        // Get relevant info to populate with given saved location ID
                        int           partition    = DataLoaderPartitionLocations.GetAbsolutePartitionNumberFromLocationId(locationId);
                        Vector3       pos          = DataLoaderPartitionLocations.GetOffsetFromLocationId(locationId);
                        MinigameTypes minigameType = DataLoaderPartitionLocations.GetMinigameTypeFromLocationId(locationId);

                        goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partition).gameObject, prefab);
                        goMiniPet.transform.localPosition = pos;
                        goMiniPet.name = prefab.name;

                        MiniPetGameMaster gameMasterScript = goMiniPet.GetComponent <MiniPetGameMaster>();
                        gameMasterScript.minigameType = minigameType;
                        gameMasterScript.Init(data);

                        // Add the pet into the dictionary to keep track
                        MiniPetTable.Add(miniPetId, goMiniPet);
                    }
                }
            }
            break;

        case MiniPetTypes.Merchant:
            ImmutableDataGate latestGate2 = GatingManager.Instance.GetLatestLockedGate();

//			if(latestGate2 == null)
//				Debug.Log("-----Spawning merchant: " + (latestGate2 == null) + " gate null");
//			else
//				Debug.Log("-----Spawning merchant: " + (latestGate2.AbsolutePartition - 1 >= 2) + " || latest gate " + latestGate2.AbsolutePartition);
            if (DataManager.Instance.GameData.MiniPetLocations.IsMerchantSpawning())
            {
                if (latestGate2 == null || (latestGate2.AbsolutePartition - 1 >= 2))
                {
                    // Check if mp needs new locations
                    // NOTE: Besides spawning new locations, there may not be any data for a minipet when coming back to same PP, do or check
                    if (isSpawnNewLocations || GetPartitionNumberForMinipet(miniPetId) == -1)
                    {
                        // Calculate the MP location
                        LgTuple <Vector3, string> merchantLocation = PartitionManager.Instance.GetRandomUnusedPosition();
                        Vector3 locationPosition = merchantLocation.Item1;
                        string  locationId       = merchantLocation.Item2;
                        int     partitionNumber  = DataLoaderPartitionLocations.GetAbsolutePartitionNumberFromLocationId(locationId);

                        // Save information for minipet
                        DataManager.instance.GameData.MiniPetLocations.SaveLocationId(miniPetId, locationId);
                        DataManager.Instance.GameData.MiniPets.SaveHunger(miniPetId, false);

                        // Set new merchant item here only
                        List <ImmutableDataMerchantItem> merchantItemsList = DataLoaderMerchantItem.GetDataList();
                        int rand = UnityEngine.Random.Range(0, merchantItemsList.Count);
                        DataManager.Instance.GameData.MiniPets.SetItem(miniPetId, rand);
                        DataManager.Instance.GameData.MiniPets.SetItemBoughtInPP(miniPetId, false);

                        // Spawn the minipet if it is in current scene
                        if (PartitionManager.Instance.IsPartitionInCurrentZone(partitionNumber))
                        {
                            goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partitionNumber).gameObject, prefab);
                            goMiniPet.transform.localPosition = locationPosition;
                            goMiniPet.name = prefab.name;

                            MiniPetMerchant merchantScript = goMiniPet.GetComponent <MiniPetMerchant>();
                            merchantScript.Init(data);
                            merchantScript.isFinishEating = false;

                            // Add the pet into the dictionary to keep track
                            MiniPetTable.Add(miniPetId, goMiniPet);
                        }
                    }

                    // Spawn based on its saved location
                    else
                    {
                        // If the saved minipet location is in the current zone
                        if (PartitionManager.Instance.IsPartitionInCurrentZone(GetPartitionNumberForMinipet(miniPetId)))
                        {
                            string locationId = DataManager.Instance.GameData.MiniPetLocations.GetLocationId(miniPetId);

                            // Get relevant info to populate with given saved location ID
                            int     partition = DataLoaderPartitionLocations.GetAbsolutePartitionNumberFromLocationId(locationId);
                            Vector3 pos       = DataLoaderPartitionLocations.GetOffsetFromLocationId(locationId);
                            //MinigameTypes minigameType = DataLoaderPartitionLocations.GetMinigameTypeFromLocationId(locationId);

                            goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partition).gameObject, prefab);
                            goMiniPet.transform.localPosition = pos;
                            goMiniPet.name = prefab.name;

                            MiniPetMerchant merchantScript = goMiniPet.GetComponent <MiniPetMerchant>();
                            merchantScript.Init(data);

                            // Add the pet into the dictionary to keep track
                            MiniPetTable.Add(miniPetId, goMiniPet);
                        }
                    }
                }
            }
            break;

        default:
            Debug.LogError("Bad minipet type specified: " + data.Type.ToString());
            break;
        }
    }
예제 #5
0
    private string GetHatchPrefabName(string miniPetID)
    {
        ImmutableDataMiniPet data = DataLoaderMiniPet.GetData(miniPetID);

        return(data.CutsceneHatchPrefabName);
    }
예제 #6
0
    public MiniPetTypes GetMinipetType(string miniPetID)
    {
        ImmutableDataMiniPet miniPetData = DataLoaderMiniPet.GetData(miniPetID);

        return(miniPetData.Type);
    }