public override int DoAttack(Pawn other)
    {
        UpdateCurrentValue();
        int num = 0;

        for (HexDirection i = HexDirection.NE; i <= HexDirection.NW; i++)
        {
            HexCell cell = currentCell.GetNeighbour(i);
            if (cell != null && cell.pawn != this && cell.CanbeAttackTargetOf(currentCell))
            {
                num++;
            }
        }
        if (num == 0)
        {
            num = 1;
        }

        if (GetLevel() >= 4)
        {
            currentMagicAttack *= num;
        }
        if (GetLevel() >= 2)
        {
            currentAttack *= num;
        }

        int damage = base.DoAttack(other);

        isDirty = true;
        return(damage);
    }
 public override void DoSkillOne(Pawn other = null)
 {
     for (HexDirection i = HexDirection.NE; i <= HexDirection.NW; i++)
     {
         HexCell cell = this.currentCell.GetNeighbour(i);
         if (cell != null && cell.CanbeAttackTargetOf(this.currentCell))
         {
             cell.pawn.TakeDamage(5, 0, this);
         }
     }
 }
Example #3
0
 public override void DoSkill(Pawn target = null)
 {
     for (HexDirection i = HexDirection.NE; i <= HexDirection.NW; i++)
     {
         HexCell cell = currentCell.GetNeighbour(i);
         if (cell != null && cell.CanbeAttackTargetOf(currentCell))
         {
             cell.pawn.addSkipCounter(1);
         }
     }
 }
Example #4
0
 public override void DoSkill(Pawn target = null)
 {
     for (HexDirection i = HexDirection.NE; i < HexDirection.NW; i++)
     {
         HexCell cell = currentCell.GetNeighbour(i);
         if (cell != null && !cell.CanbeAttackTargetOf(currentCell))
         {
             recoverHPPercentage(cell.pawn, 30);
         }
         recoverHPPercentage(this, 30);
     }
 }
Example #5
0
    public override void DoSkillOne(Pawn other = null)
    {
        GameManager gm = FindObjectOfType <GameManager>();

        for (HexDirection i = HexDirection.NE; i <= HexDirection.NW; i++)
        {
            HexCell cell = currentCell.GetNeighbour(i);
            if (cell.CanbeAttackTargetOf(currentCell))
            {
                gm.hexMap.SetCharacterCell(cell.pawn, cell.GetNeighbour(i));
            }
        }
    }
Example #6
0
 public override void PrepareSkillThree()
 {
     gm.hexMap.HideIndicator();
     for (HexDirection i = HexDirection.NE; i <= HexDirection.NW; i++)
     {
         HexCell cell = currentCell.GetNeighbour(i);
         if (cell != null && cell.CanbeAttackTargetOf(currentCell))
         {
             cell.indicator.gameObject.SetActive(true);
             cell.indicator.SetColor(Indicator.AttackColor);
         }
     }
     // maybe a button for confirmation from player?
     pawnAction.DoSkill();
 }
Example #7
0
    public HexCell GetNearestAttackableTarget(HexCell fromCell, int radius = 20)
    {
        if (fromCell.pawn == null)
        {
            return(null);
        }

        List <HexCell> cellToFind = new List <HexCell>();

        for (int i = 0; i < cells.Length; i++)
        {
            cells[i].Distance = int.MaxValue;
        }

        fromCell.Distance = 0;
        cellToFind.Add(fromCell);

        while (cellToFind.Count > 0)
        {
            HexCell cell = cellToFind[0];
            cellToFind.RemoveAt(0);

            for (HexDirection dir = (HexDirection)0; dir <= (HexDirection)5; dir++)
            {
                HexCell nextCell = cell.GetNeighbour(dir);
                if (nextCell != null)
                {
                    int distance = cell.Distance + 1;
                    if (nextCell.Distance == int.MaxValue)
                    {
                        nextCell.Distance = distance;
                        cellToFind.Add(nextCell);
                    }
                    else if (nextCell.Distance > distance)
                    {
                        nextCell.Distance = distance;
                    }
                }
            }
            if (cell.Distance <= radius && cell.CanbeAttackTargetOf(fromCell))
            {
                return(cell);
            }

            cellToFind.Sort((x, y) => x.Distance.CompareTo(y.Distance));
        }
        return(null);
    }
Example #8
0
    public override void DoSkillFive(Pawn other = null)
    {
        GameManager gm = FindObjectOfType <GameManager>();
        bool        oldIsIgnoreDefense = isIgnoreDefense;

        isIgnoreDefense = true;
        for (HexDirection i = HexDirection.NE; i <= HexDirection.NW; i++)
        {
            HexCell cell = currentCell.GetNeighbour(i);
            if (cell.CanbeAttackTargetOf(currentCell))
            {
                DoAttack(cell.pawn);
            }
        }
        isIgnoreDefense = oldIsIgnoreDefense;
    }
Example #9
0
    public override void DoSkillThree(Pawn other = null)
    {
        List <Pawn> pawns = new List <Pawn>();

        for (HexDirection i = HexDirection.NE; i <= HexDirection.NW; i++)
        {
            HexCell cell = currentCell.GetNeighbour(i);
            if (cell != null && cell.CanbeAttackTargetOf(currentCell))
            {
                pawns.Add(cell.pawn);
            }
        }
        foreach (Pawn pawn in pawns)
        {
            pawn.TakeDamage(4, 0, this);
        }
    }
Example #10
0
    public void UpdateAttackTarget()
    {
        HexCell cell = getCurrentPointerCell();

        if (cell != null && cell.CanbeAttackTargetOf(selectedPawn.currentCell))
        {
            validAttackTarget = true;
            attackTarget      = cell.pawn;
        }
        else
        {
            Pawn pawn = getCurrentPointerPawn();
            if (pawn != null && pawn.currentCell.CanbeAttackTargetOf(selectedPawn.currentCell))
            {
                validAttackTarget = true;
                attackTarget      = pawn;
            }
            else
            {
                validAttackTarget = false;
            }
        }
    }
Example #11
0
 // utility
 public bool CanbeTarget(HexCell cell)
 {
     return(cell != null && cell.pawn != null && cell.pawn != this && cell.CanbeAttackTargetOf(currentCell));
 }
Example #12
0
    public void ProbeAttackTarget(HexCell startCell, int range)
    {
        if (startCell.pawn == null)
        {
            return;
        }

        List <HexCell> cellToFind = new List <HexCell>();

        for (int i = 0; i < cells.Length; i++)
        {
            cells[i].Distance = int.MaxValue;
        }

        //Debug.Log("Attack range: " + startCell.pawn.currentAttackRange);

        startCell.Distance = 0;
        cellToFind.Add(startCell);
        reachableCells.Clear();

        while (cellToFind.Count > 0)
        {
            HexCell cell = cellToFind[0];
            cellToFind.RemoveAt(0);

            for (HexDirection dir = (HexDirection)0; dir <= (HexDirection)5; dir++)
            {
                HexCell nextCell = cell.GetNeighbour(dir);
                if (nextCell != null)
                {
                    int distance = cell.Distance + 1;
                    if (nextCell.Distance == int.MaxValue)
                    {
                        nextCell.Distance = distance;
                        cellToFind.Add(nextCell);
                    }
                }
            }
            if (cell.Distance <= range)
            {
                reachableCells.Add(cell);
            }

            cellToFind.Sort((x, y) => x.Distance.CompareTo(y.Distance));
        }

        reachableCells.Remove(startCell);

        attackableCells.Clear();
        friendCells.Clear();
        buildingCells.Clear();
        emptyCells.Clear();
        //allBuildingCells.Clear();

        foreach (HexCell cell in reachableCells)
        {
            if (cell.CanbeAttackTargetOf(startCell))
            {
                attackableCells.Add(cell);
            }
            else if (cell.pawn != null)
            {
                friendCells.Add(cell);
            }
            else if (cell.building != null && cell.building.CanbeSkillTargetOf()) // is buildings
            {
                buildingCells.Add(cell);
            }
            else
            {
                emptyCells.Add(cell);
            }
        }
        if (startCell.pawn != null)
        {
            friendCells.Add(startCell);
        }
    }