// Update is called once per frame void Update() { if (Time.time >= changeback) { bar.sprite = sprite; } if (target.GetHP() < prevHP) { bar.sprite = whiteline; changeback = Time.time + whiteDuration; } float pixels = Mathf.Floor(26f * ((float)target.GetHP() / target.maxHP)); if (target.GetHP() > 0 && pixels == 0) { pixels = 1; } float enpixels = Mathf.Floor(26f * ((float)target2.energy / target2.maxEnergy)); //Debug.Log(pixels); float width = pixels * mixelsInPixel; float width2 = enpixels * mixelsInPixel; //Debug.Log(width); if (target2.CollectedAspirin < 10) { MoneyCounter.text = ":0" + target2.CollectedAspirin; } else { MoneyCounter.text = ":" + target2.CollectedAspirin; } bar.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width); enbar.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width2); prevHP = target.GetHP(); }
// Update is called once per frame void Update() { if (Syncer.Instance.singlplayer) { enabled = false; return; } if (healthKeeper) { if (prevHP != healthKeeper.GetHP()) { prevHP = healthKeeper.GetHP(); bool cancel = false; if (pc) { cancel = pc.playerid != me.ParticipantId; } if (!cancel) { byte[] message = new byte[10]; message[0] = (byte)Syncer.MessageType.HPUpdate; int i = 1; foreach (byte b in BitConverter.GetBytes(Convert.ToInt32(name))) { message[i] = b; i++; } foreach (byte b in BitConverter.GetBytes(healthKeeper.GetHP())) { message[i] = b; i++; } } } } if (self != null && (SyncVariation == SVariations.Velocity || SyncVariation == SVariations.Both)) { if (self.velocity != prevVelocity) { prevVelocity = self.velocity; byte[] message = new byte[14]; message[0] = (byte)Syncer.MessageType.VelocitySync; int i = 1; foreach (byte b in BitConverter.GetBytes(Convert.ToInt32(name))) { message[i] = b; i++; } foreach (byte b in BitConverter.GetBytes(self.velocity.x)) { message[i] = b; i++; } foreach (byte b in BitConverter.GetBytes(self.velocity.y)) { message[i] = b; i++; } PlayGamesPlatform.Instance.RealTime.SendMessageToAll(false, message); Debug.Log("(Nebullarix) RTM msg sent: VelocitySync"); } } if (SyncVariation != SVariations.Velocity && PositionSendRate > 0) { if (Time.time > nextSend) { bool cancel = false; if (pc) { cancel = pc.playerid != me.ParticipantId; } if (!cancel) { nextSend = Time.time + (1f / PositionSendRate); byte[] message = new byte[14]; message[0] = (byte)Syncer.MessageType.PosSync; int i = 1; foreach (byte b in BitConverter.GetBytes(Convert.ToInt32(name))) { message[i] = b; i++; } foreach (byte b in BitConverter.GetBytes(transform.position.x)) { message[i] = b; i++; } foreach (byte b in BitConverter.GetBytes(transform.position.y)) { message[i] = b; i++; } PlayGamesPlatform.Instance.RealTime.SendMessageToAll(false, message); message = new byte[10]; message[0] = (byte)Syncer.MessageType.RotSync; i = 1; foreach (byte b in BitConverter.GetBytes(GetInstanceID())) { message[i] = b; i++; } foreach (byte b in BitConverter.GetBytes(transform.rotation.eulerAngles.z)) { message[i] = b; i++; } PlayGamesPlatform.Instance.RealTime.SendMessageToAll(false, message); Debug.Log("(Nebullarix) RTM msg sent: RotSync"); } } } }