Пример #1
0
 public static void GameDataInput(GameObject mainCamera, ActiveCharacterScript newCurrentCharacters, GameObject newPlayer, DayNightLight newDirLight, CarnetGoal newGoalFrame, StickersGivenToPNJ newStickerManager, Transform newBoardCanvas)
 {
     camObject         = mainCamera;
     currentCharacters = newCurrentCharacters;
     actualPlayer      = newPlayer;
     directionalLight  = newDirLight;
     goalFrame         = newGoalFrame;
     stickerManager    = newStickerManager;
     boardTransform    = newBoardCanvas;
 }
Пример #2
0
    public GameData(GameObject mainCamera, ActiveCharacterScript currentCharacters, GameObject characterToPlay, DayNightLight directionalLight, CarnetGoal goalsObject, StickersGivenToPNJ newStrickerManager, Transform BoardTransform)
    {
        currentLevel = SceneManager.GetActiveScene().name;

        if (mainCamera != null && currentCharacters != null)
        {
            actualRoomName = mainCamera.GetComponent <CameraFollow>().actualRoom.name;
            camPosition    = mainCamera.transform.position;

            for (int i = 0; i < currentCharacters.playableCharactersList.Count; i++)
            {
                playableCharacters.Add(new CharacterPosition(currentCharacters.playableCharactersList[i].character));
            }
        }

        if (characterToPlay != null)
        {
            //stickersIndexOnBoard = characterToPlay.GetComponent<PlayerMemory>().stickerIndexBoardList;
            //stickersIndexInCarnet = characterToPlay.GetComponent<PlayerMemory>().stickerIndexCarnetList;
            allStickers = characterToPlay.GetComponent <PlayerMemory>().allStickers;
            NPCmet      = characterToPlay.GetComponent <Interactions>().PnjMet;
            eventList   = characterToPlay.GetComponent <EventsCheck>().eventsList;
        }

        if (BoardTransform != null)
        {
            foreach (Transform childTransform in BoardTransform)
            {
                if (childTransform.GetComponent <Sticker_Display>())
                {
                    stickersOnBoard.Add(new StickersOnBoard(childTransform.GetComponent <Sticker_Display>().sticker.index,
                                                            childTransform.GetComponent <Sticker_Display>().sticker.type,
                                                            childTransform.localPosition));
                }
            }
        }

        if (directionalLight.time == DayNightLight.timeEnum.Day)
        {
            dayNightCycle = true;
        }
        else
        {
            dayNightCycle = false;
        }

        if (goalsObject != null)
        {
            goalsInProgress = goalsObject.goalList;
            goalsComplete   = goalsObject.removeGoalList;
        }

        if (newStrickerManager != null)
        {
            pnjStickerManager = newStrickerManager.PnjsInGame;
        }
    }
Пример #3
0
 void Awake()
 {
     SGTP = this;
 }
Пример #4
0
    public void ReturnGameData(GameData gameSave)
    {
        for (int i = 0; i < gameSave.playableCharacters.Count; i++)
        {
            GameObject[] playableCharacterInScene = GameObject.FindGameObjectsWithTag("Player");

            if (playableCharacterInScene != null)
            {
                foreach (GameObject character in playableCharacterInScene)
                {
                    if (gameSave.playableCharacters[i].characterName == character.name)
                    {
                        //if (i == 0)
                        //{
                        //    FindObjectOfType<ActiveCharacterScript>().playableCharactersList.Clear();

                        //}

                        character.transform.position = gameSave.playableCharacters[i].characterPosition;
                        //FindObjectOfType<ActiveCharacterScript>().playableCharactersList.Add(new ActiveCharacterScript.PlayableCharacter(character, true));
                    }
                }
            }
        }

        GameObject savedRoom = null;

        for (int i = 0; i < roomList.Count; i++)
        {
            if (roomList[i].name == gameSave.actualRoomName)
            {
                savedRoom = roomList[i];
            }
        }

        GameObject KPlayer = null;

        foreach (EventsCheck actualPlayer in FindObjectsOfType <EventsCheck>())
        {
            if (actualPlayer.gameObject.name == "Kenneth")
            {
                KPlayer = actualPlayer.gameObject;
            }
        }

        if (!savedRoom.activeInHierarchy)
        {
            CameraFollow gameCam = FindObjectOfType <CameraFollow>();
            gameCam.actualRoom.SetActive(false);
            gameCam.actualRoom = savedRoom;
            gameCam.actualRoom.SetActive(true);
            gameCam.transform.position = gameSave.camPosition;
            gameCam.InitRoomLimit();
            gameCam.YOffset = gameCam.actualRoom.GetComponent <SceneInformations>().YOffset;
            StartCoroutine(ShowSceneNameAtLoad(gameCam.actualRoom));
            //gameCam.actualRoom.GetComponent<SceneInformations>().PlaceCamera();
        }

        Transform BoardCanvas = default;

        foreach (CanvasManager.CharactersInterfaces CI in GameObject.FindObjectOfType <CanvasManager>().charactersInterfaces)
        {
            if (CI.CharcterName == FindObjectOfType <ActiveCharacterScript>().actualCharacter.name)
            {
                foreach (CanvasManager.CanvasInfos CanI in CI.CanvasList)
                {
                    if (CanI.CanvasName == "Board_FIX")
                    {
                        BoardCanvas = CanI.CanvasGO.transform;
                    }
                }
            }
        }



        GameObject levelLight = FindObjectOfType <DayNightLight>().gameObject;

        if (levelLight != null)
        {
            if (gameSave.dayNightCycle)
            {
                levelLight.GetComponent <DayNightLight>().DayTime();
                levelLight.GetComponent <Light>().intensity = savedRoom.GetComponent <SceneInformations>().dayLightValue;
            }
            else
            {
                levelLight.GetComponent <DayNightLight>().NightTime();
                levelLight.GetComponent <Light>().intensity = savedRoom.GetComponent <SceneInformations>().nightLightValue;
            }
        }

        GameObject player = null;

        foreach (Interactions Charac in FindObjectsOfType <Interactions>())
        {
            if (Charac.gameObject.name == "Kenneth")
            {
                player = Charac.gameObject;
            }
        }
        if (player != null)
        {
            foreach (int index in gameSave.allStickers)
            {
                if (!player.GetComponent <PlayerMemory>().stickerIndexBoardList.Contains(index))
                {
                    player.GetComponent <PlayerMemory>().stickerIndexBoardList.Add(index);
                }
                if (!player.GetComponent <PlayerMemory>().stickerIndexCarnetList.Contains(index))
                {
                    player.GetComponent <PlayerMemory>().stickerIndexCarnetList.Add(index);
                }
                if (!player.GetComponent <PlayerMemory>().allStickers.Contains(index))
                {
                    player.GetComponent <PlayerMemory>().allStickers.Add(index);
                }
            }

            player.GetComponent <Interactions>().PnjMet    = gameSave.NPCmet;
            player.GetComponent <EventsCheck>().eventsList = gameSave.eventList;
        }

        if (FindObjectOfType <TutoKenneth>() != null)
        {
            FindObjectOfType <TutoKenneth>().skipTuto();
            FindObjectOfType <TutoKenneth>().canSave = true;
        }

        CarnetGoal gameGoals = GameObject.FindObjectOfType <Ken_Canvas_Infos>().transform.Find("Panel").Find("Carnet").Find("Goal").Find("GoalFrame").GetComponent <CarnetGoal>();

        if (gameGoals != null)
        {
            gameGoals.goalList       = gameSave.goalsInProgress;
            gameGoals.removeGoalList = gameSave.goalsComplete;

            //foreach (GoalKeys goal in gameSave.goalsInProgress)
            //{
            //    gameGoals.NewGoal(goal);
            //}
            //foreach (GoalKeys goal in gameSave.goalsComplete)
            //{
            //    gameGoals.RemoveGoal(goal);
            //}
        }

        StickersGivenToPNJ actualStickersManager = GameObject.FindObjectOfType <StickersGivenToPNJ>();

        if (actualStickersManager != null)
        {
            actualStickersManager.PnjsInGame = gameSave.pnjStickerManager;
        }
    }