public void ContinueToNextLevel()
    {
        int currentLevel = MemoryCard.GetSelectedLevel();

        MemoryCard.SetSelectedLevel(currentLevel + 1);
        Loading.This.TransiteTo("SampleScene");
    }
Exemple #2
0
 private void ResetPlayer()
 {
     for (int i = 0; i < LevelManager.beginBlocks.Count; i++)
     {
         var p = MapBuilder.LoadMap(MemoryCard.GetSelectedLevel()).initialPosition[i];
         LevelManager.beginBlocks[i].player.SetPosition((int)p.x, (int)p.y);
         LevelManager.beginBlocks[i].player.SetLook(0, -1);
         LevelManager.beginBlocks[i].player.transform.GetChild(2).GetComponent <PlayerErrorMessage>().HideError();
     }
 }
Exemple #3
0
    private void Start()
    {
        FindObjectOfType <BlockFitter>().UpdateSize();
        me = this;
        var level = GetCurrentLevelData();

        if (level.tutorial.Count > 0)
        {
            FindObjectOfType <TutorialPanel>().OpenTutorial(level.tutorial);
        }
        CreatePlayer();
        FindObjectOfType <BlockPanel>().Create(level);
        mapBuilder.BuildMap();
        transform.position = (Vector3)levels.levels[MemoryCard.GetSelectedLevel()].cameraInitialPosition - Vector3.forward * 10;
    }
    public void CreateTreasures()
    {
        LevelMap levelMap = LoadMap(MemoryCard.GetSelectedLevel());

        foreach (var pos in levelMap.treasures)
        {
            var smallT = Instantiate(smallTreasure, treasureRoot);
            smallT.transform.position = new Vector3(pos.x, pos.y, 0) * Globals.TILE_SIZE + new Vector3(0.5f, 0.5f, 0f);
            smallT.GetComponent <Treasure>().GetPosition();
        }
        foreach (var pos in levelMap.bigTreasures)
        {
            var bigT = Instantiate(bigTreasure, treasureRoot);
            bigT.transform.position = new Vector3(pos.x, pos.y, 0) * Globals.TILE_SIZE + new Vector3(0.5f, 0.5f, 0f);
            bigT.GetComponent <Treasure>().GetPosition();
        }
    }
Exemple #5
0
    public void OpenPanel(TreasureInfo info, int steps)
    {
        CameraMovement.canBeMoved++;
        group.DOFade(1, 0.5f);
        group.interactable   = true;
        group.blocksRaycasts = true;
        panel.DOAnchorPosY(-680, 0);
        panel.DOAnchorPosY(40, 0.5f);

        var level = LevelManager.me.levels.levels[MemoryCard.GetSelectedLevel()];

        bigTreasure.text    = "<color=red>" + info.bigTreasures.Count + "</color> de " + level.map.bigTreasures.Count;
        smallTreasures.text = "<color=red>" + info.littleTreasures.Count + "</color> de " + level.map.treasures.Count;
        this.steps.text     = "<color=red>" + steps + "</color> de " + level.maxSteps;

        SaveProgress(info, steps);
    }
Exemple #6
0
    private void CreatePlayer()
    {
        beginBlocks = new List <BeginBlock>();
        LevelMap level = MapBuilder.LoadMap(MemoryCard.GetSelectedLevel());

        for (int i = 0; i < level.initialPosition.Count; i++)
        {
            var p = Instantiate(player).GetComponent <Player>();
            p.SetLook(0, -1);
            p.SetPosition((int)level.initialPosition[i].x, (int)level.initialPosition[i].y);
            p.SetColor(playerColors[i]);
            var b = Instantiate(beginBlock, beginBlockRoot).GetComponent <BeginBlock>();
            b.player = p;
            b.SetColor(playerColors[i]);
            beginBlocks.Add(b);
        }
    }
    public void BuildMap()
    {
        Clear();
        ObstacleMap.ResetMap();
        LevelMap levelMap = LoadMap(MemoryCard.GetSelectedLevel());

        DrawFloor(groundTile, levelMap.ground);
        DrawFloor(waterTile, levelMap.borders);
        CreateObstacle(horizontalBarrel, levelMap.horizonalBarrel);
        CreateObstacle(verticalBarrel, levelMap.verticalBarrel);
        CreateObstacle(woodenBox, levelMap.woodenBox);
        CreateObstacle(pointyRocks, levelMap.pointyRocks);
        CreateObstacle(verticalRaft, levelMap.verticalRaft);
        CreateObstacle(horizontalRaft, levelMap.horizontalRaft);
        CreateCannon(levelMap.upCannon, CannonType.UP);
        CreateCannon(levelMap.downCannon, CannonType.DOWN);
        CreateCannon(levelMap.leftCannon, CannonType.LEFT);
        CreateCannon(levelMap.rightCannon, CannonType.RIGHT);
        CreateTreasures();
    }
    public IEnumerator OpenPanel(TreasureInfo info, int steps)
    {
        CameraMovement.canBeMoved++;

        header.transform.DOScale(0, 0);
        stepPanel.Hide();
        diamondPanel.Hide();

        foreach (var button in buttons)
        {
            button.GetComponent <RectTransform>().DOAnchorPosY(-buttonsY, 0);
        }

        group.DOFade(1, 0.5f);
        group.interactable   = true;
        group.blocksRaycasts = true;

        yield return(new WaitForSeconds(0.5f));

        header.transform.DOScale(1f, 0.5f);

        var level = LevelManager.me.levels.levels[MemoryCard.GetSelectedLevel()];

        yield return(diamondPanel.Appear(info.littleTreasures.Count, level.map.treasures.Count));

        yield return(stepPanel.Appear(steps, level.maxSteps));

        SaveProgress(info, steps);

        bool thereIsANextLevel = MemoryCard.Load().levels.Count - 1 > MemoryCard.GetSelectedLevel();

        foreach (var button in buttons)
        {
            if (!(button == nextLevel && thereIsANextLevel))
            {
                button.GetComponent <RectTransform>().DOAnchorPosY(buttonsY, 0.1f);
                yield return(new WaitForSeconds(0.1f));
            }
        }
    }
    public void SaveProgress(TreasureInfo info, int steps)
    {
        var memory = MemoryCard.Load();

        if (memory.levels[MemoryCard.GetSelectedLevel()].bigTreasures == 0)
        {
            // Desbloquear nova fase
            memory.levels.Add(new LevelProgress());
        }

        memory.levels[MemoryCard.GetSelectedLevel()].steps =
            steps < memory.levels[MemoryCard.GetSelectedLevel()].steps ?
            steps : memory.levels[MemoryCard.GetSelectedLevel()].steps;

        memory.levels[MemoryCard.GetSelectedLevel()].treasures =
            info.littleTreasures.Count > memory.levels[MemoryCard.GetSelectedLevel()].treasures ?
            info.littleTreasures.Count : memory.levels[MemoryCard.GetSelectedLevel()].treasures;

        memory.levels[MemoryCard.GetSelectedLevel()].bigTreasures =
            info.bigTreasures.Count > memory.levels[MemoryCard.GetSelectedLevel()].bigTreasures ?
            info.bigTreasures.Count : memory.levels[MemoryCard.GetSelectedLevel()].bigTreasures;

        memory.Save();
    }