public override int AddSquareToQueue() { Square newSquare = ActiveFactory.CreateRandomSquare(); if (newSquare == null) { return(-1); } newSquare.OnSquareHit += HandleSquareHit; SpawnOrder.Enqueue(newSquare.SquareIndex); return(newSquare.SquareIndex); }
private void ActiveFactory_ConnectionAccept(object sender, ConnectionEventArgs client) { Connection server; try { server = PassiveFactory.Take(); } catch { ActiveFactory.Free(client.Connection); return; } ProcessConnections(client.Connection, server); }
public void SwitchAnchor() { if (anchorSquare != null) { anchorSquare.DestroySquare(); } anchorSquare = ActiveFactory.CreateRandomSquare(); if (anchorSquare == null) { throw new Exception("Failed to create anchor"); } anchorSquare.OnSquareHeld += HandleSquareHeld; anchorSquare.SetColor(Color.blue); anchorIndex = anchorSquare.SquareIndex; timeWithoutAnchorHold = 0.0f; }
public override int AddSquareToQueue() { Square newSquare = ActiveFactory.CreateRandomSquare(); if (newSquare == null) { return(-1); } newSquare.OnSquareHit += HandleSquareHit; Color nextColor = GetAvailableColor(); availableColors.Remove(nextColor); newSquare.SetColor(nextColor); int colorIndex = Mathf.Min(colorOrder.IndexOf(nextColor), Mathf.Max(colorSpawnOrder.Count - 1, 0)); colorSpawnOrder.Insert(colorIndex, nextColor); return(newSquare.SquareIndex); }
protected virtual void ProcessConnections(Connection client, Connection server) { try { var pair = MakePair(); ConfigurePair(pair); pair.Client.SetupConnection(client, false); pair.Server.SetupConnection(server, false); Accepting?.Invoke(this, pair); pair.Initialize(); pair.Client.Start(); pair.Server.Start(); Accepted?.Invoke(this, pair); } catch { ActiveFactory.Free(client); PassiveFactory.Free(server); } }
public void Stop() { ActiveFactory.Stop(); }
public void Start() { ActiveFactory.Start(); }