Esempio n. 1
0
    void Start()
    {
        inputController = Camera.main.GetComponent <TutorialInputController>();
        uiController    = Camera.main.GetComponent <TutorialUIController>();
        soundController = gameObject.GetComponent <SoundController>();
        camController   = Camera.main.GetComponent <CameraController>();

        TileFactory.tileMaterial = tileMaterial;
        matrix = new Matrix(MapParser.ReadMap("Maps/tutorial"));
        MapDrawer.instantiateMap(matrix.getIterable());
        players = new List <Player> ();
        players.Add(new Player("Jugador", StatsFactory.GetStat(SlimeCoreTypes.SLOTH)));         // Test with 2 players
        //players.Add(new Player("IA Tutorial", 1, StatsFactory.GetStat(SlimeCoreTypes.SLOTH))); // Test with 2 players
        players[0].SetColor(new Color(1, 1, 1));
        //players[1].SetColor(new Color(1,0,1));
        playerSlime = SlimeFactory.instantiateSlime(players[0], new Vector2(0f, -2f));
        //SlimeFactory.instantiateSlime(players[1], new Vector2(0f,2f));
        status        = GameControllerStatus.WAITINGFORACTION;
        currentPlayer = players [0];
        uiController.UpdateRound(currentTurn + 1);
        uiController.UpdatePlayer(GetCurrentPlayer().GetColor());
        uiController.UpdateActions(playerActions, GetCurrentPlayer().actions);
        uiController.ShowBothPanels();

        InitDialogChains();
        InitMarker();
        marker.SetParentTransform(playerSlime.transform);
        marker.SetMarkerRelativeSize();
        marker.SetActive(false);
        FloatingTextController.Initialize();
    }
Esempio n. 2
0
 private void SplitSlime(Tile targetTile)
 {
     if (selectedSlime.canSplit)
     {
         Slime newSlime = SlimeFactory.instantiateSlime(selectedSlime.GetPlayer(), new Vector2(targetTile.GetTileData().getPosition().x, targetTile.GetTileData().getPosition().y));
         newSlime.InitMass();             //posem vida a 0, i a la seguent linia li posem la vida real, d'aquesta manera es veu el popup amb '+'
         newSlime.SetMass((int)(selectedSlime.GetMass() / 2.0f), true);
         selectedSlime.SetMass((int)(selectedSlime.GetMass() / 2.0f), true);
         newSlime.ChangeElement(selectedSlime.GetElementType());
         playerActions++;
         status = GameControllerStatus.CHECKINGLOGIC;
     }
 }
Esempio n. 3
0
    public void tutorialFSMCheck()
    {
        List <String> texts = new List <String>();

        switch (tutorialStatus)
        {
        case TutorialFSMStatus.SELECTSLIME:
            chainTextDialog.Hide();
            texts.Add("¿Has visto que ha aparecido alrededor?\nEsas son las casillas por las que tu slime se puede mover en una acción");
            texts.Add("Prueba a moverte aquí");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
                inputController.SetActiveInput(true);
                marker.SetActive(true);
                marker.SetParentTransform(MapDrawer.GetTileAt(-1, -3).transform);
            });
            inputController.SetActiveInput(false);
            inputController.SetActiveMove(true);
            tutorialStatus = TutorialFSMStatus.MOVEFIRSTSLIME;
            break;

        case TutorialFSMStatus.MOVEFIRSTSLIME:
            texts.Add("Muy bien.\nAhora vuelve a donde estabas");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
            });
            inputController.SetActiveInput(true);
            inputController.SetActiveMove(true);
            marker.SetActive(true);
            marker.SetParentTransform(MapDrawer.GetTileAt(0, -2).transform);
            tutorialStatus = TutorialFSMStatus.RETURNSLIME;
            break;

        case TutorialFSMStatus.RETURNSLIME:
            texts.Add("Perfecto");
            texts.Add("¿Sabias que los slimes pueden hacer muchas mas cosas además de moverse?");
            texts.Add("Ya verás, si mantienes pulsado el slime verás que se marcan alrededor unas casillas.\nPrueba a arrastrar y soltar encima de esas casillas a ver que pasa");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
                inputController.SetActiveInput(true);
                marker.SetActive(true);
                marker.SetParentTransform(MapDrawer.GetTileAt(0, -1).transform);
            });
            inputController.SetActiveInput(false);
            inputController.SetActiveMove(false);
            inputController.SetActiveSplit(true);
            marker.SetActive(false);
            tutorialStatus = TutorialFSMStatus.SPLITSLIME;
            break;

        case TutorialFSMStatus.SPLITSLIME:
            texts.Add("Wow, se han separado");
            texts.Add("Como has conseguido separarte puedes ovservar que la cantidad de acciones que puedes hacer en un turno ha aumentado");
            texts.Add("Mueve el nuevo slime aquí");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
                inputController.SetActiveInput(true);
                marker.SetActive(true);
                marker.SetParentTransform(MapDrawer.GetTileAt(1, -2).transform);
            });
            inputController.SetActiveSplit(false);
            inputController.SetActiveInput(false);
            inputController.SetActiveMove(true);
            tutorialStatus = TutorialFSMStatus.MOVESECONDARYSLIME;
            break;

        case TutorialFSMStatus.MOVESECONDARYSLIME:
            texts.Add("Para juntar tu slime, has de hacer lo mismo que para separarlo pero sobre el slime nuevo");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
                inputController.SetActiveInput(true);
                inputController.SetActiveJoin(true);
                marker.SetActive(true);
                marker.SetParentTransform(MapDrawer.GetTileAt(1, -2).transform);
            });
            tutorialStatus = TutorialFSMStatus.JOINSLIME;
            break;

        case TutorialFSMStatus.JOINSLIME:
            texts.Add("¡Cuidado! Un slime enemigo ha aparecido, prueba a atacarle");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
                inputController.SetActiveAttack(true);
                inputController.SetActiveInput(true);
                marker.SetActive(true);
                marker.SetParentTransform(MapDrawer.GetTileAt(0, 0).transform);
            });
            Player p = new Player("Sida", StatsFactory.GetStat(SlimeCoreTypes.INNOCENCE));
            p.SetColor(new Color(1, 0, 0));
            SlimeFactory.instantiateSlime(p, 0, 0);
            inputController.SetActiveJoin(false);
            inputController.SetActiveInput(false);
            marker.SetActive(false);
            inputController.SetActiveInput(false);
            tutorialStatus = TutorialFSMStatus.ATTACKSLIME;
            break;

        case TutorialFSMStatus.ATTACKSLIME:
            texts.Add("¿Por que no conviertes conquistas una casilla y te curas?");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
                inputController.SetActiveMove(true);
                inputController.SetActiveInput(true);
                marker.SetActive(true);
                marker.SetParentTransform(MapDrawer.GetTileAt(-1, -1).transform);
            });
            inputController.SetActiveJoin(false);
            inputController.SetActiveInput(false);
            inputController.SetActiveMove(false);
            marker.SetActive(false);
            tutorialStatus = TutorialFSMStatus.MOVETOCONQUER;
            break;

        case TutorialFSMStatus.MOVETOCONQUER:
            texts.Add("Ahora selecciona tu slime y vuelve a hacer click en el");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
                inputController.SetActiveConquer(true);
                inputController.SetActiveInput(true);
                marker.SetActive(true);
                marker.SetParentTransform(MapDrawer.GetTileAt(-1, -1).transform);
            });
            inputController.SetActiveInput(false);
            inputController.SetActiveConquer(false);
            inputController.SetActiveMove(false);
            marker.SetActive(false);
            tutorialStatus = TutorialFSMStatus.CONQUERTILE;
            break;

        case TutorialFSMStatus.CONQUERTILE:
            texts.Add("Vuelve a tocar la casilla conquistada para curarte");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
                inputController.SetActiveEat(true);
                inputController.SetActiveConquer(true);
                inputController.SetActiveInput(true);
                marker.SetActive(true);
                marker.SetParentTransform(MapDrawer.GetTileAt(-1, -1).transform);
            });
            inputController.SetActiveInput(false);
            inputController.SetActiveEat(false);
            inputController.SetActiveConquer(false);
            marker.SetActive(false);
            tutorialStatus = TutorialFSMStatus.ATTACKWITHFIRE;
            break;

        case TutorialFSMStatus.ATTACKWITHFIRE:
            texts.Add("Te has curado");
            texts.Add("Ahora ya conoces las bases de SLIMERS");
            texts.Add("Explora los diferentes retos para descubrir sus verdaderos límites, si es que los tienen");
            chainTextDialog.SetTextList(texts);
            chainTextDialog.Show();
            chainTextDialog.SetOnClickFunction(() => {
                SceneManager.LoadScene(0);
            });
            inputController.SetActiveInput(false);
            inputController.SetActiveEat(false);
            inputController.SetActiveConquer(false);
            marker.SetActive(false);
            break;
        }
    }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        /*
         * TipDialog a = new TipDialog ();
         * a.SetButtonImage(SpritesLoader.GetInstance ().GetResource ("Buttons/button_template"));
         * a.SetBackgroundImage(SpritesLoader.GetInstance ().GetResource ("Panels/emergent"));
         * a.SetInfoTextText ("Has aceptado");
         * a.Hide ();
         * TwoOptionsDialog t = new TwoOptionsDialog();
         * t.SetButtonsImage(SpritesLoader.GetInstance ().GetResource ("Buttons/button_template"));
         * t.SetBackgroundImage(SpritesLoader.GetInstance ().GetResource ("Panels/emergent"));
         * t.SetAceptButtonColor (new Color(0f,0f,1f));
         * t.SetDeclineButtonColor (new Color(1f,0f,0f));
         * t.SetOnClickAceptFunction(()=>{
         *      a.Show();
         * });
         */

        /*
         *      Time.timeScale = 1;
         *      ChainTextDialog ctd = new ChainTextDialog ();
         *      ctd.SetButtonImage(SpritesLoader.GetInstance ().GetResource ("Buttons/button_template"));
         *      ctd.SetBackgroundImage(SpritesLoader.GetInstance ().GetResource ("Panels/emergent"));
         */

        TileFactory.tileMaterial = tileMaterial;
        //InGameMarker igm = new InGameMarker ();
        //igm.SetSprite (SpritesLoader.GetInstance().GetResource("Test/testTileSlim"));
        FloatingTextController.Initialize();
        uiController    = Camera.main.GetComponent <UIController>();
        soundController = gameObject.GetComponent <SoundController>();
        camController   = Camera.main.GetComponent <CameraController>();
        conquerSprite   = SpritesLoader.GetInstance().GetResource("Tiles/conquest_flag");
        //panelTip = GameObject.Find("PanelTip"); //ja tenim el panell, per si el necessitem activar, i desactivar amb : panelTip.GetComponent<DialogInfo> ().Active (boolean);
        //textTip = GameObject.Find("TextTip"); //ja tenim el textBox, per canviar el text : textTip.GetComponent<Text> ().text = "Text nou";
        //panelTip.GetComponent<DialogInfo>().Active(false);
        //textTip.GetComponent<Text>().text = "Aquí es mostraran els diferents trucs que pot fer el jugador";
        players        = new List <Player>();
        Time.timeScale = 1f;
        if (ModosVictoria.IsDefined(typeof(ModosVictoria), GameSelection.modoVictoria))
        {
            condicionVictoria = (ModosVictoria)GameSelection.modoVictoria;
        }
        else
        {
            condicionVictoria = ModosVictoria.ASESINATO; //por defecto
        }

        MAX_TURNS = GameSelection.MAX_TURNS;

        int maxPlayers = GameSelection.playerColors.Count;

        if (maxPlayers == 0)
        {
            GameSelection.playerColors.Add(new Color(0, 0, 1));
            GameSelection.playerColors.Add(new Color(1, 0, 0));
            GameSelection.playerCores.Add(SlimeCoreTypes.SLOTH);
            GameSelection.playerCores.Add(SlimeCoreTypes.WRATH);
            GameSelection.playerIAs.Add(false);
            GameSelection.playerIAs.Add(true);
            maxPlayers = 2;
        }
        for (int i = 0; i < maxPlayers; i++)
        {
            if (GameSelection.playerIAs [i])
            {
                //players.Add(new Player("Jugador "+(i+1),StatsFactory.GetStat(GameSelection.playerCores[i])));
                Debug.Log("Ia true");
                players.Add(new Player("Jugador " + (i + 1), StatsFactory.GetStat(GameSelection.playerCores[i]), AIManager.GetAIByVictoryCondition(this, condicionVictoria)));
            }
            else
            {
                players.Add(new Player("Jugador " + (i + 1), StatsFactory.GetStat(GameSelection.playerCores[i])));
            }
            players[i].SetColor(GameSelection.playerColors[i]);
        }
        matrix = GameSelection.map;//new Matrix(11, 0.3f, 1234567);
        if (matrix == null)
        {
            matrix = new Matrix(5 * players.Count, 0.3f, Random.Range(0, 10000));
        }
        MapDrawer.instantiateMap(matrix.getIterable());
        int numSlimesPerPlayer           = 2;
        List <List <Vector2> > positions = matrix.GetPositions(players.Count, numSlimesPerPlayer);
        int j = 0;

        foreach (Player player in players)
        {
            List <Vector2> positionsSlimes = positions[j];
            foreach (Vector2 positionSlime in positionsSlimes)
            {
                SlimeFactory.instantiateSlime(player, positionSlime);
            }
            j++;
        }
        if (players.Count == 0)
        {
            players.Add(new Player("Jugador 1", StatsFactory.GetStat(SlimeCoreTypes.WRATH), AIManager.GetAIByVictoryCondition(this, condicionVictoria)));            // Test with 2 players
            players.Add(new Player("Jugador 2", StatsFactory.GetStat(SlimeCoreTypes.GLUTTONY)));
            players[0].SetColor(Color.blue);
            players[1].SetColor(Color.red);
            positions = matrix.GetPositions(players.Count, 1);
            SlimeFactory.instantiateSlime(players[0], positions[0][0]);
            SlimeFactory.instantiateSlime(players[1], positions[1][0]);
        }
        //matrix = new Matrix(MapParser.ReadMap(MapTypes.Medium));

        currentTurn   = 0;
        currentPlayer = players[0];
        playerActions = 0;

        uiController.UpdateRound(currentTurn + 1);
        uiController.UpdatePlayer(GetCurrentPlayer().GetColor());

        uiController.UpdateActions(playerActions, GetCurrentPlayer().actions);
        uiController.ShowBothPanels();
        //iniciem la informacio de game over
        totalTiles = matrix.TotalNumTiles();
        //Debug.Log("TILES TOTALS: "+ totalTiles);

        // La condicio de victoria s'assigna mes amunt, aqui nomes s'actualitzen els requisits.
        switch (condicionVictoria)
        {
        case ModosVictoria.CONQUISTA:
            //define percentage tiles to win
            if (MAX_TURNS == 0)
            {
                percentageTilesToWin = 0.25f;
            }
            else
            {
                percentageTilesToWin = 0.75f;
            }

            //Debug.Log("Porcentaje de conquista para ganar: "+percentageTilesToWin);
            break;

        case ModosVictoria.MASA:
            //define mass to win
            massToWin = 0;
            foreach (Player player in players)
            {
                if (player.GetTotalMass() > massToWin)
                {
                    massToWin = player.GetTotalMass();
                }
            }
            massToWin *= 2;
            //Debug.Log("Masa total del jugador para ganar: "+massToWin);
            break;
        }

        GameOverInfo.Init();
        AudioClip clip = SoundsLoader.GetInstance().GetResource("Sounds/MainGameTheme");

        soundController.PlayLoop(clip);
        camController.InitMaxZoom();


        status = GameControllerStatus.CHECKINGLOGIC;
    }