Beispiel #1
0
    public void Attack(ActionCallBack.AttackFinishCallBack FinishCallBack = null,
                       ActionCallBack.PlayBeAttackOneStep hit_1           = null,
                       ActionCallBack.PlayBeAttackTwoStep hit_2           = null,
                       ActionCallBack.PlayBeAttackEffect eff         = null,
                       ActionCallBack.ShowChangePlayerInfo changeVal = null)
    {
        if (null == ActorObj)
        {
            return;
        }
//		PlayEntityAction( GlobalValue.ActionName , GlobalValue.Action_Attack );
        BattleActor self = Battle.Instance.GetActorByInstId(PlayerID);

        if (self == null)
        {
            return;
        }

        SetAnimationParam(self.attackAnim_, AnimatorParamType.APT_Trigger);
        ActionCallBack callback = ActorObj.GetComponent <ActionCallBack>();

        if (null == callback)
        {
            return;
        }
        callback.AttackFinish           = FinishCallBack;
        callback.m_PlayBeAttackOneStep  = hit_1;
        callback.m_PlayBeAttackTwoStep  = hit_2;
        callback.m_PlayBeAttackEffect   = eff;
        callback.m_ShowChangePlayerInfo = changeVal;
        hasActionCallBackToCall         = true;
    }
Beispiel #2
0
    public void UpdateHandler()
    {
        //AnimatorStateInfo animatorState = m_EntityAnimator.GetCurrentAnimatorStateInfo(0);
        //if(animatorState.normalizedTime >= 1f)

        if (isPlayBack)
        {
            float newPlaybackTime = m_EntityAnimator.playbackTime + Time.deltaTime;
            if (newPlaybackTime > m_EntityAnimator.recorderStopTime)
            {
                newPlaybackTime = 0f;
                m_EntityAnimator.StopPlayback();
                isPlayBack = false;
                return;
            }
            m_EntityAnimator.playbackTime = newPlaybackTime;
        }

        if (stateList_ != null)
        {
            for (int i = 0; i < stateList_.Count; ++i)
            {
                if (stateList_[i].workingInst_ != null)
                {
                    BoxCollider box = ActorObj.GetComponent <BoxCollider>();
                    Vector3     pos = new Vector3(ActorObj.transform.position.x, ActorObj.transform.position.y, ActorObj.transform.position.z + box.center.z + box.size.z);
                    stateList_[i].workingInst_.transform.localPosition = pos;
                }
            }
        }
    }
Beispiel #3
0
    public void LookAt(GameObject target, ActionCallBack.LookAtFinishCallBack callback = null, float time = -1)
    {
        if (null == target)
        {
            return;
        }
        if (ActorObj == null)
        {
            return;
        }

        ActionCallBack acb = ActorObj.GetComponent <ActionCallBack>();

        if (ActorObj != null && acb != null)
        {
            acb.m_LookAtFinishCallBack = callback;
        }
        Hashtable args = new Hashtable();

        args.Add("time", time < 0? CalcRotateTime(ActorObj.transform, target.transform): time);
        args.Add("delay", 0.0f);
        args.Add("looktarget", target.transform.position);
        args.Add("oncomplete", "ActionLookAtFinishCallBack");
        args.Add("oncompleteparams", "end");
        args.Add("oncompletetarget", m_EntityObj);
        iTween.LookTo(ActorObj, args);
    }
Beispiel #4
0
        /// <summary>
        /// 判断技能是否使用完毕,有连招的会继续使用连招。
        /// </summary>
        /// <param name="actor">角色对象。</param>
        /// <param name="skillid">技能编号。</param>
        /// <returns>是否使用完毕。</returns>
        public static bool IsCastSkillOver(ActorObj actor, int skillid)
        {
            if (actor.curActorState != ACTOR_STATE.AS_ATTACK)
            {
                return(true);
            }

            //如果在攻击状态没有动作,则视为技能施放完毕
            if (actor.GetComponent <Animation>().isPlaying == false && actor.m_bIsTower == false)
            {
                return(true);
            }

            //判断连招,是否组合技能
            ComposeSkillDesc desc = CoreEntry.gGameDBMgr.GetComposeSkillDesc(actor.curCastSkillID, skillid);

            if (desc != null)
            {
                StateParameter param = new StateParameter();
                param.state            = ACTOR_STATE.AS_ATTACK;
                param.skillID          = skillid;
                param.isComposeSkill   = true;
                param.composeSkillDesc = desc;

                //请求连招切换,能连招则认为此技能结束了
                bool bRet = actor.ComposeSkillCanCastSkill(param.composeSkillDesc.changeTime);
                return(bRet);
            }

            return(false);
        }
Beispiel #5
0
        public override void OnEnter(ActorObj actorBase)
        {
            m_state = ACTOR_STATE.AS_STONE;

            m_actor = actorBase;

            //m_actor.PlayAction("stand");
            m_actor.GetComponent <Animation>().Stop();
        }
Beispiel #6
0
        public void Init(ActorObj actor)
        {
            m_AnimationActor = actor;

            if (m_AnimationActor != null)
            {
                m_Animation = m_AnimationActor.GetComponent <Animation>();
            }
        }
Beispiel #7
0
    void RegisterActionCallBack()
    {
        ActionCallBack acb = ActorObj.GetComponent <ActionCallBack>();

        acb.m_BeAttackFinishCallBack  = BeAttackActionFinishCallBack;
        acb.m_PlaySingBrustCallBack   = SingActionBrustCallBack;
        acb.m_PlaySingAcitonCallBack  = SingActionFinishCallBack;
        acb.m_PlayerDieFinishCallBack = DieActionFinishCallBack;
        acb.m_UpdateCallBack          = UpdateHandler;
    }
Beispiel #8
0
    public void MoveTo(Vector3 TargetPos, ActionCallBack.MoveFinishCallBack CallBack = null, bool bUseOffset = true, bool bPlayAnim = true, float moveTime = MOVETOTAGETTIME, int iVal = 0, bool lookTarget = true)
    {
        // one position to another is 0.5f
        float distance = Vector3.Distance(TargetPos, ActorObj.transform.position);

        if (distance < GlobalValue.MoveMinGap || Mathf.Approximately(distance, GlobalValue.MoveMinGap))
        {
            if (CallBack != null)
            {
                CallBack(iVal);
            }
            return;
        }
        if (bPlayAnim)
        {
            SetAnimationParam(GlobalValue.FMove, AnimatorParamType.APT_Float, distance);
        }
//			PlayEntityAction( GlobalValue.ActionName , GlobalValue.Action_Run);
        ActionCallBack callback = ActorObj.GetComponent <ActionCallBack>();

        callback.m_MoveFinishCallBack = CallBack;
        Hashtable args = new Hashtable();

        args.Add("easeType", iTween.EaseType.linear);
        args.Add("time", moveTime);
        args.Add("delay", 0.0f);
        if (lookTarget)
        {
            args.Add("looktarget", TargetPos);
            m_EntityObj.transform.LookAt(TargetPos);
        }
        args.Add("loopType", "none");
        //args.Add("onstart", "MoveStartCallBack");
        //args.Add("onstarttarget", m_EntityObj);
        args.Add("oncomplete", "ActionMoveFinishCallBack");
        args.Add("oncompleteparams", iVal);
        args.Add("oncompletetarget", m_EntityObj);
        args.Add("onupdate", "MoveUpdateCallBack");
        //args.Add("onupdatetarget", m_EntityObj);
        args.Add("onupdateparams", true);
        if (bUseOffset)
        {
            Vector3 shortPos = (TargetPos - m_EntityObj.transform.position).normalized;
            args.Add("position", TargetPos - shortPos * 0.5f);
        }
        else
        {
            args.Add("position", TargetPos);
        }

        iTween.MoveTo(m_EntityObj, args);
    }
Beispiel #9
0
        private void DoFightOver()
        {
            ActorObj winner = null;
            ActorObj loser  = null;

            if (mFightResult == 0)
            {
                winner = CoreEntry.gActorMgr.MainPlayer;
                loser  = CoreEntry.gActorMgr.GetPlayerActorByServerID(ArenaFighters[1 - mLocalIndex].RoleID);
            }
            else
            {
                winner = CoreEntry.gActorMgr.GetPlayerActorByServerID(ArenaFighters[1 - mLocalIndex].RoleID);
                loser  = CoreEntry.gActorMgr.MainPlayer;
            }

            if (null != winner)
            {
                PlayerAgent agent = winner.GetComponent <PlayerAgent>();
                if (null != agent)
                {
                    agent.enabled = false;
                }
            }
            if (null != loser)
            {
                PlayerAgent agent = loser.GetComponent <PlayerAgent>();
                if (null != agent)
                {
                    agent.enabled = false;
                }
                loser.OnDead(0, winner, null, null);
            }

            if (mFightResult == 0)
            {
                MainPanelMgr.Instance.ShowPanel("UIArenaSuccess");
            }
            else
            {
                MainPanelMgr.Instance.ShowPanel("UIArenaFail");
            }

            isFightOver = true;
        }
Beispiel #10
0
        public bool IsCastSkillOver(int nSkillID)
        {
            if (m_actor.curActorState == ACTOR_STATE.AS_ATTACK)
            {
                if (m_actor.GetComponent <Animation>().isPlaying == false && m_actor.m_bIsTower == false)
                {
                    LogMgr.UnityWarning("IsCastSkillOver.m_actor.animation.isPlaying == false :" + m_actor);
                    //如果在攻击状态没有动作,则视为技能施放完毕
                    return(true);
                }
            }
            else
            {
                return(true);
            }

            m_bNeedRandom = true;

            //判断连招
            StateParameter param = new StateParameter();

            param.state          = ACTOR_STATE.AS_ATTACK;
            param.skillID        = nSkillID;
            param.isComposeSkill = false;

            //是否组合技能
            ComposeSkillDesc composeSkillDesc = m_actor.m_gameDBMgr.GetComposeSkillDesc(m_actor.curCastSkillID, nSkillID);

            if (composeSkillDesc != null)
            {
                param.isComposeSkill   = true;
                param.composeSkillDesc = composeSkillDesc;
            }

            if (param.isComposeSkill)
            {
                bool bRet = m_actor.ComposeSkillCanCastSkill(param.composeSkillDesc.changeTime);
                return(bRet);
            }

            return(m_actor.curActorState != ACTOR_STATE.AS_ATTACK);
        }
Beispiel #11
0
    public void DealEntityDie(DeathMaster.DieActionType dieType = DeathMaster.DieActionType.DAT_Normal)
    {
        BattleActor self = Battle.Instance.GetActorByInstId(PlayerID);

        if (self != null)
        {
            self.SetIprop(PropertyType.PT_HpCurr, 0);
        }
        if (hitOver_)
        {
            dieType = Random.Range(0f, 1f) > 0.5f ? DeathMaster.DieActionType.DAT_Fly : DeathMaster.DieActionType.DAT_Knock;
            EffectAPI.Play((EFFECT_ID)GlobalValue.EFFECT_Dead, self.ControlEntity.ActorObj.transform.position, null, null, null, (EffectInst inst, ParamData pData) =>
            {
                if (hitoverEffectPlayed)
                {
                    GameObject.Destroy(inst.gameObject);
                    return;
                }
                hitoverEffectPlayed = true;
                inst.gameObject.AddComponent <Destroy>().lifetime = 0.5f;
            });

            //飞的是自己 回主城
            //if (PlayerID == GamePlayer.Instance.InstId)
            //{
            //    Battle.Instance.beFlied_ = true;
            //}
        }

        DeathMaster dm = ActorObj.GetComponent <DeathMaster>();

        GlobalInstanceFunction.Instance.setTimeScale(Battle.Instance.reportPlaySpeed_);
        if (dm == null)
        {
            dm = ActorObj.AddComponent <DeathMaster>();
        }
        dm.Do(dieType, self);
        AttaclPanel.Instance.SetEnityUIVisble(m_PlayerID, false);
        ClearState();
    }
Beispiel #12
0
        public void EventFunction(GameEvent ge, EventParameter parameter)
        {
            switch (ge)
            {
            case GameEvent.GE_NOTIFY_CAST_SKILL:
            {
                //释放技能
                int        skillID = (int)parameter.intParameter;
                GameObject actor   = parameter.goParameter;

                //调用actorbase释放技能
                ActorObj actorObj = actor.GetComponent <ActorObj>();

                //是否学习了该技能
                if (actorObj.IsHadLearnSkill(skillID))
                {
                    //玩家释放技能前选择目标
                    if (actorObj.mActorType == ActorType.AT_LOCAL_PLAYER)
                    {
                        //若没有目标则马上选择目标
                        CoreEntry.gActorMgr.MainPlayer.CheckSkillTarget();
                    }

                    actorObj.OnRunToAttack(skillID);
                    //actorObj.OnCastSkill(skillID);
                }
            }
            break;

            case GameEvent.GE_NOTIFY_SHOW_SKILL_SCOPE:
            {
                //释放技能
                int        skillID = (int)parameter.intParameter;
                GameObject actor   = parameter.goParameter;

                //调用actorbase释放技能
                ActorObj actorObj = actor.GetComponent <ActorObj>();

                //是否学习了该技能
                if (actorObj.IsHadLearnSkill(skillID))
                {
                    actorObj.OnShowSkillScope(skillID);
                    //actorObj.OnCastSkill(skillID);
                }
            }
            break;

            case GameEvent.GE_NOTIFY_HIDE_SKILL_SCOPE:
            {
                //释放技能
                int        skillID = (int)parameter.intParameter;
                GameObject actor   = parameter.goParameter;

                //调用actorbase释放技能
                ActorObj actorObj = actor.GetComponent <ActorObj>();

                //是否学习了该技能
                if (actorObj.IsHadLearnSkill(skillID))
                {
                    actorObj.OnHideSkillScope(skillID);
                    //actorObj.OnCastSkill(skillID);
                }
            }
            break;

            //
            case GameEvent.GE_SC_SKILLEFFECT:
            {
                MsgData_sCastEffect data = parameter.msgParameter as MsgData_sCastEffect;

                if (data == null)
                {
                    return;
                }


                //服务器这里只冒伤害数字
                bool bIsMainPlayer = false;

                BehitParam behitParam = new BehitParam();

                DamageParam damageParam = new DamageParam();
                damageParam.attackActor = CoreEntry.gActorMgr.GetActorByServerID(data.CasterID);
                damageParam.behitActor  = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);
                damageParam.skillID     = data.SkillID;
                damageParam.Flags       = data.Flags;
                damageParam.DamagaType  = data.DamagaType;
                damageParam.Damage      = (int)data.Damage;
                damageParam.IsClient    = false;


                behitParam.damgageInfo = damageParam;
                behitParam.displayType = (DamageDisplayType)data.DamagaType;
                behitParam.hp          = (int)data.Damage;


                if (behitParam.damgageInfo.attackActor != null &&
                    behitParam.damgageInfo.attackActor.mActorType == ActorType.AT_LOCAL_PLAYER)
                {
                    bIsMainPlayer = true;
                }

                if (behitParam.damgageInfo.attackActor != null)
                {
                    if (bIsMainPlayer)
                    {
                        behitParam.damgageInfo.attackActor.OnDamage((int)data.Damage, data.SkillID, bIsMainPlayer, behitParam);
                    }
                    else
                    {
                        //其他人要播受击动作
                        OnSkillDamage(damageParam);
                    }
                }
            }
            break;


            case GameEvent.GE_SC_OTHER_CASTSKILL_BEGIN:
            {
                MsgData_sCastBegan data = parameter.msgParameter as MsgData_sCastBegan;
                if (data == null)
                {
                    return;
                }
                ActorObj attackObj = CoreEntry.gActorMgr.GetActorByServerID(data.CasterID);

                if (attackObj == null)
                {
                    return;
                }

                if (attackObj != null && attackObj.mActorType == ActorType.AT_LOCAL_PLAYER)
                {
                    return;
                }



                //todo ,先强行同步位置
                attackObj.SetServerPosition(new Vector2(data.CasterPosX, data.CasterPosY));
                attackObj.OnCastSkill(data.SkillID, data.CasterID, data.TargetID, data.PosX, data.PosY);
            }
            break;


            case GameEvent.GE_SC_OTHER_CASTSKILL_END:
            {
                MsgData_sCastEnd data = parameter.msgParameter as MsgData_sCastEnd;
                if (data == null)
                {
                    return;
                }
                ActorObj attackObj = CoreEntry.gActorMgr.GetActorByServerID(data.CasterID);

                if (attackObj == null)
                {
                    return;
                }

                attackObj.SkillEnd(data.SkillID);
            }
            break;


            //hitback
            case GameEvent.GE_SC_KNOCKBACK:
            {
                MsgData_sKnockBack data = parameter.msgParameter as MsgData_sKnockBack;
                if (data == null)
                {
                    return;
                }
                ActorObj beHitActor  = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);
                ActorObj attackActor = CoreEntry.gActorMgr.GetActorByServerID(data.CasterID);

                if (beHitActor == null || attackActor == null)
                {
                    return;
                }

                beHitActor.OnHitBack(attackActor, data.MotionSpeed, data.PosX, data.PosY, data.MotionTime);
            }
            break;

            case GameEvent.GE_SC_ADDBUFFList:
            {
                MsgData_sAddBufferList data = parameter.msgParameter as MsgData_sAddBufferList;
                if (data == null)
                {
                    return;
                }
                ActorObj targetObj = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);
                if (targetObj == null)
                {
                    return;
                }
                for (int i = 0; i < data.BufferList.Count; i++)
                {
                    MsgData_sBuffer _buff    = data.BufferList[i];
                    BuffData        buffdata = new BuffData();
                    buffdata.BufferInstanceID = _buff.BufferInstanceID;
                    buffdata.buffType         = _buff.BufferTemplateID;
                    buffdata.Life             = _buff.Life;
                    buffdata.Count            = 1;
                    //buffdata.Param[0] = data.Param;
                    CoreEntry.gBuffMgr.AddBuff(buffdata, targetObj);
                }
            }
            break;

            case GameEvent.GE_SC_ADDBUFF:
            {
                MsgData_sAddBuffer data = parameter.msgParameter as MsgData_sAddBuffer;

                if (data == null)
                {
                    return;
                }

                /*
                 * if (data.BufferTemplateID == 24100001 || data.BufferTemplateID == 24100002)
                 * {
                 *  Debug.LogError("target目标 "+ data.TargetID +"  添加 iBuffId = " + data.BufferTemplateID);
                 * }
                 */
                // Debug.LogError("target目标 " + data.TargetID + "  添加 iBuffId = " + data.BufferTemplateID);
                ActorObj targetObj = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);

                if (targetObj == null)
                {
                    return;
                }

                BuffData buffdata = new BuffData();
                buffdata.BufferInstanceID = data.BufferInstanceID;
                buffdata.buffType         = data.BufferTemplateID;
                buffdata.Life             = data.Life;
                buffdata.Count            = 1;

                buffdata.Param[0] = data.Param;
                //LogMgr.LogError("SkillMgr AddBuff " + buffdata.buffType);
                CoreEntry.gBuffMgr.AddBuff(buffdata, targetObj);
            }
            break;

            case GameEvent.GE_SC_UPDATEBUFF:
            {
                MsgData_sUpdateBuffer data = parameter.msgParameter as MsgData_sUpdateBuffer;

                if (data == null)
                {
                    return;
                }

                BuffData buffdata = new BuffData();
                buffdata.BufferInstanceID = data.BufferInstanceID;
                buffdata.Life             = data.Life;
                buffdata.Count            = data.Count;
                buffdata.Param            = data.Param;
                //LogMgr.LogError("SkillMgr UpdateBuff " + buffdata.buffType);
                CoreEntry.gBuffMgr.UpdateBuff(buffdata);
            }
            break;

            case GameEvent.GE_SC_DELBUFF:
            {
                MsgData_sDelBuffer data = parameter.msgParameter as MsgData_sDelBuffer;
                if (data == null)
                {
                    return;
                }
                if (data.BufferTemplateID == 24100001 || data.BufferTemplateID == 24100002)
                {
                    //LogMgr.DebugLog("target目标 "+ data.TargetID + "  删除 iBuffId = " + data.BufferTemplateID);
                }

                //LogMgr.LogError("SkillMgr DelBuff " + data.BufferTemplateID);
                //  if(data.BufferInstanceID)
                ActorObj targetObj = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);

                if (targetObj != null)
                {
                    //LogMgr.LogError("SKillMgr CoreEntry.gBuffMgr.RemoveBuff " + data.BufferTemplateID);
                    CoreEntry.gBuffMgr.RemoveBuff(data.BufferInstanceID, targetObj);
                    if (targetObj.ServerID == CoreEntry.gActorMgr.MainPlayer.ServerID)
                    {
                        EventParameter msg = new EventParameter();
                        msg.longParameter = data.BufferTemplateID;
                        //Debug.LogError("删除BUFF  " + data.BufferTemplateID);
                        CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_CC_DELEBUFF, msg);
                    }
                }
            }
            break;

            case GameEvent.GE_SC_CAST_MOVE_EFFECRT:
            {
                MsgData_sCastMoveEffect data = parameter.msgParameter as MsgData_sCastMoveEffect;
                if (null == data)
                {
                    return;
                }

                if (data.caseterID == CoreEntry.gActorMgr.MainPlayer.ServerID)
                {
                    return;
                }

                ActorObj casterObj = CoreEntry.gActorMgr.GetActorByServerID(data.caseterID);
                if (null == casterObj)
                {
                    return;
                }

                LuaTable skill_action = CoreEntry.gSkillMgr.GetSkillActon(data.skillID);
                if (null == skill_action)
                {
                    return;
                }

                float   posX    = (float)data.posX;
                float   posZ    = (float)data.posY;
                Vector3 destPos = new Vector3(posX, CommonTools.GetTerrainHeight(new Vector2(posX, posZ)), posZ);

                AnimationCurveData curveData = casterObj.GetComponent <AnimationCurveData>();
                if (null == curveData)
                {
                    LogMgr.LogError(casterObj.gameObject.name + " has no AnimationCurveBase, skill id:" + data.skillID);

                    return;
                }

                casterObj.UseCurveData3(skill_action.Get <string>("animation"), destPos, null);
            }
            break;

            default:
                break;
            }
        }
Beispiel #13
0
    public void Beattack_1(int skillId, int skillLv, bool playAnim = true, bool isDead = false, bool isDodge = false, BattleActor attacker = null, bool playEffect = true)
    {
        //SkillData skill = SkillData.GetData(skillId);
        BattleActor entity = Battle.Instance.GetActorByInstId(PlayerID);

        if (entity == null)
        {
            return;
        }

        if (entity.isDead)
        {
            Reborn();
        }
        else if (skillId == 1031)//崩击
        {
            int effId = GetStateBeattackEffectID(skillId);
            if (effId != -1)
            {
                // 如果是防御特效
                ExcuteState(StateInst.ExcuteType.ET_Beattack, null, null, true);

                //die
                if (isDead)
                {
                    GlobalInstanceFunction.Instance.setTimeScale(Battle.Instance.reportPlaySpeed_ * 0.3f);
                    m_EntityAnimator.Play("Base Layer.beattack02", -1, 0.1f);
                    SetEntityActionTime(0f);
                    XShake shake = ActorObj.GetComponent <XShake>();
                    if (shake != null)
                    {
                        GameObject.Destroy(shake);
                    }
                    shake                         = ActorObj.AddComponent <XShake>();
                    shake.battlePos               = Battle.Instance.GetActorByInstId(PlayerID).BattlePos;
                    shake.originPos_              = ActorObj.transform.position;
                    shake.OnBeattackActionFinish += OnBeattackActionFinish;
                    shake.OnMoveBackActionFinish += OnMoveBackActionFinish;
                    m_bPlayingBeattackAction      = true;
                }
                else
                {
                    if (playAnim)
                    {
                        if (takeDmgAction.Equals(GlobalValue.TTakeDmg))
                        {
                            //if (!m_bPlayingBeattackAction)
                            //{
                            //    m_EntityAnimator.Play("Base Layer.beattack02", -1, 0.1f);
                            SetAnimationParam(takeDmgAction, AnimatorParamType.APT_Trigger);
                            //    m_EntityAnimator.StartRecording(0);
                            //    m_bPlayingBeattackAction = true;
                            //}
                            //else
                            //{
                            //    m_EntityAnimator.StopRecording();
                            //    m_EntityAnimator.StartPlayback();
                            //    m_EntityAnimator.playbackTime = 0f;
                            //    isPlayBack = true;
                            //}
                            //SetEntityActionTime(0);
                            //GlobalInstanceFunction.Instance.Invoke(() =>
                            //{
                            XShake shake = ActorObj.GetComponent <XShake>();
                            if (shake != null)
                            {
                                GameObject.Destroy(shake);
                            }
                            shake = ActorObj.AddComponent <XShake>();
                            shake.OnlyBack();
                            selfActor_                    = Battle.Instance.GetActorByInstId(m_PlayerID);
                            shake.battlePos               = selfActor_.BattlePos;
                            shake.originPos_              = ActorObj.transform.position;//Battle.Instance.GetStagePointByIndex(selfActor_.BattlePos).position;
                            shake.OnBeattackActionFinish += OnBeattackActionFinish;
                            shake.OnMoveBackActionFinish += OnMoveBackActionFinish;
                            //SetEntityActionTime(1);
                            //}, 1);
                        }
                        else
                        {
                            //if (!m_bPlayingBeattackAction)
                            //{
                            SetAnimationParam(takeDmgAction, AnimatorParamType.APT_Trigger);
                            //    m_EntityAnimator.StartRecording(0);
                            //    m_bPlayingBeattackAction = true;
                            //}
                            //else
                            //{
                            //    m_EntityAnimator.StopRecording();
                            //    m_EntityAnimator.StartPlayback();
                            //    m_EntityAnimator.playbackTime = 0f;
                            //    isPlayBack = true;
                            //}
                        }
                    }
                }
            }
            else
            {
                m_bPlayingBeattackAction = false;
                EffectAPI.PlaySceneEffect(EFFECT_ID.EFFECT_BengjiMiss, Vector3.zero, ActorObj.transform, null, true);
            }
        }
        else if (/*skill != null &&*/ skillId != 2391 /*复活技能不调用受击动作*/)
        {
            if (playEffect)
            {
                int effId = GetStateBeattackEffectID(skillId);
                if (effId != -1)
                {
                    SkillData skilldata = null;
                    if (attacker != null)
                    {
                        skilldata = SkillData.GetData(skillId, skillLv);
                        if (skilldata != null)
                        {
                            //如果该闪避但没有闪避状态 强制闪避一下。。。
                            if (isDodge && !HasState(StateType.ST_Dodge))
                            {
                                if (crtStateData_._BeattackPkg.effectId_ != 0)
                                {
                                    EffectAPI.Play(EFFECT_ID.EFFECT_DODGE, ActorObj, null, null, null, (EffectInst ei, ParamData data) =>
                                    {
                                        ei.transform.parent     = ActorObj.transform;
                                        ei.transform.localScale = Vector3.one;
                                    });
                                }
                            }
                            ExcuteState(StateInst.ExcuteType.ET_Beattack, null, null, skilldata._IsPhysic, isDodge);
                            takeDmgAction = GlobalValue.TDodge;
                        }
                    }
                }
            }

            //die
            if (isDead)
            {
                GlobalInstanceFunction.Instance.setTimeScale(Battle.Instance.reportPlaySpeed_ * 0.7f);
                m_EntityAnimator.Play("Base Layer.beattack02", -1, 0.1f);
                SetEntityActionTime(0f);
                XShake shake = ActorObj.GetComponent <XShake>();
                if (shake != null)
                {
                    GameObject.Destroy(shake);
                }
                shake                         = ActorObj.AddComponent <XShake>();
                shake.battlePos               = Battle.Instance.GetActorByInstId(PlayerID).BattlePos;
                shake.originPos_              = ActorObj.transform.position;
                shake.OnBeattackActionFinish += OnBeattackActionFinish;
                shake.OnMoveBackActionFinish += OnMoveBackActionFinish;
                m_bPlayingBeattackAction      = true;
            }
            else
            {
                if (playAnim)
                {
                    if (takeDmgAction.Equals(GlobalValue.TTakeDmg))
                    {
                        //if (!m_bPlayingBeattackAction)
                        //{
                        SetAnimationParam(takeDmgAction, AnimatorParamType.APT_Trigger);
                        //m_EntityAnimator.StartRecording(0);
                        //m_bPlayingBeattackAction = true;
                        //}
                        //else
                        //{
                        //    m_EntityAnimator.StopRecording();
                        //    m_EntityAnimator.StartPlayback();
                        //    m_EntityAnimator.playbackTime = 0f;
                        //    isPlayBack = true;
                        //}
                        //SetEntityActionTime(0);
                        //GlobalInstanceFunction.Instance.Invoke(() =>
                        //{
                        XShake shake = ActorObj.GetComponent <XShake>();
                        if (shake != null)
                        {
                            GameObject.Destroy(shake);
                        }
                        shake = ActorObj.AddComponent <XShake>();
                        shake.OnlyBack();
                        selfActor_                    = Battle.Instance.GetActorByInstId(m_PlayerID);
                        shake.battlePos               = selfActor_.BattlePos;
                        shake.originPos_              = ActorObj.transform.position;//Battle.Instance.GetStagePointByIndex(selfActor_.BattlePos).position;
                        shake.OnBeattackActionFinish += OnBeattackActionFinish;
                        shake.OnMoveBackActionFinish += OnMoveBackActionFinish;
                        //SetEntityActionTime(1);
                        //}, 1);
                    }
                    else
                    {
                        //if (!m_bPlayingBeattackAction)
                        //{
                        SetAnimationParam(takeDmgAction, AnimatorParamType.APT_Trigger);
                        //    m_EntityAnimator.StartRecording(0);
                        //    m_bPlayingBeattackAction = true;
                        //}
                        //else
                        //{
                        //    m_EntityAnimator.StopRecording();
                        //    m_EntityAnimator.StartPlayback();
                        //    m_EntityAnimator.playbackTime = 0f;
                        //    isPlayBack = true;
                        //}
                    }
                }
            }
        }
        takeDmgAction = GlobalValue.TTakeDmg;
    }
Beispiel #14
0
        // Use this for initialization
        void Start()
        {
            CancelInvoke("Start");
            ////
            //m_skillBase = this.transform.root.gameObject.GetComponent<SkillBase>();
            if (m_skillBase == null || m_skillBase.m_actor == null)
            {
                return;
            }

            // 普通分身不产生分身
            if (m_skillBase.m_actor.m_bSummonMonster)
            {
                return;
            }

            // 是否删除之前召唤的生物
            if (m_summonDesc.killBefore == 1)
            {
                if (m_skillBase.m_actor.m_skillSummonList == null)
                {
                    m_skillBase.m_actor.m_skillSummonList = new List <ActorObj.SummonData>();
                }

                int index = 0;
                while (true)
                {
                    if (m_skillBase.m_actor.m_skillSummonList.Count <= index)
                    {
                        break;
                    }
                    ActorObj.SummonData summon = m_skillBase.m_actor.m_skillSummonList[index];
                    if (m_skillBase.m_actor.m_skillSummonList[index].SummonID == m_summonDesc.npcID)
                    {
                        OnSummonDeath(m_skillBase.m_actor.m_skillSummonList[index].entityid);
                        m_skillBase.m_actor.m_skillSummonList.Remove(summon);
                    }
                    else
                    {
                        index++;
                    }
                }
            }

            Vector3 origin = m_skillBase.m_actor.transform.position;


            int POS_TYPE_TARGET = 6;

            for (int i = 0; i < m_summonDesc.npcCount; i++)
            {
                Vector3 summonPos = GetSummonPos(m_skillBase.m_actor.transform, i);

                if (m_summonDesc.npcPosType == POS_TYPE_TARGET) //召唤位置在敌方脚下
                {
                    ActorObj actorObj = m_skillBase.m_actor.GetAttackObj();

                    if (actorObj == null)
                    {
                        actorObj = m_skillBase.m_hitActor;
                    }
                    else
                    {
                        return;
                    }

                    summonPos = actorObj.transform.position;
                }
                else
                {
                    summonPos = GetSummonPos(m_skillBase.m_actor.transform, i);
                }


                if (summonPos != Vector3.zero)
                {
                    // 是否有障碍
                    Vector3 bornPos = BaseTool.instance.GetWallHitPoint(origin, summonPos);
                    // 地面高度
                    bornPos = BaseTool.instance.GetGroundPoint(bornPos);
                    // 载入
                    GameObject obj = null;

                    if (m_summonDesc.summonType == 2)
                    {
                        CoreEntry.gObjPoolMgr.PushToPool(m_skillBase.m_actor.resid); // 加到对象池子里
                        CoreEntry.gGameMgr.SpawnMonster(m_skillBase.m_actor.resid, bornPos, out obj);
                    }
                    else
                    {
                        CoreEntry.gObjPoolMgr.PushToPool(m_summonDesc.npcID); // 加到内存池子里
                        CoreEntry.gGameMgr.SpawnMonster(m_summonDesc.npcID, bornPos, out obj);
                    }

                    obj.transform.localRotation = m_skillBase.m_actor.transform.localRotation;

                    ActorObj summonActorbase = obj.GetComponent <ActorObj>();
                    if (m_summonDesc.killBefore == 1)
                    {
                        ActorObj.SummonData data = new ActorObj.SummonData();
                        data.SummonID     = m_summonDesc.npcID;
                        data.entityid     = summonActorbase.entityid;
                        data.lifeTime     = m_summonDesc.lifeTime;
                        data.deadthToKill = m_summonDesc.deadthToKill;
                        data.startTime    = Time.time;
                        m_skillBase.m_actor.m_skillSummonList.Add(data);
                    }

                    summonActorbase.m_bSummonMonster = true; // 召唤生物标记

                    if (m_skillBase.m_actor.mActorType == ActorType.AT_PVP_PLAYER)
                    {
                        summonActorbase.mActorType = m_skillBase.m_actor.mActorType;
                    }

                    if (m_skillBase.m_actor.mActorType == ActorType.AT_LOCAL_PLAYER)
                    {
                        summonActorbase.TeamType = 1;
                    }
                    else
                    {
                        summonActorbase.TeamType = 3;
                    }

                    if (summonActorbase.mActorType == ActorType.AT_BOSS)
                    {
                        summonActorbase.mActorType = ActorType.AT_AVATAR;
                    }

                    // 1.属性从召唤者继承*表里设置的属性百分比
                    if (m_summonDesc.summonType == 1)
                    {
                        // m_skillBase.m_actor.mBaseAttr.SummonTo(summonActorbase.mBaseAttr);
                        summonActorbase.curHp = summonActorbase.mBaseAttr.MaxHP;

                        // 重置AI
                        Destroy(summonActorbase.GetComponent <ActorAgent>());
                        ActorAgent actorAgent = null;
                        if (m_summonDesc.followMe)
                        {
                            actorAgent = summonActorbase.gameObject.AddComponent <PlayerAgent>();
                        }


                        ActorObj actorobj = summonActorbase.GetComponent <ActorObj>();

                        actorAgent.enabled = true;
                        actorobj.enabled   = true;
                        //summonActorbase.actorCreatureInfo.battleSpeed = m_skillBase.m_actor.actorCreatureInfo.battleSpeed;
                        //summonActorbase.mBaseAttr.Speed = summonActorbase.actorCreatureInfo.battleSpeed;
                        actorobj.SetSpeed(summonActorbase.mBaseAttr.Speed);
                    }
                    else
                    // 2.属性从召唤者继承*表里设置的属性百分比 模型外观变成召唤者
                    if (m_summonDesc.summonType == 2)
                    {
                        // 设置当前血量百分比
                        BaseAttr newCardAttr = new BaseAttr();
                        summonActorbase.mBaseAttr = newCardAttr;
                        summonActorbase.mBaseAttr = newCardAttr;
                        // m_skillBase.m_actor.mBaseAttr.SummonTo(summonActorbase.mBaseAttr);
                        float fHpRatio = (float)m_skillBase.m_actor.curHp / (float)m_skillBase.m_actor.mBaseAttr.MaxHP;
                        summonActorbase.curHp = (int)(summonActorbase.mBaseAttr.MaxHP * fHpRatio);
                        //
                        //MonsterHeath monsterHeath = summonActorbase.GetComponent<MonsterHeath>();
                        //if (monsterHeath != null)
                        //    monsterHeath.ResetHp(summonActorbase.mBaseAttr.MaxHP);
                        //PlayerHeath  playerHeath  = summonActorbase.GetComponent<PlayerHeath>();
                        //if (playerHeath != null)
                        //    playerHeath.OnResetHP();

                        // 重置AI
                        Destroy(summonActorbase.GetComponent <ActorAgent>());

                        ActorAgent actorAgent = null;
                        if (m_summonDesc.followMe)
                        {
                            actorAgent = summonActorbase.gameObject.AddComponent <PlayerAgent>();
                        }

                        // 设置速度
                        if (actorAgent != null)
                        {
                            actorAgent.enabled = true;
                            ActorObj actorobj = summonActorbase.GetComponent <ActorObj>();
                            actorobj.enabled = true;

                            //summonActorbase.actorCreatureInfo.battleSpeed = m_skillBase.m_actor.actorCreatureInfo.battleSpeed;
                            //summonActorbase.mBaseAttr.Speed = summonActorbase.actorCreatureInfo.battleSpeed;
                            actorobj.SetSpeed(summonActorbase.mBaseAttr.Speed);
                        }

                        // 颜色
                        Color color = new Color(67f / 255f, 146f / 255f, 223f / 255f, 205f / 255f);
                        summonActorbase.SetMaterialColor("DZSMobile/CharacterColor", "_BobyColor", color);
                        //summonActorbase.NoRecoverShader();

                        summonActorbase.m_bNoDieAction = true; // 不播放死亡动作
                    }

                    //
                    if (m_summonDesc.buffID != 0)
                    {
                        //         summonActorbase.Addbuff(m_summonDesc.buffID, m_skillBase.m_actor, 0);
                    }
                }
            }
        }