Exemplo n.º 1
0
 private void Start()
 {
     pathfinding = GetComponent <Pathfinding>();
     if (classroomFight)
     {
         GenerateClassroomGrid();
     }
     else if (corridorFight)
     {
         GenerateCorridorGrid();
     }
     else if (terraceFight)
     {
         GenerateTerraceGrid();
     }
     GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
     foreach (GameObject player in players)
     {
         GameObject hexWithAPlayer = pathfinding.CharacterToHexPosition(player);
         hexWithAPlayer.GetComponent <HexProperties>().CharacterInHex = player;
     }
     GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
     foreach (GameObject enemy in enemies)
     {
         GameObject hexWithAnEnemy = pathfinding.CharacterToHexPosition(enemy);
         hexWithAnEnemy.GetComponent <HexProperties>().CharacterInHex = enemy;
     }
 }
Exemplo n.º 2
0
    public void MoveToNewPosition()
    {
        MoveCharacter = true;
        inputManager.ChangeCombatButtonsTo(false);
        character = turnManager.GetCharacterInTurn();
        CalculatePath();
        ChangeMovementValues(character);
        combatAnimationManager.MoveAnimation(character.GetComponent <Animator>(), true);
        combatAnimationManager.TurnTowardsTarget(character, nextHex);
        GameObject previousHex = pathfinding.CharacterToHexPosition(character);

        previousHex.GetComponent <HexProperties>().CharacterInHex = null;
        nextHex.GetComponent <HexProperties>().CharacterInHex     = character;
        pathfinding.ClearAllHexes();
        pathfinding.CharacterToHexPosition(nextHex).GetComponentInChildren <SpriteRenderer>().color = Color.white; //deixa o hex em que o personagem está ,branco
        inputManager.MoveButtonPressed = false;
    }
Exemplo n.º 3
0
    private bool CheckIfAdjacentToAPlayer(out GameObject adjacentPlayer)
    {
        adjacentPlayer = null;
        GameObject        enemy      = turnManager.GetCharacterInTurn();
        List <GameObject> allPlayers = GetAllPlayersInCombat();
        bool       closeToAPlayer    = false;
        GameObject enemyHex          = pathfinding.CharacterToHexPosition(enemy);

        foreach (GameObject player in allPlayers)
        {
            GameObject playerHex = pathfinding.CharacterToHexPosition(player);

            Vector3 playerHexPosition = playerHex.transform.position;
            Vector3 enemyHexPosition  = enemyHex.transform.position;

            Vector3 northWestHexPosition = new Vector3(enemyHexPosition.x - 0.6f, enemyHexPosition.y + 0.525f, enemyHexPosition.z + 0.9f);
            Vector3 northEastHexPosition = new Vector3(enemyHexPosition.x + 0.6f, enemyHexPosition.y + 0.525f, enemyHexPosition.z + 0.9f);
            Vector3 westHexPosition      = new Vector3(enemyHexPosition.x - 1.2f, enemyHexPosition.y, enemyHexPosition.z);
            Vector3 eastHexPosition      = new Vector3(enemyHexPosition.x + 1.2f, enemyHexPosition.y, enemyHexPosition.z);
            Vector3 southWestHexPosition = new Vector3(enemyHexPosition.x - 0.6f, enemyHexPosition.y - 0.525f, enemyHexPosition.z - 0.9f);
            Vector3 southEastHexPosition = new Vector3(enemyHexPosition.x + 0.6f, enemyHexPosition.y - 0.525f, enemyHexPosition.z - 0.9f);
            if (playerHexPosition == northWestHexPosition || playerHexPosition == northEastHexPosition || playerHexPosition == westHexPosition || enemyHexPosition == eastHexPosition || playerHexPosition == southWestHexPosition || playerHexPosition == southEastHexPosition)
            {
                adjacentPlayer = player;
                closeToAPlayer = true;
                break;
            }
            else
            {
                closeToAPlayer = false;
            }
        }
        return(closeToAPlayer);
    }//ok
Exemplo n.º 4
0
    public List <GameObject> FindHexesAvailableForSkill()
    {
        List <GameObject> skillableHexes       = new List <GameObject>();
        GameObject        fenrir               = turnManager.GetCharacterInTurn();
        float             xDistance            = mapGenerator.xDistance;
        GameObject        fenrirHex            = pathfinding.CharacterToHexPosition(fenrir);
        Vector3           fenrirHexPosition    = fenrirHex.transform.position;
        List <Vector3>    allPossiblePositions = new List <Vector3>();

        for (int i = 1; i <= 3; i++)
        {
            Vector3 possibleSkillPosition = new Vector3(fenrirHexPosition.x + xDistance * i, fenrirHexPosition.y, fenrirHexPosition.z);
            allPossiblePositions.Add(possibleSkillPosition);
        }
        for (int i = 1; i <= 3; i++)
        {
            Vector3 possibleSkillPosition = new Vector3(fenrirHexPosition.x - xDistance * i, fenrirHexPosition.y, fenrirHexPosition.z);
            allPossiblePositions.Add(possibleSkillPosition);
        }
        if (hexesToTheRightOfPlayer.Count > 0)
        {
            pathfinding.ClearAllHexes();
            hexesToTheRightOfPlayer.Clear();
        }
        if (hexesToTheLeftOfPlayer.Count > 0)
        {
            pathfinding.ClearAllHexes();
            hexesToTheLeftOfPlayer.Clear();
        }
        foreach (GameObject hex in mapGenerator.gridHexesObjects)
        {
            foreach (Vector3 possiblePosition in allPossiblePositions)
            {
                if (possiblePosition == hex.transform.position)
                {
                    if (hex.transform.position.x > fenrir.transform.position.x)
                    {
                        hexesToTheRightOfPlayer.Add(hex);
                    }
                    else if (hex.transform.position.x < fenrir.transform.position.x)
                    {
                        hexesToTheLeftOfPlayer.Add(hex);
                    }
                    skillableHexes.Add(hex);
                    break;
                }
            }
            if (skillableHexes.Count == 6)
            {
                break;
            }
        }
        return(skillableHexes);
    }