public void ShowChallengeMsg(MinigameTypes type) { Hashtable msgOption = new Hashtable(); switch (type) { case MinigameTypes.TriggerNinja: msgOption.Add(SpeechController.SpeechKeys.MessageText, Localization.Localize("MINIPET_GAMEMASTER_NINJA")); break; case MinigameTypes.Clinic: msgOption.Add(SpeechController.SpeechKeys.MessageText, Localization.Localize("MINIPET_GAMEMASTER_DOC")); break; case MinigameTypes.Memory: msgOption.Add(SpeechController.SpeechKeys.MessageText, Localization.Localize("MINIPET_GAMEMASTER_MEMORY")); break; case MinigameTypes.Runner: msgOption.Add(SpeechController.SpeechKeys.MessageText, Localization.Localize("MINIPET_GAMEMASTER_RUNNER")); break; case MinigameTypes.Shooter: msgOption.Add(SpeechController.SpeechKeys.MessageText, Localization.Localize("MINIPET_GAMEMASTER_SHOOTER")); break; } speechController.TalkMiniPet(msgOption); }
/// <summary> /// Meant to be called at the end of every minigame scene. /// </summary> private void EvaluateMinigameResults() { //Stop update calling doMinigameCountdown = false; if (myAudioSource == null) { myAudioSource = GetComponent <AudioSource>(); } resultScreenHolder.ToggleResultsScreen(true); //Which minigame did we just complete? switch (curMinigame) { ///We should go here if we are re-entering the main scene. default: curMinigame = MinigameTypes.notMinigame; //Reset this bad boy curMinigameDuration = 0.0f; break; case (MinigameTypes.Dig): curScore = FindObjectOfType <DigController>().Digs; CheckScoreThreshold(); /// break; case (MinigameTypes.ChaseTail): curScore = FindObjectOfType <Tailchase>().NumSpins; CheckScoreThreshold(); break; case (MinigameTypes.chewMinigame): curScore = FindObjectOfType <Chew>().Score; CheckScoreThreshold(); break; case (MinigameTypes.DDRfinalGame): curScore = FindObjectOfType <DDR>().curidx; CheckScoreThreshold(); break; case (MinigameTypes.couchGame): //Invert this curScore = 3 - FindObjectOfType <WaitingGame>().FuckupCounter; if (null != GameObject.Find("StayCanvas")) { GameObject.Find("StayCanvas").SetActive(false); } CheckScoreThreshold(); break; } }
/// <summary> /// Gets called when a button for minigame selection is called. /// /// Note that the int arg corresponds directly to Build order set in Unity Build settings. /// </summary> /// <param name="_minigameScene"></param> public void NotifyMinigameManagerOfNewMinigame(int _minigameScene) { switch (_minigameScene) { ///We should go here if we are re-entering the main scene. default: curMinigame = MinigameTypes.notMinigame; //Reset this bad boy curMinigameDuration = 0.0f; break; ///There's definitely better way to handle this lol. case (2): curMinigame = MinigameTypes.Dig; curMinigameDuration = digMinigame.myDuration; // curMediumThreshold = digMinigame.mehThreshold; curGoodDogThreshold = digMinigame.goodDoggoThreshold; curBestestDoggoThreshold = digMinigame.bestDoggohreshold; break; case (3): curMinigame = MinigameTypes.chewMinigame; curMinigameDuration = chewMinigame.myDuration; // curMediumThreshold = chewMinigame.mediumScoreThreshold; curGoodDogThreshold = chewMinigame.goodDoggoThreshold; curBestestDoggoThreshold = chewMinigame.bestDoggohreshold; break; //case (3): // curMinigame = MinigameTypes.ChaseTail; // curMinigameDuration = chaseTailMinigame.myDuration; // // curMediumThreshold = chaseTailMinigame.mediumScoreThreshold; // curGoodDogThreshold = chaseTailMinigame.goodDoggoThreshold; // curBestestDoggoThreshold = chaseTailMinigame.bestDoggohreshold; // break; case (4): curMinigame = MinigameTypes.DDRfinalGame; curMinigameDuration = DDRminigame.myDuration; // curMediumThreshold = chaseTailMinigame.mediumScoreThreshold; curGoodDogThreshold = DDRminigame.goodDoggoThreshold; curBestestDoggoThreshold = DDRminigame.bestDoggohreshold; break; case (5): curMinigame = MinigameTypes.couchGame; curMinigameDuration = CouchGame.myDuration; curGoodDogThreshold = CouchGame.goodDoggoThreshold; curBestestDoggoThreshold = CouchGame.bestDoggohreshold; break; } // Debug.Log("MinigameLoopManager.NotifyMinigameGamaner reporting for duty. Current Minigame type: " + curMinigame); }
private static void IncomingHandler() { NetIncomingMessage incoming; while (IsRunning) { while ((incoming = client.ReadMessage()) != null) { switch (incoming.MessageType) { case NetIncomingMessageType.Data: PacketTypes val = (PacketTypes)incoming.ReadInt16(); Logger.WriteLine("Got new message: " + val.ToString()); if (val == PacketTypes.GETROOM) { UpdateRoom(incoming); } if (val == PacketTypes.MINIGAME) { MinigameTypes minigame = (MinigameTypes)incoming.ReadInt16(); switch (minigame) { case MinigameTypes.FlySwat: Room.GotoRoom(typeof(Game1.Minigames.FlySwat.FlySwat)); break; case MinigameTypes.MainGame: Room.GotoRoom(typeof(Game1.Rooms.Room1)); break; case MinigameTypes.FollowTheLeader: Room.GotoRoom(typeof(Game1.Minigames.FollowTheLeader.FollowTheLeader)); break; case MinigameTypes.ClimbTheMountain: Room.GotoRoom(typeof(Game1.Minigames.ClimbTheMountain.ClimbTheMountain)); break; case MinigameTypes.DinoCollectStuff: Room.GotoRoom(typeof(Game1.Minigames.DinoCollectStuff.DinoCollectStuff)); break; case MinigameTypes.GameSelect: Room.GotoRoom(typeof(Game1.Rooms.MultiRandomGame)); break; case MinigameTypes.TapWhite: Room.GotoRoom(typeof(Game1.Minigames.DontTapWhite.Donttapwhite)); break; case MinigameTypes.Quiz: Room.GotoRoom(typeof(Game1.Minigames.Quiz.Quiz)); break; default: Room.GotoRoom(typeof(Game1.Rooms.DebugRoom)); break; } } if (handlers.ContainsKey(val)) { handlers[val].Invoke(incoming); } break; default: break; } } Thread.Sleep(10); } client.Disconnect("DOEI"); }
public static MinigameTypes GetMinigameTypeFromLocationId(string locationId) { PartitionLocationTypes partitionLocType = GetData(locationId).Attribute; if (partitionLocType == PartitionLocationTypes.Base) { // Not supported for parsing return(MinigameTypes.None); } else { // Parse convert string to another enum MinigameTypes minigameType = (MinigameTypes)Enum.Parse(typeof(MinigameTypes), partitionLocType.ToString()); return(minigameType); } }
private MiniPetGameMaster gameMasterScript; // Reference to minipet logic public void InitializeContent(string taskID, MinigameTypes type, MiniPetGameMaster gameMasterScript) { this.gameMasterScript = gameMasterScript; task = WellapadMissionController.Instance.GetTask(taskID); ImmutableDataWellapadTask missionTask = DataLoaderWellapadTasks.GetTask(task.TaskID); string desc = missionTask.GetText(); if (task.Amount > 0) { desc = String.Format(desc, task.Amount); } label.text = desc; spriteIcon.sprite = SpriteCacheManager.GetSprite("mapIcons" + type.ToString()); rewardButton.SetActive(false); SetCheckboxSprite(true); }
/// <summary> /// Gets the unused position next to minigame /// NOTE: GetRandomUnlockedMinigameType() does not keep track of local, if picked already /// </summary> /// <returns>The unused position next to minigame.</returns> public LgTuple<Vector3, string> GetPositionNextToMinigame(MinigameTypes minigameType){ CheckInitializeOpenLocations(); // Converting to the MinigameTypes to a PartitionLocationType PartitionLocationTypes locationType = PartitionLocationTypes.None; switch(minigameType){ case MinigameTypes.Clinic: locationType = PartitionLocationTypes.Clinic; break; case MinigameTypes.Memory: locationType = PartitionLocationTypes.Memory; break; case MinigameTypes.Runner: locationType = PartitionLocationTypes.Runner; break; case MinigameTypes.Shooter: locationType = PartitionLocationTypes.Shooter; break; case MinigameTypes.TriggerNinja: locationType = PartitionLocationTypes.TriggerNinja; break; case MinigameTypes.MicroMix: locationType = PartitionLocationTypes.MicroMix; break; default: return null; } // Initialize all to null first LgTuple<Vector3, string> tupleToReturn = null; ImmutableDataPartitionLocation locationToDelete = null; // Loop through available list and keep track if found foreach(ImmutableDataPartitionLocation location in openMinipetLocationsList){ if(location.Attribute == locationType){ tupleToReturn = new LgTuple<Vector3, string>(location.Offset, location.Id); locationToDelete = location; break; } } // Remove the tuple from the list if is exists, outside foreach iteration if(locationToDelete != null){ openMinipetLocationsList.Remove(locationToDelete); } return tupleToReturn; }
private string PickMinigameMissionKey(MinigameTypes type) { if (type == MinigameTypes.TriggerNinja) { int rand = UnityEngine.Random.Range(0, 2); switch (rand) { case 0: return("ScoreNinja"); case 1: return("ComboNinja"); default: return("ComboNinja"); } } else if (type == MinigameTypes.Memory) { return("ScoreMemory"); } else if (type == MinigameTypes.Clinic) { return("ScoreClinic"); } else if (type == MinigameTypes.Shooter) { int rand = UnityEngine.Random.Range(0, 2); switch (rand) { case 0: return("ScoreShooter"); case 1: return("SurvivalShooter"); default: return("ScoreShooter"); } } else if (type == MinigameTypes.Runner) { int rand = UnityEngine.Random.Range(0, 3); switch (rand) { case 0: return("ScoreRUNNER"); case 1: return("CoinsRUNNER"); case 2: return("DistanceRUNNER"); default: return("CoinsRUNNER"); } } else { Debug.LogError("Invalid minigame type detected"); return("ScoreNinja"); } }
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; } }
// Called from minipet script children themselves public void OpenUIMinipetType(MiniPetTypes type, Hashtable hash, MonoBehaviour baseScript) { GameObject contentPrefab; switch (type) { case MiniPetTypes.Retention: minipetType = MiniPetTypes.Retention; //Debug.Log(DataManager.Instance.GameData.Wellapad.CurrentTasks.ContainsKey(hash[0].ToString())); if (DataManager.Instance.GameData.Wellapad.CurrentTasks.ContainsKey(hash[0].ToString())) { // Debug.Log(DataManager.Instance.GameData.Wellapad.CurrentTasks[hash[0].ToString()].RewardStatus); if (DataManager.Instance.GameData.Wellapad.CurrentTasks[hash[0].ToString()].isReward == RewardStatuses.Unclaimed || DataManager.Instance.GameData.Wellapad.CurrentTasks[hash[0].ToString()].isReward == RewardStatuses.Unearned) { contentPrefab = Resources.Load("ContentParentRetention") as GameObject; content = GameObjectUtils.AddChildWithPositionAndScale(contentParent, contentPrefab); content.GetComponentInChildren <Button>().onClick.AddListener(() => MiniPetManager.Instance.MiniPetTable["MiniPet0"].GetComponent <MiniPetRetentionPet>().OnTurnInButton()); MiniPetRetentionUIController minipetRetentionUIController = content.GetComponent <MiniPetRetentionUIController>(); minipetRetentionUIController.InitializeContent(hash[0].ToString(), (MiniPetRetentionPet)baseScript); SelectedMiniPetContentUIScript = minipetRetentionUIController; if (TutorialManager.Instance == null || !TutorialManager.Instance.IsTutorialActive()) { contentTweenParent = content.GetComponent <TweenToggle>(); //if(IsOpen() && (contentTweenParent != null)){ // Pet just finished eating, show asap HACK if (contentTweenParent != null) { StartCoroutine(ShowContentHelper()); } } } } break; case MiniPetTypes.GameMaster: minipetType = MiniPetTypes.GameMaster; if (DataManager.Instance.GameData.Wellapad.CurrentTasks[hash[0].ToString()].isReward == RewardStatuses.Unclaimed || DataManager.Instance.GameData.Wellapad.CurrentTasks[hash[0].ToString()].isReward == RewardStatuses.Unearned) { contentPrefab = Resources.Load("ContentParentGameMaster") as GameObject; content = GameObjectUtils.AddChildWithPositionAndScale(contentParent, contentPrefab); MinigameTypes minigameType = (MinigameTypes)Enum.Parse(typeof(MinigameTypes), hash[1].ToString()); content.GetComponentInChildren <Button>().onClick.AddListener(() => MiniPetManager.Instance.MiniPetTable["MiniPet1"].GetComponent <MiniPetGameMaster>().OnTurnInButton()); MiniPetGameMasterUIController minipetGameMasterUIController = content.GetComponent <MiniPetGameMasterUIController>(); minipetGameMasterUIController.InitializeContent(hash[0].ToString(), minigameType, (MiniPetGameMaster)baseScript); SelectedMiniPetContentUIScript = minipetGameMasterUIController; if (TutorialManager.Instance == null || !TutorialManager.Instance.IsTutorialActive()) { contentTweenParent = content.GetComponent <TweenToggle>(); //if(IsOpen() && (contentTweenParent != null)){ // Pet just finished eating, show asap HACK if (contentTweenParent != null) { StartCoroutine(ShowContentHelper()); } } } break; case MiniPetTypes.Merchant: minipetType = MiniPetTypes.Merchant; contentPrefab = Resources.Load("ContentParentMerchant") as GameObject; content = GameObjectUtils.AddChildWithPositionAndScale(contentParent, contentPrefab); ItemType itemType = (ItemType)Enum.Parse(typeof(ItemType), hash[1].ToString()); MiniPetMerchantUIController minipetMerchantUIController = content.GetComponent <MiniPetMerchantUIController>(); minipetMerchantUIController.InitializeContent(hash[0].ToString(), false, itemType, (MiniPetMerchant)baseScript); SelectedMiniPetContentUIScript = minipetMerchantUIController; if (TutorialManager.Instance == null || !TutorialManager.Instance.IsTutorialActive()) { contentTweenParent = content.GetComponent <TweenToggle>(); //if(IsOpen() && (contentTweenParent != null)){ // Pet just finished eating, show asap HACK if (contentTweenParent != null) { StartCoroutine(ShowContentHelper()); } } break; default: minipetType = MiniPetTypes.None; Debug.LogError("No minipet type found: " + type.ToString()); return; } }