public void OnButtonPressed() { Static_Var.Money += 150; string level = "Level" + Static_Var.currentLevel.ToString(); FFMessage <TriggerFade> .SendToLocal(new TriggerFade(level)); }
private void OnTriggerExit(Collider other) { LeaveArea la; la.area = transform; FFMessage <LeaveArea> .SendToLocal(la); }
private void OnClickStartNewServer() { if (_playerName != null && _playerName.Length > 0) { StartNewServerEvent SNSE; string ipAddress = FFClient.GetLocalIP().ToString(); SNSE.serverIpAddress = System.Net.IPAddress.Parse(ipAddress); SNSE.serverName = _playerName; FFMessage <StartNewServerEvent> .SendToLocal(SNSE); #if UNITY_WEBPLAYER // Start + Connect to local Server FFServer.StartServer(80, _playerName + "'s Server", true); FFClient.StartClient(ipAddress, 80, _playerName); #endif #if UNITY_STANDALONE // Start + Connect to local Server FFServer.StartServer(6532, _playerName + "'s Server", true); FFClient.StartClient(ipAddress, 6532, _playerName); #endif ChangeLevelStateEvent CLSE; CLSE.newState = LevelState.In_Game; FFMessage <ChangeLevelStateEvent> .SendToLocal(CLSE); } else { NoticeAddPlayerName(); } Debug.Log("Clicked StartNewServer"); // debug }
// Update is called once per frame void FixedUpdate() { distance += Time.fixedDeltaTime * speed; var path = PathToFollow.GetComponent <FFPath>(); if (path) { var PrevPos = path.PointAlongPath(distance - 0.01f); var position = path.PointAlongPath(distance); var vecForward = Vector3.Normalize(position - PrevPos); transform.position = position; transform.up = vecForward; if ((int)(distance / path.PathLength) > loopCounter) { loopCounter = (int)(distance / path.PathLength); PathFollowerCompletedLoopEvent e; e.distTraveled = path.PathLength; e.obj = gameObject; FFMessage <PathFollowerCompletedLoopEvent> .SendToLocal(e); } } }
private void OnClickJoinServer() { if (_serverIPAddress != null && _playerName != null && _playerName.Length > 0) { JoinServerEvent e; e.serverIpAddress = _serverIPAddress; e.playerName = _playerName; FFMessage <JoinServerEvent> .SendToLocal(e); FFClient.StartClient(_serverIPAddress.ToString(), 6532, _playerName); ChangeLevelStateEvent CLSE; CLSE.newState = LevelState.In_Game; FFMessage <ChangeLevelStateEvent> .SendToLocal(CLSE); } else { if (_serverIPAddress == null) { NoticeValidIPAddress(); } if (_playerName == null) { NoticeAddPlayerName(); } } Debug.Log("Clicked JoinServer"); // debug }
private static void OnClientConnected(ClientConnectedEvent e) { if (e.clientGuid == singleton._clientData.clientGuid) { double localwatchtime = FFSystem.clientWatchTime; FFSystem.ResetClientWatch(); // Set ping ( 0 < ping < 1.0 ) double calculatedPingTime = Math.Min(Math.Max((localwatchtime - e.clientSendTime) / 2.0, 0.0), 1.0); singleton._serverPingTime = (calculatedPingTime + singleton._serverPingTime * 4.0) / 5.0; singleton._clientId = e.clientId; singleton._serverLifeTime = e.serverTime + singleton._serverPingTime; singleton._serverStartDateTime = e.serverStartTime; singleton._serverName = e.serverName; Debug.Log("Retrieved id: " + singleton._clientId + " from Server with start time of: " + e.serverStartTime + ", and a server life time of: " + e.serverTime); singleton._ready = true; ClientConnectionReadyEvent CCRE; CCRE.clientId = singleton._clientId; CCRE.clientTime = clientTime; FFMessage <ClientConnectionReadyEvent> .SendToLocal(CCRE); FFLocalEvents.TimeChangeEvent TCE; TCE.newCurrentTime = FFSystem.time; FFMessage <FFLocalEvents.TimeChangeEvent> .SendToLocal(TCE); } }
float QueryLight() { QueryLight lightVal = new QueryLight(transform.position); FFMessage <QueryLight> .SendToLocal(lightVal); return(lightVal.out_intensity); }
void SetCursor(Sprite sprite, Color color) { ChangePlayerCursorEvent cpce; cpce.color = color; cpce.sprite = sprite; FFMessage <ChangePlayerCursorEvent> .SendToLocal(cpce); }
void FixedUpdate() { Ser_FixedUpdateEvent e; e.deltaTime = Time.deltaTime; e.serverTime = serverTime; FFMessage <Ser_FixedUpdateEvent> .SendToLocal(e); }
// Used to unpack messages from the net public override bool SendToLocal(FFBasePacket package) { FFPacket <EventType> sentPackage = (FFPacket <EventType>)package; FFPacket <EventType> .Decrypt(ref sentPackage.message); return(FFMessage <EventType> .SendToLocal(sentPackage.message)); }
private void OnTriggerEnter(Collider other) { Debug.Log("Enter Area"); EnterArea ea; ea.area = transform; FFMessage <EnterArea> .SendToLocal(ea); }
public static void RefreshUI() { MoneyStruct msg; msg.updatedString = money.ToString(); msg.color = Color.black; FFMessage <MoneyStruct> .SendToLocal(msg); }
IEnumerator endLevel() { yield return(null); string level = "Level" + Static_Var.currentLevel.ToString(); FFMessage <TriggerFade> .SendToLocal(new TriggerFade(level)); }
int DoThing(PathFollowerCompletedLoopEvent p) { if (p.obj.name.Contains("Player")) { string level = "Office"; FFMessage <TriggerFade> .SendToLocal(new TriggerFade(level)); } return(0); }
void LateUpdate() { ExecuteMessages(); FFLocalEvents.LateUpdateEvent e; e.dt = Time.deltaTime; e.time = FFSystem.time; FFMessage <FFLocalEvents.LateUpdateEvent> .SendToLocal(e); }
void UpdatePlayerMessage(PlayerMessage pm, float progress = -1.0f) { UI_Text ut; ut.font = pm.font; ut.text = pm.message; ut.progress = progress; FFMessage <UI_Text> .SendToLocal(ut); }
IEnumerator waitAndExit() { yield return(new WaitForSeconds(5f)); string level = "Level" + Static_Var.currentLevel.ToString(); FFMessage <TriggerFade> .SendToLocal(new TriggerFade(level)); PlayerPrefs.SetInt("IsLate", 0); }
void FixedUpdate() { ExecuteMessages(); FFLocalEvents.FixedUpdateEvent e; e.dt = Time.fixedDeltaTime; e.time = FFSystem.time; e.fixedDt = Time.fixedDeltaTime; FFMessage <FFLocalEvents.FixedUpdateEvent> .SendToLocal(e); }
// Update is called once per frame void Update() { if (Input.GetKeyUp(KeyCode.K)) // Activator Triggered { PlayerDiedEvent e = new PlayerDiedEvent(); e.Killer = gameObject; e.timeOfDeath = Time.realtimeSinceStartup; e.overkillDamage = 9001.0f; FFMessage <PlayerDiedEvent> .SendToLocal(e); } }
private void OnClickLeaveServer() { ChangeLevelStateEvent CLSE; CLSE.newState = LevelState.In_Menu; FFMessage <ChangeLevelStateEvent> .SendToLocal(CLSE); // 1.0 seconds to make sure everything is finished in the ChangelevelState event // before we close down networking DisconnectSequence.Delay(0.5); DisconnectSequence.Sync(); DisconnectSequence.Call(DestroyClientAndServer); }
IEnumerator minusMoney() { yield return(new WaitForEndOfFrame()); Static_Var.RefreshUI(); yield return(new WaitForSeconds(3f)); Static_Var.Money -= Daily_Income; UI_Text tx = new UI_Text { text = "-100 FROM INCOME", font = font, progress = 0f }; FFMessage <UI_Text> .SendToLocal(tx); }
void UpdateMovement(float dt) { var movementVec = Vector3.zero; if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) { movementVec += Vector3.up; } if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) { movementVec -= Vector3.up; } if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) { movementVec += Vector3.right; } if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) { movementVec -= Vector3.right; } // normalize movement if (movementVec != Vector3.zero) { movementVec = movementVec.normalized; lookDir = movementVec; } if (movementVec == Vector3.zero) { rigid.velocity = Vector2.Lerp(rigid.velocity, Vector2.zero, slowCoeficient * dt); } else // want to move { rigid.velocity += new Vector2(movementVec.x, movementVec.y) * acceleration * dt; } // limit speed if (rigid.velocity.magnitude > maxSpeed) { rigid.velocity = rigid.velocity.normalized * maxSpeed; } if (Input.GetKey(KeyCode.P)) { FFMessage <TriggerFade> .SendToLocal(new TriggerFade("EndScene")); } }
public static void StartServer(int portNumber, string serverName, bool serverIsClient) { FFServer.GetReady(); if (singleton._TCPSocket != null || singleton._UDPClient != null) { Debug.LogError("ERROR, Tried to make a second server with an existing one, Delete the old one first"); return; } AddMessageInterceptors(); if (serverIsClient) { singleton._sendToLocal = false; } singleton._serverName = serverName; singleton._portNumber = portNumber; #region SocketStart try { // Setup TCP singleton._TCPSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); singleton._TCPSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); singleton._TCPSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, false); singleton._TCPSocket.Bind(new IPEndPoint(IPAddress.Any, portNumber)); // TODO change to loopback? singleton._TCPSocket.Listen(250); singleton._TCPSocket.BeginAccept(new AsyncCallback(AcceptCallback), singleton._TCPSocket); singleton._serverStartTime = DateTime.Now.ToUniversalTime(); singleton._serverWatch.Reset(); singleton._serverWatch.Start(); Debug.Log("Server Started..." + "\nportNumber:" + portNumber + " serverName:" + serverName); } catch (Exception exp) { Debug.Log(exp.Message); } #endregion Ser_StartupEvent e; FFMessage <Ser_StartupEvent> .SendToLocal(e); }
void Awake() { if (this == singleton) { _clientWatch.Start(); //FFMessage<NetObjectCreatedEvent>.Connect(OnNetObjectCreatedEvent); //FFMessage<NetObjectDestroyedEvent>.Connect(OnNetObjectDestroyedEvent); //FFMessage<ClientConnectionReadyEvent>.Connect(OnClientConnectionReady); //FFMessage<GameObjectNetIdRecievedEvent>.Connect(OnGameObjectNetIdRecieved); Debug.Log("FFSystem is awake!"); FFLocalEvents.TimeChangeEvent TCE; TCE.newCurrentTime = FFSystem.time; FFMessage <FFLocalEvents.TimeChangeEvent> .SendToLocal(TCE); } }
// Use this for initialization void Start() { Static_Var.currentLevel = ((Static_Var.currentLevel + 1) % 3) + 1; StartCoroutine(minusMoney()); FogMsg fog; fog.FogDensity = Static_Var.FogValue; Debug.Log("Fog Value " + Static_Var.FogValue); FFMessage <FogMsg> .SendToLocal(fog); if (Static_Var.FogValue >= 1.9) { Debug.Log("Transition to end scene"); } }
// Wait For Input State void WaitForInput() { var goForard = Input.GetButtonUp("A" + 0) || Input.GetButtonUp("A" + 1) || Input.GetButtonUp("A" + 2) || Input.GetKeyDown(KeyCode.RightArrow); if (goForard) // go forwards { if (currentPointNumber < PathToFollow.points.Length) { ++currentPointNumber; movementSeq.Call(MoveForward); PlayAudio(); return; } else // finished Path, Goto Next level { TriggerFade tf; FFMessage <TriggerFade> .SendToLocal(tf); } } var gobackward = //Input.GetButtonUp("B" + 0) || //Input.GetButtonUp("B" + 1) || //Input.GetButtonUp("B" + 2) || Input.GetKeyDown(KeyCode.LeftArrow); if (gobackward) // go backwards { if (currentPointNumber > 0) { --currentPointNumber; movementSeq.Call(MoveBackward); PlayAudio(); return; } } movementSeq.Sync(); movementSeq.Call(WaitForInput); }
void OnDestroy() { _clientWatch.Reset(); // Notify any FFAction of the time shift FFLocalEvents.TimeChangeEvent TCE; TCE.newCurrentTime = FFSystem.time; FFMessage <FFLocalEvents.TimeChangeEvent> .SendToLocal(TCE); singleton.recievedMessages.Clear(); singleton = null; //FFMessage<ClientConnectionReadyEvent>.Disconnect(OnClientConnectionReady); //FFMessage<GameObjectNetIdRecievedEvent>.Disconnect(OnGameObjectNetIdRecieved); //FFMessage<NetObjectCreatedEvent>.Disconnect(OnNetObjectCreatedEvent); //FFMessage<NetObjectDestroyedEvent>.Disconnect(OnNetObjectDestroyedEvent); Debug.Log("On Destroy of FFSystem, recieved Messages erased: " + recievedMessages.Count); }
private void Timer_behavior_OnTimerEnd(string timerName) { if (timerName.Contains("Office Time")) { PlayerPrefs.SetInt("IsLate", 1); } else if (timerName.Contains("World Time")) { Static_Var.FogValue = Static_Var.FogValue + 0.3f; UI_Text tx = new UI_Text { text = "SLEEP TIME...", font = font, progress = 0f }; FFMessage <UI_Text> .SendToLocal(tx); string level = "Level" + Static_Var.currentLevel.ToString(); FFMessage <TriggerFade> .SendToLocal(new TriggerFade(level)); } }
// Update is called once per frame void Update() { distance += Time.deltaTime * speed; var path = PathToFollow.GetComponent <FFPath>(); if (path) { var position = path.PointAlongPath(distance); transform.position = position; if ((int)(distance % path.PathLength) > loopCounter) { loopCounter = (int)(distance % path.PathLength); PathFollowerCompletedLoopEvent e; e.distTraveled = path.PathLength; FFMessage <PathFollowerCompletedLoopEvent> .SendToLocal(e); } } }
public void OnValueChange(string value) { if (inputText) { inputText = false; return; } inputText = true; //Display the string. stringTracker++; string display = workString.Substring(0, Mathf.Min(stringTracker * 4, workString.Length - 1)); inputTextField.text = display; inputTextField.caretPosition = stringTracker * 4; //Handle player sound if (enumerator != null) { StopAllCoroutines(); } StartCoroutine(PlayerKeyDown()); //update progress bar UI_Text tx = new UI_Text { text = "WORK HARDER", font = office_Font, progress = (stringTracker / 50f) }; FFMessage <UI_Text> .SendToLocal(tx); //Check for button interactable condition if (stringTracker > game_end_string_length) { end_game_button.interactable = true; } else { end_game_button.interactable = false; } }