예제 #1
0
    void AIIStartsMoving(BattleHex targetToAttack)                               //determines the distance from the attack target to each hex
    {
        battleController.CleanField();                                           //clear properties of all hexes before new calculation
        targetToAttack.DefineMeAsStartingHex();                                  //the starting hex is the hex occupied by the target of the attack
        int           stepsLimit      = battleController.stepsToCheckWholeField; //number of steps enough to check the entire battlefield
        IInitialHexes getInitialHexes = new InitialPos();                        //each hex validation rule

        //determines the distance from the attack target to each hex
        tocheckTheField.GetAvailablePositions(stepsLimit, getInitialHexes, targetToAttack);
        IAdjacentFinder adjFinder = BattleController.currentAtacker.GetTypeOfHero(); //determines the type of movement

        AIDefinesPath(adjFinder);                                                    //determines the optimal path and starts moving
    }
예제 #2
0
    void AIIStartsMoving(BattleHex targetToAttack)                               // determina la distancia desde el objetivo del ataque a cada hex
    {
        battleController.CleanField();                                           // borrar las propiedades de todos los hexes antes de un nuevo cálculo
        targetToAttack.DefineMeAsStartingHex();                                  // el hex de inicio es el hex ocupado por el objetivo del ataque
        int           stepsLimit      = battleController.stepsToCheckWholeField; // número de pasos suficientes para comprobar todo el campo de batalla
        IInitialHexes getInitialHexes = new InitialPos();                        // cada regla de validación hexadecimal

        // determina la distancia desde el objetivo del ataque a cada hex
        tocheckTheField.GetAvailablePositions(stepsLimit, getInitialHexes, targetToAttack);
        IAdjacentFinder adjFinder = BattleController.currentAtacker.GetTypeOfHero(); // determina el tipo de movimiento

        AIDefinesPath(adjFinder);                                                    // determina la ruta óptima y comienza a moverse
    }
예제 #3
0
    void AIDefinesPath(IAdjacentFinder adjFinder)//determines the optimal path and starts moving
    {
        //assigns a value to the static variable used by the Move and Optimal Path classes
        BattleController.targetToMove = AISelectsPosToOcuppy();
        battleController.CleanField();                    // clear the entire battlefield from previous calculations
        IInitialHexes getInitialHexes = new InitialPos(); //each hex validation rule
        int           stepsLimit      = hero.heroData.CurrentVelocity;
        BattleHex     startingHex     = BattleController.currentAtacker.GetComponentInParent <BattleHex>();

        startingHex.DefineMeAsStartingHex();//marks a new starting hex

        //select all the hexes that the troll can occupy
        availablePos.GetAvailablePositions(stepsLimit, adjFinder, getInitialHexes);
        GetComponent <OptimalPath>().MatchPath(); //determine the optimal path
        move.StartsMoving();                      //troll begins to move
    }
예제 #4
0
    void AIDefinesPath(IAdjacentFinder adjFinder)// determina la ruta óptima y comienza a moverse
    {
        // asigna un valor a la variable estática utilizada por las clases Move y Optimal Path
        BattleController.targetToMove = AISelectsPosToOcuppy();
        battleController.CleanField();                    // limpia todo el campo de batalla de los cálculos anteriores
        IInitialHexes getInitialHexes = new InitialPos(); // cada regla de validación hexadecimal
        int           stepsLimit      = hero.heroData.CurrentVelocity;
        BattleHex     startingHex     = BattleController.currentAtacker.GetComponentInParent <BattleHex>();

        startingHex.DefineMeAsStartingHex();// marca un nuevo hexadecimal inicial

        // selecciona todos los hexes que puede ocupar el troll
        availablePos.GetAvailablePositions(stepsLimit, adjFinder, getInitialHexes);
        GetComponent <OptimalPath>().MatchPath(); // determina la ruta óptima
        move.StartsMoving();                      // El troll comienza a moverse
    }
예제 #5
0
    public void InitializeNewTurn()
    {
        battleController.CleanField();
        battleController.DefineNewAtacker();                   //finds an attacking hero
        Hero currentAtacker = BattleController.currentAtacker; //gets local atacker (for parameters)

        GetStartingHex();
        if (currentAtacker.GetComponent <Enemy>() == null)//checks if it is a player’s turn
        {
            IInitialHexes getInitialHexes = new InitialPos();
            currentAtacker.PlayersTurn(getInitialHexes);//player starts his turn
        }
        //player starts its turn
        else
        {
            IInitialHexes getInitialHexes = new InitialPosAI();
            currentAtacker.GetComponent <Enemy>().Aisturnbegins(getInitialHexes);
        }
    }
예제 #6
0
    public void InitializeNewTurn()
    {
        battleController.CleanField();
        battleController.DefineNewAtacker();                   // encuentra un héroe atacante
        Hero currentAtacker = BattleController.currentAtacker; // obtiene atacante local (para parámetros)

        GetStartingHex();
        if (currentAtacker.GetComponent <Enemy>() == null)// comprueba si es el turno de un jugador
        {
            IInitialHexes getInitialHexes = new InitialPos();
            currentAtacker.PlayersTurn(getInitialHexes);// El jugador comienza su turno
        }
        // El jugador comienza su turno
        else
        {
            IInitialHexes getInitialHexes = new InitialPosAI();
            currentAtacker.GetComponent <Enemy>().Aisturnbegins(getInitialHexes);
        }
    }
예제 #7
0
        /// <summary>
        /// event of the maze board loading
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MazeBoard_Loaded(object sender, RoutedEventArgs e)
        {
            string[] startPos = InitialPos.Split(',');
            rowStartPos = Int32.Parse(startPos[0]);
            colStartPos = Int32.Parse(startPos[1]);
            string[] goalPos = GoalPos.Split(',');
            rowGoalPos = Int32.Parse(goalPos[0]);
            colGoalPos = Int32.Parse(goalPos[1]);

            rowPlayerPos = Int32.Parse(startPos[0]);
            colPlayerPos = Int32.Parse(startPos[1]);

            width  = myCanvas.Width / Cols;
            height = myCanvas.Height / Rows;
            int counter = 0;

            // drawing the board
            for (int i = 0; i < Rows; i++)
            {
                for (int j = 0; j < Cols; j++)
                {
                    Maze.Count();
                    if (Maze[counter] == '1')
                    {
                        AddWall(j, i);
                    }
                    if (i == rowStartPos && j == colStartPos)
                    {
                        AddImage(j, i, ImageSource, "Player");
                        initialIndexInMaze = counter;
                        indexInMaze        = counter;
                    }
                    if (i == rowGoalPos && j == colGoalPos)
                    {
                        AddImage(j, i, ExitImageFile, "Exit");
                        endOfGame = counter;
                    }

                    counter++;
                }
            }
        }