示例#1
0
    public override void OnEnterState()
    {
        BattleboxHelper.Instance.HideAllBlocks();
        BattleStateMechine.Instance.BindBattleAction(null);

        m_currentRole = BattleStateMechine.Instance.CurrentRole;
        if (m_currentRole == null)
        {
            GameUtil.LogError("ai当前角色为空");
            return;
        }
        AIManager.Instance.GetAIResult(BattleStateMechine.Instance.CurrentRole, (result) =>
        {
            m_aiResult = result;
            BattleBlockVector MoveTo    = new BattleBlockVector(result.MoveX, result.MoveY);
            BattleBlockVector SkillTo   = new BattleBlockVector(result.AttackX, result.AttackY);
            BattleZhaoshiInstance Skill = result.Zhaoshi;
            Jyx2Item Item = result.Item;
            DoAIAction(MoveTo, SkillTo, Skill, Item);
        });
    }
示例#2
0
    List <GameObject> hitGoList = new List <GameObject>();//当前技能可以打到的角色
    public override void OnEnterState()
    {
        role     = BattleStateMechine.Instance.CurrentRole;
        zhaoshi  = BattleStateMechine.Instance.CurrentZhaoshi;
        skillPos = BattleStateMechine.Instance.CurrentSkillPos;
        if (role == null || zhaoshi == null || skillPos == null)
        {
            GameUtil.LogError("进入技能展示范围状态失败");
            return;
        }
        var blockList = BattleManager.Instance.GetSkillCoverBlocks(zhaoshi, skillPos, role.Pos);

        BattleboxHelper.Instance.ShowBlocks(blockList);//显示技能范围
        FillBeHitEnemeyGameObject(blockList);
        // 将要受到攻击的敌人描边
        ShowEnemyOutLine();

        BattleBlockData blockData = BattleboxHelper.Instance.GetBlockData(skillPos.X, skillPos.Y);

        //面板需要根据世界坐标算出ui坐标 显示在格子上方 方便点击
        Jyx2_UIManager.Instance.ShowUI("BattleOKPanel", blockData.WorldPos, new Action(OnConfirm), new Action(OnCancel));
    }
示例#3
0
    void ShowSkillDamage()
    {
        BattleZhaoshiInstance zhaoshi = BattleStateMechine.Instance.CurrentZhaoshi;
        RoleInstance          role    = BattleStateMechine.Instance.CurrentRole;

        if (zhaoshi == null || role == null)
        {
            return;
        }
        //int level_index = zhaoshi.Data.GetLevel();
        //int damage = role.Attack + zhaoshi.Data.GetSkillLevelInfo(level_index).Attack / 3;
        //if (role.Weapon >= 0)
        //{
        //    var i = ConfigTable.Get<Jyx2Item>(role.Weapon);
        //    damage += i.Attack;
        //}
        //if (role.Armor >= 0)
        //{
        //    var i = ConfigTable.Get<Jyx2Item>(role.Armor);
        //    damage += i.Attack;
        //}
        DamageText_Text.text = $"{zhaoshi.Data.Name} Lv.{zhaoshi.Data.GetLevel()}";
    }
示例#4
0
    public SkillCastResult GetSkillResult(RoleInstance r1, RoleInstance r2, BattleZhaoshiInstance skill, BattleBlockVector blockVector)
    {
        SkillCastResult rst         = new SkillCastResult(r1, r2, skill, blockVector.X, blockVector.Y);
        var             magic       = skill.Data.GetSkill();
        int             level_index = skill.Data.GetLevel();

        level_index = skill.calMaxLevelIndexByMP(r1.Mp, level_index);
        //普通攻击
        if (magic.DamageType == 0)
        {
            if (r1.Mp <= 10)
            {
                rst.damage = 1 + UnityEngine.Random.Range(0, 10);
                return(rst);
            }
            int attack  = r1.Attack + skill.Data.GetSkillLevelInfo(level_index).Attack / 3;
            int defence = r2.Defence;
            if (r1.Weapon >= 0)
            {
                var i = ConfigTable.Get <Jyx2Item>(r1.Weapon);
                attack += i.Attack;
            }
            if (r1.Armor >= 0)
            {
                var i = ConfigTable.Get <Jyx2Item>(r1.Armor);
                attack += i.Attack;
            }
            if (r2.Weapon >= 0)
            {
                var i = ConfigTable.Get <Jyx2Item>(r2.Weapon);
                defence += i.Defence;
            }
            if (r2.Armor >= 0)
            {
                var i = ConfigTable.Get <Jyx2Item>(r2.Armor);
                defence += i.Defence;
            }

            int v   = attack - defence;
            int dis = r1.Pos.GetDistance(r2.Pos);
            v  = (int)(v / Math.Exp((dis - 1) / 10));
            v += UnityEngine.Random.Range(0, 10) - UnityEngine.Random.Range(0, 10);
            if (v < 10)
            {
                v = 1 + UnityEngine.Random.Range(0, 10);
            }
            rst.damage = v;
            return(rst);
        }
        else if (magic.DamageType == 1) //吸内
        {
            int v = skill.Data.GetSkillLevelInfo().KillMp;
            v += UnityEngine.Random.Range(0, 10) - UnityEngine.Random.Range(0, 10);
            if (v < 10)
            {
                v = 1 + UnityEngine.Random.Range(0, 10);
            }
            rst.damageMp = v;
            return(rst);
        }
        else if (magic.DamageType == 2) //用毒 -GameUtil::usePoison
        {
            rst.poison = usePoison(r1, r2);
            return(rst);
        }
        else if (magic.DamageType == 3) //解毒
        {
            rst.depoison = detoxification(r1, r2);
            return(rst);
        }
        else if (magic.DamageType == 4) //治疗
        {
            rst.heal = medicine(r1, r2);
            return(rst);
        }
        return(null);
    }
示例#5
0
    public void GetMoveAndCastPos(RoleInstance role, BattleZhaoshiInstance zhaoshi, List <BattleBlockVector> moveRange)
    {
        //clear
        m_GetMoveAndCastPosResult[0] = null;
        m_GetMoveAndCastPosResult[1] = null;

        //丢给自己的,随便乱跑一个地方丢
        if (zhaoshi.GetCoverType() == SkillCoverType.POINT && zhaoshi.GetCastSize() == 0 && zhaoshi.GetCoverSize() == 0)
        {
            BattleBlockVector targetBlock = null;
            if ((float)role.Hp / role.MaxHp > 0.5)
            {
                targetBlock = GetNearestEnemyBlock(role, moveRange); //生命大于50%前进
            }
            else
            {
                targetBlock = GetFarestEnemyBlock(role, moveRange); //生命小于50%后退
            }
            m_GetMoveAndCastPosResult[0] = targetBlock;
            m_GetMoveAndCastPosResult[1] = targetBlock;
        }

        bool   isAttack = zhaoshi.IsCastToEnemy();
        double maxScore = 0;

        //带攻击范围的,找最多人丢
        foreach (var moveBlock in moveRange)
        {
            int castSize   = zhaoshi.GetCastSize();
            var coverType  = zhaoshi.GetCoverType();
            var sx         = moveBlock.X;
            var sy         = moveBlock.Y;
            var castBlocks = rangeLogic.GetSkillCastBlocks(sx, sy, zhaoshi, role);

            int splitFrame = 0;//分帧
            foreach (var castBlock in castBlocks)
            {
                double score       = 0;
                var    coverSize   = zhaoshi.GetCoverSize();
                var    tx          = castBlock.X;
                var    ty          = castBlock.Y;
                var    coverBlocks = rangeLogic.GetSkillCoverBlocks(coverType, tx, ty, sx, sy, coverSize);

                foreach (var coverBlock in coverBlocks)
                {
                    var targetSprite = BattleModel.GetAliveRole(coverBlock);
                    //位置没人
                    if (targetSprite == null)
                    {
                        continue;
                    }

                    //如果判断是施展给原来的自己,但自己已经不在原位置了,相当于没打中
                    if (targetSprite == role && !(targetSprite.Pos.X == moveBlock.X && targetSprite.Pos.Y == moveBlock.Y))
                    {
                        continue;
                    }
                    //如果是自己的新位置,则相当于施展给自己
                    if (targetSprite.Pos.X == moveBlock.X && targetSprite.Pos.Y == moveBlock.Y)
                    {
                        continue;
                        //targetSprite = sprite;
                    }
                    else if (targetSprite.team != role.team && targetSprite.Hp > 0)
                    {
                        score += 0.1;
                    }
                }

                if (score > maxScore)
                {
                    maxScore = score;

                    m_GetMoveAndCastPosResult[0] = new BattleBlockVector(moveBlock.X, moveBlock.Y);
                    m_GetMoveAndCastPosResult[1] = new BattleBlockVector(castBlock.X, castBlock.Y);
                }
            }
            if (splitFrame++ > 5)//分帧
            {
                // yield return 0;
                splitFrame = 0;
            }
        }
        if (maxScore > 0)
        {
        }
        else
        {
            m_GetMoveAndCastPosResult[0] = null;
            m_GetMoveAndCastPosResult[1] = null;
        }
    }
示例#6
0
 //只绑定招式 玩家指挥使用
 public void BindSkill(BattleZhaoshiInstance zhaoshi)
 {
     CurrentZhaoshi = zhaoshi;
 }
示例#7
0
 //绑定当前使用招式 一次绑定技能和技能释放位置 ai使用
 public void BindBattleAction(BattleZhaoshiInstance zhaoshi, BattleBlockVector data = null)
 {
     CurrentZhaoshi  = zhaoshi;
     CurrentSkillPos = data;
 }
示例#8
0
 public override void OnLeaveState()
 {
     m_role     = null;
     m_skill    = null;
     m_skillPos = null;
 }