示例#1
0
    //获取伤害范围
    public Vector2Int GetDamageRange(Unit _origin, Unit _target, bool _isRangeAttack = false)
    {
        Vector2Int range = _origin.damage;

        float damageRate = DamageRate(_origin.att, _target.def);

        //print("伤害倍率:" + damageRate);

        //远程攻击,没有近战伤害不减的特质,超过10格伤害减半
        if (_isRangeAttack &&
            !TraitManager.PossessTrait(_origin, "No melee penalty") &&
            AStarManager.GetNodeItemDistance(_origin.nodeItem, _target.nodeItem, true)
            > BattleManager.instance.rangeAttackRange)
        {
            damageRate /= 2;
        }

        //圣灵庇佑和诅咒判定,根据后来居上原则
        for (int i = 0; i < _origin.behaviors.Count; i++)
        {
            if (_origin.behaviors[i].name == "Bestow Hope")
            {
                range   = _origin.damage;
                range.x = range.y;
            }
            else if (_origin.behaviors[i].name == "Bestow Hope_2")
            {
                range = _origin.damage;
                range.y++;
                range.x = range.y;
            }
            else if (_origin.behaviors[i].name == "Cursed Strikes")
            {
                range   = _origin.damage;
                range.y = range.x;
            }
            else if (_origin.behaviors[i].name == "Cursed Strikes_2")
            {
                range = _origin.damage;
                range.x--;
                range.y = range.x;
            }
        }

        //至少也有1点
        range.x = Mathf.Max(range.x, 1);
        range.y = Mathf.Max(range.y, 1);

        //伤害乘以伤害倍率
        range.x = (int)(range.x * damageRate);
        range.y = (int)(range.y * damageRate);

        return(range * _origin.num);
    }
示例#2
0
    //鼠标进入节点
    public void OnNodeHovered(NodeItem_Battle _node)
    {
        _node.ChangeBackgoundColor("hover");

        playerHovered = _node;

        //是可到达节点,则显示路径
        if (_node.battleNodeType == BattleNodeType.reachable)
        {
            CursorManager.instance.ChangeCursor("reachable");

            //是地面移动单位,则计算路径
            if (BattleManager.currentActionUnit.isWalker)
            {
                //print("hover");
                FindPath(BattleManager.currentActionUnit, _node);
            }
        }
        else if (_node.battleNodeType == BattleNodeType.attackable)
        {
            if (BattleManager.currentActionUnit.IsRangeAttack)
            {
                //(有远程伤害不减的特质),或者距离10以内
                //TraitManager.PossessTrait(BattleManager.currentActionUnit, "No melee penalty") ||
                if (AStarManager.GetNodeItemDistance(BattleManager.currentActionUnit.nodeItem,
                                                     _node, true) <= BattleManager.instance.rangeAttackRange)
                {
                    CursorManager.instance.ChangeCursor("arrow");
                }
                else
                {
                    CursorManager.instance.ChangeCursor("arrow_penalty");
                }
            }

            //显示文本
            BattleInfoMgr.instance.SetText_Attack(BattleManager.currentActionUnit, _node.unit);
        }
        else if (_node.battleNodeType == BattleNodeType.spellable)
        {
            CursorManager.instance.ChangeCursor("spell");
        }
        else
        {
            //如果不是可行动节点
            //如果是单位
            if (_node.nodeObject != null &&
                _node.nodeObject.nodeObjectType == NodeObjectType.unit)
            {
                //显示并更新单位属性UI
                //BattleManager.instance.ShowUnitStatUI(true, _node.unit);

                //如果不是当前行动单位,开始闪烁
                if (_node.nodeObject != BattleManager.currentActionUnit)
                {
                    if (BattleManager.instance.isSamePlayer(_node.unit,
                                                            BattleManager.currentActionUnit))
                    {
                        UnitHaloMgr.instance.HaloFlashStart(_node.unit, "friend");
                    }
                    else
                    {
                        UnitHaloMgr.instance.HaloFlashStart(_node.unit, "enemy");
                    }
                }

                //根据敌友改变指针
                if (BattleManager.instance.isSamePlayer(_node.unit,
                                                        BattleManager.currentActionUnit))
                {
                    CursorManager.instance.ChangeCursor("friend");
                }
                else
                {
                    CursorManager.instance.ChangeCursor("enemy");
                }
            }
        }
        //不可到达点
        // else if (_node.battleNodeType == BattleNodeType.empty)
        // {
        //     CursorManager.instance.ChangeCursor("stop");
        // }
    }