Ejemplo n.º 1
0
    public void clickOnCountry(Country countryClicked)
    {
        switch (currentPhase)
        {
        case GameConstants.Phase.Start:
            GameConstants.ClearConsole();
            if (!currentPlayer.droppedArmy && currentPlayer.isTurn && unitsDropped < startingUnits)      //¿Dropeo army?
            {
                Debug.Log("- Hay que dorpear army. " + currentPlayer.playerName);
                if (maxCountries > unitsDropped)      //¿Hay algún país vacío?
                {
                    Debug.Log("- Hay países vacíos. maxCountries: " + maxCountries);
                    if (countryClicked.army.units == 0)      //Si se hace click sobre un país vacío
                    {
                        currentPlayer.currentUnits -= 1;
                        countryClicked.army.units  += 1;
                        Debug.Log("- countryClicked.army.units: " + countryClicked.army.units);
                        countryClicked.army.gameObject.SetActive(true);
                        countryClicked.army.GetComponent <SpriteRenderer>().sprite = currentPlayer.meeple;
                        countryClicked.owner      = currentPlayer;
                        currentPlayer.droppedArmy = true;
                        unitsDropped += 1;
                        changeTurn();
                    }
                }
                else
                {
                    Debug.Log("No hay paises vacíos");
                    if (countryClicked.owner == currentPlayer && currentPlayer.currentUnits > 0)
                    {
                        Debug.Log("- Hay que dropear en el propio país");
                        currentPlayer.currentUnits -= 1;
                        countryClicked.army.units  += 1;
                        Debug.Log("countryClicked.army.units: " + countryClicked.army.units);
                        countryClicked.army.textUnits.text = "x" + countryClicked.army.units.ToString();
                        unitsDropped += 1;
                        currentPlayer.droppedArmy = true;
                        changeTurn();
                    }
                    else if (countryClicked.owner != currentPlayer)
                    {
                        Debug.Log("- Hay que dropear en OTRO país");
                    }
                    else
                    {
                        //FIN DE FASE
                        Debug.Log("SACABO LA FASE INICIAL - Todos los países están ocupados");
                        changePhase();
                    }
                }
            }
            else         //Poner a parpadear el botoncico de next player
            {
                Debug.Log("//Hay que activar el botón de cambio de turno");
                //StartCoroutine(nextPlayerButton.GetComponent<InAndOut>().ZoomInOut());
                //De momento cambio automático de turno
                //changeTurn();
            }
            countryClicked = null;
            break;

        case GameConstants.Phase.Combat:
            phaseText.text = "Combate";
            cartelMaderaFase.GetComponent <SpriteRenderer>().sprite = GameConstants.IMG2Sprite.LoadNewSprite("F:/UnityRepository/riskrepository/Assets/Resources/Pics/cartelmaderafase.combate.png");
            countryClicked.GetComponent <SpriteRenderer>().color    = GameConstants.ConvertColor(255, 0, 255, 1);
            Debug.Log("FASE DE COMBATE. SELECCIONAR DEFENSOR");
            break;

        case GameConstants.Phase.Relocate:
            phaseText.text = "Ubicación";
            Debug.Log("FASE DE REUBICACIÓN. SELECCIONAR 2 CIUDADES CONECTADAS ENTRE SÍ");
            break;

        case GameConstants.Phase.Reinforcement:
            phaseText.text = "Combate";
            Debug.Log("FASE DE REFUERZOS.");
            break;
        }
    }