Exemplo n.º 1
0
    private void onCellMouseEnter(object sender, EventArgs e)
    {
        if (!fsm.GetCurrentState().CellMouseEnterAllowed())
        {
            Debug.Log("Cell mouse enter not allowed in this state");
            return;
        }

        int    APAmountRequired           = 0;
        string cellInformationText        = "";
        bool   cellInformationTextAchtung = false;

        // Battleboard decides, what action to do if cell clicked (bc Battleboard is kinda CellManager)
        BattleboardCell cell = sender as BattleboardCell;

        if (cell.IsVacant())
        {
            BattleboardCell currentCell = FindCellOfCharacter(currentCharacter);

            currentRoute = BuildRoute(currentCell, cell);

            var routeRealLength = currentRoute.Count - 1;
            APAmountRequired = currentCharacter.WalkCost * routeRealLength;
            if (APAmountRequired > 0) // we need this check here in order not to create cellinfo when mouse is on current character's cell with 0 AP
            {
                // #localize:
                cellInformationText = currentCharacter.APEnoughForWalk(routeRealLength) ?
                                      "Walk here\nfor " + APAmountRequired + " AP" + Utility.GetIntegerEnding(APAmountRequired) :
                                      cellInformationText = String.Format("{0} to walk here\nRequired: {1}", Log.NOT_ENOUGH_AP, APAmountRequired);
                cellInformationTextAchtung = !currentCharacter.APEnoughForWalk(routeRealLength);
            }

            MarkInRouteCells();
        }

        if (cell.IsOccupiedByCharacterOfParty(cell, enemyParty))
        {
            if (AreCellsAdjacent(cell.transform.position, currentCharacter.transform.position))
            {
                APAmountRequired = currentCharacter.AttackCost;

                cell.ExternalModificatorColor = currentCharacter.APEnoughForAttack() ?
                                                BattleboardCell.enoughAPColor :
                                                BattleboardCell.noAPColor;
                // #localize:
                cellInformationText = currentCharacter.APEnoughForAttack() ?
                                      String.Format("Attack {0} {3}\nfor {1} AP{2}", cell.Character.GetHealthStatus(), APAmountRequired, Utility.GetIntegerEnding(APAmountRequired), cell.Character.Name) :
                                      String.Format("{0} for attack {2} {3}\nRequired: {1}", Log.NOT_ENOUGH_AP, APAmountRequired, cell.Character.GetHealthStatus(), cell.Character.Name);
                cellInformationTextAchtung = !currentCharacter.APEnoughForAttack();
            }
            else   // show enemy's name and health status
            {
                // #localize:
                cellInformationText = String.Format("{0}\n{1}", cell.Character.Name, cell.Character.GetHealthStatus());
            }
        }

        // if it's out teammate, show his/her name and exact HP
        if (cell.IsOccupiedByCharacterOfParty(cell, playerParty))
        {
            // #localize:
            cellInformationText = String.Format("{0}\nHP: {1}", cell.Character.Name, cell.Character.HP);
        }

        if (!String.IsNullOrEmpty(cellInformationText))
        {
            ShowCellInformation(cell, cellInformationText, cellInformationTextAchtung);
        }
    }