Ejemplo n.º 1
0
        // Called from BattleManager when player has won the battle
        public void EndBattleActions()
        {
            UIManager.Inst.StartMessage(null, UIManager.Inst.characterSlideIn(largeCharacerSprite));

            // Play congradulatory sound for beating boss
            if (isGymLeader)
            {
                SoundEffectManager.Inst.PlaySoundImmediate("BossWin");
            }

            // Trainer says something after being beaten
            foreach (string message in afterBattleMessage)
            {
                UIManager.Inst.StartNPCMessage(message, NPCName);
            }

            // Give player item if any
            if (rewardItem != null)
            {
                GameManager.Inst.AddItem(rewardItem, numberOfItem, true);
            }

            UIManager.Inst.StartMessage(null, UIManager.Inst.characterSlideOut(), () => UIManager.Inst.EndNPCMessage());

            GameManager.Inst.curSceneData.trainers[index] = true;

            // Remove all obstacles from defeating trainer
            foreach (SceneInteractableObstacle sio in obstacleRemovals)
            {
                // Remove obstacle to next town/path/etc.
                SceneInteractionData sceneWithObstacle = GameManager.Inst.sceneInteractions.Find(si => si.sceneName == sio.sceneName);

                sceneWithObstacle.interactables[sio.index] = true;
            }

            if (isGymLeader)
            {
                // Note: Should never use Find* commands, but this only happens once per gym battle (pretty safe)
                GameObject exitDoor = GameObject.FindGameObjectWithTag("Finish");
                exitDoor.GetComponent <DoorAction>().ActivateDoor();
            }

            UIManager.Inst.StartMessage(null, null, () => PlayerMovement.Inst.ResumeMoving());
        }
Ejemplo n.º 2
0
        // Save new scene data for a scene
        public void InitializeSceneData(string initSceneName, byte numOfInteractables, byte[] childInteracts, byte numOfTrainers, bool discovered = false)
        {
            SceneInteractionData sceneDataInit = new SceneInteractionData();

            sceneDataInit.sceneName     = initSceneName;
            sceneDataInit.interactables = new bool[numOfInteractables];
            sceneDataInit.trainers      = new bool[numOfTrainers];
            sceneDataInit.discovered    = discovered;

            for (byte i = 0; i < numOfInteractables; i++)
            {
                sceneDataInit.interactables[i] = false;
            }
            if (childInteracts != null)
            {
                for (byte i = 0; i < childInteracts.Length; i++)
                {
                    sceneDataInit.interactables[childInteracts[i]] = true;
                }
            }
            for (byte i = 0; i < numOfTrainers; i++)
            {
                sceneDataInit.trainers[i] = false;
            }

            SceneInteractionData prevSI = sceneInteractions.Find(si => si.sceneName == initSceneName);

            if (prevSI == null)
            {
                sceneInteractions.Add(sceneDataInit);
            }
            else
            {
                prevSI = sceneDataInit;
            }
        }
Ejemplo n.º 3
0
        // Load the scene interactable data
        public bool UpdateSceneData(string sceneName)
        {
            // Put player and UI in the scene
            GameObject testForReferenceObject = GameObject.FindGameObjectWithTag("EditorOnly");

            if (testForReferenceObject != null)
            {
                PlayerMovement.Inst.transform.SetParent(testForReferenceObject.transform.root);
            }
            else
            {
                Debug.Log("> ERROR: No Ref obj found for player!");
            }
            GameObject testForUI = GameObject.FindGameObjectWithTag("UI");

            if (testForUI != null)
            {
                UIManager.EntireUI.SetParent(testForUI.transform);
            }

            SceneInteractionData load = sceneInteractions.Find(si => si.sceneName == sceneName);

            if (load != null)
            {
                // Set current scene interaction data
                curSceneData = load;

                // Find GameObjects containing scene interactables, trainers
                GameObject interactables = GameObject.FindGameObjectWithTag("Interactables");
                GameObject trainers      = GameObject.FindGameObjectWithTag("Trainers");

                // Find objects that have been interacted with and remove them
                for (int i = 0; i < load.interactables.Length; i++)
                {
                    InteractAction ia = interactables.transform.GetChild(i).GetComponent <InteractAction>();
                    if (ia != null)
                    {
                        ia.index = i;
                        if (load.interactables[i])
                        {
                            GameObject nextTile = ia.nextTile;
                            if (nextTile != null)
                            {
                                nextTile.SetActive(true);
                                ia.gameObject.SetActive(false);
                            }
                            else
                            {
                                ia.hasBeenViewed = true;
                                if ((ia.actionT == actionType.message) || (ia.actionT == actionType.itemWithNext))
                                {
                                    ia.gameObject.SetActive(false);
                                }
                            }
                        }
                    }
                    else
                    {
                        interactables.transform.GetChild(i).gameObject.SetActive(!load.interactables[i]);
                    }
                }
                // Find trainers that have been defeated with and set their hasTriggered bool
                for (int i = 0; i < load.trainers.Length; i++)
                {
                    NPCInteraction trainer = trainers.transform.GetChild(i).GetComponent <NPCInteraction>();
                    if (trainer == null)
                    {
                        Debug.Log("NULL TRAINER!");
                    }
                    trainer.index = i;
                    if (load.trainers[i])
                    {
                        trainer.hasTriggered = true;
                    }
                }

                return(true);
            }
            else
            {
                // Some scenes do not require scene data
                // Ex. Main menu, New Game, Recovery Center and Shop
                //Debug.Log ("> ERROR: Scene data not present!");
                return(false);
            }
        }