예제 #1
0
    public void Load()
    {
        SaveState            levelState       = new SaveState();
        LevelStatusSaveState levelStatusState = new LevelStatusSaveState();
        SaveManager          sm = new SaveManager();

        levelState = sm.Load(LevelName.text);
        levelStatusState.LevelName = LevelName.text;
        levelStatusState.Load();

        if (levelStatusState.IsLocked)
        {
            Locked.text = "T";
        }
        else
        {
            Locked.text = "F";
        }

        MaxTime.text  = levelState.MaxTime.ToString();
        MaxTries.text = levelState.MaxTries.ToString();

        Coins.text    = levelState.Coins.ToString();
        Diamonds.text = levelState.Diamonds.ToString();

        BestTime.text  = levelStatusState.BestTime.ToString();
        BestTries.text = levelStatusState.BestTries.ToString();
        Stars.text     = levelStatusState.Stars.ToString();
    }
예제 #2
0
    public void SetDetails(string levelname)
    {
        LevelName = levelname;
        var state = new LevelStatusSaveState();

        state.LevelName = levelname;
        state.Load();
        IsLocked = state.IsLocked;
        IsLocked = false;

        var flag = false;

        for (var i = 1; i <= SeasonManager.NumberOfLevelsInSeasons.Count; i++)
        {
            for (var j = 1; j <= SeasonManager.NumberOfLevelsInSeasons[i - 1]; j++)
            {
                if (LevelName == string.Format("level_{0}_{1}_{2}", i.ToString(), j.ToString(), "L"))
                {
                    flag = true;
                    break;
                }
            }

            if (flag)
            {
                break;
            }
        }
        Status.text = IsLocked ? "LOCKED" : LevelName;
    }
예제 #3
0
    public static void GameWon()
    {
        Debug.Log("won the game");
        SaveManager          sm    = new SaveManager();
        LevelStatusSaveState state = new LevelStatusSaveState();

        state.LevelName = string.Format("level_{0}_{1}_" + "s", CurrentLevel.Split('_')[1], (int.Parse(CurrentLevel.Split('_')[2])).ToString());
        state.Load();
        Player.NoOfMoves               = IndexOfCoinsCollected.Count;
        state.IndexOfCoinsCollected    = state.IndexOfCoinsCollected.Union(IndexOfCoinsCollected).ToList();
        state.IndexOfDiamondsCollected = state.IndexOfDiamondsCollected.Union(IndexOfDiamondsCollected).ToList();
        state.Save();

        if (LevelManager.NextLevelPresent)
        {
            state.LevelName = string.Format("level_{0}_{1}_" + "s", CurrentLevel.Split('_')[1], (int.Parse(CurrentLevel.Split('_')[2]) + 1).ToString());
            state.Load();
            state.IsLocked = false;
            state.Save();
        }
        IsGameWon = true;
        IsPlaying = false;
    }
예제 #4
0
    }           // Use this for initialization

    public void SetCardDetails(int cardIndex)
    {
        SeasonIndex             = cardIndex;
        NumberOfLevels          = SeasonManager.NumberOfLevelsInSeasons[cardIndex - 1];
        NumberOfLevelsText.text = string.Format("{0} LEVELS", NumberOfLevels.ToString());
        SeasonNameText.text     = string.Format("SEASON {0}", SeasonIndex.ToString());

        for (int i = 1; i <= NumberOfLevels; i++)
        {
            LevelStatusSaveState state = new LevelStatusSaveState {
                LevelName = string.Format("level_{0}_{1}_{2}", cardIndex.ToString(), i.ToString(), "s")
            };
            Debug.Log(state.LevelName);

            state.Load();

            DiamondsCollected += state.IndexOfDiamondsCollected.Count;
            CoinsCollected    += state.IndexOfCoinsCollected.Count;
        }

        CoinsCollectedText.text    = string.Format("{0} COINS", CoinsCollected.ToString());
        DiamondsCollectedText.text = string.Format("{0} DIAMONDS", DiamondsCollected.ToString());
    }
예제 #5
0
    public int Load()
    {
        PointsCollected = 0;
        LevelStatusSaveState StatusState = new LevelStatusSaveState();

        StatusState.LevelName = string.Format("level_{0}_{1}_s", GameManager.CurrentLevel.Split('_')[1], GameManager.CurrentLevel.Split('_')[2]);
        StatusState.Load();
        GameManager.IndexOfCoinsCollected    = StatusState.IndexOfCoinsCollected;
        GameManager.IndexOfDiamondsCollected = StatusState.IndexOfDiamondsCollected;
        SaveManager.levelName = GameManager.CurrentLevel;
        for (int i = 0; i < Parts.Count; i++)
        {
            Destroy(Parts[i]);
        }
        state      = sm.Load();
        nodes      = new System.Collections.Generic.List <Node>();
        PartsTypes = new System.Collections.Generic.List <PrefabType>();
        Parts      = new System.Collections.Generic.List <GameObject>();
        for (int i = 0; i < state.Node.Count; i++)
        {
            nodes.Add(state.Node[i].ConvertToNode());
        }
        MazeSize              = state.LevelSize;
        MazeOffset            = MazeSize / 2;
        DownStep              = MazeOffset / MazeSize;
        SaveManager.levelSize = state.LevelSize;

        var keyFlag      = false;
        var guardianFlag = false;

        GameObject preKey = new GameObject();

        GameObject tempObj = new GameObject();

        int coinIndex    = 0;
        int diamondIndex = 0;

        for (var i = 0; i < state.Node.Count; i++)
        {
            var startEndFlag = false;
            switch (nodes[i].Type)
            {
            case (PrefabType.Part01):
                tempObj = Instantiate(ListOfParts[0], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                PartsTypes.Add(PrefabType.Part01);
                break;

            case (PrefabType.Part02):
                tempObj = Instantiate(ListOfParts[1], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                PartsTypes.Add(PrefabType.Part02);
                break;

            case (PrefabType.Part03):
                tempObj = Instantiate(ListOfParts[2], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                PartsTypes.Add(PrefabType.Part03);
                break;

            case (PrefabType.Part04):
                tempObj = Instantiate(ListOfParts[3], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                PartsTypes.Add(PrefabType.Part04);
                break;

            case (PrefabType.Part05):
                tempObj = Instantiate(ListOfParts[4], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                PartsTypes.Add(PrefabType.Part05);
                break;

            case PrefabType.Start:
                Debug.Log("here");
                startEndFlag  = true;
                StartPosition = nodes[i].transform;
                CheckPoint.StartPointPosition = StartPosition.localPosition;
                CheckPoint.SetCheckPointTransfrom(StartPosition.localPosition);
                break;

            case PrefabType.End:
                tempObj = Instantiate(ListOfParts[5], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                EndPosition          = nodes[i].transform;
                GameManager.EndState = tempObj;
                break;

            case PrefabType.KeyWall:
                keyFlag = true;
                tempObj = Instantiate(ListOfParts[6], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                preKey = tempObj;
                NoOfGates++;
                break;

            case PrefabType.Coins:
                coinIndex++;
                if (!StatusState.IndexOfCoinsCollected.Contains(coinIndex))
                {
                    tempObj = Instantiate(ListOfParts[7], nodes[i].transform.position, nodes[i].transform.rotation, Maze.transform);
                    tempObj.GetComponent <Points>().Index = coinIndex;
                }
                break;

            case PrefabType.Spike:
                tempObj = Instantiate(ListOfParts[8], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                tempObj.GetComponent <Spikes>().LocalTimerIndex = Spikes.CurrentFlagIndex++;
                Spikes.SpikeInitializeFlag = true;
                break;

            case PrefabType.KeyPortal:
                break;

            case PrefabType.CheckPoint:
                tempObj = Instantiate(ListOfParts[9], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                break;

            case PrefabType.Guardian:
                if (guardianFlag == false)
                {
                    tempObj = Instantiate(ListOfParts[10], nodes[i].transform.position, nodes[i].transform.rotation,
                                          Maze.transform);
                    tempObj.GetComponent <Guardian>().GuardianPath
                    .Add(nodes[i].transform.transform);         // added initial position of the guardian
                }
                else
                {
                    tempObj.GetComponent <Guardian>().GuardianPath.Add(nodes[i].transform.transform);
                }

                guardianFlag = true;

                break;

            case PrefabType.Hammer:
                tempObj = Instantiate(ListOfParts[11], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                break;

            case PrefabType.GoliathWalk:
                tempObj = Instantiate(ListOfParts[12], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                Goliath.PossiblePositions.Add(tempObj.transform);
                break;

            case PrefabType.Goliath:
                tempObj = Instantiate(ListOfParts[13], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                Goliath.InitialPosition = tempObj.transform.localPosition;
                break;

            case PrefabType.GoliathAttackSwitch:
                tempObj = Instantiate(ListOfParts[14], nodes[i].transform.position, nodes[i].transform.rotation,
                                      Maze.transform);
                GoliathAttackSwitch.SwitchLists.Add(tempObj);
                break;

            case PrefabType.Chest:
                var flag = false;
                foreach (var chest in TreasureManager.TreasureListGot.Treasures)
                {
                    if (chest.LevelName == GameManager.CurrentLevel)
                    {
                        Debug.Log("chest is already taken");
                        flag = true;
                        break;
                    }
                }

                if (!flag)
                {
                    tempObj = Instantiate(ListOfParts[15], nodes[i].transform.position, nodes[i].transform.rotation,
                                          Maze.transform);

                    foreach (var chest in TreasureManager.TreasureListAll.Treasures)
                    {
                        if (chest.LevelName == GameManager.CurrentLevel)
                        {
                            Chest.CurrentChest = chest;
                            break;
                        }
                    }
                }

                break;

            case PrefabType.Diamonds:
                diamondIndex++;
                if (!StatusState.IndexOfDiamondsCollected.Contains(diamondIndex))
                {
                    tempObj = Instantiate(ListOfParts[16], nodes[i].transform.position, nodes[i].transform.rotation, Maze.transform);
                    tempObj.GetComponent <Diamond>().Index = diamondIndex;
                }
                break;

            default:
                break;
            }

            if (nodes[i].Type != PrefabType.Guardian)
            {
                guardianFlag = false;
            }
            if (nodes[i].Type != PrefabType.Spike || i == nodes.Count - 1)
            {
                if (Spikes.SpikeInitializeFlag)
                {
                    Spikes.SpikeInitializeFlag = false;
                    for (var j = 1; j < Spikes.CurrentFlagIndex + 1; j++)
                    {
                        Parts[Parts.Count - j].GetComponent <Spikes>().IndexLimit = Spikes.CurrentFlagIndex + 1;
                    }
                }
                Spikes.CurrentFlagIndex = 0;
            }

            if (startEndFlag)
            {
                continue;
            }
            tempObj.GetComponent <Renderer>().material = ListOfMaterials[0];
            Parts.Add(tempObj);

            if (keyFlag && nodes[i].Type != PrefabType.KeyWall)
            {
                keyFlag = false;
                preKey.GetComponentInChildren <Key>().Lock = Parts[Parts.Count - 1];
                Parts[Parts.Count - 1].GetComponent <Renderer>().material = ListOfMaterials[NoOfGates];
                foreach (Transform child in Parts[Parts.Count - 2].transform)
                {
                    child.GetComponent <Renderer>().material = ListOfMaterials[NoOfGates];
                }
            }
        }
        noOfParts = state.Node.Count;
        maze_body.transform.localScale = new Vector3(SaveManager.levelSize, SaveManager.levelSize, SaveManager.levelSize);
        mainCamera.orthographicSize    = SaveManager.levelSize + 7;
        transform.position             = StartPosition.localPosition;
        transform.eulerAngles          = Vector3.zero;
        destination = transform.position;
        return(1);
    }