示例#1
0
    /// <summary>
    /// 判断目标是否还在攻击范围
    /// </summary>
    /// <param name="entityModel"></param>
    /// <returns></returns>
    protected bool CheckAtAttackRange(EntityModel entityModel)
    {
        Vector3 center = this.m_PlayerBehaviour.ThisTransform.position;
        Vector3 target = entityModel.GO.transform.position;

        //float distance = this.m_PlayerBehaviour.LockRadius;
        //float angle = this.m_PlayerBehaviour.LockAngle;
        return((Vector3.Distance(center, target) <= this.m_attackDistance) && CommonTools.AngleBetween2Vector(m_PlayerBehaviour.ThisTransform.forward, (target - center)) <= this.m_attackAngle / 2);
    }
示例#2
0
 public EntityModel LockAttackMonster(float radius, float angle)
 {
     if (GameManager.Instance.CurrentState == GameManager.GameState.GAME_STATE_BATTLE && !PVPBattleManager.Instance.IsPVPBattle)
     {
         var forward = m_PlayerBehaviour.ThisTransform.forward;
         if (m_stateID == StateID.PlayerRun)
         {
             forward = ((PlayerRunState)this).MoveVector;
         }
         var center         = m_PlayerBehaviour.ThisTransform.position;
         var monstersTarget = MonsterManager.Instance.SearchBeAttackedMonster(center, radius, forward, angle);
         if (monstersTarget == null)
         {
             return(null);
         }
         var monsters = monstersTarget.ToList();
         if (monsters.Count > 0)
         {
             monsters.Sort((a, b) =>
             {
                 float anga = CommonTools.AngleBetween2Vector(forward, (a.GO.transform.position - center));
                 float angb = CommonTools.AngleBetween2Vector(forward, (b.GO.transform.position - center));
                 if (anga == angb)
                 {
                     return(0);
                 }
                 else if (anga > angb)
                 {
                     return(1);
                 }
                 else
                 {
                     return(-1);
                 }
             });
             return(monsters[0]);
         }
     }
     return(null);
 }