/// <summary> /// Constructor /// </summary> internal InterfaceInfo(SafeClientHandle client, Guid id, string description, InterfaceState state) { this.Id = id; this.Description = description; this.State = state; this.Client = client; }
public void Stop() { if (this.state != InterfaceState.Started) { Debug.LogWarning($"[{this}] Client already stopped."); return; } this.state = InterfaceState.Stopped; this.tcpClient.Close(); while (this.clientReceiveThread.IsAlive) { Thread.Sleep(10); } this.networkStream.Close(); this.networkStream.Dispose(); this.tcpClient.Dispose(); this.writeStream.Dispose(); this.writer.Dispose(); Debug.Log($"[{this}] Client stopped correctly "); }
/*--------------------------------------------------------------------------------------------*/ public void Update() { int count = vGameObjects.Length; for (int i = 0; i < count; i++) { GameObject handGo = vGameObjects[i]; if (InitializePalmsOnly && (i - 2) % TrackersPerHand != 0) { handGo.SetActive(false); continue; } bool isLeft = (i < TrackersPerHand); LeapAnalogs.HandInfo handInfo = (isLeft ? Analogs.LeftHand : Analogs.RightHand); if (!handInfo.IsAvailable) { handGo.SetActive(false); continue; } InterfaceState <Pose3> poseState = vInterfaces[i].GetState(); Vector3 pos = Math.ConvertPosition(poseState.Value.translation); Quaternion rot = Math.ConvertOrientation(poseState.Value.rotation); handGo.SetActive(true); handGo.transform.localPosition = pos; handGo.transform.localRotation = rot; handGo.transform.localScale = Vector3.Lerp(Vector3.one, Vector3.one * 0.5f, handInfo.GrabStrength) * 0.01f; } }
// Use this for initialization void Start() { world = new World(Width, Height); currentInterfaceState = InterfaceState.Default; SpawnSprites(); SpawnTrees(); SpawnRocks(); }
public ControlState(ControlState _old) { if (_old == null) { return; } InterfaceState = _old.InterfaceState; }
public PlayerInterface(ContentManager content) { PlayerSb = new StringBuilder[] { new StringBuilder("Player1"), new StringBuilder("Player2") }; state = InterfaceState.MainMenu; MainMenuButtons = new List<Button>() { new Button(new Vector2(470, 300), content, "nowa-gra"), new Button(new Vector2(440, 400), content, "stworz-graf"), new Button(new Vector2(485, 500), content, "wyjscie"), }; NewGameTextBoxes = new List<TextBox>() { new TextBox(content,colorsNr.ToString(),new Vector2(650,220),new Vector2(845,305),"liczba-kolorow",0,"CzcionkaUI"), new TextBox(content,"",new Vector2(650,50),new Vector2(0,0),"kolorowanie"), }; p1 = new Player(); p2 = new Player(); GraphButtons = new List<ClickableObject>() { new Button(new Vector2(50, 50), content, "graf1"), new Button(new Vector2(210, 50), content, "graf2"), new Button(new Vector2(370, 50), content, "graf3"), }; GameColoringButtons = new List<Button>(){ new Button(new Vector2(660, 90), content, "kwiatkow"), new Button(new Vector2(660, 140), content, "plotkow"), }; NewGameButtons = new List<ClickableObject>(){ new Button(new Vector2(350, 730), content, "anuluj"), new Button(new Vector2(650, 730), content, "start"), }; Mode = new List<Button>(){ new Button(new Vector2(400, 400), content, "OhvsSh"), new Button(new Vector2(400, 470), content, "OhvsSe"), new Button(new Vector2(400, 540), content, "OevsSh"), new Button(new Vector2(400, 610), content, "OevsSe") }; foreach (Button b in GameColoringButtons) NewGameButtons.Add(b); foreach (Button b in Mode) NewGameButtons.Add(b); foreach (ClickableObject b in GraphButtons) NewGameButtons.Add(b); LoginTextBoxes = new List<TextBox>() { new TextBox(content, "Player1", new Vector2(100, 200), new Vector2(550, 250), "Gracz1",0,"CzcionkaUI") , new TextBox(content, "Player2", new Vector2(100, 500), new Vector2(550, 550), "Gracz2",0,"CzcionkaUI") }; LoginButtons = new List<Button>(){ new Button(new Vector2(350, 30), content, "anuluj"), new Button(new Vector2(650, 30), content, "start"), }; titleTexture = content.Load<Texture2D>("title"); titleVector = new Vector2(250, 100); chosenGraph = null; }
/// <summary> /// Constructor /// </summary> /// <param name="isState"></param> /// <param name="connectionMode"></param> /// <param name="profileName"></param> public ConnectionAttributePack( InterfaceState isState, ConnectionMode connectionMode, string profileName) { this.IsState = isState; this.ConnectionMode = connectionMode; this.ProfileName = profileName; }
public void SetInterfaceState(int index, InterfaceState state) { int r = Connector.SetNetworkInterfaceState(_sockFd, index, state == InterfaceState.UP); if (r < 0) { throw new NetlinkSocketException(r); } }
public void OnFightClick() { var model = PlanetModel.GeneratePlanet(PlanetDifficulty.BabyMode); CurrentInterfaceState = InterfaceState.World; PlanetVisualizer.result = model.FightMe(_otherController.DNA); PlanetVisualizer.enabled = true; }
// Update is called once per frame void Update() { if (CurrentInterfaceState == InterfaceState.Intro) { if (Input.anyKeyDown) { CurrentInterfaceState = InterfaceState.Evolution; } } }
public ReplayController() { State = new InterfaceState(); if (ActiveSettings.current.UseReplayAPI) { Logging.Verbose("Starting ReplayAPI tick"); StateController.GameStart += (s, e) => { StartupUI(); Connected = false; }; } StateController.GameStop += (s, e) => { Connected = false; }; }
public void Awake() { state = InterfaceState.Idle; cardFactory = CardRendererFactory.GetFactory; manager.OnCardDrawn += VisualiseNewCard; manager.OnCardSelected += SelectCardFromHand; manager.OnCardDeselected += DeselectActiveCard; manager.OnCardDiscarded += DiscardCard; cancelCardButton.gameObject.SetActive(false); }
private NetworkInterface CreateNetworkInterfaceInstanceFromInterfaceState(InterfaceState interfaceState) { string ipAddress = string.Empty; try { ipAddress = interfaceState.InetAddr.First().IPAddr.ToString(); } catch (Exception) { } return(new NetworkInterface() { Name = interfaceState.Name, MacAddress = interfaceState.HWAddr, IpAddress = ipAddress }); }
// Use this for initialization void Start() { _playerController = PlayerGO.GetComponent <DNAController>(); _playerController.ResetDNA(); //GameObject tp = Instantiate(TinderPrefab, Canvas.transform); _otherController = OtherGO.GetComponentInChildren <DNAController>(); _otherController.ResetDNA(); CurrentInterfaceState = InterfaceState.Intro; }
public void ToggleState() { if (currentInterfaceState == InterfaceState.Default) { currentInterfaceState = InterfaceState.Construction; } else { currentInterfaceState = InterfaceState.Default; } }
public void Login() { if (username == null || password == null) { Debug.Log("Inputfields not set."); return; } if (username.text.Length <= 0 || password.text.Length <= 0) { Debug.Log("Login info not filled."); return; } //user:testacclin, pass: linphone account = new Account(username.text, password.text, "sip.linphone.org"); phone = new Phone(account); phone.connectedEvent += delegate() { Debug.Log("Phone connected."); callOn = false; state = InterfaceState.Base; }; phone.disconnectedEvent += delegate() { Debug.Log("Phone disconnected."); callOn = false; state = InterfaceState.Login; }; phone.loginErrorEvent += delegate(Phone.RegisterError error_type, string message) { Debug.Log("Failed login. " + message); }; phone.IncomingRingingEvent += delegate(Call call) { Debug.Log("Incoming call!"); callName = call.from; state = InterfaceState.Incoming; }; phone.OutgoingRingingEvent += delegate(Call call) { Debug.Log("Outgoing call!"); callName = call.to; state = InterfaceState.Outgoing; }; phone.StreamsRunningEvent += delegate(Call call) { Debug.Log("Answered. Call is active!"); callOn = true; state = InterfaceState.Video; }; phone.EndedEvent += delegate(Call call) { Debug.Log("Completed."); callOn = false; state = InterfaceState.Base; }; phone.Connect(); }
public SSID(string name, string bssid, string signal, decimal rx_rate, decimal tx_rate, int channel, Radio radio, Cipher cipher, Security security, InterfaceState interfaceState) { this.name = name; this.bssid = bssid; this.signal = signal; this.rx_rate = rx_rate; this.tx_rate = tx_rate; this.radio = radio; this.channel = channel; this.cipher = cipher; this.bssid = bssid; this.security = security; this.interfaceState = interfaceState; }
public void ResetCompletely(string saveName) { saveFiles = NodeEditorSaveManager.GetSceneSaves(); this.saveName = saveName; for (int i = 0; i < saveFiles.Length; i++) { if (saveFiles[i] == saveName) { saveChoice = i; break; } } Awake(); state = InterfaceState.Dirty; }
public SingleEntityResult OfferSingleEntitySelection(ICollection <Entity> options) { SingleEntityResult result = new SingleEntityResult(); SingleEntitySelection ses = Instantiate(singleEntityPromptPrefab); ses.Initialize(this, options, result); ses.transform.parent = transform; activeSelection = ses; pendingResult = result; state = InterfaceState.BusyWithSelection; return(result); }
public void ToggleState(InterfaceState state) { // Dose the state flags already contain the state? bool isActive = HasBit(mInterfaceState, (int)state); ToggleBit(ref mInterfaceState, (int)state); switch (state) { case InterfaceState.ActionSelector: { // Toggle the active/inactive state of the action selector ActionSelector.SetEnabled(!isActive); } break; } }
/// <summary> /// Moves the <see cref="CardRenderer"/> that matches the active card back into the hand. /// </summary> /// <remarks>Used to respond to <see cref="GameManager.OnCardDeselected"/></remarks> public void DeselectActiveCard() { if (activeCardRenderer != null) { hand.AddCardToHand(activeCardRenderer); hand.HoldCardsDown = false; activeCardRenderer.UpdateDescription(useStatic: true); activeCardRenderer = null; cancelCardButton.gameObject.SetActive(false); } if (state == InterfaceState.BusyWithSelection) { pendingResult = null; activeSelection.Cleanup(); activeSelection = null; state = InterfaceState.Idle; } }
/** * Builds a neat button given its iteration count. */ private void BuildButton(DialogueNode node, int i, string decision) { // figure out of the button is enabled or not. var isEnabled = node.CheckConstraintAt(i); var isEnabledText = isEnabled ? "" : " [too dumb]"; var buttonPanel = Instantiate(choiceField) as GameObject; // build a button buttons.Add(buttonPanel); // register the button var rectTransform = buttonPanel.transform as RectTransform; buttonPanel.transform.SetParent(baseCanvas.transform); // nest it properly in the object hirachy // ReSharper disable once PossibleNullReferenceException rectTransform.anchoredPosition = Vector2.down * (i % 3) * (rectTransform.rect.height + 10) * 0.5f; // move it around a bit var rows = (node.Outputs.Count - 1) / 3; var pos = i / 3; if (rows > 0) // if we have more than one single row, we have to move it (move it!) { rectTransform.anchoredPosition += Vector2.left * 340; rectTransform.anchoredPosition += Vector2.right * pos * 340; } var buttonText = buttonPanel.GetComponentInChildren <Text>(); if (buttonText == null) { Debug.LogError("FATAL: Nodegraph ButtonText is null"); } else { buttonText.text = decision + isEnabledText; } var button = buttonPanel.GetComponent <Button>(); button.onClick.AddListener(() => { // And register an EventListener when the button is clicked. state = InterfaceState.Dirty; if (isEnabled) { GetNext(i); } }); }
void Start() { toNextSnapShot = 1.0f; currentTime = 0.0f; snapshotIndex = 0; textureIndex = 0; videoCanvas = GameObject.Find("Video").GetComponent <RawImage>();//(RawImage)GameObject.Find("Video").GetComponent<RawImage>(); takeSnapshot = true; canvasTexture = new Texture2D(2, 2); //videoImage= videoCanvas.GetComponent<RawImage>(); state = InterfaceState.Login; lastState = InterfaceState.Null; DisablePanels(); if (!System.IO.Directory.Exists(Application.dataPath + "/snapshots")) { System.IO.Directory.CreateDirectory(Application.dataPath + "/snapshots"); } }
/// <summary> /// Converts enum InterfaceState (ManagedNativeWifi) to internal type WiFiInterfaceState. /// </summary> private WiFiInterfaceState InterfaceStateConverter(InterfaceState interfaceState) { WiFiInterfaceState wiFiInterfaceState = default(WiFiInterfaceState); switch (interfaceState) { case InterfaceState.NotReady: wiFiInterfaceState = WiFiInterfaceState.NotReady; break; case InterfaceState.Connected: wiFiInterfaceState = WiFiInterfaceState.Connected; break; case InterfaceState.AdHocNetworkFormed: wiFiInterfaceState = WiFiInterfaceState.AdHocNetworkFormed; break; case InterfaceState.Disconnecting: wiFiInterfaceState = WiFiInterfaceState.Disconnecting; break; case InterfaceState.Disconnected: wiFiInterfaceState = WiFiInterfaceState.Disconnected; break; case InterfaceState.Associating: wiFiInterfaceState = WiFiInterfaceState.Associating; break; case InterfaceState.Discovering: wiFiInterfaceState = WiFiInterfaceState.Discovering; break; case InterfaceState.Authenticating: wiFiInterfaceState = WiFiInterfaceState.Authenticating; break; } return(wiFiInterfaceState); }
public void Stop() { if (this.state != InterfaceState.Started) { Debug.LogWarning("[Server] Server already stopped."); return; } this.state = InterfaceState.Stopped; this.tcpListener.Stop(); while (this.tcpListenerThread.IsAlive) { Thread.Sleep(10); } this.writeStream.Dispose(); this.writer.Dispose(); Debug.Log("[Server] Server stopped correctly."); }
public void Update() { switch (state) { case InterfaceState.BusyWithSelection: { if (pendingResult.IsReadyOrCancelled()) { pendingResult = null; activeSelection.Cleanup(); activeSelection = null; state = InterfaceState.Idle; } }; break; } if (activeCardRenderer != null) { activeCardRenderer.UpdateDescription(); //ABSOLUTELY DON'T DO THIS EVERY TURN } }
public void Start() { if (this.state != InterfaceState.None) { Debug.LogWarning($"[Server] Server has already been started once."); return; } try { // Start TcpServer background thread this.tcpListenerThread = new Thread(this.ListenForData) { IsBackground = true }; this.tcpListenerThread.Start(); this.state = InterfaceState.Started; } catch (Exception exception) { Debug.Log("On client connect exception " + exception); } }
public void Start() { if (this.state != InterfaceState.None) { Debug.LogWarning($"[{this}] Client has already been started once."); return; } try { this.writeStream = new MemoryStream(); this.writer = new BinaryWriter(this.writeStream); this.clientReceiveThread = new Thread(this.ListenForData) { IsBackground = true }; this.clientReceiveThread.Start(); this.state = InterfaceState.Started; } catch (Exception exception) { Debug.Log("[{this}] On client connect exception " + exception); } }
public void InterfaceUp(InterfaceState state, InterfaceEventType eventType, object data) { if (_controller.DeviceConfigurationMap[DeviceID].IsLoopback) { RaiseEvent(InterfaceEventType.LoopInd); return; } _helloTimer = new Timer(); Timer helloTimer = _helloTimer; helloTimer.Interval = 1000; helloTimer.Elapsed += HelloElapsed; helloTimer.Start(); switch (OspfNetworkType) { case OspfNetworkType.PointToPoint: case OspfNetworkType.PointToMultiPoint: case OspfNetworkType.VirtualLink: InterfaceState = InterfaceState.PointToPoint; break; default: if (Priority == 0) { InterfaceState = InterfaceState.DROther; } else { InterfaceState = InterfaceState.Waiting; _beginWaitTime = DateTime.Now; _waitTimer = new Timer(); _waitTimer.Interval = 1000; _waitTimer.Elapsed += (s, e) => { if ((DateTime.Now - _beginWaitTime).Seconds < RouterDeadInterval) { return; } _waitTimer.Stop(); CalculateDRAndBDR(); }; if (OspfNetworkType == OspfNetworkType.NBMA) { SetupManualNeighborData(); } _waitTimer.Start(); } break; } }
internal void InitMahine(InterfaceState _ControlState) { Parent.m_ControlState.InterfaceState = _ControlState; }
void Start() { _iState = InterfaceState.Load; _audio = GameObject.Find("Camera").GetComponent("AudioListener") as AudioListener; _camera = Camera.main; _cameraTools = GameObject.Find("Camera").GetComponent("CameraTools") as CameraTools; _game = Game.getInstance(); _map = Map.getInstance(); _player = PlayerManager.instance; }
public void ChangeCellDisplay(InterfaceState state) { switch (state) { //ENABLE TEXT AND ICONS ONLY FOR PLAYER ROLE case InterfaceState.Hide: CellName.gameObject.SetActive(false); Images[0].SetActive(false); Images[1].SetActive(false); Images[2].SetActive(false); StatusText[0].gameObject.SetActive(false); StatusText[1].gameObject.SetActive(false); StatusText[2].gameObject.SetActive(false); break; case InterfaceState.Grey: CellName.gameObject.SetActive(true); Images[0].GetComponent <SpriteRenderer>().color = Color.grey; Images[1].GetComponent <SpriteRenderer>().color = Color.grey; Images[2].GetComponent <SpriteRenderer>().color = Color.grey; switch (LocalManager.Instance.RoleType) { case Vars.Player1: Images[0].SetActive(true); Images[1].SetActive(false); Images[2].SetActive(false); StatusText[0].gameObject.SetActive(true); StatusText[1].gameObject.SetActive(false); StatusText[2].gameObject.SetActive(false); break; case Vars.Player2: Images[0].SetActive(false); Images[1].SetActive(true); Images[2].SetActive(false); StatusText[0].gameObject.SetActive(false); StatusText[1].gameObject.SetActive(true); StatusText[2].gameObject.SetActive(false); break; case Vars.Player3: Images[0].SetActive(false); Images[1].SetActive(false); Images[2].SetActive(true); StatusText[0].gameObject.SetActive(false); StatusText[1].gameObject.SetActive(false); StatusText[2].gameObject.SetActive(true); break; } break; case InterfaceState.White: //ENABLE ALL TEXT AND ICONS CellName.gameObject.SetActive(true); Images[0].GetComponent <SpriteRenderer>().color = Color.white; Images[1].GetComponent <SpriteRenderer>().color = Color.white; Images[2].GetComponent <SpriteRenderer>().color = Color.white; switch (LocalManager.Instance.RoleType) { case Vars.Player1: Images[0].SetActive(true); Images[1].SetActive(true); Images[2].SetActive(true); StatusText[0].gameObject.SetActive(true); StatusText[1].gameObject.SetActive(true); StatusText[2].gameObject.SetActive(true); break; case Vars.Player2: Images[0].SetActive(true); Images[1].SetActive(true); Images[2].SetActive(true); StatusText[0].gameObject.SetActive(true); StatusText[1].gameObject.SetActive(true); StatusText[2].gameObject.SetActive(true); break; case Vars.Player3: Images[0].SetActive(true); Images[1].SetActive(true); Images[2].SetActive(true); StatusText[0].gameObject.SetActive(true); StatusText[1].gameObject.SetActive(true); StatusText[2].gameObject.SetActive(true); break; } break; } }
private void BackupSeen(InterfaceState state, InterfaceEventType eventType, object data) { _waitTimer.Stop(); CalculateDRAndBDR(); }
private void CalculateDRAndBDR() { lock (DecisionLock) { DR = IPAddress.GetDefault(); BDR = IPAddress.GetDefault(); var neighborData = NeighborMap.Values .Where(p => ((int)p.OspfNeighborState) >= (int)OspfNeighborState.TwoWay && p.Priority != 0) .Select(p => new Tuple<IPAddress, IPAddress, IPAddress, byte, IPAddress>(p.Address, p.DR, p.BDR, p.Priority, p.RouterID)) .ToList(); neighborData.Add(new Tuple<IPAddress, IPAddress, IPAddress, byte, IPAddress>(IPAddress, DR, BDR, Priority, Module.RouterID)); var sortedData = neighborData .OrderByDescending(p => p.Item4) .OrderByDescending(p => p.Item5).ToList(); var haveNoDRClaim = sortedData.Where(p => p.Item2 != p.Item1); var bdrData = sortedData.Where(p => p.Item3 == p.Item1).FirstOrDefault() ?? haveNoDRClaim.FirstOrDefault(); var drData = sortedData.Where(p => p.Item2 == p.Item1).FirstOrDefault() ?? bdrData; IPAddress claimedBdr; IPAddress claimedDr; if ((Module.RouterID != DR && Module.RouterID == drData.Item1) || (Module.RouterID != BDR && Module.RouterID == bdrData.Item1) || (Module.RouterID == DR && Module.RouterID != drData.Item1) || (Module.RouterID == BDR && Module.RouterID != bdrData.Item1)) { claimedBdr = bdrData.Item2; claimedDr = drData.Item2; neighborData = NeighborMap.Values .Where(p => ((int)p.OspfNeighborState) >= (int)OspfNeighborState.TwoWay && p.Priority != 0) .Select(p => new Tuple<IPAddress, IPAddress, IPAddress, byte, IPAddress>(p.Address, p.DR, p.BDR, p.Priority, p.RouterID)) .ToList(); neighborData.Add(new Tuple<IPAddress, IPAddress, IPAddress, byte, IPAddress>(IPAddress, claimedBdr, claimedDr, Priority, Module.RouterID)); sortedData = neighborData .OrderByDescending(p => p.Item4) .OrderByDescending(p => p.Item5).ToList(); haveNoDRClaim = sortedData.Where(p => p.Item2 != p.Item1); bdrData = sortedData.Where(p => p.Item3 == p.Item1).FirstOrDefault() ?? haveNoDRClaim.FirstOrDefault(); drData = sortedData.Where(p => p.Item2 == p.Item1).FirstOrDefault() ?? bdrData; } if (Module.RouterID == drData.Item1) { InterfaceState = InterfaceState.DR; } else if (Module.RouterID == bdrData.Item1) { InterfaceState = InterfaceState.Backup; } else { InterfaceState = InterfaceState.DROther; } DR = drData.Item1; BDR = bdrData.Item1; Log.Write("OSPF", "CalculateDRAndBDR", string.Format("DR: {0}, BDR: {1}", DR, BDR)); if ((Module.RouterID != DR && Module.RouterID == drData.Item1) || (Module.RouterID != BDR && Module.RouterID == bdrData.Item1) || (Module.RouterID == DR && Module.RouterID != drData.Item1) || (Module.RouterID == BDR && Module.RouterID != bdrData.Item1)) { NeighborMap.Values .Where(p => ((int)p.OspfNeighborState) >= (int)OspfNeighborState.TwoWay && p.Priority != 0) .ToList().ForEach(p => p.RaiseEvent(NeighborEventType.AdjOK, new Tuple<IPAddress, IPAddress, IPAddress>(drData.Item1, bdrData.Item1, IPAddress))); } } }
private void InterfaceDown(InterfaceState state, InterfaceEventType eventType, object data) { }
internal void InitializeMachine(InterfaceState controlState) { m_Parent.m_ControlState.InterfaceState = controlState; }
/// <summary> /// Funkcja sprawdzajaca nacisk myszy na element okna Menu Glownego /// </summary> /// <param name="mousePos"></param> /// <param name="content"></param> public void MainMenuCheck(Point mousePos, ContentManager content) { for (int i = 0; i < MainMenuButtons.Count; i++) { if (MainMenuButtons[i].ContainsPoint(mousePos)) { switch (MainMenuButtons[i].name) { case "nowa-gra": InterfaceUpdate(content); state = InterfaceState.NewGame; break; case "stworz-graf": state = InterfaceState.GCVertices; break; case "wyjscie": Game1.ExitGame(); break; } } } }
private void spawnUnit(string unit, GameObject tile) { AttackingUnit attackingUnit = getUnit(unit); IStructureStats structureStats = attackingUnit.StructureStats; if(_player.Gold >= attackingUnit.StructureStats.price) { structureManager.addStructure(tile.GetComponent<Tile>().transform.localPosition, attackingUnit.StructureBehavior, attackingUnit.StructureStats); _player.Gold -= attackingUnit.StructureStats.price; _game.GState = Game.GameState.Regular; _iState = InterfaceState.Regular; _selectedTile = null; } else{ _game.GState = Game.GameState.Regular; _iState = InterfaceState.Regular; _selectedTile = null; Messenger<string>.Broadcast("Notification", "Not enough gold!" ); } }
/// <summary> /// Funkcja sprawdzajaca nacisk myszy na element w oknie kreatora nowej gry /// </summary> /// <param name="mousePos"></param> /// <param name="game"></param> /// <param name="content"></param> public void NewGameCheck(Point mousePos, ref Game game, ContentManager content) { for (int i = 0; i < NewGameButtons.Count; i++) { if (NewGameButtons[i].ContainsPoint(mousePos)) { switch (NewGameButtons[i].name) { case "start": if (p1 != null && chosenGraph != null) state = p2 is Computer ? InterfaceState.LoginSingle : InterfaceState.LoginMulti; else Game1.MessageBox(new IntPtr(), "Wybierz graf do rozgrywki", "", 0); break; case "anuluj": state = InterfaceState.MainMenu; break; case "graf1": ClearButtons(GraphButtons); chosenGraph = PredefinedGraphs.graphs[0].Copy(); NewGameButtons[i].color = Color.LightBlue; break; case "graf2": ClearButtons(GraphButtons); chosenGraph = PredefinedGraphs.graphs[1].Copy(); NewGameButtons[i].color = Color.LightBlue; break; case "graf3": ClearButtons(GraphButtons); chosenGraph = PredefinedGraphs.graphs[2].Copy(); NewGameButtons[i].color = Color.LightBlue; break; case "graphcreated": ClearButtons(GraphButtons); chosenGraph = PredefinedGraphs.graphs[NewGameButtons[i].index].Copy(); NewGameButtons[i].color = Color.LightBlue; break; case "gra-vs-gra": ClearButtons(GameTypeButtons); p1 = new Player("Gracz1"); p2 = new Player("Gracz2"); UpdateLogins(); UpdatePlayers(); NewGameButtons[i].color = Color.LightBlue; break; case "gra-vs-komp": ClearButtons(GameTypeButtons); p1 = new Player("Gracz1"); p2 = new Computer(easyMode); UpdateLogins(); UpdatePlayers(); NewGameButtons[i].color = Color.LightBlue; break; case "kwiatkow": ClearButtons(GameColoringButtons); gT = GameType.VerticesColoring; NewGameButtons[i].color = Color.LightBlue; break; case "plotkow": ClearButtons(GameColoringButtons); gT = GameType.EdgesColoring; NewGameButtons[i].color = Color.LightBlue; break; case "sasiad-ogrodnik": ClearButtons(GameModeButtons); gO = GameOrder.NG; UpdatePlayers(); NewGameButtons[i].color = Color.LightBlue; break; case "ogrodnik-sasiad": ClearButtons(GameModeButtons); gO = GameOrder.GN; UpdatePlayers(); NewGameButtons[i].color = Color.LightBlue; break; case "latwy": ClearButtons(GameDifButtons); easyMode = true; if(p2 is Computer) { Computer c = p2 as Computer; c.easyMode = true; } NewGameButtons[i].color = Color.LightBlue; break; case "trudny": ClearButtons(GameDifButtons); easyMode = false; if (p2 is Computer) { Computer c = p2 as Computer; c.easyMode = false; } NewGameButtons[i].color = Color.LightBlue; break; } } } }
void Update() { if(_game.GState == Game.GameState.Regular){ if(_iState == InterfaceState.Load){ _iState = InterfaceState.Regular; } if(Input.GetMouseButton(0)){ _selectedTile = _map.getTile(_map.coordinateToTile(_cameraTools.ScreenToWorld(Input.mousePosition))); if(_selectedTile != null){ if(_selectedTile.GetComponent<Tile>().slot && _selectedTile.GetComponent<Tile>().isEmpty()){ _game.GState = Game.GameState.Build; _iState = InterfaceState.TileSelected; } } } } if(_game.GState == Game.GameState.Build){ if(Input.GetMouseButtonUp(1)){ _game.GState = Game.GameState.Regular; _iState = InterfaceState.Regular; } if(Input.GetKeyDown(KeyCode.Escape)){ _game.GState = Game.GameState.Regular; _iState = InterfaceState.Regular; } } if(_game.GState == Game.GameState.Menu){ if(Input.GetKeyDown(KeyCode.Escape)){ _game.GState = Game.GameState.Regular; _iState = InterfaceState.Regular; } } }
public PlayerInterface(ContentManager content) { PlayerSb = new StringBuilder[] { new StringBuilder("Gracz1"), new StringBuilder("Gracz2") }; state = InterfaceState.MainMenu; MainMenuButtons = new List<Button>() { new Button(Game1.GetRatioDimensions(new Vector2(470, 300)), content, "nowa-gra"), new Button(Game1.GetRatioDimensions(new Vector2(440, 400)), content, "stworz-graf"), new Button(Game1.GetRatioDimensions(new Vector2(485, 500)), content, "wyjscie"), }; NewGameTextBoxes = new List<TextBox>() { new TextBox(content,colorsNr.ToString(),Game1.GetRatioDimensions(new Vector2(650,390)),Game1.GetRatioDimensions(new Vector2(845,475)),"liczba-kolorow",0,"CzcionkaUI"), new TextBox(content,"",Game1.GetRatioDimensions(new Vector2(650,50)),new Vector2(0,0),"trybBox"), new TextBox(content,"",Game1.GetRatioDimensions(new Vector2(650,220)),new Vector2(0,0),"kolorowanie"), new TextBox(content,"",Game1.GetRatioDimensions(new Vector2(650,560)),new Vector2(0,0),"gra"), new TextBox(content,"",Game1.GetRatioDimensions(new Vector2(50,560)),new Vector2(0,0),"poziom"), }; p1 = new Player(); p1.isGardener = true; p1.login = "******"; p2 = new Player(); p2.login = "******"; easyMode = true; GraphButtons = new List<ClickableObject>() { new Button(Game1.GetRatioDimensions(new Vector2(50, 50)), content, "graf1"), new Button(Game1.GetRatioDimensions(new Vector2(210, 50)), content, "graf2"), new Button(Game1.GetRatioDimensions(new Vector2(370, 50)), content, "graf3"), }; GameTypeButtons = new List<Button>(){ new Button(Game1.GetRatioDimensions(new Vector2(660, 100)), content, "gra-vs-gra", Color.LightBlue), new Button(Game1.GetRatioDimensions(new Vector2(660, 150)), content, "gra-vs-komp"), }; GameDifButtons = new List<Button>(){ new Button(Game1.GetRatioDimensions(new Vector2(60, 610)), content, "latwy", Color.LightBlue), new Button(Game1.GetRatioDimensions(new Vector2(60, 660)), content, "trudny"), }; GameColoringButtons = new List<Button>(){ new Button(Game1.GetRatioDimensions(new Vector2(660, 260)), content, "kwiatkow", Color.LightBlue), new Button(Game1.GetRatioDimensions(new Vector2(660, 310)), content, "plotkow"), }; GameModeButtons = new List<Button>(){ new Button(Game1.GetRatioDimensions(new Vector2(660, 610)), content, "sasiad-ogrodnik"), new Button(Game1.GetRatioDimensions(new Vector2(660, 660)), content, "ogrodnik-sasiad", Color.LightBlue), }; NewGameButtons = new List<ClickableObject>(){ new Button(Game1.GetRatioDimensions(new Vector2(350, 730)), content, "anuluj"), new Button(Game1.GetRatioDimensions(new Vector2(650, 730)), content, "start"), }; foreach (Button b in GameDifButtons) NewGameButtons.Add(b); foreach (Button b in GameTypeButtons) NewGameButtons.Add(b); foreach (Button b in GameColoringButtons) NewGameButtons.Add(b); foreach (Button b in GameModeButtons) NewGameButtons.Add(b); foreach (ClickableObject b in GraphButtons) NewGameButtons.Add(b); LoginTextBoxes = new List<TextBox>() { new TextBox(content, "Gracz1", Game1.GetRatioDimensions(new Vector2(100, 200)), Game1.GetRatioDimensions(new Vector2(550, 250)), "Gracz1",0,"CzcionkaUI") , new TextBox(content, "Gracz2", Game1.GetRatioDimensions(new Vector2(100, 500)), Game1.GetRatioDimensions(new Vector2(550, 550)), "Gracz2",0,"CzcionkaUI") }; LoginButtons = new List<Button>(){ new Button(Game1.GetRatioDimensions(new Vector2(350, 30)), content, "anuluj"), new Button(Game1.GetRatioDimensions(new Vector2(650, 30)), content, "start"), }; titleTexture = content.Load<Texture2D>("title"); titleVector = Game1.GetRatioDimensions(new Vector2(250, 100)); chosenGraph = null; }
/// <summary> /// Funkcja sprawdzajaca nacisk myszy na element okna pojedynczego loginu /// </summary> /// <param name="mousePos"></param> /// <param name="game"></param> /// <param name="content"></param> public void LoginSingleCheck(Point mousePos,ref Game game, ContentManager content) { for (int i = 0; i < LoginButtons.Count; i++) { if (LoginButtons[i].ContainsPoint(mousePos)) { switch (LoginButtons[i].name) { case "start": state = InterfaceState.Game; game = new Game(gT, p2 is Computer ? GameMode.SinglePlayer : GameMode.MultiPlayer, chosenGraph, colorsNr, content, p1, p2,gO); break; case "anuluj": state = InterfaceState.MainMenu; break; } } } if (LoginTextBoxes[0].ContainsPoint(mousePos)) ActiveTextBox = 0; }
private void NeighborChange(InterfaceState state, InterfaceEventType eventType, object data) { CalculateDRAndBDR(); }
private void UnloopInd(InterfaceState state, InterfaceEventType eventType, object data) { }
public void OnStateChanged(InterfaceState interfaceState) { InterfaceState = interfaceState; OnStateChanged(); }
private void WaitTimer(InterfaceState state, InterfaceEventType eventType, object data) { CalculateDRAndBDR(); }
/// <summary> /// Funkcja sprawdzajaca nacisk myszy na element w oknie kreatora nowej gry /// </summary> /// <param name="mousePos"></param> /// <param name="game"></param> /// <param name="content"></param> public void NewGameCheck(Point mousePos, ref Game game, ContentManager content) { for (int i = 0; i < NewGameButtons.Count; i++) { if (NewGameButtons[i].ContainsPoint(mousePos)) { switch (NewGameButtons[i].name) { case "start": if(p1!=null && chosenGraph != null) { state = InterfaceState.Game; game = new Game(gT,GameMode.ZeroPlayer, chosenGraph, colorsNr, content, p1, p2, gO); } break; case "anuluj": state = InterfaceState.MainMenu; break; case "graf1": ClearButtons(GraphButtons); chosenGraph = PredefinedGraphs.graphs[0].Copy(); NewGameButtons[i].color = Color.LightBlue; break; case "graf2": ClearButtons(GraphButtons); chosenGraph = PredefinedGraphs.graphs[1].Copy(); NewGameButtons[i].color = Color.LightBlue; break; case "graf3": ClearButtons(GraphButtons); chosenGraph = PredefinedGraphs.graphs[2].Copy(); NewGameButtons[i].color = Color.LightBlue; break; case "graphcreated": ClearButtons(GraphButtons); chosenGraph = PredefinedGraphs.graphs[NewGameButtons[i].index].Copy(); NewGameButtons[i].color = Color.LightBlue; break; case "kwiatkow": ClearButtons(GameColoringButtons); gT = GameType.VerticesColoring; NewGameButtons[i].color = Color.LightBlue; break; case "plotkow": ClearButtons(GameColoringButtons); gT = GameType.EdgesColoring; NewGameButtons[i].color = Color.LightBlue; break; case "OhvsSh": ClearButtons(Mode); NewGameButtons[i].color = Color.LightBlue; p1 = new Computer(false); p1.isGardener = true; p2 = new Computer(false); p2.isGardener = false; break; case "OevsSh": ClearButtons(Mode); NewGameButtons[i].color = Color.LightBlue; p1 = new Computer(true); p1.isGardener = true; p2 = new Computer(false); p2.isGardener = false; break; case "OhvsSe": ClearButtons(Mode); NewGameButtons[i].color = Color.LightBlue; p1 = new Computer(false); p1.isGardener = true; p2 = new Computer(true); p2.isGardener = false; break; case "OevsSe": ClearButtons(Mode); NewGameButtons[i].color = Color.LightBlue; p1 = new Computer(true); p1.isGardener = true; p2 = new Computer(true); p2.isGardener = false; break; } } } }