private void CheckActivation() { if (!_targetIActivatable.Activated) { _targetIActivatable.Activate(); } }
public void Switch() { AudioManager.instance.PlaySound("Switch"); activated = !activated; animator.SetBool("Activated", activated); if (activated) { _targetIActivatable.Activate(); } else { _targetIActivatable.Deactivate(); } }
public void Interact(GameObject sender) { if (_activableObject != null) { _sr.color = (_activableObject.Activate()) ? Color.green : Color.red; } }
public static void RegisterWidgetVariants(this IComponentsApplicationBuilder appBuilder) { IWidgetFactory widgetFactory = appBuilder.Services.GetService <IWidgetFactory>(); widgetFactory.Register(WidgetVariants.SHOW_WIDGET, new WidgetVariant <ButtonWidgetMediator, ButtonWidgetPresenter> { Customisation = new ButtonWidgetCustomisation { // Hind: Example of usage of strategy (delegate) in widget mediator Title = "Activate text widget in first container!", ClickStrategy = () => { // Hind: Manual widget build and activation, in most of cases would be easier to use IWidgetManagementService WidgetInfo info = widgetFactory.Build(WidgetVariants.TEXT_FIRST); IActivatable <string> activatable = (IActivatable <string>)info.Mediator; activatable.Activate("FIRST_WIDGET_CONTAINER"); } } }); var textVariant = new CustomisedWidgetVariant <TextWidgetMediator, TextWidgetCustomisation>(); textVariant.Customisation.Text = "This text has been activated from runtime!"; widgetFactory.Register(WidgetVariants.TEXT_FIRST, textVariant); widgetFactory.Register(WidgetVariants.RANDOM_UPDATER, new WidgetVariant <RandomUpdaterWidgetMediator>()); widgetFactory.Register(WidgetVariants.COUNTER, new WidgetVariant <CounterWidgetMediator, CounterWidgetPresenter, CounterWidgetState>()); widgetFactory.Register(WidgetVariants.LAYOUT, new WidgetVariant(typeof(ExampleLayoutWidget)) { StateType = typeof(LayoutState) }); }
public void Hide() { Init(); if (_showable != null) { _showable.Hide(null, () => { _activatable?.Activate(); _activatable = null; }); } else { _activatable?.Activate(); _activatable = null; gameObject.SetActive(false); } }
public void Interact(Node caller) { if (!HasBeenPressed && Target != null) { Target.Activate(); HasBeenPressed = true; SetColour(PressedColor, 2); } }
public void ActivateHeldItem() { if (heldItem != null) { IActivatable item = heldItem.GetComponentInChildren <IActivatable>(); if (item != null) { item.Activate(); } } }
private void ActivateItem() { if (objectToActivate != null) { if (Input.GetButtonDown("Activate") && pickUp.IsLiftingObj == true) { pickUp.CurrentPickupObj.Activate(); } else if (Input.GetButtonDown("Activate")) { objectToActivate.Activate(); } } }
public static bool Activate(this IDrawingCell aCell) { if (aCell == null) { return(false); } IActivatable act = aCell.GetActivatableCell(); if (act != null) { act.Activate(); return(true); } return(false); }
void Update() { transform.localPosition = new Vector3(transform.localPosition.x + 0.1f * Time.deltaTime, 0, 0); if (transform.localPosition.x > 0) { transform.localPosition = Vector3.zero; off = true; } if (transform.localPosition.x < -activationDepth) { transform.localPosition = new Vector3(-activationDepth, 0, 0); if (off) { off = false; audioSource.Play(); activatable.Activate(); } } // Debug.Log(transform.localPosition.x); }
// Update is called once per frame void Update() { Vector3 point = new Vector3(_camera.pixelWidth / 2, _camera.pixelHeight / 2, 0); Ray ray = _camera.ScreenPointToRay(point); RaycastHit hitObject; // Anything that activates off from e action if (Input.GetKeyDown("e")) { if (Physics.Raycast(ray, out hitObject)) { GameObject hitGameObject = hitObject.transform.gameObject; IActivatable eAction = hitGameObject.GetComponent <IActivatable>(); if (eAction != null) { eAction.Activate(); } } } // Stopping an enemy/NPC - Causing them to wait if (Input.GetMouseButtonDown(0)) { if (Physics.Raycast(ray, out hitObject)) { GameObject hitGameObject = hitObject.transform.gameObject; ReactiveTarget targetScript = hitGameObject.GetComponent <ReactiveTarget>(); // If the target in front of you is not null, then do action... if (targetScript != null) { // Custom scripted behavior that is created in ReactiveTarget class targetScript.ReactToHit(); } } } }
public void OnTriggerEnter2D(Collider2D other) { if (target == null) { return; } if (activated) { return; } if (other.tag.Equals("Player") || other.tag.Equals("Pallet") || other.tag.Equals("PlayerHitbox")) { target.Activate(); anim.SetTrigger("activate"); activated = true; // anim.Play("Charge"); } // if (other.tag.Equals("Pallet")) // { // permOpen = true; // } }
private void OnMouseUpAsButton() { if (isSource) { foreach (Part connectedObject in wiredObjects) { IActivatable a = connectedObject.GetComponent(typeof(IActivatable)) as IActivatable; if (a != null) { if (a.isActivated) { a.Deactivate(); } else { a.Activate(); } } a.isActivated = !a.isActivated; //connectedObject.GetComponent(connectedObject.GetComponent<MonoBehaviour>().GetType().Name).GetType().GetMethod("Deactivate").Invoke(connectedObject.GetComponent(connectedObject.GetComponent<MonoBehaviour>().GetType().Name), null); } sourceOn = !sourceOn; } }
public static void ActivateForRead(IActivatable tba) { tba.Activate(ActivationPurpose.Read); }
public void Activate() { _wayPointMovment.Activate(); }
public void Activate() { target.Activate(); }
protected override void OnKeyPress(object sender, KeyPressEventArgs e) { if (splitMessages.Count != 0) // Any input goes to next message { splitMessages.RemoveAt(0); } else { Direction dirToMove = Direction.NONE; switch (Input.ActionFor(e.KeyPress)) { case InputAction.UP: dirToMove = Direction.UP; e.Cancel = true; break; case InputAction.UP_RIGHT: dirToMove = Direction.UP_RIGHT; e.Cancel = true; break; case InputAction.RIGHT: dirToMove = Direction.RIGHT; e.Cancel = true; break; case InputAction.DOWN_RIGHT: dirToMove = Direction.DOWN_RIGHT; e.Cancel = true; break; case InputAction.DOWN: dirToMove = Direction.DOWN; e.Cancel = true; break; case InputAction.DOWN_LEFT: dirToMove = Direction.DOWN_LEFT; e.Cancel = true; break; case InputAction.LEFT: dirToMove = Direction.LEFT; e.Cancel = true; break; case InputAction.UP_LEFT: dirToMove = Direction.UP_LEFT; e.Cancel = true; break; case InputAction.DOWN_STAIR: // Check for stairy-stuff. Probably need to split this off, teleporter may go away since direction would be diff (Up gate vs down-gate would be seperate classes). foreach (var gObject in MapToRender.ObjectsAt(ApprenticeGame.Player.Position)) { if (gObject is Teleporter teleporter) { teleporter.Traverse(ApprenticeGame.Player); e.Cancel = true; break; } } break; case InputAction.ACTIVATE: // Activate top layer of whatever is below us, if something can be activated int topLayer = (int)Map.Layer.Terrain; IActivatable activatable = null; foreach (var gObj in MapToRender.ObjectsAt(ApprenticeGame.Player.Position)) { if (gObj is IActivatable activate && (int)gObj.Layer >= topLayer) { topLayer = (int)gObj.Layer; activatable = activate; } } if (activatable != null) { activatable.Activate(); e.Cancel = true; } break; case InputAction.SPELLS_SCREEN: ApprenticeGame.GameScreen.Hide(); ApprenticeGame.SpellsPanel.Show(); e.Cancel = true; break; case InputAction.MESSAGE_RECALL_SCREEN: ApprenticeGame.GameScreen.Hide(); ApprenticeGame.MessageRecallPanel.Show(); e.Cancel = true; break; } if (dirToMove != Direction.NONE) { if (!ApprenticeGame.Player.MoveIn(dirToMove)) { ApprenticeGame.Player.Combat.AttackIn(dirToMove); } } } }