Example #1
0
    public void CompraUnidades()
    {
        //Random rnd = new Random();
        int seleccionRandom = Random.Range(0, 5);

        switch (seleccionRandom)
        {
        default:
            Debug.Log("Se decide no comprar nada");
            SiguienteUnidad();
            return;

        case 1:     //Se selecciona al caballero
            Debug.Log("Trata de comprar un caballero");
            creaPersonajes.BuyUnit(caballero);
            break;

        case 2:     //Se selecciona al arquero
            Debug.Log("Trata de comprar un arquero");
            creaPersonajes.BuyUnit(arquero);
            break;

        case 3:     //Se selecciona al dragón
            Debug.Log("Trata de comprar un dragón");
            creaPersonajes.BuyUnit(dragon);
            break;

        case 4:     //Se selecciona la aldea
            Debug.Log("Trata de comprar una aldea");
            creaPersonajes.BuyVillage(aldea);
            break;
        }
    }
Example #2
0
    private void f_Buy_Unit(bool random)
    {
        if (random)
        {
            int r = UnityEngine.Random.Range(0, 3);
            switch (r)
            {
            case 0:
                _ch_Craeation.BuyUnit(_blue_knight);
                break;

            case 1:
                _ch_Craeation.BuyUnit(_blue_archer);
                break;

            case 2:
                _ch_Craeation.BuyUnit(_blue_bat);
                break;

            default:
                break;
            }
        }
        else
        {
            if (player2Gold < 100)
            {
                if (player2Gold >= 80)
                {
                    _ch_Craeation.BuyUnit(_blue_bat);
                }
                else if (player2Gold >= 70)
                {
                    _ch_Craeation.BuyUnit(_blue_archer);
                }
                else
                {
                    _ch_Craeation.BuyUnit(_blue_knight);
                }
            }
            else
            {
                if (player2Gold >= 400)
                {
                    _ch_Craeation.BuyUnit(_blue_bat);
                }
                else if (player2Gold >= 300)
                {
                    _ch_Craeation.BuyUnit(_blue_archer);
                }
                else if (player2Gold >= 200)
                {
                    _ch_Craeation.BuyUnit(_blue_knight);
                }
            }
        }

        Tile spawn_tile = null;

        if (_state.Equals("Normal")) //Spawn unit in a random tile
        {
            Tile[] tiles = _ch_Craeation._tiles_to_place_things.ToArray();
            spawn_tile = tiles[UnityEngine.Random.Range(0, tiles.Length)];
        }
        else
        {
            foreach (Tile t in _ch_Craeation._tiles_to_place_things)
            {
                if (_state.Equals("Attack"))                                                                                                                                                                //Spawn units near the enemy base
                {
                    if (spawn_tile == null || Vector2.Distance(_player_house.transform.position, t.transform.position) < Vector2.Distance(_player_house.transform.position, spawn_tile.transform.position)) //DECIDIR CON MAPA DE INFLUENCIA-----------------------------!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!
                    {
                        spawn_tile = t;
                    }
                }
                else if (_state.Equals("Defend"))                                                                                                                                                           //Spawn units near your base
                {
                    if (spawn_tile == null || Vector2.Distance(_player_house.transform.position, t.transform.position) > Vector2.Distance(_player_house.transform.position, spawn_tile.transform.position)) //DECIDIR CON MAPA DE INFLUENCIA-----------------------------!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!
                    {
                        spawn_tile = t;
                    }
                }
            }
        }
        if (spawn_tile != null)
        {
            spawn_tile.f_Buy_Move();
        }
    }