示例#1
0
        private void OnPlayerAnimationUpdate(PlayerAnimationUpdate packet, NebulaConnection conn)
        {
            Player player = playerManager.GetPlayer(conn);

            packet.PlayerId = player.Id;
            playerManager.SendPacketToOtherPlayers(packet, player, DeliveryMethod.Unreliable);
        }
示例#2
0
 public static void UpdateRemotePlayerAnimation(PlayerAnimationUpdate packet)
 {
     if (remotePlayersModels.TryGetValue(packet.PlayerId, out RemotePlayerModel player))
     {
         player.Animator.UpdateState(packet);
     }
 }
示例#3
0
    void Start()
    {
        player      = GetComponent <Player>();
        animUpdater = GetComponent <PlayerAnimationUpdate>();
        current     = new PlayerSnapshot();
        scale       = Mathf.Abs(transform.localScale.x);

        if (!isLocalPlayer)
        {
            GetComponent <Rigidbody2D>().isKinematic = true;

            GetComponent <SpriteRenderer>().enabled = false;
            //player.t_hand.GetComponent<SpriteRenderer>().enabled = false;
            //player.t_weapon.GetComponent<SpriteRenderer>().enabled = false;

            GameObject go = GameSystem.LoadPool("puppet", transform.position);

            puppet        = go.GetComponent <MyNetworkPuppet>();
            puppet.target = gameObject;
            puppet.player = GetComponent <Player>();
            puppet.LoadWeapon(GameManager.weapon);

            GameSystem.CopyComponent(GetComponent <PlayerAnimationUpdate>(), go);
            animUpdater = puppet.GetComponent <PlayerAnimationUpdate>();

            InputSystem.listPuppet.Add(puppet);
        }

        InvokeRepeating("TransmitPosition", 0.2f, 0.2f);
    }
示例#4
0
        private void OnPlayerAnimationUpdate(PlayerAnimationUpdate packet, NebulaConnection conn)
        {
            var player = PlayerManager.GetPlayerById(conn.Id);

            if (player != null)
            {
                player.Animator.UpdateState(packet);
            }
        }
示例#5
0
 public static void UpdateRemotePlayerAnimation(PlayerAnimationUpdate packet)
 {
     using (GetRemotePlayersModels(out var remotePlayersModels))
     {
         if (remotePlayersModels.TryGetValue(packet.PlayerId, out RemotePlayerModel player))
         {
             player.Animator.UpdateState(packet);
             player.Effects.UpdateState(packet);
         }
     }
 }
示例#6
0
 public void UpdateState(PlayerAnimationUpdate packet)
 {
     ApplyAnimationState(idle, packet.Idle);
     ApplyAnimationState(runSlow, packet.RunSlow);
     ApplyAnimationState(runFast, packet.RunFast);
     ApplyAnimationState(drift, packet.Drift);
     ApplyAnimationState(driftF, packet.DriftF);
     ApplyAnimationState(driftL, packet.DriftL);
     ApplyAnimationState(driftR, packet.DriftR);
     ApplyAnimationState(fly, packet.Fly);
     ApplyAnimationState(sail, packet.Sail);
     ApplyAnimationState(mining0, packet.Mining0);
 }
示例#7
0
 private void OnPlayerAnimationUpdate(PlayerAnimationUpdate packet, NebulaConnection conn)
 {
     packet.PlayerId = conn.Id;
     SendPacketToOthers(conn.Id, packet, DeliveryMethod.Unreliable);
 }
示例#8
0
 private void OnPlayerAnimationUpdate(PlayerAnimationUpdate packet)
 {
     RemotePlayerManager.GetPlayerById(packet.PlayerId)?.Animator.UpdateState(packet);
 }
示例#9
0
        public void UpdateState(PlayerAnimationUpdate packet)
        {
            bool anyMovingAnimationActive = rootAnimation.RunSlow.enabled || rootAnimation.RunFast.enabled || rootAnimation.Fly.enabled || rootAnimation.Sail.enabled || rootAnimation.Drift.enabled || rootAnimation.DriftF.enabled || rootAnimation.DriftL.enabled || rootAnimation.DriftR.enabled || !IsGrounded();
            bool anyDriftActive           = rootAnimation.Drift.enabled || rootAnimation.DriftR.enabled || rootAnimation.DriftL.enabled || rootAnimation.DriftF.enabled;
            bool fireParticleOkay         = psys != null && psysr != null && (psys[0] != null && psys[1] != null && psysr[0] != null && psysr[1] != null);

            if (anyMovingAnimationActive)
            {
                UpdateExtraSoundEffects(packet);
                if (fireParticleOkay)
                {
                    if ((!rootAnimation.RunSlow.enabled && !rootAnimation.RunFast.enabled) || anyDriftActive || rootAnimation.Sail.enabled)
                    {
                        for (int i = 0; i < psys.Length; i++)
                        {
                            if (!psys[i].isPlaying)
                            {
                                psys[i].Play();
                            }
                        }
                    }
                    else
                    {
                        for (int j = 0; j < psys.Length; j++)
                        {
                            if (psys[j].isPlaying)
                            {
                                psys[j].Stop();
                            }
                        }
                        StopAllFlyAudio();
                        PlayFootsteps();
                    }
                    for (int i = 0; i < psysr.Length; i++)
                    {
                        if (rootAnimation.RunSlow.enabled || rootAnimation.RunFast.enabled)
                        {
                            if (rootAnimation.RunFast.weight != 0)
                            {
                                // when flying over the planet
                                psysr[i].lengthScale = Mathf.Lerp(-3.5f, -8f, Mathf.Max(packet.horzSpeed, packet.vertSpeed) * 0.04f);
                            }
                            else
                            {
                                // when "walking" over water and moving in air without button press or while "walking" over water
                                psysr[i].lengthScale = Mathf.Lerp(-3.5f, -8f, Mathf.Max(packet.horzSpeed, packet.vertSpeed) * 0.03f);
                            }
                        }
                        if (rootAnimation.Drift.enabled)
                        {
                            // when in air without pressing spacebar
                            psysr[i].lengthScale = -3.5f;
                            if (driftAudio == null)
                            {
                                driftAudio = VFAudio.Create("drift", base.transform, Vector3.zero, false);
                                driftAudio?.Play();
                            }
                        }
                        else
                        {
                            if (driftAudio != null)
                            {
                                driftAudio.Stop();
                                driftAudio = null;
                            }
                        }
                        if (rootAnimation.Fly.enabled)
                        {
                            // when pressing spacebar but also when landing (Drift is disabled when landing)
                            psysr[i].lengthScale = Mathf.Lerp(-3.5f, -10f, Mathf.Max(packet.horzSpeed, packet.vertSpeed) * 0.03f);
                            if (flyAudio0 == null)
                            {
                                flyAudio0 = VFAudio.Create("fly-atmos", base.transform, Vector3.zero, false);
                                flyAudio0.Play();
                            }
                        }
                        else
                        {
                            if (flyAudio0 != null)
                            {
                                flyAudio0.Stop();
                                flyAudio0 = null;
                            }
                        }
                        if (rootAnimation.Sail.enabled)
                        {
                            psysr[i].lengthScale = Mathf.Lerp(-3.5f, -10f, Mathf.Max(packet.horzSpeed, packet.vertSpeed) * 15f);
                            if (flyAudio1 == null)
                            {
                                flyAudio1 = VFAudio.Create("fly-space", base.transform, Vector3.zero, false);
                                flyAudio1.Play();
                            }
                        }
                        else
                        {
                            if (flyAudio1 != null)
                            {
                                flyAudio1.Stop();
                                flyAudio1 = null;
                            }
                        }
                    }
                }
            }
            else
            {
                if (fireParticleOkay)
                {
                    for (int i = 0; i < psys.Length; i++)
                    {
                        if (psys[i].isPlaying)
                        {
                            psys[i].Stop();
                        }
                    }
                    StopAllFlyAudio();
                }
            }

            if (torchEffect != null && rootAnimation.Mining0.weight > 0.99f)
            {
                if (!torchEffect.isPlaying && miningAudio == null)
                {
                    torchEffect.Play();
                    miningAudio = VFAudio.Create("mecha-mining", base.transform, Vector3.zero, false);
                    miningAudio?.Play();
                }
            }
            else if (torchEffect != null && rootAnimation.Mining0.weight <= 0.99f)
            {
                if (torchEffect.isPlaying)
                {
                    torchEffect.Stop();
                    miningAudio?.Stop();
                    miningAudio = null;
                }
            }
        }
示例#10
0
        // collision with vegetation, landing sound effect
        private void UpdateExtraSoundEffects(PlayerAnimationUpdate packet)
        {
            if (localPlanetId < 0)
            {
                return;
            }

            if (localPlanetId > 0)
            {
                PlanetData    pData          = GameMain.galaxy.PlanetById(localPlanetId);
                PlanetPhysics pPhys          = (pData != null) ? pData.physics : null;
                PlanetFactory pFactory       = (pData != null) ? pData.factory : null;
                float         tmpMaxAltitude = rootTransform.localPosition.magnitude - pData.realRadius;
                if (tmpMaxAltitude > 1000f)
                {
                    tmpMaxAltitude = 1000f;
                }

                if (rootAnimation.RunSlow.enabled || rootAnimation.RunFast.enabled || rootAnimation.Drift.enabled || rootAnimation.DriftF.enabled || rootAnimation.DriftR.enabled || rootAnimation.DriftL.enabled)
                {
                    bool ground = IsGrounded();

                    if (DriftDetermineInWater(pData))
                    {
                        if (maxAltitude > 1f && pData.waterItemId > 0)
                        {
                            VFAudio audio = VFAudio.Create("landing-water", base.transform, Vector3.zero, false, 0);
                            audio.volumeMultiplier = Mathf.Clamp01(maxAltitude / 5f + 0.5f);
                            audio.Play();
                            PlayFootstepEffect(true, 0f, true);
                            PlayFootstepEffect(false, 0f, true);
                        }
                        maxAltitude = 0f;
                    }
                    if (ground && maxAltitude > 3f)
                    {
                        VFAudio audio = VFAudio.Create("landing", base.transform, Vector3.zero, false, 0);
                        audio.volumeMultiplier = Mathf.Clamp01(maxAltitude / 25f + 0.5f);
                        audio.Play();
                        maxAltitude = 0f;
                    }
                    if (!ground && tmpMaxAltitude > maxAltitude)
                    {
                        maxAltitude = tmpMaxAltitude;
                    }
                }
                else
                {
                    maxAltitude = 15f;
                }

                // NOTE: the pPhys can only be loaded if the player trying to load it has the planet actually loaded (meaning he is on the same planet or near it)
                if (pPhys != null && pFactory != null && packet.horzSpeed > 5f)
                {
                    int number = Physics.OverlapSphereNonAlloc(base.transform.localPosition, 1.8f, collider, 1024, QueryTriggerInteraction.Collide);
                    for (int i = 0; i < number; i++)
                    {
                        int          colId = pPhys.nearColliderLogic.FindColliderId(collider[i]);
                        ColliderData cData = pPhys.GetColliderData(colId);
                        if (cData.objType == EObjectType.Vegetable && cData.objId > 0)
                        {
                            VegeData  vData  = pFactory.vegePool[cData.objId];
                            VegeProto vProto = LDB.veges.Select((int)vData.protoId);
                            if (vProto != null && vProto.CollideAudio > 0 && vegeCollideColdTime <= 0)
                            {
                                VFAudio.Create(vProto.CollideAudio, base.transform, Vector3.zero, true, 0);
                                vegeCollideColdTime = UnityEngine.Random.value * 0.23f + 0.1f;
                            }
                        }
                    }
                }
            }

            if (vegeCollideColdTime > 0)
            {
                vegeCollideColdTime -= Time.deltaTime * 2;
            }
            else
            {
                vegeCollideColdTime = 0;
            }
        }