public void SpeakToPeople() { IInteractiveObject otherObject = null; MapGenerator.Coord myPosition = MapGenerator.ConvertWorldToIndex(transform.position); switch (currentDirection) { case direction.up: otherObject = GetInteractiveObject(myPosition.i, myPosition.j - 1); break; case direction.down: otherObject = GetInteractiveObject(myPosition.i, myPosition.j + 1); break; case direction.left: otherObject = GetInteractiveObject(myPosition.i - 1, myPosition.j); break; case direction.right: otherObject = GetInteractiveObject(myPosition.i + 1, myPosition.j); break; } if (otherObject != null && Input.GetKey(KeyCode.Space)) { otherObject.StartInteraction(); } }
public async Task <IInteractiveObject> InteractAsync(IInteractiveObject obj, object message) => (await SendAsync <InteractResponse> ( new InteractRequest { InteractiveObjectHandle = obj.Handle, Message = message }, SessionCancellationToken))?.Result;
public Task <IInteractiveObject> InteractAsync( IInteractiveObject obj, object message, CancellationToken cancellationToken = default) => SendAsync <IInteractiveObject> ( new InteractRequest(obj.Handle, message), GetCancellationToken(cancellationToken));
internal InteractionEvent(IInteractiveObject interactiveObject, EventType type) : base("Event") { InteractiveObject = interactiveObject; _eventType = type; _cases = new InteractionCases(this); }
public bool IsBelowBottom(IInteractiveObject interactiveObject) { if (interactiveObject.Position.y < Bottom - interactiveObject.Size.y) { return(false); } return(true); }
/// <summary> /// Registers the interactive object and returns an IUnsubscriber that can /// be used to unregister the object. The unsubscriber will invoke Unsubscribe() /// in its finalizer, so a reference to the unsubscriber must be kept. When /// the interactive object is supposed to be destroyed, make sure to Unsubscribe() /// or else some code that captured it during OnInteractiveObjectRegistered /// might keep it alive indefinitely. /// </summary> /// <returns>The interactive object.</returns> /// <param name="obj">Object.</param> public IUnsubscriber RegisterInteractiveObject(IInteractiveObject obj) { m_currentInteractiveObjects.Add(obj); OnInteractiveObjectRegistered?.Invoke(obj); return(new ListUnsubscriber <IInteractiveObject>(m_currentInteractiveObjects, obj, (x) => OnInteractiveObjectUnregistered?.Invoke(x))); }
/// <summary> /// Finishes an active interaction. /// </summary> /// <param name="item">Active item.</param> /// <param name="invalidateItem">Need invalidate active item.</param> protected override void FinishInteraction(IInteractiveObject item, bool invalidateItem) { base.FinishInteraction(item, invalidateItem); if (_needBuildBarcodeImage) { RefreshBarcodeImage(false); _needBuildBarcodeImage = false; } }
public void InteractionHandler_GameStateWithOneInteractive_InteractIsNotCalled() { IInteractiveObject interactiveMock = Substitute.For <IInteractiveObject>(); _interactiveObjects[5, 1] = interactiveMock; //_state = _uut.Interact(_state); interactiveMock.DidNotReceive().interact(Arg.Any <IGameState>()); }
public static InteractiveObjectData Create(IInteractiveObject obj) { return(new InteractiveObjectData { Availibility = obj.Availibility, Backlight = obj.Backlight, Danger = obj.Danger, Impassable = obj.Impassable, MinimapVisability = obj.MinimapVisability }); }
/// <summary> /// Raises the interaction event for specified interactive object. /// </summary> /// <param name="item">The interactive object.</param> /// <param name="args">The interaction event args.</param> protected override bool OnInteraction(IInteractiveObject item, InteractionEventArgs args) { bool result = base.OnInteraction(item, args); if ((args.Action & InteractionAreaAction.Begin) != 0) { string interactionName = args.Area.InteractionName; if (interactionName == "Resize" || interactionName == "Build") { _needBuildBarcodeImage = true; } } return(result); }
internal void Interact(Vector3 pos) { int i = (int)pos.x; int j = (int)pos.y; if (i < 1 || j < 1 || i > 9 || j > 9) { return; } IInteractiveObject obj = mapsInterctac[i, j]; if (obj != null) { obj.StartInteraction(); } }
public async Task <IInteractiveObject> InteractAsync( IRenderer renderer, IInteractiveObject source, object message = null) { if (!ClientSession.Agent.IsConnected) { return(null); } try { return(await ClientSession.Agent.Api.InteractAsync(source, message)); } catch (Exception e) { Log.Error(TAG, e); return(null); } }
public Layer GenerateLayer(int layerNumber) { uint width = 10; uint height = 10; INpc[,] npcs = new INpc[width, height]; ITile[,] tiles = new ITile[width, height]; IInteractiveObject[,] objects = new IInteractiveObject[width, height]; for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { tiles[x, y] = new Tile(false); npcs[x, y] = null; } } return(new MiddelLayer(tiles, npcs, new Position(0, 0), new Position(9, 9), objects)); }
void Start() { PrefabByTiles = new Dictionary <Tiles, GameObject> { { Tiles.Grass, Grass }, { Tiles.Solide, Solide }, { Tiles.Tree, Tree }, { Tiles.Bomb, Bomb }, { Tiles.SpeedBoost, SpeedBoost }, { Tiles.Switch, Switch }, { Tiles.Button, Button }, }; Vector2 Position = new Vector2(0, 0); int index = 0; for (int i = 0; i < MAPS_MAX; i++) { for (int j = 0; j < MAPS_MAX; j++) { Vector2 offset = new Vector2(TILE_SIZE / PIXEL_PER_UNIT * j, -TILE_SIZE / PIXEL_PER_UNIT * i); Vector2 spawnPos = new Vector2(i, j); IInteractiveObject obj = CreateTiles((Tiles)maps[i, j], spawnPos); if (obj != null) { mapsInterctac[i, j] = obj; if (obj is Switchs) { ((Switchs)obj).index = index++; } else if (obj is Button) { ((Button)obj).InteractionStarted += OnDoorOpen; } } } } }
// Update is called once per frame private void Update() { m_objectTracker.Update(); IInteractiveObject nearest = m_objectTracker.GetClosest(); if (nearest.GetDistanceTo(this) > m_maximumInteractionDistance) { nearest = null; } if (nearest != m_previousNearest) { nearest?.ShowSelectionVisual(); m_previousNearest?.HideSelectionVisual(); } if (Input.GetKeyDown(KeyCode.UpArrow)) { nearest?.TryInteractWith(this); } m_previousNearest = nearest; }
// Update is called once per frame void Update() { if (Managers.player.moveBlock) { return; } if (selectedObject != null) { IInteractiveObject iObject = selectedObject.gameObject.GetComponent <IInteractiveObject>(); if (iObject != null) { iObject.HideObjectName(); } } selectedObject = null; if (Managers.player.battleMode) { return; //Нельзя в боевом режиме собирать предметы или обращаться к НПС } float prevDotValue = 0; //Предыдущее значение скалярного произведения Collider[] hitColliders = Physics.OverlapSphere(transform.position, 2.5f); //Обработка выделения ближайшего объекта foreach (Collider hitCollider in hitColliders) { InteractiveObject laObject = hitCollider.GetComponent <InteractiveObject>(); if (laObject != null) { Vector3 dis = laObject.transform.position - transform.position; //Debug.Log("Dot select" + Vector3.Dot(transform.forward, dis.normalized)); if (Vector3.Dot(transform.forward, dis.normalized) > 0.5) { //Из всех предметов которы расположены перед персонажем выбираем тот на которого ближе смотрит камера Vector3 camLookForward = new Vector3(myCam.transform.forward.x, 0, myCam.transform.forward.z); if (Vector3.Dot(camLookForward, dis.normalized) > prevDotValue) { selectedObject = laObject; prevDotValue = Vector3.Dot(camLookForward, dis.normalized); } } } } //Отображение имени объекта if (selectedObject != null) { IInteractiveObject iObject = selectedObject.gameObject.GetComponent <IInteractiveObject>(); if (iObject != null) { iObject.ShowObjectName(); } } //Обарботка нажатия на выделенном объекте (выделенным объектом может быть игровой перс, игр предмет или механизм) //- Добавление в инвентарь if (selectedObject != null && Input.GetMouseButtonDown(0) && Managers.inventory.inventoryPanelWindow.activeSelf == false) { GameItem _item = selectedObject.gameObject.GetComponent <GameItem>(); if (_item != null) { StartCoroutine(AddItem(_item)); } NPC_Manager _npc = selectedObject.gameObject.GetComponent <NPC_Manager>(); if (_npc != null) { _npc.ExploreNpc(); } } }
public Task <IInteractiveObject> InteractAsync( IInteractiveObject obj, object message, CancellationToken cancellationToken = default) => throw new NotImplementedException();
public Layer GenerateLayer(int layerNumber) { uint width = 10; uint height = 10; ICharacter[,] characters = new ICharacter[width, height]; ITile[,] tiles = new ITile[width, height]; IInteractiveObject[,] objects = new IInteractiveObject[width, height]; Random rnd = new Random(); if (rnd.Next(0, 2) == 0) { objects[3, 0] = new Chest(); } else { objects[3, 0] = new ChestMimic(); } for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { tiles[x, y] = new Tile(false); characters[x, y] = null; } } for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { if (x <= 3 && y <= 1) { tiles[x, y].Walkable = true; } if (x == 3 && y <= 4) { tiles[x, y].Walkable = true; } if (x >= 3 && x <= 6 && y == 4) { tiles[x, y].Walkable = true; } if (x >= 7 && x <= 9 && y >= 4 && y <= 6) { tiles[x, y].Walkable = true; } } } characters[3, 1] = new HostileNPC(new Position(3, 1), new Stats(1, 1, 1), new StandStillMovementStrategy(), "Hurtigfar", 30); characters[3, 4] = new HostileNPC(new Position(3, 4), new Stats(10, 2, 2), new StandStillMovementStrategy(), "Mellemhurtigfar", 20); characters[8, 4] = new HostileNPC(new Position(8, 4), new Stats(10, 10, 10), new RandomMovementStrategy(), "Langsomfar", 10); tiles[layerNumber, 9].Walkable = true; Layer layer; switch (layerNumber) { case 0: layer = new TopLayer(tiles, characters, new Position(8, 5), new Position(0, 0), objects); break; case 2: layer = new MiddelLayer(tiles, characters, new Position(2, 0), new Position(8, 6), objects); break; case 3: characters[1, 1] = new HostileNPC(new Position(1, 1), new Stats(35, 5, 4), new StandStillMovementStrategy(), "TankyFar", 200); layer = new MiddelLayer(tiles, characters, new Position(9, 4), new Position(0, 1), objects); break; case 4: layer = new BottomLayer(tiles, characters, new Position(8, 5), objects); break; default: layer = new MiddelLayer(tiles, characters, new Position(0, 0), new Position(8, 5), objects); break; } return(layer); }
public bool IsOnScreen(IInteractiveObject interactiveObject) { return(interactiveObject.Position.y < Top); }
private void OnDoorOpen(IInteractiveObject source) { Debug.Log("door open"); }
public void setup() { gameState = Substitute.For <IGameState>(); accendingStair = new AccendingStair(); decendingStair = new DecendingStair(); }
public InteractionEvents(IInteractiveObject interactiveObject) : base("Events") { InteractiveObject = interactiveObject; }
internal InteractionEvent(IInteractiveObject interactiveObject) : this(interactiveObject, EventType.None) { }