private void Start() { RightKey.DeActivateKey(); UpKey.DeActivateKey(); DownKey.DeActivateKey(); LeftKey.DeActivateKey(); RKey.DeActivateKey(); GameManager.AddInfection(this); }
// Get the user rights data string, as sent by the server, and fill the user rights array internal void fillUserRights(String rights) { // Start by reseting all rights to false _rights.SetAll(false); _rightsTab.Clear(); //Even if project doesn't have any right, rights string is not blank System.Diagnostics.Debug.Assert(rights.Trim().Length > 0); // The first token in the rights is the userRights. // The second one is the rights ISNs hash. // And, the third onwards, is the map between CtlIdx. RealIdx and index in the userRights. string[] userRights = rights.Split(";".ToCharArray()); string[] parsedRights = userRights[0].Split(new[] { ',' }); // the 1st comma delimited value is the maximum number of rights possible for the user, considering all opened applications _rights.Length = Convert.ToInt32(parsedRights[0]); // Loop on user rights, set them if they are found, else turn them off for (ushort i = 1; i < parsedRights.Length; i++) { int idx = Convert.ToInt32(parsedRights[i]); try { _rights.Set(idx, true); } catch { Logger.Instance.WriteWarningToLog("(Temp)Backwards compatibility between client >= 1.8.1.341 and server <= 1.8.1.340"); _rights.SetAll(false); _rightsTab.Clear(); foreach (var item in parsedRights) { idx = Convert.ToInt32(item); if (idx >= _rights.Length) { _rights.Length = idx + 1; } _rights.Set(idx, true); } break; } } setRightsHashKey(userRights[1]); for (int i = 2; i < userRights.Length; i++) { String[] userRight = userRights[i].Split(",".ToCharArray()); System.Diagnostics.Debug.Assert(userRight.Length == 3); RightKey rightKey = new RightKey(Convert.ToInt32(userRight[0]), Convert.ToInt32(userRight[1])); _rightsTab.Add(rightKey, Convert.ToInt32(userRight[2])); } }
private void EndGame() { gameCodes.Clear(); gameStarted = false; RightKey.DeActivateKey(); UpKey.DeActivateKey(); DownKey.DeActivateKey(); LeftKey.DeActivateKey(); RKey.DeActivateKey(); }
public bool Equals(Condition other) { if (other == null) { return(false); } return(LeftKey.Equals(other.LeftKey) && RightKey.Equals(other.RightKey) && Operator.Equals(other.Operator) && Negated.Equals(other.Negated)); }
internal Boolean getRight(int ctlIdx, int realIdx) { Boolean hasRight = false; if (realIdx == 0 || realIdx > _rights.Length) { Logger.Instance.WriteExceptionToLog("UserRights.getRight(): bad index"); } else { RightKey rightKey = new RightKey(ctlIdx, realIdx); int indexInRights = (int)_rightsTab[rightKey]; hasRight = _rights.Get(indexInRights); } return(hasRight); }
public void OnTriggerExit2D(Collider2D collision) { Player p = collision.gameObject.GetComponent <Player>(); if (p == null) { return; } entered = false; Debug.Log("Exited range of infection :("); Player.EnableCure(false); Player.UnSubscribePlayerKeyPressEvent(OnPlayerKeyPress); RightKey.DeActivateKey(); UpKey.DeActivateKey(); DownKey.DeActivateKey(); LeftKey.DeActivateKey(); RKey.DeActivateKey(); if (gameStarted) { gameStarted = false; } }
private IEnumerator MiniGameEnumeration() { currentCheck = KeyCode.None; float currentCooldown = GameProperties.GetCheckTime(); while (gameStarted) { //get new check if (currentCheck == KeyCode.None) { currentCheck = gameCodes.Dequeue(); } switch (currentCheck) { case KeyCode.UpArrow: RightKey.DeActivateKey(); UpKey.ActivateKey(); DownKey.DeActivateKey(); LeftKey.DeActivateKey(); RKey.DeActivateKey(); break; case KeyCode.RightArrow: RightKey.ActivateKey(); UpKey.DeActivateKey(); DownKey.DeActivateKey(); LeftKey.DeActivateKey(); RKey.DeActivateKey(); break; case KeyCode.DownArrow: RightKey.DeActivateKey(); UpKey.DeActivateKey(); DownKey.ActivateKey(); LeftKey.DeActivateKey(); RKey.DeActivateKey(); break; case KeyCode.LeftArrow: RightKey.DeActivateKey(); UpKey.DeActivateKey(); DownKey.DeActivateKey(); LeftKey.ActivateKey(); RKey.DeActivateKey(); break; } //start timer currentCooldown = GameProperties.GetCheckTime(); while (currentFramePressed != currentCheck) { yield return(new WaitForEndOfFrame()); currentCooldown -= Time.fixedDeltaTime; if (currentCooldown < 0) { Debug.Log("FAIL"); EndGame(); yield break; } } currentCheck = KeyCode.None; //check if any left if (gameCodes.Count == 0) { Debug.Log("WIN"); GameManager.RemoveInfection(this); transform.parent.GetComponent <SpriteRenderer>().enabled = false; Destroy(gameObject); yield break; } } }
public bool ButtonPressed() { return(UpKey.Down() || DownKey.Down() || LeftKey.Down() || RightKey.Down()); }
public override void Update(GameTime gt) { if (AutoSwitchInputs) //Switch the inputs { if (Input != MovementInput.Analog && AnalogStickMoved()) { Input = MovementInput.Analog; EntityGame.Log.Write("Input switched to Analog", this, Alert.Info); } else if (Input != MovementInput.Buttons && ButtonPressed()) { Input = MovementInput.Buttons; EntityGame.Log.Write("Input switched to Buttons", this, Alert.Info); } } switch (Input) { case MovementInput.Analog: if (!HasFocus && (AnalogStickMoved() || SelectKey.Down())) { GetFocus(this); } if (HasFocus) { //TODO: Use normalized positition for this. Position = new Vector2(Position.X + AnalogStick.Position.X * MovementSpeed.X, Position.Y - AnalogStick.Position.Y * MovementSpeed.Y); //Move it with the camera. //Position += EntityGame.Camera.Delta; //Keep it from leaving the bounds of the window. if (Body.Position.X < EntityGame.ActiveCamera.ScreenSpace.Left) { Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Left; } else if (Body.BoundingRect.Right > EntityGame.ActiveCamera.ScreenSpace.Right) { Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Right - Body.Bounds.X; } if (Body.Position.Y < EntityGame.ActiveCamera.ScreenSpace.Top) { Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Top; } else if (Body.BoundingRect.Bottom > EntityGame.ActiveCamera.ScreenSpace.Bottom) { Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Bottom - Body.Bounds.Y; } } break; case MovementInput.Buttons: if (!HasFocus && ButtonPressed() || SelectKey.Down()) { GetFocus(this); } if (HasFocus) { Position = new Vector2( Position.X + ((LeftKey.Down()) ? -MovementSpeed.X : 0) + ((RightKey.Down()) ? MovementSpeed.X : 0), Position.Y + ((UpKey.Down()) ? -MovementSpeed.Y : 0) + ((DownKey.Down()) ? MovementSpeed.Y : 0) ); //Move it with the camera. Position += EntityGame.ActiveCamera.Delta; //Keep it from leaving the bounds of the window. if (Body.Position.X < EntityGame.ActiveCamera.ScreenSpace.Left) { Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Left; } else if (Body.BoundingRect.Right > EntityGame.ActiveCamera.ScreenSpace.Right) { Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Right - Body.Bounds.X; } if (Body.Position.Y < EntityGame.ActiveCamera.ScreenSpace.Top) { Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Top; } else if (Body.BoundingRect.Bottom > EntityGame.ActiveCamera.ScreenSpace.Bottom) { Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Bottom - Body.Bounds.Y; } } break; } base.Update(gt); }