void MakeDoor(DoorState doorState){ if(doorState == DoorState.open){ OperateDoor(true, doorOpenSound, "dooropen"); }else if(doorState == DoorState.shut){ OperateDoor(false, doorShutSound, "doorshut"); } }
/// <summary> /// Directly sets the state of the door. /// </summary> /// <param name="state">The new state of the door</param> public void SetState(DoorState state) { if (state == DoorState.OPENED) Open(); else Close(); }
public Vehicle(Model model, ObjectStats.VehicleStats vehicleStats) : base(model, vehicleStats) { rearWheelsCount = vehicleStats.RearWheelCount; frontWheelsCount = vehicleStats.FrontWheelCount; doorCount = vehicleStats.DoorCount; hasTurret = vehicleStats.HasTurret; waterSourceCount = vehicleStats.WaterSourceCount; leftDoorAngle = 0; rightDoorAngle = 0; leftDoorState = DoorState.Closed; rightDoorState = DoorState.Closed; wheelAngle = 0; wheelState = WheelState.Straight; NextStep = new Vector2(Position.X,Position.Z); //TEMP //leftDoorState = DoorState.Opening; //rightDoorState = DoorState.Opening; //wheelState = WheelState.StraightLeft; //gi = new GameInfo(); }
protected void Open() { if (state != DoorState.closed) { return; } state = DoorState.opening; StartCoroutine(Lerp.move(transform, closed, open, timeToOpen, () => { state = DoorState.open; })); }
/** * @param state */ public void setState(DoorState state) { //throws CannotChangeStateOfLockedDoor { if (this.lockStatus.Equals(LockStatus.LOCKED)) { throw new CannotChangeStateOfLockedDoor(); } this.doorState = state; }
void OnTriggerExit() { if(state == DoorState.OPENED) { closing = true; state = DoorState.ANIM; StartCoroutine(CloseDoorAnimated()); } }
void Start() { closed = transform.position; open = transform.position + transform.TransformDirection(Vector3.right * metresToMove); state = DoorState.closed; }
void OnTriggerEnter(Collider other) { if(other.gameObject.tag == "Prim") { if (state == DoorState.CLOSED) { opening = true; state = DoorState.ANIM; StartCoroutine(OpenDoorAnimated()); } } }
public Door(Vector2 position) { Position = position; cube = new Cube(Position.ToVector3(), RM.GetTexture("door")); cube.SetPosition(new Vector3(Position.X, Y, Position.Y)); HudIcons.Add(new HudIcon() { text = "Open door", texture = RM.GetTexture("opendooricon"), Action = (() => state = DoorState.Opening) }); HudIcons.Add(new HudIcon() { text = "Close door", texture = RM.GetTexture("closedooricon"), Action = (() => state = DoorState.Closing) }); HudIcons.Add(new HudIcon() { text = "Lock/unlock", texture = RM.GetTexture("lockicon"), Action = (() => Locked = !Locked) }); HudIcons.Add(new HudIcon() { text = "Toggle AI", texture = RM.GetTexture("dooraiicon"), Action = (() => ai = !ai) }); }
void FixedUpdate() { if (lerpsToDo > 0 && (myDoorState == DoorState.DoorStopped || myDoorState == DoorState.DoorClosed) ) { if (myDoorState != DoorState.DoorStopped) { myDoorLerp = 0.0f; } myPuzzlesSolved++; myDoorState = DoorState.DoorOpening; audio.Play (); lerpsToDo--; } if (myDoorState == DoorState.DoorClosing) { myDoorLerp += (Time.deltaTime * myDoorSpeed); Vector3 pos = transform.localPosition; pos.x = Mathf.Lerp (myOpenPosition.x, myClosedPosition.x, myDoorLerp); pos.y = Mathf.Lerp (myOpenPosition.y, myClosedPosition.y, myDoorLerp); pos.z = Mathf.Lerp (myOpenPosition.z, myClosedPosition.z, myDoorLerp); transform.localPosition = pos; if (myDoorLerp >= 1.0f) { myDoorState = DoorState.DoorClosed; } } if (myDoorState == DoorState.DoorOpening) { myDoorLerp += (Time.deltaTime * myDoorSpeed); Vector3 pos = transform.localPosition; pos.x = Mathf.Lerp (myClosedPosition.x, myOpenPosition.x, myDoorLerp); pos.y = Mathf.Lerp (myClosedPosition.y, myOpenPosition.y, myDoorLerp); pos.z = Mathf.Lerp (myClosedPosition.z, myOpenPosition.z, myDoorLerp); transform.localPosition = pos; float targetLerp = (1.0f / myNumberOfPuzzles) * myPuzzlesSolved; if (myDoorLerp >= targetLerp) { myDoorState = DoorState.DoorStopped; } if (myDoorLerp >= 1.0f) { myDoorState = DoorState.DoorOpen; //if( mySolvedSound.isPlaying == false) mySolvedSound.Play(); } } // Enable emitters while rigidbody reports a veloicty on the y plane if (myDoorState == DoorState.DoorClosing || myDoorState == DoorState.DoorOpening) { if (myEmittersEnabled == false) { EnableEmitters (); } } else if (myDoorState == DoorState.DoorClosed || myDoorState == DoorState.DoorOpen) { if (myEmittersEnabled == true) { DisableEmitters (); } } }
// for when tile is moved, // test adjacencies public void UpdateDoorState() { switch (Orientation) { case Direction.Up: if (parent.MapIndexY + 1 < map.worldSize) { Tile adjacent = map.grid[parent.MapIndexX, parent.MapIndexY + 1]; if (adjacent == null) { State = DoorState.Locked; } else { State = DoorState.Unlocked; } } else if (parent.MapIndexY + 1 == map.worldSize) { State = DoorState.Locked; } break; case Direction.Down: if (parent.MapIndexY - 1 >= 0) { Tile adjacent = map.grid[parent.MapIndexX, parent.MapIndexY - 1]; if (adjacent == null) { State = DoorState.Locked; } else { State = DoorState.Unlocked; } } else if (parent.MapIndexY - 1 < 0) { State = DoorState.Locked; } break; case Direction.Left: if (parent.MapIndexX - 1 >= 0) { Tile adjacent = map.grid[parent.MapIndexX - 1, parent.MapIndexY]; if (adjacent == null) { State = DoorState.Locked; } else { State = DoorState.Unlocked; } } else if (parent.MapIndexX - 1 < 0) { State = DoorState.Locked; } break; case Direction.Right: if (parent.MapIndexX + 1 < map.worldSize) { Tile adjacent = map.grid[parent.MapIndexX + 1, parent.MapIndexY]; if (adjacent == null) { State = DoorState.Locked; } else { State = DoorState.Unlocked; } } else if (parent.MapIndexX + 1 == map.worldSize) { State = DoorState.Locked; } break; } }
public override void Update() { switch (state) { case DoorState.Opening: { Y += 0.25f; if (Y >= 22) { Y = 22; state = DoorState.Open; } } break; case DoorState.Closing: { Y -= 0.25f; if (Y <= 0) { state = DoorState.Closed; Y = 0; } } break; case DoorState.Closed: Y = 0; break; case DoorState.Open: Y = 22; break; default: break; } if (ai) { if ((state == DoorState.Closed || state == DoorState.Open) && !Locked) { if (World.entities.OfType<WalkingEntity>().Any(e => e.Alive && (e.Position - Position).Length() < 32)) { if (state == DoorState.Closed) state = DoorState.Opening; } else { if (state == DoorState.Open) state = DoorState.Closing; } } } base.Update(); cube.SetPosition(new Vector3(Position.X, Y, Position.Y)); }
public void closeDoor() { if (state == DoorState.Closed) return; state = DoorState.Closed; #if UNITY_EDITOR if (audioSource == null) return; #endif audioSource.clip = sound.closeDoorSound(); audioSource.Play(); }
void Start() { float angle = transform.eulerAngles.z; if (angle > 89 && angle < 91) doorState = DoorState.BottomLeft; else if (angle > 179 && angle < 181) doorState = DoorState.BottomRight; else if (angle > 269 && angle < 271) doorState = DoorState.TopRight; else doorState = DoorState.TopLeft; rotateTimer = -1; }
public void Toggle() { if (State == DoorState.Closed) { State = DoorState.Opening; // Open the door! rotationAngle = 0; // We just started to open/close, so reset the rotation angle } else if (State == DoorState.Open) { State = DoorState.Closing; // Close the door! rotationAngle = 0; // We just started to open/close, so reset the rotation angle } }
public void Close() { if (m_RequirePower == true) { if (m_Receiver != null && m_Receiver.isPowered == false) { return; } } if(m_State != DoorState.CLOSED) { m_State = DoorState.CLOSING; } }
/** * @fn public void HandleAction(ACTION_TYPE type) * @brief When the trigger action for the parent of the door object sends a message with PARENT_TRIGGER_ACTIVATED then the door will turn on gravity and slam shut... * @author Eagan * @date 2/3/2012 * @param type The type. */ public void HandleAction(ACTION_TYPE type) { if (type == ACTION_TYPE.PARENT_TRIGGER_ACTIVATED) { myDoorLerp = 0.0f; myDoorState = DoorState.DoorClosing; audio.Play (); } else if (type == ACTION_TYPE.PUZZLE_SOLVED) { if(myPuzzlesSolved < myNumberOfPuzzles) { lerpsToDo++; } } }
/// <summary> /// Returns the displacement matrix for each door /// </summary> /// <param name="gameTime">Amount of time that has passed since last call</param> /// <param name="startClosing"> should the door be closing,</param> /// <param name="openSignal"> should the door be opening</param> /// <returns> displacement matrix for the door</returns> public Matrix Update(GameTime gameTime, bool startClosing) { Vector3 translate = new Vector3(0,0,0); switch (currentstate) { case(DoorState.open): if (startClosing) currentstate= DoorState.closing; break; case(DoorState.opening): if (startClosing) { currentstate = DoorState.closing; break; } float change =(float) gameTime.ElapsedGameTime.TotalSeconds * raiseSpeed; height += change; if (height > 200) { height = 200; currentstate = DoorState.open; } break; case(DoorState.closing): if (!startClosing) { currentstate = DoorState.opening; break; } change =(float) gameTime.ElapsedGameTime.TotalSeconds * raiseSpeed; height -= change; if (height < 0) { height = 0; currentstate = DoorState.closed; } break; case(DoorState.closed): if (!startClosing) currentstate = DoorState.opening; break; } translate.Y = height; return Matrix.CreateTranslation(translate); }
public void OpenDoor() { if (doorTriggerActive){ doorOpenAudio.Play(); doorState = DoorState.OPENING; Transform particleSystemTransform = transform.parent.FindChild("Particle System"); if (particleSystemTransform !=null) { ParticleSystem particleSystem = (ParticleSystem) particleSystemTransform.GetComponent(typeof(ParticleSystem)); particleSystem.enableEmission = false; } } if (!doorTriggerActive){ doorOpenAudio.PlayOneShot(closedClip); } }
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) { int state = 0; if (stream.isWriting) { state = (int)State; stream.Serialize(ref state); } else { stream.Serialize(ref state); State = (DoorState)state; } if(State == DoorState.Open) (m_viewObject as AgentDoor).OpenDoor(); else if(State == DoorState.Closed) (m_viewObject as AgentDoor).CloseDoor(); }
private void fixAngle() { if (clockwise) { switch (doorState) { case DoorState.TopLeft: transform.eulerAngles = new Vector3(0,0,270); doorState = DoorState.TopRight; break; case DoorState.TopRight: transform.eulerAngles = new Vector3(0,0,180); doorState = DoorState.BottomRight; break; case DoorState.BottomRight: transform.eulerAngles = new Vector3(0,0,90); doorState = DoorState.BottomLeft; break; case DoorState.BottomLeft: transform.eulerAngles = new Vector3(0,0,0); doorState = DoorState.TopLeft; break; } } else { switch (doorState) { case DoorState.TopLeft: transform.eulerAngles = new Vector3(0,0,90); doorState = DoorState.BottomLeft; break; case DoorState.TopRight: transform.eulerAngles = new Vector3(0,0,0); doorState = DoorState.TopLeft; break; case DoorState.BottomRight: transform.eulerAngles = new Vector3(0,0,270); doorState = DoorState.TopRight; break; case DoorState.BottomLeft: transform.eulerAngles = new Vector3(0,0,180); doorState = DoorState.BottomRight; break; } } rotateTimer = -1; }
IEnumerator CloseDoorAnimated() { StartCoroutine(Wait(animationTime)); float step = angle / animationTime; step /= 100.0f; float rotated = 0; while (rotated + 0.1 < angle) { yield return new WaitForSeconds(1 / 100.0f); doorPanel.Rotate(Vector3.forward, -step); rotated += step; } closing = false; state = DoorState.CLOSED; }
public Door(Vector3 position) { this.position = position; doorBaseMesh = new Mesh(); doorBaseMesh.Model = AssetLoader.mdl_doorBase; doorBaseMesh.Transform = FLIP90Y * Matrix.CreateTranslation(position); doorLeftMesh = new Mesh(); doorLeftMesh.Model = AssetLoader.mdl_doorPanel; doorLeftMesh.Transform = FLIP90Y * Matrix.CreateTranslation(position); doorRightMesh = new Mesh(); doorRightMesh.Model = AssetLoader.mdl_doorPanel; doorRightMesh.Transform = FLIP180X * FLIP90Y * Matrix.CreateTranslation(position + new Vector3(0, 2.5f, 0)); Globals.gameInstance.sceneGraph.Setup(doorBaseMesh); Globals.gameInstance.sceneGraph.Add(doorBaseMesh); Globals.gameInstance.sceneGraph.Setup(doorLeftMesh); Globals.gameInstance.sceneGraph.Add(doorLeftMesh); Globals.gameInstance.sceneGraph.Setup(doorRightMesh); Globals.gameInstance.sceneGraph.Add(doorRightMesh); lightLeft = new Light(); lightLeft.LightType = Light.Type.Point; lightLeft.Color = Color.Red; lightLeft.Radius = 2; lightLeft.Transform = Matrix.CreateTranslation(position + new Vector3(-0.6f, 1.5f, -1.4f)); lightRight = new Light(); lightRight.LightType = Light.Type.Point; lightRight.Color = Color.Red; lightRight.Radius = 2; lightRight.Transform = Matrix.CreateTranslation(position + new Vector3(-0.6f, 1.5f, 1.4f)); Globals.gameInstance.sceneGraph.Add(lightRight); Globals.gameInstance.sceneGraph.Add(lightLeft); state = DoorState.CLOSED; openPercent = MINOPEN; UpdatePanelPositions(); }
public virtual void OnProximityDetect(Transform target) { closeDelayCooldown = CloseDelayTime; if (!IsLocked) { if (State != DoorState.Open && !audioSource.isPlaying) audioSource.Play(); if (State != DoorState.Opening && State != DoorState.Open) { State = DoorState.Opening; slideCooldown = SlideTime; } if (PlayerController.Current != null) { if (target == PlayerController.Current.transform) { Side = (int)Mathf.Sign(Vector3.Dot(PlayerController.Current.transform.position - transform.position, transform.forward)); } } } }
// Update is called once per frame void Update() { if (closedRotationAngle >= openDegree || closedRotationAngle <= -1*openDegree) { doorState = DoorState.OPEN; } if (doorState.Equals(DoorState.OPENING)){ float openingAngle; if (clockWiseOpenDoor == true){ openingAngle = 2f; } else { openingAngle = -2f; } Transform parentTransform = gameObject.transform.parent; parentTransform.RotateAround(doorHingeTransform.position, Vector3.up, openingAngle); closedRotationAngle = closedRotationAngle + openingAngle; } }
protected void Awake() { if (leftDoorTransform != false) { leftClosedPosition = leftDoorTransform.position; leftOpenPosition = (Vector2)leftDoorTransform.position - moveAxis; } if (rightDoorTransform != false) { rightClosedPosition = rightDoorTransform.position; rightOpenPosition = (Vector2)rightDoorTransform.position + moveAxis; } animator = GetComponent <Animator>(); state = DoorState.Closed; animator.enabled = false; audioSource = gameObject.GetComponent <AudioSource>(); if (audioSource) { Sound sound = AudioManager.instance.GetSound("DoorOpen"); audioSource.clip = sound.clip; audioSource.volume = sound.volume; audioSource.pitch = sound.pitch; } }
public override void LoadFromStream(BinaryReader stream, FileVersion version) { try { fID = (BuildingID)StreamUtils.ReadInt(stream); Area = StreamUtils.ReadRect(stream); Doors.Clear(); sbyte count = (sbyte)StreamUtils.ReadByte(stream); for (int i = 0; i < count; i++) { int dx = StreamUtils.ReadInt(stream); int dy = StreamUtils.ReadInt(stream); int dir = StreamUtils.ReadByte(stream); DoorState st = (DoorState)StreamUtils.ReadByte(stream); AddDoor(dx, dy, dir, st); } int idx = StreamUtils.ReadInt(stream); Holder = ((idx == -1) ? null : (CreatureEntity)((NWField)Owner).Creatures.GetItem(idx)); } catch (Exception ex) { Logger.Write("Building.loadFromStream(): " + ex.Message); throw ex; } }
public Door(ContentManager content, Vector3 position, Vector3 rotation, Vector3 moveToPos, float scale, Vector3 openFromDirection, ref List<AABB> collisionList, string openedByKeyWithID, DoorState state = DoorState.CLOSED, bool canToggle = false) : base(@"Models\Environment\SecretDoor", content, position, rotation, scale) { base.color = new Vector3(0.2f, 0.2f, 0.2f); this.OpenedByKeyWithID = openedByKeyWithID; this.doorState = state; CreateUseAABB(openFromDirection, position, 150, 150); Interactables.AddInteractable(this); emitter = new AudioEmitter(); emitter.Position = position; orgOpenPos = moveToPos; orgMoveToPos = moveToPos; this.canToggle = canToggle; collisionAABB = new AABB(); CreateCollision(position, rotation, scale); collisionList.Add(collisionAABB); velocity = Vector3.Subtract(moveToPos, position); }
/// <inheritdoc /> protected override void OnStart(DoorState initialState) { //TODO: Handle both states. switch (StateContainer.State) { case DoorState.Unlocked: this.OnDoorUnlocked?.Invoke(); foreach (Animator a in animationControllers) { a.SetTrigger(DefaultDoorAnimationTrigger.Unlock.ToString()); } break; case DoorState.Locked: foreach (Animator a in animationControllers) { a.SetTrigger(DefaultDoorAnimationTrigger.Lock.ToString()); } break; default: break; } }
private void Update() { switch (_doorState) { case DoorState.Closing: _frame.transform.localPosition = new Vector3(_frame.transform.localPosition.x - 0.01f, _frame.transform.localPosition.y, _frame.transform.localPosition.z); if (_frame.transform.localPosition.x <= _closedPosition) { _doorState = DoorState.Closed; } break; case DoorState.Opening: _frame.transform.localPosition = new Vector3(_frame.transform.localPosition.x + 0.01f, _frame.transform.localPosition.y, _frame.transform.localPosition.z); if (_frame.transform.localPosition.x >= _openedPosition) { _doorState = DoorState.Opened; } break; default: break; } }
void UpdateDoorState(TreeNode doorNode, DoorState state) { TreeNode node = doorNode.Nodes["Alarm"]; node.Text = "Alarm: " + (state.AlarmSpecified ? state.Alarm.ToString() : "Not specified"); node = doorNode.Nodes["DoubleLockPhysicalState"]; node.Text = "DoubleLockPhysicalState: " + (state.DoubleLockPhysicalStateSpecified ? state.DoubleLockPhysicalState.ToString() : "Not specified"); node = doorNode.Nodes["DoorPhysicalState"]; node.Text = "DoorPhysicalState: " + (state.DoorPhysicalStateSpecified ? state.DoorPhysicalState.ToString() : "Not specified"); node = doorNode.Nodes["DoorMode"]; node.Text = "DoorMode: " + (state.DoorMode.ToString()); node = doorNode.Nodes["LockPhysicalState"]; node.Text = "LockPhysicalState: " + (state.LockPhysicalStateSpecified ? state.LockPhysicalState.ToString() : "Not specified"); node = doorNode.Nodes["Tamper"]; node.Text = "Tamper: " + (state.Tamper != null ? state.Tamper.State.ToString() : "Undefined"); node = doorNode.Nodes["Fault"]; node.Text = "Fault: " + (state.Fault != null ? state.Fault.State.ToString() : "Undefined"); }
private void HandleHordeCreation() { if (_producedUnit.Definition.KindOf.Get(ObjectKinds.Horde)) { _currentDoorState = DoorState.OpenForHordePayload; } else if (_producedUnit.ParentHorde != null) { var hordeContain = _producedUnit.ParentHorde.FindBehavior <HordeContainBehavior>(); hordeContain.Register(_producedUnit); var count = _producedUnit.AIUpdate.TargetPoints.Count; var direction = _producedUnit.AIUpdate.TargetPoints[count - 1] - _producedUnit.Translation; if (count > 1) { direction = _producedUnit.AIUpdate.TargetPoints[count - 1] - _producedUnit.AIUpdate.TargetPoints[count - 2]; } var formationOffset = hordeContain.GetFormationOffset(_producedUnit); var offset = Vector3.Transform(formationOffset, Quaternion.CreateFromYawPitchRoll(MathUtility.GetYawFromDirection(direction.Vector2XY()), 0, 0)); _producedUnit.AIUpdate.AddTargetPoint(_producedUnit.AIUpdate.TargetPoints[count - 1] + offset); _producedUnit.AIUpdate.SetTargetDirection(direction); } }
void BlockFound(GridScanArgs <IMyTerminalBlock> item) { if (item.First) { Updating = true; foreach (var d in Doors) { Intervals[d.Door.EntityId] = d.Interval; } Doors.Clear(); } if (item.Item is IMyDoor && Owner.PolicyCheck(Policy, item.Item) && !string.IsNullOrWhiteSpace(item.Item.CustomData) && parser.TryParse(item.Item.CustomData, Category)) { var d = new DoorState(item.Item as IMyDoor, parser.Get(Category, "Opposite").ToString(null), parser.Get(Category, "Timeout").ToDouble(0)); if (!Intervals.TryGetValue(d.Door.EntityId, out d.Interval)) { d.Interval = 0; } Doors.Add(d); } if (item.Last) { Intervals.Clear(); foreach (var d in Doors) { d.Opposite = Doors.Find((other) => string.Equals(d.OppositeDoorName, other.Door.CustomName, StringComparison.CurrentCultureIgnoreCase))?.Door; } UpdateIdx = Doors.Count - 1; Updating = false; } }
private void UpdateUi(DoorState doorState) { switch (doorState) { case SamsungWatchGarage.Integration.Models.DoorState.opening: case SamsungWatchGarage.Integration.Models.DoorState.closing: button.BackgroundColor = Color.Brown; button.Text = doorState.ToString(); button.IsEnabled = false; break; case SamsungWatchGarage.Integration.Models.DoorState.open: button.BackgroundColor = Color.Red; button.IsEnabled = true; button.Text = "Close"; break; case SamsungWatchGarage.Integration.Models.DoorState.closed: button.BackgroundColor = Color.Green; button.IsEnabled = true; button.Text = "Open"; break; } }
public void CloseDoor() { _currentDoorState = DoorState.Open; }
internal ProductionUpdate(GameObject gameObject, ProductionUpdateModuleData moduleData) { _gameObject = gameObject; _moduleData = moduleData; _currentDoorState = DoorState.Closed; }
private void Update() { //To Check if the player is in the zone if (playerInZone) { if (doorState == DoorState.Opened) { txtToDisplay.GetComponent <Text>().text = "Press 'F' to Close"; doorCollider.enabled = false; } else if (doorState == DoorState.Closed || gotKey) { txtToDisplay.GetComponent <Text>().text = "Press 'F' to Open"; doorCollider.enabled = true; } else if (doorState == DoorState.Jammed) { txtToDisplay.GetComponent <Text>().text = "Needs Key"; doorCollider.enabled = true; } } if (Input.GetKeyDown(KeyCode.F) && playerInZone) { doorOpened = !doorOpened; //The toggle function of door to open/close if (doorState == DoorState.Closed && !doorAnim.isPlaying) { if (!keyNeeded) { doorAnim.Play("Door_Open"); doorState = DoorState.Opened; } else if (keyNeeded && !gotKey) { doorAnim.Play("Door_Jam"); doorState = DoorState.Jammed; } } if (doorState == DoorState.Closed && gotKey && !doorAnim.isPlaying) { doorAnim.Play("Door_Open"); doorState = DoorState.Opened; } if (doorState == DoorState.Opened && !doorAnim.isPlaying) { doorAnim.Play("Door_Close"); doorState = DoorState.Closed; } if (doorState == DoorState.Jammed && !gotKey) { doorAnim.Play("Door_Jam"); doorState = DoorState.Jammed; } else if (doorState == DoorState.Jammed && gotKey && !doorAnim.isPlaying) { doorAnim.Play("Door_Open"); doorState = DoorState.Opened; } } }
public void SetState(DoorState _state) { m_CurrentState = _state; m_CurrentState.EnterState(); }
/// <summary> /// check if the animal door is in the desired state /// </summary> /// <param name="building">the building on which the door is located</param> /// <param name="state">the desired state for the door</param> /// <returns></returns> private bool IsDoorInDesiredState(Building building, DoorState state) { return(state == DoorState.Open ? building.animalDoorOpen : !building.animalDoorOpen); }
private void Update() { if (GameObject.Find("keypiece8") == null) { hasKey = true; } else { { hasKey = false; } } //if you don't have the key if (hasKey == false) { //To Check if the player is in the zone and doesn't have key if (playerInZone) { if (doorState == DoorState.Opened) { // txtToDisplay.GetComponent<Text>().text = "Press 'E' to Close"; doorCollider.enabled = false; } else if (doorState == DoorState.Closed || gotKey) { txtToDisplay.GetComponent <Text>().text = "Press 'E' to Open"; doorCollider.enabled = true; } else if (doorState == DoorState.Jammed) { txtToDisplay.GetComponent <Text>().text = "Needs Key"; doorCollider.enabled = true; } } if (Input.GetKeyDown(KeyCode.E) && playerInZone) { doorOpened = !doorOpened; //The toggle function of door to open/close if (doorState == DoorState.Closed && !doorAnim.isPlaying) { if (!keyNeeded) { doorAnim.Play("Door_Open"); doorState = DoorState.Opened; Destroy(txtToDisplay); SceneManager.LoadScene("Response8"); } } else if (keyNeeded && !gotKey) { doorAnim.Play("Door_Jam"); doorState = DoorState.Jammed; } } if (doorState == DoorState.Closed && gotKey && !doorAnim.isPlaying) { doorAnim.Play("Door_Open"); doorState = DoorState.Opened; } /* * if (doorState == DoorState.Opened && !doorAnim.isPlaying) * { * doorAnim.Play("Door_Close"); * doorState = DoorState.Closed; * } */ if (doorState == DoorState.Jammed && !gotKey) { doorAnim.Play("Door_Jam"); doorState = DoorState.Jammed; } else if (doorState == DoorState.Jammed && gotKey && !doorAnim.isPlaying) { doorAnim.Play("Door_Open"); doorState = DoorState.Opened; } } else { doorOpened = true; doorState = DoorState.Opened; doorCollider.enabled = false; //doorAnim.Play("Door_Open"); } }
void closeDoor() { Debug.Log("You closed door"); this.doorState = DoorState.closed; doorCollider.enabled = true; }
public void OpenDoor() { state = DoorState.Open; isMoving = true; }
/// <summary> /// This function sets the state of the specified door on the vehicle. /// </summary> public bool SetDoorState(Door door, DoorState state) { return(MtaShared.SetVehicleDoorState(element, (int)door, (int)state)); }
void CommonDoorPropertyEventTest(Func <DoorInfo, bool> doorCapabilitiesTest, TopicInfo topicInfo, Action <XmlElement, TopicInfo> validateTopic, ValidateMessageFunction validateMessageFunction, Func <DoorState, string> stateValueSelector, string stateSimpleItemName) { EndpointReferenceType subscriptionReference = null; System.DateTime subscribeStarted = System.DateTime.MaxValue; int timeout = 60; RunTest( () => { //3. Get complete list of doors from the DUT (see Annex A.1). //4. Check that there is at least one Door with [DOOR CAPABILITIES TEST]= “true”. // Otherwise skip other steps and go to the next test. List <DoorInfo> fullList = GetDoorInfoList(); List <DoorInfo> doors = fullList.Where(D => doorCapabilitiesTest(D)).ToList(); if (doors.Count == 0) { LogTestEvent("No Doors with required Capabilities found, exit the test" + Environment.NewLine); return; } //5. ONVIF Client will invoke GetEventPropertiesRequest message to retrieve // all events supported by the DUT. //6. Verify the GetEventPropertiesResponse message from the DUT. //7. Check if there is an event with Topic [TOPIC]. If there is no event with // such Topic skip other steps, fail the test and go to the next test. XmlElement topicElement = GetTopicElement(topicInfo); // if only one topic should be checked //ValidateTopicXml(topicElement); Assert(topicElement != null, string.Format("Topic {0} not supported", topicInfo.GetDescription()), "Check that the event topic is supported"); //8. Check that this event is a Property event (MessageDescription.IsProperty="true"). //9. Check that this event contains Source.SimpleItemDescription item with // Name="DoorToken" and Type="pt:ReferenceToken". //10. Check that this event contains Data.SimpleItemDescription item with Name=[NAME] // and Type=[TYPE]. XmlElement messageDescription = topicElement.GetMessageDescription(); validateTopic(messageDescription, topicInfo); FilterInfo filter = CreateFilter(topicInfo, messageDescription); Dictionary <NotificationMessageHolderType, XmlElement> notifications = new Dictionary <NotificationMessageHolderType, XmlElement>(); //11. ONVIF Client will invoke SubscribeRequest message with tns1:DoorControl/DoorMode Topic as Filter and an InitialTerminationTime of 60s to ensure that the SubscriptionManager is deleted after one minute. //12. Verify that the DUT sends a SubscribeResponse message. //13. Verify that DUT sends Notify message(s) //14. Verify received Notify messages (correct value for UTC time, TopicExpression and wsnt:Message). //15. Verify that TopicExpression is equal to tns1:DoorControl/DoorMode for all received Notify messages. //16. Verify that each notification contains Source.SimpleItem item with Name="DoorToken" and Value is equal to one of existing Door Tokens (e.g. complete list of doors contains Door with the same token). Verify that there are Notification messages for each Door. //17. Verify that each notification contains Data.SimpleItem item with Name="DoorMode" and Value with type is equal to tdc:DoorMode. //18. Verify that Notify PropertyOperation="Initialized". subscriptionReference = ReceiveMessages(filter.Filter, timeout, new Action(() => { }), fullList.Count, notifications, out subscribeStarted); EntityListInfo <DoorInfo> data = new EntityListInfo <DoorInfo>(); data.FullList = fullList; data.FilteredList = doors; ValidateMessages(notifications, topicInfo, OnvifMessage.INITIALIZED, data, validateMessageFunction); Dictionary <string, NotificationMessageHolderType> doorsMessages = new Dictionary <string, NotificationMessageHolderType>(); ValidateMessagesSet(notifications.Keys, doors, doorsMessages); //19. ONVIF Client will invoke GetDoorStateRequest message for each Door // with corresponding tokens. //20. Verify the GetDoorStateResponse messages from the DUT. Verify that // Data.SimpleItem item with Name=[SIMPLEITEMNAME] from Notification message has the // same value with [ELEMENT SELECTION] elements from corresponding GetDoorStateResponse // messages for each Door. foreach (string doorToken in doorsMessages.Keys) { DoorState state = GetDoorState(doorToken); string expectedState = stateValueSelector(state); XmlElement dataElement = doorsMessages[doorToken].Message.GetMessageData(); Dictionary <string, string> dataSimpleItems = dataElement.GetMessageElementSimpleItems(); string notificationState = dataSimpleItems[stateSimpleItemName]; Assert(expectedState == notificationState, string.Format("State is different ({0} in GetDoorStateResponse, {1} in Notification)", expectedState, notificationState), "Check that state is the same in Notification and in GetDoorStateResponse"); } }, () => { ReleaseSubscription(subscribeStarted, subscriptionReference, timeout); }); }
public void DoorOpened() { _state = DoorState.Open; _door.Close(); _state = DoorState.Closing; }
public void Open() { if (state == DoorState.CLOSED || state == DoorState.CLOSING) { state = DoorState.OPENING; lightRight.Color = Color.Green; lightLeft.Color = Color.Green; } }
internal override void Update(BehaviorUpdateContext context) { var time = context.Time; // If door is opening, halt production until it's finished opening. if (_currentDoorState == DoorState.Opening) { if (time.TotalTime >= _currentStepEnd) { _productionQueue.RemoveAt(0); Logger.Info($"Door waiting open for {_moduleData.DoorWaitOpenTime}"); _currentStepEnd = time.TotalTime + _moduleData.DoorWaitOpenTime; _currentDoorState = DoorState.Open; GetDoorConditionFlags(out var doorOpening, out var doorWaitingOpen, out var _); _gameObject.ModelConditionFlags.Set(doorOpening, false); _gameObject.ModelConditionFlags.Set(doorWaitingOpen, true); MoveProducedObjectOut(); } return; } if (_productionQueue.Count > 0) { var front = _productionQueue[0]; var result = front.Produce((float)time.DeltaTime.TotalMilliseconds); if (result == ProductionJobResult.Finished) { if (front.Type == ProductionJobType.Unit) { if (_moduleData.NumDoorAnimations > 0 && ExitsThroughDoor(front.ObjectDefinition) && (_currentDoorState != DoorState.OpenForHordePayload)) { Logger.Info($"Door opening for {_moduleData.DoorOpeningTime}"); _currentStepEnd = time.TotalTime + _moduleData.DoorOpeningTime; _currentDoorState = DoorState.Opening; SetDoorIndex(); GetDoorConditionFlags(out var doorOpening, out var _, out var _); _gameObject.ModelConditionFlags.Set(doorOpening, true); ProduceObject(front); } else { ProduceObject(front); MoveProducedObjectOut(); _productionQueue.RemoveAt(0); } } else if (front.Type == ProductionJobType.Upgrade) { GrantUpgrade(front); _productionQueue.RemoveAt(0); } } } switch (_currentDoorState) { case DoorState.Open: if (time.TotalTime >= _currentStepEnd) { _productionExit ??= _gameObject.FindBehavior <IProductionExit>(); if (_productionExit is ParkingPlaceBehaviour) { break; // Door is closed on aircraft death from JetAIUpdate } CloseDoor(time, _doorIndex); } break; case DoorState.Closing: if (time.TotalTime >= _currentStepEnd) { Logger.Info($"Door closed"); _currentDoorState = DoorState.Closed; GetDoorConditionFlags(out var _, out var _, out var doorClosing); _gameObject.ModelConditionFlags.Set(doorClosing, false); } break; case DoorState.OpenForHordePayload: break; //door is closed again by HordeContain } }
void openDoorToRight() { Debug.Log("You opened from left"); this.doorState = DoorState.rightOpened; doorCollider.enabled = false; }
// Update is called once per frame void Update() { if (InputService.Instance().GetInput(KeyMap.Knife) == true) { if (knifeController.GetIsStaying() && knifeController.GetIsPowered()) { transform.position = knifeController.transform.position; m_rigidbody2D.simulated = false; StartCoroutine(IsStayWithKnife(knifeController.m_stayTime)); } else if (m_rigidbody2D.simulated == false) { m_rigidbody2D.simulated = true; } else { m_state = WeaponState.Knife; } } if (InputService.Instance().GetInput(KeyMap.Door) == true) { m_state = WeaponState.SetDoor; } //Whether enter a door if (Input.GetKeyDown(KeyCode.Mouse0)) { if (m_state == WeaponState.Knife && m_rigidbody2D.simulated == true) { Debug.Log("Shoot knife"); Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 dir = new Vector2(mousePos.x - transform.position.x, mousePos.y - transform.position.y); dir.Normalize(); knifeController.Shoot(transform.position, dir); } //if (m_state == WeaponState.Knife && m_rigidbody2D.simulated == false) { // Collider2D [] others = Physics2D.OverlapCircleAll (this.transform.position, m_effectRange, m_enemyLayerMask); //获取指定范围所有碰撞体 // foreach (var other in others) { // if (other.name == "Enemy") { // transform.position = other.transform.position; // Destroy (other.gameObject); // } // } //} if (m_state == WeaponState.SetDoor) { if (m_doorState == DoorState.None) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 dir = new Vector2(mousePos.x - transform.position.x, mousePos.y - transform.position.y); dir.Normalize(); bool result = GameObject.Find("Door1").GetComponent <DoorController> ().Shoot(new Vector3(transform.position.x + dir.x, transform.position.y + dir.y, transform.position.z), dir); if (result) { m_doorState = DoorState.One; return; } } if (m_doorState == DoorState.One) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 dir = new Vector2(mousePos.x - transform.position.x, mousePos.y - transform.position.y); dir.Normalize(); bool result = GameObject.Find("Door2").GetComponent <DoorController> ().Shoot(new Vector3(transform.position.x + dir.x, transform.position.y + dir.y, transform.position.z), dir); if (result) { m_doorState = DoorState.Two; return; } } if (m_doorState == DoorState.Two) { //bool result = false; //result = GameObject.Find ("Door2").GetComponent<DoorController> ().GetIsDoorStay (); //result = GameObject.Find ("Door1").GetComponent<DoorController> ().GetIsDoorStay (); //if (result) { GameObject.Find("Door1").GetComponent <DoorController> ().Disappear(); GameObject.Find("Door2").GetComponent <DoorController> ().Disappear(); m_doorState = DoorState.None; return; //} } } } }
public void DoorClosed() { _state = DoorState.Closed; }
public void Close() { if (state == DoorState.OPENING || state == DoorState.OPEN) { state = DoorState.CLOSING; lightRight.Color = Color.Red; lightLeft.Color = Color.Red; } }
void Start() { state = initialState; UpdateEndPositions(); }
public void Update(float ms) { if (state == DoorState.CLOSING) { openPercent -= ms * SPEED; if (openPercent < ALMOSTCLOSED) { state = DoorState.CLOSED; openPercent = MINOPEN; }; UpdatePanelPositions(); } else if (state == DoorState.OPENING) { openPercent += ms * SPEED; if (openPercent > ALMOSTOPEN) { state = DoorState.OPEN; openPercent = MAXOPEN; }; UpdatePanelPositions(); } }
public override void Spawn() { base.Spawn(); SetupPhysicsFromModel(PhysicsMotionType.Keyframed); // Setup run-thru trigger trigger = new(); trigger.Position = Position; trigger.Rotation = Rotation; trigger.Owner = this; trigger.SetupPhysics(); PositionA = Position; // Get the direction we want to move var dir = Rotation.From(MoveDir).Forward; if (MoveDirIsLocal) { dir = Transform.NormalToWorld(dir); } // Open position is the size of the bbox in the direction minus the lip size var boundSize = OOBBox.Size; PositionB = Position + dir * (MathF.Abs(boundSize.Dot(dir)) - Lip); State = DoorState.Closed; SpawnFlags.Add(Flags.Use); if (SpawnOpen) { Position = PositionB; State = DoorState.Open; } RotationClosed = Rotation.Angles(); var degrees = RotationDegrees - Lip; if (SpawnFlags.Has(Flags.RotateBackwards)) { degrees *= -1.0f; } // Setup back rotation if (SpawnFlags.Has(Flags.Pitch)) { RotationBack = RotationClosed + new Angles(degrees, 0, 0); } else if (SpawnFlags.Has(Flags.Roll)) { RotationBack = RotationClosed + new Angles(0, 0, degrees); } else { RotationBack = RotationClosed + new Angles(0, degrees, 0); } // Setup front rotation if (SpawnFlags.Has(Flags.Pitch)) { RotationFront = RotationClosed - new Angles(degrees, 0, 0); } else if (SpawnFlags.Has(Flags.Roll)) { RotationFront = RotationClosed - new Angles(0, 0, degrees); } else { RotationFront = RotationClosed - new Angles(0, degrees, 0); } }
public void ChangeState(DoorState state) { this.state = state; doorDisplay.ChangeDoorState(); }
private async Task SaveDoorStateAsync(string vehicleId, DoorKind kind, DoorState state, CancellationToken cancellation) { string key = MakeCacheKey(vehicleId, kind); var stateStr = state.ToString().ToLowerInvariant(); await cache.SetStringAsync(key, stateStr, cancellation); }
public void CloseDoor() { state = DoorState.Close; isMoving = true; }
// Use this for initialization void Start() { doorState = DoorState.stopped; }
private void TransitState(StateTransition stateTransition) { TimerBar.localScale = Vector3.one; if (Type == CellType.Interactive) { CurrentInteractiveCellStateID = stateTransition.TransitionToID; } else { DoorCellState = stateTransition.TransitionToDoorState; } UpdateCellType(); }
public void ChangeDoorState(DoorState doorState) { this.doorState = doorState; }