public void Refresh(Vector3 a_pos, float a_rotation, CharAnim2.ePose a_anim = CharAnim2.ePose.eStand, float a_health = 100f, float a_energy = 100f)
 {
     if (this.RefreshStatus(a_health, a_energy))
     {
         if (!this.m_visible)
         {
             this.SwitchVisibility();
             base.transform.position = a_pos;
             base.transform.rotation = Quaternion.Euler(0f, a_rotation, 0f);
         }
         if (null != this.m_animControl)
         {
             this.m_animControl.m_isTakingAction = (CharAnim2.ePose.eAttack == a_anim);
             this.m_animControl.m_isSitting      = (CharAnim2.ePose.eSit == a_anim);
             this.m_sound.enabled = !this.m_animControl.m_isSitting;
         }
         else if (null != this.m_animControl2)
         {
             this.m_animControl2.PlayAnimation(a_anim);
         }
         this.m_targetPos = a_pos;
         this.m_targetRot = Quaternion.Euler(0f, a_rotation, 0f);
         float num = Time.time - this.m_lastUpdate;
         if (num > 0f && num < 1f)
         {
             this.m_interpSpeed = 1f / num * this.m_interpPercent;
         }
         this.m_lastUpdate = Time.time;
     }
 }
示例#2
0
    public void PlayAnimation(CharAnim2.ePose a_anim)
    {
        if (null != base.animation)
        {
            switch (a_anim)
            {
            case CharAnim2.ePose.eAttack:
                base.animation.CrossFade(this.m_attackAni, this.m_fadeDur);
                return;

            case CharAnim2.ePose.eDead:
                base.animation.CrossFade(this.m_dieAni, this.m_fadeDur);
                return;

            case CharAnim2.ePose.eSit:
                base.animation.CrossFade(this.m_sitAni, this.m_fadeDur);
                return;
            }
            base.animation.CrossFade((!this.m_isMoving) ? this.m_idleAni : this.m_runAni, this.m_fadeDur);
        }
    }
示例#3
0
    private void GetAndUpdateOwnPlayer(NetIncomingMessage a_msg)
    {
        byte b = a_msg.ReadByte();

        CharAnim2.ePose a_anim   = ((b & 0x80) == 128) ? CharAnim2.ePose.eAttack : CharAnim2.ePose.eStand;
        float           a_health = (int)(b = (byte)(b & 0x7F));
        byte            b2       = a_msg.ReadByte();

        m_isInVehicle = (128 == (b2 & 0x80));
        float a_energy = (int)(b2 = (byte)(b2 & 0x7F));

        if (!m_isInVehicle)
        {
            Vector3 zero = Vector3.zero;
            zero.x = (float)a_msg.ReadInt16() * 0.1f;
            zero.z = (float)a_msg.ReadInt16() * 0.1f;
            float a_rot = (float)(int)a_msg.ReadByte() / 255f * 360f;
            UpdateOrSpawnCharacter(m_myOnlineId, zero, a_rot, eCharType.ePlayer, a_anim, a_health, a_energy);
        }
        else if (IsSpawned())
        {
            m_players[m_myOnlineId].RefreshStatus(a_health, a_energy);
        }
    }
示例#4
0
    private void UpdateOrSpawnCharacter(int a_onlineId, Vector3 a_pos, float a_rot, eCharType a_type, CharAnim2.ePose a_anim, float a_health, float a_energy = 100f)
    {
        RemoteCharacter[] array = null;
        switch (a_type)
        {
        case eCharType.ePlayer:
        case eCharType.ePlayerFemale:
            array = m_players;
            break;

        case eCharType.eCar:
            array = m_cars;
            break;

        default:
            array = m_npcs;
            break;
        }
        if (a_onlineId <= -1 || a_onlineId >= array.Length)
        {
            return;
        }
        bool flag = array != null && null == array[a_onlineId];

        if (flag && !(0f < a_health))
        {
            return;
        }
        CharData[] array2 = null;
        switch (a_type)
        {
        case eCharType.ePlayer:
        case eCharType.ePlayerFemale:
            array2 = m_playerData;
            break;

        default:
            array2 = m_npcData;
            break;

        case eCharType.eCar:
            break;
        }
        if (flag)
        {
            GameObject gameObject = (GameObject)Object.Instantiate(m_remoteCharPrefab);
            array[a_onlineId] = gameObject.GetComponent <RemoteCharacter>();
            array[a_onlineId].Spawn(a_onlineId, a_type, (a_type == eCharType.ePlayer || a_type == eCharType.ePlayerFemale) && m_myOnlineId == a_onlineId);
            if (array2 != null)
            {
                array[a_onlineId].SetInfo(array2[a_onlineId]);
            }
            switch (a_type)
            {
            case eCharType.ePlayer:
            case eCharType.ePlayerFemale:
                gameObject.name = "player_" + array2[a_onlineId].name + "_" + a_onlineId;
                if (m_myOnlineId == a_onlineId)
                {
                    BirdCam birdCam = (BirdCam)Object.FindObjectOfType(typeof(BirdCam));
                    birdCam.m_target = gameObject.transform;
                    AudioListener audioListener = (AudioListener)Object.FindObjectOfType(typeof(AudioListener));
                    if (null != audioListener)
                    {
                        Object.Destroy(audioListener);
                    }
                    gameObject.AddComponent <AudioListener>();
                }
                break;

            default:
                gameObject.name = "npc_" + a_onlineId;
                break;

            case eCharType.eCar:
                gameObject.name = "car_" + a_onlineId;
                break;
            }
        }
        array[a_onlineId].Refresh(a_pos, a_rot, a_anim, a_health, a_energy);
    }
示例#5
0
 private void UpdateOrSpawnCharacter(int a_onlineId, Vector3 a_pos, float a_rot, eCharType a_type, CharAnim2.ePose a_anim, float a_health, float a_energy = 100f)
 {
     RemoteCharacter[] array;
     if (a_type == eCharType.ePlayer || a_type == eCharType.ePlayerFemale)
     {
         array = this.m_players;
     }
     else if (a_type == eCharType.eCar)
     {
         array = this.m_cars;
     }
     else
     {
         array = this.m_npcs;
     }
     if (a_onlineId > -1 && a_onlineId < array.Length)
     {
         bool flag = array != null && null == array[a_onlineId];
         if (!flag || 0f < a_health)
         {
             CharData[] array2 = null;
             if (a_type == eCharType.ePlayer || a_type == eCharType.ePlayerFemale)
             {
                 array2 = this.m_playerData;
             }
             else if (a_type != eCharType.eCar)
             {
                 array2 = this.m_npcData;
             }
             if (flag)
             {
                 GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(this.m_remoteCharPrefab);
                 array[a_onlineId] = gameObject.GetComponent <RemoteCharacter>();
                 array[a_onlineId].Spawn(a_onlineId, a_type, (a_type == eCharType.ePlayer || a_type == eCharType.ePlayerFemale) && this.m_myOnlineId == a_onlineId);
                 if (array2 != null)
                 {
                     array[a_onlineId].SetInfo(array2[a_onlineId]);
                 }
                 if (a_type == eCharType.ePlayer || a_type == eCharType.ePlayerFemale)
                 {
                     gameObject.name = string.Concat(new object[]
                     {
                         "player_",
                         array2[a_onlineId].name,
                         "_",
                         a_onlineId
                     });
                     if (this.m_myOnlineId == a_onlineId)
                     {
                         BirdCam birdCam = (BirdCam)UnityEngine.Object.FindObjectOfType(typeof(BirdCam));
                         birdCam.m_target = gameObject.transform;
                         AudioListener audioListener = (AudioListener)UnityEngine.Object.FindObjectOfType(typeof(AudioListener));
                         if (null != audioListener)
                         {
                             UnityEngine.Object.Destroy(audioListener);
                         }
                         gameObject.AddComponent <AudioListener>();
                     }
                 }
                 else if (a_type != eCharType.eCar)
                 {
                     gameObject.name = "npc_" + a_onlineId;
                 }
                 else
                 {
                     gameObject.name = "car_" + a_onlineId;
                 }
             }
             array[a_onlineId].Refresh(a_pos, a_rot, a_anim, a_health, a_energy);
         }
     }
 }