Esempio n. 1
0
    //获取范围内的敌人或者友军
    public List <RoleInstance> GetRoleInSkillRange(BattleZhaoshiInstance skill, List <BattleBlockVector> range, int team)
    {
        List <RoleInstance> result = new List <RoleInstance>();

        for (int i = 0; i < range.Count; i++)
        {
            BattleBlockVector pos   = range[i];
            RoleInstance      rolei = BattleModel.GetAliveRole(pos);
            if (rolei == null || rolei.IsDead())
            {
                continue;
            }
            //打敌人的招式
            if (skill.IsCastToEnemy() && rolei.team == team)
            {
                continue;
            }
            if (!skill.IsCastToEnemy() && rolei.team != team)
            {
                continue;
            }
            result.Add(rolei);
        }

        return(result);
    }
Esempio n. 2
0
    /// <summary>
    /// 添加角色到战场里面
    /// </summary>
    /// <param name="role"></param>
    /// <param name="team"></param>
    public void AddBattleRole(RoleInstance role, int team)
    {
        //计算NPC应该站的点
        BattleBlockData npcStandBlock = FindNearestBattleBlock(/*team == 0 ? _player.View.transform.position :*/ role.View.transform.position);

        if (npcStandBlock == null)
        {
            Debug.LogError($"错误,{role.Key}找不到有效格子");
            return;
        }
        //加入战场
        BattleModel.AddBattleRole(role, npcStandBlock.BattlePos, team, (team != 0));

        //待命
        role.View.Idle();
        var enemy = AIManager.Instance.GetNearestEnemy(role);

        if (enemy != null)
        {
            //面向最近的敌人
            role.View.LookAtWorldPosInBattle(enemy.View.transform.position);
        }

        //死亡的关键角色默认晕眩
        if (role.View.m_IsKeyRole && role.IsDead())
        {
            role.Stun(-1);
        }
    }
Esempio n. 3
0
 private void Update()
 {
     if (currentRole == null)
     {
         return;
     }
     UpdatePosition();
     if (currentRole.Hp == preHp)
     {
         return;
     }
     preHp          = currentRole.Hp;
     hpSlider.value = (float)currentRole.Hp / currentRole.MaxHp;
     UpdateHpColor();
     if (currentRole.IsDead())
     {
         transform.gameObject.SetActive(false);
     }
 }
Esempio n. 4
0
    int maxShowCount = 8;//最大显示行动条人数
    //显示行动条
    void ShowActOrder()
    {
        List <RoleInstance> roles      = model.Roles;
        List <RoleInstance> aliveRoles = new List <RoleInstance>();
        int curCount = 0;

        for (int i = 0; i < roles.Count; i++)
        {
            RoleInstance role = roles[i];
            if (role.IsDead())//死亡的排除掉
            {
                continue;
            }
            aliveRoles.Add(role);
            curCount++;
            if (curCount >= maxShowCount)
            {
                break;
            }
        }
        //Jyx2_UIManager.Instance.ShowUI("BattleActionOrderPanel", aliveRoles);
    }