Ejemplo n.º 1
0
    public void OnTriggerEnter(GameObject selfObj, Collider other)
    {
        if (other.isTrigger)
        {
            //Debug.LogWarning("OnTriggerEnter other.isTrigger is true");
            return;
        }
        Actor     target    = null;
        Transform targetObj = other.transform;

        while (null != targetObj && targetObj.name != "body")
        {
            targetObj = targetObj.parent;
        }
        if (null == targetObj)
        {
            //Debug.LogWarning("OnTriggerEnter target obj is null");
            return;
        }
        ActorProp prop = targetObj.parent.GetComponent <ActorProp>();

        target = prop.ActorLogicObj;
        if (null == target)
        {
            Debug.LogWarning("OnTriggerEnter target is null");
            return;
        }
        if (target.IsDead)
        {
            Debug.LogWarning("OnTriggerEnter target is deaded");
            return;
        }
        //Debug.LogWarning("OnTriggerEnter target id is " +target.ID.ToString());
        SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(mSkillResultID);

        if (info == null)
        {
            return;
        }
        ActorProp selfProp = selfObj.transform.parent.GetComponent <ActorProp>();
        Trap      self     = selfProp.ActorLogicObj as Trap;

        if (!self.CheckActorAttackResult(target))
        {
            return;
        }

        if (ClientNet.Singleton.IsConnected)
        {
            IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, self.ID, target.ID,
                                                             mSkillResultID, 0);
            if (r != null)
            {
                target.SetBlastPos(self.RealPos, self.GetBodyObject().transform.forward);
                r.ResultExpr(null);
                BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r);
            }
        }
        else
        {
            IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, self.ID, target.ID,
                                                             mSkillResultID, 0);
            if (r != null)
            {
                target.SetBlastPos(self.RealPos, self.GetBodyObject().transform.forward);
                r.ResultExpr(null);
                BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r);
            }
        }
//         if (!string.IsNullOrEmpty(info.SoundList))
//         {//播放击中声音
//             string[] param = info.SoundList.Split(new char[1] { ',' });
//             string sound = param[0];
//             if (!string.IsNullOrEmpty(sound))
//             {
//                 m_audioPos = selfObj.transform.position;
//                 GameResManager.Singleton.LoadResourceAsyncCallback(GameData.GetSoundPath(sound), Callback);
//                 //AudioClip clip = PoolManager.Singleton.CreateSoundObj(sound) as AudioClip;
//                 //AudioSource.PlayClipAtPoint(clip, selfObj.transform.position);
//             }
//             else
//             {
//                 Debug.LogWarning("sound string is null");
//             }
//         }
    }