Exemple #1
0
    public void GameOver(bool success)
    {
        EndGame = true;
        RunGame = false;
        SoundManager.SoundM.StartCoroutine("MusicBackDecrease");

        if (final_reward == 1 || success)
        {
            MissionsManager.MissionsM.MissionComplete(actual_mission, actual_worldID);
            Dictionary <string, object> list = new Dictionary <string, object> ();
            list.Add("exp", actual_reward_exp);
            list.Add("carrots", carrots);
            Dictionary <int, int> list2 = new Dictionary <int, int> ();

            foreach (var rewardID in rewards)
            {
                list2.Add(rewardID.Key, rewardID.Value);
            }
            list.Add("objects", list2);
            RewardSystem.RewardS.UpdateInventory(list);
            GameOverUI.SetActive(true);
            GameOverUI.transform.GetChild(0).gameObject.SetActive(true);

            GameOverUI.transform.GetChild(0).transform.GetChild(0).transform.GetChild(3).transform.GetChild(1).GetComponent <TextMeshProUGUI> ().text = string.Format("{0} <sprite name=\"icon_carrot\"> {1} <gradient=\"Gradient_green\"><size=75%>EXP</size></gradient>", carrots, actual_reward_exp);

            if (rewards.Count > 0)
            {
                GameOverUI.transform.GetChild(0).transform.GetChild(0).transform.GetChild(4).transform.GetChild(1).gameObject.SetActive(true);
                ScrollSprite  ImgReward   = GameOverUI.transform.GetChild(0).transform.GetChild(0).transform.GetChild(4).transform.GetChild(1).transform.GetChild(1).GetComponent <ScrollSprite> ();
                List <Sprite> listSprites = new List <Sprite> ();
                foreach (var rewardID in rewards)
                {
                    listSprites.Add(ObjectsManager.ObjectsM.GetImageObject(rewardID.Key));
                }
                ImgReward.listSprites = listSprites;
                ImgReward.Start();
            }
            else
            {
                GameOverUI.transform.GetChild(0).transform.GetChild(0).transform.GetChild(4).transform.GetChild(1).gameObject.SetActive(false);
            }

            PrintObjectives(GameOverUI.transform.GetChild(0).transform.GetChild(0).transform.GetChild(4).transform.GetChild(0).transform.GetChild(0).gameObject, true);
        }
        else
        {
            GameOverUI.SetActive(true);
            GameOverUI.transform.GetChild(1).gameObject.SetActive(true);
        }
        ImportantUI.SetActive(true);
        UI_user_normal.SetActive(false);
        ObjectsGameUI.SetActive(false);
    }
Exemple #2
0
    public void LoadMissionsData(int WorldID)

    {
        if (WorldID == 1)
        {
            mission = missionW1;
        }
        else
        {
            mission = missionW2;
        }
        worldID = WorldID;
        if (MissionsCreated == false)
        {
            ScrollMissions.work = false;
            Array.Clear(ScrollMissions.bttn, 0, ScrollMissions.bttn.Length);
            for (int i = 0; i < MissionsList.transform.childCount; i++)
            {
                Destroy(MissionsList.transform.GetChild(i).gameObject);
            }

            Array.Resize(ref ScrollMissions.bttn, mission.Count);
            LastMissionCompleted = 0;
            foreach (MissionID missions in mission)
            {
                GameObject missionPrefab = (GameObject)Instantiate(missionsPrefab, transform.position, Quaternion.identity);
                missionPrefab.transform.SetParent(MissionsList.transform, false);
                // Asignar el prefab de UI de la misión a la lista de Scroll.
                ScrollMissions.bttn [missions.ID - 1] = missionPrefab;
                //Crear gameobject
                missionPrefab.name = missions.ID.ToString();

                missionPrefab.transform.GetChild(2).GetComponent <MissionButton> ().missionID = missions.ID;
                missionPrefab.transform.GetChild(1).transform.GetChild(1).GetComponent <TextMeshProUGUI> ().text = missions.ID.ToString();
                missionPrefab.transform.localScale = new Vector3(1.0f, 1.0f, 0.0f);
                ScrollSprite ImgReward   = missionPrefab.transform.GetChild(0).transform.GetChild(1).GetComponent <ScrollSprite> ();
                bool         isCompleted = false;
                if (UserInfo.UserI.missionsComplete.ContainsKey(WorldID.ToString()))
                {
                    if (UserInfo.UserI.missionsComplete [WorldID.ToString()].Contains(missions.ID))
                    {
                        isCompleted = true;
                    }
                    else
                    {
                        isCompleted = false;
                    }
                }
                else
                {
                    isCompleted = false;
                }

                if (isCompleted)
                {
                    Debug.Log("Mision:" + missions.ID + "- COMPLETADA -");
                    LastMissionCompleted = missions.ID;
                    missionPrefab.transform.GetChild(2).GetComponent <Button> ().interactable = false;
                    missionPrefab.transform.GetChild(2).transform.GetChild(0).GetComponent <TextMeshProUGUI> ().text = "Completada";
                    ImgReward.isChecked = true;
                }
                else
                {
                    if (LastMissionCompleted + 1 != missions.ID)
                    {
                        missionPrefab.transform.GetChild(2).GetComponent <Button> ().interactable = false;
                        missionPrefab.transform.GetChild(2).transform.GetChild(0).GetComponent <TextMeshProUGUI> ().text = "Bloqueada";
                        ImgReward.isChecked = false;
                    }
                    Debug.Log("Mision:" + missions.ID + "- NO COMPLETADA -");

                    if (missions.ID < LastMissionCompleted + 3)
                    {
                        List <Sprite> listSprites = new List <Sprite> ();
                        foreach (var rewardID in missions.rewards)
                        {
                            listSprites.Add(ObjectsManager.ObjectsM.GetImageObject(rewardID.Key));
                        }
                        ImgReward.listSprites = listSprites;
                    }
                }
            }

            for (int i = 0; i < DecorationUI.transform.childCount; i++)
            {
                Destroy(DecorationUI.transform.GetChild(i).gameObject);
            }

            GameObject UIMenuPrefab = (GameObject)Instantiate(WorldManager.WorldM.worlds[WorldID - 1].UIMenu, transform.position, Quaternion.identity);
            UIMenuPrefab.transform.SetParent(DecorationUI.transform, false);
            UIMenuPrefab.transform.localScale = new Vector3(1.0f, 1.0f, 0.0f);

            //Iniciar el sistema de ScrollRect
            ScrollMissions.WorkNow();
            //Iniciar la UI desde el prefab de la última misión
            ScrollMissions.Gotobutton(LastMissionCompleted);

            MissionsCreated = true;
        }
    }