Example #1
0
    //受击飞
    public void BeHitFly(SMsgFightHitFly_SC sMsgFightHitFly_SC)
    {
        //if (m_FSMSystem.CurrentStateID == StateID.MonsterBeHitFly)
        //{
        //    m_MonsterBeHitFlyState.BeHitWhenFlying(sMsgFightHitFly_SC);
        //}
        //else
        //{
        //    m_MonsterBeHitFlyState.BeHitFly(sMsgFightHitFly_SC);
        //    m_FSMSystem.PerformTransition(Transition.MonsterToBeHitFly);
        //}
        if (m_FSMSystem.CurrentStateID == StateID.MonsterBeAttacked ||
            m_FSMSystem.CurrentStateID == StateID.MonsterBeAdsorb ||
            m_FSMSystem.CurrentStateID == StateID.MonsterBeHitFly ||
            m_FSMSystem.CurrentStateID == StateID.MonsterBeHorde ||
            m_FSMSystem.CurrentStateID == StateID.MonsterStand

            )
        {
            ((MonsterFsmState)m_FSMSystem.CurrentState).DoNotSendBeatEnd = true;
        }
        else
        {
            ((MonsterFsmState)m_FSMSystem.CurrentState).DoNotSendBeatEnd = false;
        }

        m_MonsterBeHitFlyState.BeHitFly(sMsgFightHitFly_SC);
        m_FSMSystem.PerformTransition(Transition.MonsterToBeHitFly);
    }
Example #2
0
    public void BeHitFly(SMsgFightHitFly_SC smsg)
    {
        m_g = this.m_PlayerBehaviour.HitFlyHeight;

        m_time = smsg.hSpedd * 0.1f * 2 / m_g;  //公式

        //位置处理
        mCorrectPos = mCorrectPos.GetFromServer(smsg.hitedPosX, smsg.hitedPosY);

        Vector3 unitDir = new Vector3(smsg.directionX, 0, smsg.directionY * -1f);

        m_motionVector = unitDir.normalized * smsg.lSpeed * 0.1f;

        m_angle = 90 - Mathf.Atan2(smsg.directionY * -1f, smsg.directionX) * Mathf.Rad2Deg + 180;

        //TraceUtil.Log("下发加速度的值:" + smsg.Accelerated);

        if (smsg.Accelerated != 0)
        {
            m_accelerationVector = m_motionVector * (smsg.Accelerated * 1f / smsg.lSpeed);
        }
        else
        {
            m_accelerationVector = Vector3.zero;
        }

        //TraceUtil.Log("speed"+ m_motionVector + "accleration:" + m_accelerationVector +" ,g:" + m_g + " ,时间:" + m_time);

        //高度位移
        m_highVector = new Vector3(0, smsg.hSpedd * 0.1f, 0);
        gVector      = new Vector3(0, m_g, 0);
    }
Example #3
0
    public static SMsgHitFlyContextNum_SC ParseResultPackage(byte[] pkgData)
    {
        int offset = 0;
        int singleContextLength = Marshal.SizeOf(typeof(SMsgFightHitFly_SC));

        SMsgHitFlyContextNum_SC sMsgHitFlyContextNum_SC;

        offset += PackageHelper.ReadData(pkgData.Skip(offset).ToArray(), out sMsgHitFlyContextNum_SC.byContextNum);
        sMsgHitFlyContextNum_SC.list = new List <SMsgFightHitFly_SC>();
        for (int i = 0; i < sMsgHitFlyContextNum_SC.byContextNum; i++)
        {
            SMsgFightHitFly_SC sMsgFightHitFly_SC = SMsgFightHitFly_SC.ParseResultPackage(pkgData.Skip(offset).Take(singleContextLength).ToArray());
            sMsgHitFlyContextNum_SC.list.Add(sMsgFightHitFly_SC);
            offset += singleContextLength;
        }
        return(sMsgHitFlyContextNum_SC);
    }
Example #4
0
    public void BeHitFly(SMsgFightHitFly_SC smsg)
    {
        m_g = this.m_MonsterBehaviour.m_MonsterConfigData._flyHigh;
        m_h = this.m_MonsterBehaviour.m_MonsterConfigData._fly_initial_high;

        //时间公式
        //m_time = smsg.hSpedd * 0.1f * 2 / m_g;
        float speed = smsg.hSpedd * 0.1f;

        m_time = (speed + Mathf.Sqrt(speed * speed + 2 * m_g * m_h)) / m_g;

        //位置处理
        mCorrectPos = Vector3.zero;
        mCorrectPos = mCorrectPos.GetFromServer(smsg.hitedPosX, smsg.hitedPosY) + Vector3.up * m_h;

        Vector3 unitDir = new Vector3(smsg.directionX, 0, smsg.directionY * -1f);

        m_motionVector = unitDir.normalized * smsg.lSpeed * 0.1f;

        m_angle = 90 - Mathf.Atan2(smsg.directionY * -1f, smsg.directionX) * Mathf.Rad2Deg + 180;

        //TraceUtil.Log("下发加速度的值:" + smsg.Accelerated);

        if (smsg.Accelerated != 0)
        {
            m_accelerationVector = m_motionVector * (smsg.Accelerated * 1f / smsg.lSpeed);
        }
        else
        {
            m_accelerationVector = Vector3.zero;
        }

        //TraceUtil.Log("speed"+ m_motionVector + "accleration:" + m_accelerationVector +" ,g:" + m_g + " ,时间:" + m_time);

        //高度位移
        m_highVector = new Vector3(0, smsg.hSpedd * 0.1f, 0);
        gVector      = new Vector3(0, m_g, 0);
    }
Example #5
0
    private void BeatFly(long uid, Vector3 pos, Vector3 dir)
    {
        SMsgFightHitFly_SC sMsgFightHitFly_SC = new SMsgFightHitFly_SC();

        sMsgFightHitFly_SC.uidFighter  = uid;
        sMsgFightHitFly_SC.hitedPosX   = pos.x * 10.0f;
        sMsgFightHitFly_SC.hitedPosY   = -pos.z * 10.0f;
        sMsgFightHitFly_SC.directionX  = dir.x;
        sMsgFightHitFly_SC.directionY  = -dir.z;
        sMsgFightHitFly_SC.lSpeed      = (int)(m_impactData.m_beatFlySpeed * 10.0f);
        sMsgFightHitFly_SC.Accelerated = (int)(m_impactData.m_beatFlyAcceleration * 10.0f);
        sMsgFightHitFly_SC.hSpedd      = (int)(m_impactData.m_beatFlyVerticalSpeed * 10.0f);
        RaiseEvent(EventTypeEnum.FightFly.ToString(), sMsgFightHitFly_SC);

        //send to server
        SMsgFightHitFly_CS sMsgFightHitFly_CS = new SMsgFightHitFly_CS();

        sMsgFightHitFly_CS.uidFighter = uid;
        sMsgFightHitFly_CS.byType     = 1;
        sMsgFightHitFly_CS.hitedPosX  = pos.x * 10.0f;
        sMsgFightHitFly_CS.hitedPosY  = -pos.z * 10.0f;
        //NetServiceManager.Instance.BattleService.SendFightHitFlyCS(sMsgFightHitFly_CS);
        beatFlyList.Add(sMsgFightHitFly_CS);
    }