Exemple #1
0
 protected override void onAwake()
 {
     mAnim   = new AnimPlugin(this);
     mAttr   = new AttrPlugin(this);
     mSkill  = new Skill.Plug(this);
     mBuff   = new Buff.Plug(this);
     mEffect = new EffectPlugin(this);
     mAI     = new AIPlugin(this);
     mMove   = new Move.Plug(this);
 }
Exemple #2
0
    void onMoveEvent(Move.Event evt, Move mv)
    {
        if (evt == Move.Event.Stop)
        {
            dispear();
        }
        else if (evt == Move.Event.Arrive)
        {
            if (!isServer)
            {
                Invoke("dispear", table.life);
                return;
            }

            switch (mv.table.type)
            {
            case 1:
                IArea       area  = GameArea.fromString("0,1.0");
                Matrix4x4   mt    = Matrix4x4.TRS(pos, Quaternion.LookRotation(dir), Vector3.one).inverse;
                List <Unit> units = mgr.getUnitInArea(UnitType.Monster | UnitType.Player, area, mt);
                Unit        ower  = mgr.getUnit(mOwner);
                for (int i = 0; i < units.Count; ++i)
                {
                    Unit u = units[i];
                    if (u.relation(ower) >= 0)
                    {
                        continue;
                    }
                    u.anim.sendEvent(AnimPlugin.Hit);
                    AttrPlugin ap = u.attr;
                    ap.HP -= mHarm;
                    ap.sync();
                }
                break;

            case 3:
                Unit target = mv.uTarget;
                if (target != null)
                {
                    target.anim.sendEvent(AnimPlugin.Hit);
                    AttrPlugin ap = target.attr;
                    ap.HP -= mHarm;
                    ap.sync();
                }
                break;
            }
            Invoke("dispear", table.life);
        }
    }
Exemple #3
0
    void affectUnit(Unit u, SkillHarm n)
    {
        if (u == null)
        {
            return;
        }
        if (n.harm > 0)
        {
            u.anim.sendEvent(AnimPlugin.Hit);
        }
        AttrPlugin ap = u.attr;

        ap.HP -= n.harm;
        ap.sync();
        u.sendUnitEvent((int)UnitEvent.BeHit, mUnit.guid, true);
    }
Exemple #4
0
    protected virtual void hit()
    {
        if (!isServer || mHarm == 0)
        {
            return;
        }
        //自己实现碰撞(可以对目标进行拣选)

        /*List<Unit> units = mgr.getUnitInSphere (1, pos, 1);
         * Ray ray = new Ray (pos, dir);
         * for (int i = 0, max = units.Count; i < max; ++i)
         * {
         *      Unit u = units [i];
         *      float dis = 0;
         *      if (u.bound.IntersectRay(ray, out dis) && dis<mMove.speed)
         *      {
         *              //碰撞到u
         *              Debug.LogError("hit0:"+u.guid);
         *      }
         * }*/
        //利用unity物理引擎检测碰撞体
        RaycastHit[] rh = Physics.RaycastAll(pos, dir, mMove.speed, 0x01 << LayerMask.NameToLayer("Server"));
        if (rh != null)
        {
            for (int i = 0; i < rh.Length; ++i)
            {
                Unit u = rh [i].collider.GetComponent <Unit> ();
                if (u == null)
                {
                    continue;
                }
                Log.i("hit target=" + u.guid, Log.Tag.Skill);
                u.dir = -dir;
                u.anim.sendEvent(AnimPlugin.Hit);
                AttrPlugin ap = u.attr;
                ap.HP -= mHarm;
                ap.sync();
            }
        }
    }