public override void Update() { //Console.WriteLine("Gate -> " + state.ToString() + " - " + getCurrentFrame() + "/" + getNumSprites()); switch(state) { case GateState.OPENING: //Opening gate if (!isLastFrame()) nextSprite(); else //Gate is now open state = GateState.OPEN; break; case GateState.CLOSING: //Closing gate if (!isFirstFrame()) lastSprite(); else //Gate is now closed state = GateState.CLOSED; break; default: //Do nothing if closed or open. break; } }
void Start() { animator_ = GetComponent <Animator>(); numObjectsInTriggerZone_ = 0; audio_ = GetComponent <AudioSource>(); state_ = initialState; animator_.SetInteger("State", (int)state_); if (triggerType == GateTriggerType.kPressurePlate && triggerPlate == null) { Debug.LogWarning("Trigger type is PressurePlate but no pressure plate was linked on Gate with name " + name + ". Trigger type will be set to no trigger."); triggerType = GateTriggerType.kNoTrigger; } if (triggerType == GateTriggerType.kSwitch && triggerSwitch == null) { Debug.LogWarning("Trigger type is Switch but no switch was linked on Gate with name " + name + ". Trigger type will be set to no trigger."); triggerType = GateTriggerType.kNoTrigger; } if (triggerType == GateTriggerType.kPressurePlate) { triggerPlate.PressurePlateEvent += PressurePlateListener; } if (triggerType == GateTriggerType.kSwitch) { triggerSwitch.SwitchEvent += SwitchListener; } }
protected override void SolveInstance(IGH_DataAccess da) { if (Params.Input.Count != Params.Output.Count) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input and output count must be equal"); return; } switch (_state) { case GateState.Closed: SetBlankData(da); break; case GateState.Activated: SetData(da); _inputState = new int[Params.Input.Count]; _state = GateState.Reset; break; case GateState.Reset: SetBlankData(da); ExpireAllOutputs(); _state = GateState.Closed; break; default: throw new ArgumentOutOfRangeException(); } }
private IEnumerator SwitchGate(GateState state) { switch (state) { case GateState.Opening: gateAnimator.Play("DoorOpen"); break; case GateState.Closing: gateAnimator.Play("DoorClose"); break; } while ((gateAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime > 0f && gateAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1f)) { yield return(new WaitForEndOfFrame()); } if (state == GateState.Opening) { gateState = GateState.Opened; Debug.Log("GATE OPENED"); } else if (state == GateState.Closing) { gateState = GateState.Closed; Debug.Log("GATE CLOSED"); } }
// Start is called before the first frame update void Start() { playerHealth = player.GetComponent <PlayerHealth> (); currentGameState = GateState.LevelState; ShowScreen(Level); }
public void Update() { gateKey.Rotation.Y -= MathHelper.ToRadians(6); switch (State) { case GateState.Closing: if (gate.Position.Y < 0.3f) { gate.Position.Y += 0.5f; } else { State = GateState.Closed; } break; case GateState.Opening: if (gate.Position.Y > -4.2f) { gate.Position.Y -= 0.5f; } else { State = GateState.Opened; } break; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.P)) { if (isPaused) { isPaused = false; currentGameState = GateState.LevelState; ShowScreen(Level); } else { isPaused = true; currentGameState = GateState.PauseState; ShowScreen(Pause); } } if (playerHealth.isDead == true) { currentGameState = GateState.LoseState; ShowScreen(Lose); } }
public void DoReportState(GateState state) { if (thisDHD != null) { thisDHD.ReportState(state); } }
public void Open() { if (state == GateState.CLOSED) { state = GateState.CHANGING; LeanTween.moveLocal(model, new Vector3(0, 0, 10), 2.0f).setOnComplete(OnOpen); } }
public void Close() { if (state == GateState.OPEN) { state = GateState.CHANGING; LeanTween.moveLocal(model, new Vector3(0, 0, 0), 2.0f).setOnComplete(OnClose); } }
void OpenGate() { m_GateState = GateState.Opened; if (m_GateCoroutne != null) { StopCoroutine(m_GateCoroutne); } m_GateCoroutne = StartCoroutine(OpenGateCoroutine()); }
void CloseGate() { m_GateState = GateState.Closed; if (m_GateCoroutne != null) { StopCoroutine(m_GateCoroutne); } m_GateCoroutne = StartCoroutine(CloseGateCoroutine()); }
IEnumerator unlockDoor() { source.Play(); gate_state = GateState.UNLOCKING; anim.SetBool("unlock", true); yield return(new WaitForSecondsRealtime(1f)); gateSolidCollider.enabled = false; gate_state = GateState.UNLOCKED; }
public void SetActivation(GateParam param) { var index = Params.Input.IndexOf(param); _inputState[index] = 1; if (_inputState.All(x => x == 1)) { _state = GateState.Activated; _inputState = new int[Params.Input.Count]; } }
public FinalGate(ContentManager content, ref List<AABB> collisionList, Vector3 position, Vector3 rotation, float scale) : base(@"Models\Environment\FinalGatePillars", content, position, rotation, scale) { CreateDoors(content, ref collisionList, position, scale); base.FogEnd = 3000; currentState = GateState.CLOSED; emitter = new AudioEmitter(); emitter.Position = position; }
public void CloseGate() { if (m_currentState == GateState.Closed) { return; } transform.DORotate(new Vector3(0, m_closedYRotation, 0), m_openCloseSpeed).OnComplete(() => { if (m_onDoorClose != null) { m_onDoorClose.Invoke(); } });; m_currentState = GateState.Closed; }
public void Rewind(bool isOpen) { if (isOpen) { State = GateState.Opened; gate.Position.Y = -4.2f; } else { State = GateState.Closed; gate.Position.Y = 0.3f; } }
private async void Update() { await EnsureSubscribeRegisteredAsync(); if (_state == _newState) { return; } _state = _newState; beamAnimator.SetBool(Open, _state == GateState.Open); if (blocker != null) { blocker.SetActive(_state == GateState.Closed); } }
private async Task EnsureSubscribeRegisteredAsync() { if (_isSubscribed || !communicationsManager.IsInitialized || topic == null) { return; } await communicationsManager.Client.SubscribeAsync(Topic, state => { Debug.Log($"Received state {state} for {Topic}"); _newState = (GateState)int.Parse(state); }); _isSubscribed = true; }
private void openCloseBtn_OnButtonClicked(Object o, String tag) { Gates gates = this.parent as Gates; GateState gatesState = gates.OpenCloseState; if (gatesState == GateState.Closed) { gates.OpenCloseState = GateState.Empty; this.openCloseBtn.BtnTexture = this.openBtnTex; } else { gates.OpenCloseState = GateState.Empty; this.openCloseBtn.BtnTexture = this.closeBtnTex; } }
public void TriggerKey(int[] position) { if (KeyPosition[0] != position[0] || KeyPosition[1] != position[1]) { return; } SoundController.PlaySound(PlayContentHolder.Instance.SoundGateToggle); if (State == GateState.Closed) { State = GateState.Opening; } if (State == GateState.Opened) { State = GateState.Closing; } }
public GateSystem(int[] gatePosition, int[] keyPosition, PlayScene parent) { _parent = parent; gate = new CModel(PlayContentHolder.Instance.ModelGate); gateWall = new CModel(PlayContentHolder.Instance.ModelGateWall); gateKey = new CModel(PlayContentHolder.Instance.ModelGateKey); GatePosition = gatePosition; KeyPosition = keyPosition; gate.Position.X = gateWall.Position.X = GatePosition[1] * 10 + 5; gate.Position.Z = gateWall.Position.Z = (GatePosition[0] + 1) * 10; gateKey.Position.X = KeyPosition[1] * 10 + 5; gateKey.Position.Z = KeyPosition[0] * 10 + 5; State = GateState.Closed; }
public void AddCapture(IImage image, CaptureSource source, GateState state = GateState.Open, DateTime?timestamp = null) { if (!IsEnabled) { return; } var dateTime = timestamp ?? DateTime.UtcNow; DateTime lastTimestamp; if (_lastTimestamps.TryGetValue(source, out lastTimestamp) && (dateTime - lastTimestamp).TotalMilliseconds < minCaptureInterval) { return; } var capture = new CaptureEntry() { Timestamp = dateTime, GateState = state, Source = source, FilePath = SaveImage(image, source.ToString()), }; var command = _db.CreateCommand(); command.CommandText = string.Format( "INSERT INTO CaptureEntries (Timestamp, GateState, Source, FilePath) VALUES ('{0}Z', {1}, {2}, '{3}')", capture.Timestamp.ToString("yyyy-MM-dd HH:mm:ss.fffffff"), (int)capture.GateState, (int)capture.Source, capture.FilePath); try { lock (_dbLock) { command.ExecuteNonQuery(); } _lastTimestamps[source] = dateTime; } catch (Exception e) { TryDeleteImage(capture.FilePath); throw new CaptureStorageException("Failed to add a capture to DB", e); } finally { command.Dispose(); } }
// Start is called before the first frame update void Start() { animator = GetComponent <Animation>(); animator.playAutomatically = false; openAnimation.legacy = true; closeAnimation.legacy = true; animator.AddClip(openAnimation, GateState.Open.ToString()); animator.AddClip(closeAnimation, GateState.Closed.ToString()); currentState = initialState; var clip = GetCurrentAnimation(); animator[clip].speed = 9999; animator.Play(clip); SetCollider(); }
public Gate(Game game, int xPos, int yPos, int screenWidth, int screenHeight, Texture2D texture, Level _parentLevel) { parentLevel = _parentLevel; position = new Rectangle(); position.Width = screenWidth / colsPerScreen; position.Height = screenHeight / rowsPerScreen; position.X = xPos * position.Width; position.Y = yPos * position.Height; leftHalf = new Rectangle(0, 0, spriteWidth, spriteHeight); rightHalf = new Rectangle(spriteWidth, 0, spriteWidth, spriteHeight); state = GateState.closed; status = GateStatus.closing; ticker = -1; gateTexture = texture; /* Block off the right half of the gate right now */ Rectangle changeRect = new Rectangle((position.X / position.Width) + 1, position.Y / position.Height, 1, 4); parentLevel.modifyTiles(changeRect, CollisionType.invisible); }
public void IsClosed_GateClosed_ReturnsExpected(GpioPinValue closedPinValue, GpioPinValue openPinValue, bool expected) { // Arrange var closedSwithPin = new Mock <IPin>(); closedSwithPin .Setup(p => p.Read()) .Returns(closedPinValue); var openSwithPin = new Mock <IPin>(); openSwithPin .Setup(p => p.Read()) .Returns(openPinValue); var dut = new GateState(closedSwithPin.Object, openSwithPin.Object); // Act var actual = dut.IsClosed; // Assert Assert.Equal(expected, actual); }
public void HandleSelection(Vector3 dir, bool firstPoint = false) { if (firstPoint) { // Do unique first point stuff } switch (gateStatus) { case GateState.empty: // Add In Point dirToLastPlanet = dir; gateStatus = GateState.hasIn; AddPoint(dirToLastPlanet); break; case GateState.hasIn: // Add out dirToNextPlanet = dir; Vector3 last = dirToLastPlanet.normalized; Vector3 next = dirToNextPlanet.normalized; Vector3 midPtDirection = (last + next) / 2; AddPoint(midPtDirection); AddPoint(dirToNextPlanet); angleToNextPlanet = 180 - Vector3.Angle(next, last); Debug.Log(angleToNextPlanet); ConvertPlanetTension(); break; } }
/// <summary> /// Opens the gate. /// </summary> public void openGate() { if(state == GateState.CLOSED || state == GateState.CLOSING) state = GateState.OPENING; }
public void ReportState(GateState state) { this.state = state; Log.Write(LogLevel.Info, "Gate State: " + state); }
private void OpenGate() { Game.SoundManager.PlaySound("GateDoorOpening", this); gateState = GateState.OPENING; }
public override void Update(float deltaTime) { base.Update(deltaTime); if (gateState == GateState.OPENING) { if (base.Position.Y < openedPosition.Y) { base.Position += (openingVelocity * deltaTime); CreateCollision(base.Position, base.Rotation, base.Scale); } else { gateState = GateState.OPEN; gateBeenOpenFor = 0.0f; } } else if (gateState == GateState.CLOSING) { if (base.Position.Y > closedPosition.Y) { base.Position += (closingVelocity * deltaTime); CreateCollision(base.Position, base.Rotation, base.Scale); } else { foreach (IInteractableObject interactable in interactingParties) interactable.UsedCallback(); gateState = GateState.CLOSED; } } else if (gateState == GateState.OPEN) { gateBeenOpenFor += deltaTime; if(gateBeenOpenFor >= closeAfter) { CloseGate(); } } }
public void Use(AABB interactingParty) { currentState = GateState.OPENING; }
public void Open() { currentState = GateState.OPENING; }
public void StopOpening() { currentState = GateState.OPEN; }
public void Use(AABB interactingParty) { if (currentState == GateState.CLOSED) { currentState = GateState.OPENING; } }
public GateDoor(ContentManager content, ref List<AABB> collisionList, Vector3 position, float scale, string meshName, Vector3 _moveToPos) : base(meshName, content, position, new Vector3(0, 180, 0), scale) { base.FogEnd = 3000; currentState = GateState.CLOSED; CreateCollision(position, new Vector3(0, 180, 0), scale); collisionList.Add(this); emitter = new AudioEmitter(); emitter.Position = position; this.moveToPos = _moveToPos; velocity = Vector3.Subtract(moveToPos, position); velocity.Normalize(); velocity *= 45;//Needs tweaking }
public void Update(GameTime gameTime) { if (ticker == 0) { if (state == GateState.closed) { leftHalf.X = spriteWidth * 0; if (status == GateStatus.opening) state = GateState.quarterOpen; else ticker = -1; } else if (state == GateState.quarterOpen) { leftHalf.X = spriteWidth * 1 * 2; if (status == GateStatus.opening) state = GateState.halfOpen; else state = GateState.closed; } else if (state == GateState.halfOpen) { //Gate is not fully open - make sure it won't let anything through now Rectangle changeRect = new Rectangle(((position.X + totalDeltaX)/ position.Width) + 1, position.Y / position.Height, 1, 4); parentLevel.modifyTiles(changeRect, CollisionType.invisible); leftHalf.X = spriteWidth * 2 * 2; if (status == GateStatus.opening) state = GateState.open; else state = GateState.quarterOpen; } else if (state == GateState.open) { leftHalf.X = spriteWidth * 3 * 2; if (status == GateStatus.closing) { state = GateState.halfOpen; } else { //Gate has fully opened. Stop the timer and change the underlying tiles to let it through ticker = -1; parentLevel.modifyTiles(new Rectangle(((position.X + totalDeltaX) / position.Width) + 1, position.Y / position.Height, 1, 4), CollisionType.passable); } } rightHalf.X = leftHalf.X + spriteWidth; } if (ticker >= 0) { ticker++; if (ticker >= 15) ticker = 0; } }
// Start is called before the first frame update void Start() { gate_state = GateState.LOCKED; anim = GetComponentInChildren <Animator>(); }
public void flip() { if (status == GateStatus.closing && state == GateState.closed) { status = GateStatus.opening; state = GateState.quarterOpen; } else if (status == GateStatus.opening && state == GateState.open) { status = GateStatus.closing; state = GateState.halfOpen; } ticker = 0; }
private void CloseGate() { Game.SoundManager.PlaySound("GateDoorClosing", this); gateState = GateState.CLOSING; }
public void ChangeState(GateState state) { gateState = state; StartCoroutine(SwitchGate(state)); }
void Start() { gateState = GetComponentInParent <GateState>(); }
public void NodeInfo_GetGateState_Test() { GateState state = NodeInfo.GetGateState(); Assert.IsTrue(state == GateState.Left || state == GateState.Right); }
/// <summary> /// Constructor /// </summary> /// <param name="state">Gate state - Left or Right</param> public NodeInfo(GateState state) { GateState = state; }
/// <summary> /// Closes the gate. /// </summary> public void closeGate() { if(state == GateState.OPEN || state == GateState.OPENING) state = GateState.CLOSING; }