Exemple #1
0
    private float mRadius = 0.0f; //选人半径

    public override void Filter(PkMsg _msg)
    {
        //base.Filter(_msg);

        GameObject target    = _msg.Target;
        Vector3    targetLoc = Vector3.zero;
        Quaternion quat      = Quaternion.identity;

        if (target != null)
        {
            targetLoc = target.transform.position;
            quat      = Quaternion.Euler(target.transform.eulerAngles);
        }
        else
        {
            targetLoc = _msg.TargetLoc;
        }

        if (targetLoc != Vector3.zero)
        {
            Collider[] hits = Physics.OverlapSphere(targetLoc, mRadius, mLayerMask); //指定层获取,减少不必要的遍历
            for (int i = 0; i < hits.Length; ++i)
            {
                Actor actor = hits[i].GetComponent <Actor>();


                if (mCount > 0)
                {
                    mDestChars.Add(actor);
                    mCount -= 1;
                }
                else if (mCount == -1)
                {
                    mDestChars.Add(actor);
                }
                else
                {
                    break;
                }
            }

            #region debug mode - display range
            if (DefineMgr.DrawFilter)
            {
                GameObject go   = (GameObject)GameObject.Instantiate(DefineMgr.DrawNode, targetLoc, quat);
                DrawComp   comp = go.AddComponent <DrawComp>();
                comp.SetRadius(mRadius);
                comp.SetColor(DefineMgr.DrawColor);

                for (int i = 0; i < mDestChars.Count; ++i)
                {
                    Debug.DrawLine(targetLoc, mDestChars[i].transform.position, DefineMgr.DrawColor, DefineMgr.DrawTime);
                }
            }
            #endregion
        }
    }
Exemple #2
0
 public void MyRotateModifier(DrawComp drawComp, double value)
 {
     drawComp.DrawRotation = (float)value;
 }