void TriggerHealthEmpty() { EmptyHealthEvent e; e.currentHealth = currentHealth; FFMessageBoard <EmptyHealthEvent> .SendToLocal(e, gameObject); FFMessageBoard <EmptyHealthEvent> .SendToNet(e, gameObject, true); }
private void UpdatePositionCall() { ExPlayerPositionUpdate e; e.position = transform.position; e.time = FFSystem.time; FFMessageBoard <ExPlayerPositionUpdate> .SendToNet(e, gameObject, false); PositionUpdateSeq.Delay(0.6f); PositionUpdateSeq.Sync(); PositionUpdateSeq.Call(UpdatePositionCall); }
/// <summary> /// returns true if it could be sent to the net, if this box wasn't /// created via a FFMessageBoard it will not be able to send to Net /// </summary> public bool SendToNet(EventType e, bool varifiedPacket = false) { if (active && messageBoard != null) { messageBoard.IncrementCallCount(); ++callCountLocal; FFMessageBoard <EventType> .SendToNet(e, entry, varifiedPacket); return(true); } Debug.LogError("Warning, an FFMessageBox which is not connected to a FFMessageBoard tried to SendToNet."); return(false); }
// Update is called once per frame void OnUpdateEvent(FFLocalEvents.UpdateEvent e) { FFVector3 moveDirection; moveDirection.x = Input.GetAxis("Horizontal"); moveDirection.y = Input.GetAxis("Vertical"); moveDirection.z = 0; if (Vector3.Magnitude(moveDirection) >= 1) { moveDirection = Vector3.Normalize(moveDirection); } // optimization: Don't send if its not different from the last // move packet sent if (_moveVec != moveDirection) { ExPlayerMoveAction moveEvent; moveEvent.moveDirection = moveDirection; moveEvent.time = FFSystem.time; moveEvent.position = gameObject.transform.position; FFMessageBoard <ExPlayerMoveAction> .SendToLocal(moveEvent, gameObject); FFMessageBoard <ExPlayerMoveAction> .SendToNet(moveEvent, gameObject, false); _moveVec = moveDirection; //Debug.Log("Moving!"); // debug } if (Input.GetButtonDown("Fire1")) { ExPlayerFireAction ePFA; ePFA.position = transform.position + FiringLocation; ePFA.time = FFSystem.time; FFMessageBoard <ExPlayerFireAction> .SendToLocal(ePFA, gameObject); FFMessageBoard <ExPlayerFireAction> .SendToNet(ePFA, gameObject, true); //Debug.Log("Fire1"); //debug } }
private void OnClientConnected(FFNetEvents.ClientConnectedEvent e) { FFMessageBoard <ExHealth> .SendToNet((ExHealth)this.MemberwiseClone(), gameObject, true); }