Exemplo n.º 1
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();
    }
    //==========================处理网络数据结束=============================================================
    //==========================处理摇杆等本地操作开始=======================================================
    void Start()
    {
        bloodStrip = transform.gameObject.AddComponent <BloodStrip>();
        bloodStrip.InitBloodStrip(mActorAttr);
        InitWillUsedPrefabs();
        Camera mCamera = transform.Find("camera").GetComponent <Camera>();

        if (this.IsETCControl == false)
        {
            mCamera.enabled = false;
            return;
        }
        mCamera.enabled = true;
        _FightCamera    = mCamera;
        splatManager    = ActorObj.AddComponent <SplatManager>();
        InitSkill();
        splatManager.AutoInit();
        joy_move    = GameObject.Find("Joystick_move").GetComponent <ETCJoystick>();
        joy_skill_1 = GameObject.Find("Joystick_skill_1").GetComponent <ETCJoystick>();
        button_1    = GameObject.Find("ETCButton_1").GetComponent <ETCButton>();
        joy_skill_2 = GameObject.Find("Joystick_skill_2").GetComponent <ETCJoystick>();
        button_2    = GameObject.Find("ETCButton_2").GetComponent <ETCButton>();
        joy_skill_3 = GameObject.Find("Joystick_skill_3").GetComponent <ETCJoystick>();
        button_3    = GameObject.Find("ETCButton_3").GetComponent <ETCButton>();
        //joy_skill_4 = GameObject.Find("Joystick_skill_4").GetComponent<ETCJoystick>();
        button_4     = GameObject.Find("ETCButton_4").GetComponent <ETCButton>();
        image_quxiao = GameObject.Find("Image_quxiao");
        image_quxiao.SetActive(false);
        image_quxiao2 = GameObject.Find("Image_quxiao2");
        image_quxiao2.SetActive(false);
        ScreenWidth      = Screen.width;
        ScreenHeigth     = Screen.height;
        ScreenScale      = Screen.width * 1000 / 1920;   //已宽度为准的缩放比例
        ScreenWidth_Min  = ScreenWidth - 325 * ScreenScale / 1000;
        ScreenWidth_Max  = ScreenWidth - 175 * ScreenScale / 1000;
        ScreenHeigth_Min = ScreenHeigth - 325 * ScreenScale / 1000;
        ScreenHeigth_Max = ScreenHeigth - 175 * ScreenScale / 1000;
        //Debug.LogErrorFormat("Screen==========>{0},{1},{2}", ScreenWidth, ScreenHeigth, ScreenScale);
        //Debug.LogErrorFormat("Scale===========>{0},{1},{2},{3}", ScreenWidth_Min, ScreenWidth_Max, ScreenHeigth_Min, ScreenHeigth_Max);
        if (joy_move != null)
        {
            joy_move.onMoveStart.AddListener(StartMoveCallBack);
            joy_move.onMove.AddListener(MoveCallBack);
            joy_move.onMoveEnd.AddListener(EndMoveCallBack);
        }
        if (button_1 != null)
        {
            switch (SkillControlType_1)
            {
            case SkillControlType.Button_KeyDown:
            case SkillControlType.Button_KeyUp:    //操作上都生效,网络不一定都发送
                joy_skill_1.activated = false;
                button_1.activated    = true;
                button_1.onUp.AddListener(onUp_Skill_1);
                button_1.onDown.AddListener(onDown_Skill_1);
                break;

            case SkillControlType.Joy_Angle:
                button_1.activated    = false;
                button_1.visible      = false;
                joy_skill_1.activated = true;
                joy_skill_1.onMoveStart.AddListener(StartMoveCallBack_Skill_1);
                joy_skill_1.onMove.AddListener(MoveCallBack_Skill_1);
                joy_skill_1.onMoveEnd.AddListener(EndMoveCallBack_Skill_1);
                break;

            case SkillControlType.Joy_XY:
                button_1.activated    = false;
                button_1.visible      = false;
                joy_skill_1.activated = true;
                joy_skill_1.activated = true;
                joy_skill_1.onMoveStart.AddListener(StartMoveCallBack_Skill_1);
                joy_skill_1.onMove.AddListener(MoveCallBack_Skill_1);
                joy_skill_1.onMoveEnd.AddListener(EndMoveCallBack_Skill_1);
                break;
            }
        }
        if (button_2 != null)
        {
            switch (SkillControlType_2)
            {
            case SkillControlType.Button_KeyDown:
            case SkillControlType.Button_KeyUp:
                joy_skill_2.activated = false;
                button_2.activated    = true;
                button_2.onUp.AddListener(onUp_Skill_2);
                button_2.onDown.AddListener(onDown_Skill_2);
                break;

            case SkillControlType.Joy_Angle:
                button_2.activated    = false;
                button_2.visible      = false;
                joy_skill_2.activated = true;
                joy_skill_2.onMoveStart.AddListener(StartMoveCallBack_Skill_2);
                joy_skill_2.onMove.AddListener(MoveCallBack_Skill_2);
                joy_skill_2.onMoveEnd.AddListener(EndMoveCallBack_Skill_2);
                break;

            case SkillControlType.Joy_XY:
                button_2.activated    = false;
                button_2.visible      = false;
                joy_skill_2.activated = true;
                joy_skill_2.onMoveStart.AddListener(StartMoveCallBack_Skill_2);
                joy_skill_2.onMove.AddListener(MoveCallBack_Skill_2);
                joy_skill_2.onMoveEnd.AddListener(EndMoveCallBack_Skill_2);
                break;
            }
        }
        if (button_3 != null)
        {
            switch (SkillControlType_3)
            {
            case SkillControlType.Button_KeyDown:
            case SkillControlType.Button_KeyUp:
                joy_skill_3.activated = false;
                button_3.activated    = true;
                button_3.onUp.AddListener(onUp_Skill_3);
                button_3.onDown.AddListener(onDown_Skill_3);
                break;

            case SkillControlType.Joy_Angle:
                button_3.activated    = false;
                button_3.visible      = false;
                joy_skill_3.activated = true;
                joy_skill_3.onMoveStart.AddListener(StartMoveCallBack_Skill_3);
                joy_skill_3.onMove.AddListener(MoveCallBack_Skill_3);
                joy_skill_3.onMoveEnd.AddListener(EndMoveCallBack_Skill_3);
                break;

            case SkillControlType.Joy_XY:
                button_3.activated    = false;
                button_3.visible      = false;
                joy_skill_3.activated = true;
                joy_skill_3.onMoveStart.AddListener(StartMoveCallBack_Skill_3);
                joy_skill_3.onMove.AddListener(MoveCallBack_Skill_3);
                joy_skill_3.onMoveEnd.AddListener(EndMoveCallBack_Skill_3);
                break;
            }
        }
        if (button_4 != null)
        {
            switch (SkillControlType_4)
            {
            case SkillControlType.Button_KeyDown:
            case SkillControlType.Button_KeyUp:
                //joy_skill_4.activated = false;
                button_4.activated = true;
                button_4.onUp.AddListener(onUp_Skill_4);
                button_4.onDown.AddListener(onDown_Skill_4);
                break;

            case SkillControlType.Joy_Angle:
                button_4.activated = false;
                //joy_skill_4.activated = true;
                //joy_skill_4.onMoveStart.AddListener(StartMoveCallBack_Skill_4);
                //joy_skill_4.onMove.AddListener(MoveCallBack_Skill_4);
                //joy_skill_4.onMoveEnd.AddListener(EndMoveCallBack_Skill_4);
                break;

            case SkillControlType.Joy_XY:
                button_4.activated = false;
                //joy_skill_4.activated = true;
                //joy_skill_4.onMoveStart.AddListener(StartMoveCallBack_Skill_4);
                //joy_skill_4.onMove.AddListener(MoveCallBack_Skill_4);
                //joy_skill_4.onMoveEnd.AddListener(EndMoveCallBack_Skill_4);
                break;
            }
        }
    }
Exemplo n.º 3
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;
    }