示例#1
0
 public StepAction(ActionType type, IInteract subject, Point position)
 {
     Type        = type;
     Subject     = subject;
     Position    = position;
     CurrentStep = StepCounter.GetInstance().GetCounter();
 }
 public void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Statue")
     {
         interactable = other.GetComponent <IInteract>();
     }
 }
 public void OnTriggerExit(Collider other)
 {
     if (other.tag == "Statue")
     {
         interactable = null;
     }
 }
    // Update is called once per frame
    void Update()
    {
        //RaycastHit hit;
        Ray ray = playerCamera.ScreenPointToRay(Input.mousePosition);

        var hits = Physics.RaycastAll(ray, raycastLength);

        uiText.enabled = false;

        foreach (var hit in hits)
        {
            Transform objectHit    = hit.transform;
            IInteract interactable = hit.collider.gameObject.GetComponent <IInteract>();

            if (interactable != null && interactable.CanInteract())
            {
                uiText.enabled = true;

                if (Input.GetKeyDown(KeyCode.E))
                {
                    Debug.Log("can interact with object.");
                    interactable.Use();
                }
                break;
            }
        }

        if (hits.Length == 0)
        {
            uiText.enabled = false;
        }
    }
示例#5
0
    void onTriggerEnterEvent(Collider2D col)
    {
        IStartDialogue    dialogue   = col.GetComponent <IStartDialogue>();
        ITransitionCamera transition = col.GetComponentInParent <ITransitionCamera>();
        IInteract         interact   = col.GetComponent <IInteract>();

        if (dialogue != null)
        {
            dialogue.StartDialogue();
        }

        if (transition != null)
        {
            transition.TransitionCamera();
        }

        if (interact != null)
        {
            interact.Interact();
        }

        if (col.gameObject.layer == LayerMask.NameToLayer("Kill"))
        {
            /* Death Count Statistics */
            StatisticsCollector.instance.deathCount++;
            transform.position = (m_lastCheckpoint + Vector2.up);
        }

        if (col.gameObject.layer == LayerMask.NameToLayer("Checkpoints"))
        {
            m_lastCheckpoint = transform.position;
        }
    }
    public void OnClick(RaycastHit hit, Transform t)
    {
        IInteract obj = interact.GetHolding();

        if (obj == null && !CookUI.isMoving && canInteract)
        {
            if (!gameObject.CompareTag("Tray")) //trays cannot be picked up, after some deliberartion
            {
                if (gameObject.CompareTag("Plate"))
                {
                    CheckPlateCount();
                }
                interact.OnPickUp(transform);
                CheckForFood();
            }
        }
        else if (obj != null && !CookUI.isMoving && canInteract)
        {
            if (obj.GetObject().CompareTag("Food") && !interact.Moving()) //putiing food on move_s
            {
                if (foodType != null)                                     //for trays
                {
                    if (foodType.name == obj.GetName())
                    {
                        PutFoodOn(hit, obj.GetObject());
                    }
                }
                else
                {
                    PutFoodOn(hit, obj.GetObject()); //doesn't need to distinguish between food types
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (_mira == null)
        {
            return;
        }
        _mira.color = _default;

        //if (Physics.Raycast(_camera.transform.position, _camera.transform.forward, out HitInfo, maxDistance))
        //if (Physics.Raycast(player.transform.position, player.transform.forward, out HitInfo, maxDistance))

        if (Physics.SphereCast(player.transform.position, 1, player.transform.forward, out HitInfo, maxDistance))
        {
            IInteract componente = HitInfo.transform.GetComponent <IInteract>();
            //Debug.Log(HitInfo.transform.name);

            if (componente != null)
            {
                _mira.color = _interactColor;
            }
            if ((Input.GetButtonDown("Fire1") || Input.GetKeyDown(KeyCode.E)) && componente != null)
            {
                componente.Action();
            }
        }
    }
示例#8
0
    public void OnClick(RaycastHit hit, Transform t)
    {
        IInteract inter = i.GetHolding();

        if (inter != null)
        {
            PlaceMarker m = null;

            if (gameObject.CompareTag("PShelf"))
            {
                m = i.ClosestMarker(pMarkers.ToArray(), hit.point);
            }
            else
            {
                m = i.ClosestMarker(markers, hit.point);
            }

            if (!m.GetOccupation())
            {
                if (inter.GetObject().CompareTag("Food"))
                {
                    PutFoodDown(inter.GetObject());
                }

                i.OnPutDown(m, null, false);
            }
        }
    }
示例#9
0
 public void UnsetCheckBusyWith(IInteract aCaller)
 {
     if (busyWith == aCaller)
     {
         busyWith = null;
     }
     StartCoroutine(CheckBusinessBeforeUnpause(0.1f));
 }
示例#10
0
 void Start()
 {
     RegisterNodes();
     if (itemInfo.autoRact)
     {
         activeRact = autoRact;
     }
 }
示例#11
0
    public GameObject RemovePickup()
    {
        GameObject sprite = Pickup.Sprite;

        Pickup       = null;
        Interactable = null;
        return(sprite);
    }
示例#12
0
 public void UnRegist(IInteract interact)
 {
     if (interact == interactScript)
     {
         interactScript       = null;
         interactImage.sprite = null;
     }
 }
示例#13
0
    private void OnInteract()
    {
        IInteract interact = _interactableObject.GetComponent <IInteract>();

        if (_interactableObject != null && interact != null)
        {
            interact.Enter();
        }
    }
示例#14
0
    private void InitializeInterationButton(GameObject menuItem, IInteract interaction, Vector2 interactionLocation)
    {
        InteractionButton interactionButton = menuItem.GetComponent <InteractionButton>();

        interactionButton._buttonText.text     = interaction.Name;
        interactionButton._assignedInteraction = interaction;
        interactionButton._targetPos           = interactionLocation;
        interactionButton._uiGod = this;
    }
        /// <summary>
        /// Checks
        /// </summary>
        private void StartNewInteraction()
        {
            IInteract interact = (_activeInstance == null) ? null : _activeInstance as IInteract;

            if (interact != null)
            {
                _activeInteraction            = interact.Interact(_player);
                _activeInteraction.OnDestroy += ResetInteraction;
            }
        }
 private void Start()
 {
     _dropDog = false;
     _focus   = false;
     if (_motor == null)
     {
         _motor = GetComponent <PlayerMotor>();
     }
     _iIteract = null;
 }
示例#17
0
    public void LockInInteraction(IInteract interaction, Vector3 targetPos)
    {
        if (_engaged)
        {
            Disengage();
        }

        _engagedInteraction  = interaction;
        _interactionPosition = targetPos;
        Engage();
    }
示例#18
0
 public bool AutoReact()
 {
     activeRact = autoRact;
     autoRact.autoExportEvent.Invoke();
     if (!string.IsNullOrEmpty(activeRact.OutType))
     {
         SceneMain.Current.InvokeEvents(AppConfig.EventKey.TIP, autoRact.information);
         return(true);
     }
     return(false);
 }
 private void OnEnable()
 {
     Interactable.ADD += (x) =>
     {
         currentInteraction = x;
     };
     Interactable.REMOVE += () =>
     {
         currentInteraction = null;
     };
 }
示例#20
0
    void Interact()
    {
        Ray        r = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
        RaycastHit hit;

        int ignorePlayer = ~LayerMask.GetMask("Player");

        if (Physics.Raycast(r, out hit, range, ignorePlayer))
        {
            if (hit.collider.gameObject.tag == "Escape")
            {
                if (paddle1 && paddle2 && boat.activeInHierarchy == true)
                {
                    StartCoroutine(TypeText.instance.ShowDialogText("You have found al the parts you escaped the prison enjoy your freedom!"));
                    StartCoroutine(ExitGame());
                }
                else
                {
                    for (int y = 0; y < Inventory.instance.items.Count; y++)
                    {
                        if (Inventory.instance.items[y] is RaftItem)
                        {
                            if (Inventory.instance.items[y].name == "Paddle1")
                            {
                                paddle1.SetActive(true);
                                Inventory.instance.items.Remove(Inventory.instance.items[y]);
                            }
                            else if (Inventory.instance.items[y].name == "Paddle2")
                            {
                                paddle2.SetActive(true);
                                Inventory.instance.items.Remove(Inventory.instance.items[y]);
                            }
                            else if (Inventory.instance.items[y].name == "BoatPart")
                            {
                                boat.SetActive(true);
                                Inventory.instance.items.Remove(Inventory.instance.items[y]);
                            }
                        }
                        else
                        {
                            StartCoroutine(TypeText.instance.ShowDialogText("You have to find al the raft parts to escape this prison!"));
                        }
                    }
                }
            }
            //Debug.Log("Hit " + hit.collider.gameObject.name);
            IInteract i = hit.collider.gameObject.GetComponent <IInteract>();
            if (i != null)
            {
                i.Action();
            }
        }
    }
示例#21
0
    private void PlayerInteraction()
    {
        IInteract   iIteract = null;
        BreakWindow _car;

        if (Input.GetButtonDown("GetDog"))
        {
            if (_shibaHolder.GetComponentInChildren <Rigidbody>() != null)
            {
                Rigidbody rb             = _shibaHolder.GetComponentInChildren <Rigidbody>();
                Transform transformShiba = _shibaHolder.GetComponentInChildren <Rigidbody>().transform;

                rb.useGravity  = true;
                rb.isKinematic = false;

                rb.AddForce(0, _throwForce / 2, _throwForce / 4, ForceMode.Force);

                transformShiba.SetParent(null);
            }

            if (_shibaHolder.GetComponentInChildren <Rigidbody>() == null)
            {
                if (Physics.Raycast(transform.GetChild(1).position, transform.GetChild(1).forward, out _hit, 150))
                {
                    if (_hit.transform.GetComponent <Shiba>() != null)
                    {
                        _hit.transform.GetComponent <Shiba>().transform.SetParent(ShibaHolder.transform);
                        _hit.transform.GetComponent <Shiba>().transform.position = ShibaHolder.transform.position;
                        _hit.transform.GetComponent <Rigidbody>().useGravity     = true;
                        _hit.transform.GetComponent <Rigidbody>().isKinematic    = false;
                    }
                }


                if (Physics.Raycast(transform.GetChild(1).position, transform.GetChild(1).forward, out _hit, 150))
                {
                    if (_hit.transform.GetComponent <IInteract>() != null)
                    {
                        _car = _hit.transform.GetComponent <BreakWindow>();

                        if (iIteract == null)
                        {
                            iIteract = _hit.transform.GetComponent <IInteract>();
                        }
                        if (_car.HitWindow >= 0)
                        {
                            iIteract.OnInteract();
                        }
                    }
                }
            }
        }
    }
示例#22
0
文件: Player.cs 项目: baramyu/JoyGit
    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Interact"))
        {
            IInteract interactObj = other.GetComponent <IInteract>();

            if (onStayInteractList.Contains(interactObj))
            {
                onStayInteractList.Remove(interactObj);
            }
        }
    }
    private void InteractWithObject(GameObject go)
    {
        IInteract interactable = go.GetComponent <IInteract>();

        if (interactable != null)
        {
            interactable.AbleToInteract();
            if (Input.GetKeyDown(KeyCode.F))
            {
                interactable.Interact();
            }
        }
    }
示例#24
0
        private static async Task Send(IInteract context, BufferBlock <ResponseMessageModel> messages, CancellationToken token)
        {
            while (await messages.OutputAvailableAsync(token))
            {
                using (var stream = _streamFactory.Create())
                {
                    var message = await messages.ReceiveAsync(token);

                    ProtoBuf.Serializer.Serialize(stream, message);
                    await context.Send(stream, token);
                }
            }
        }
示例#25
0
文件: Player.cs 项目: baramyu/JoyGit
    void Interact()
    {
        IInteract interactAbleObj = onStayInteractList.FindLast(interactObj => interactObj.IsInteractAble());

        if (interactAbleObj != null)
        {
            SoundManager.instance.PlayerButtonClick();
            interactAbleObj.Interact();
        }
        else
        {
            SoundManager.instance.PlayerButtonHover();
        }
    }
    private void OnCollisionEnter(Collision collision)
    {
        IInteract object_Hit = collision.gameObject.GetComponent <IInteract>();

        if (object_Hit != null)
        {
            // After 1 counter dones not go up, no idea why
            collected_eggs++;
            print(collected_eggs);
            eggs.egg_collected(collected_eggs);

            theManager.IveBeenDestroyed(this);
            Destroy(gameObject);
        }
    }
示例#27
0
 /// <summary>
 /// 输入并反应
 /// </summary>
 /// <param name="nodeId"></param>
 /// <param name="type"></param>
 /// <param name="onComplete"></param>
 public void FunctionIn(int nodeId, string type, UnityAction onComplete)
 {
     this.onComplete = onComplete;
     functionInNodes.Add(nodeId);
     activeRact = interact.Find((x) => x.nodeID == nodeId && x.intype == type);
     if (activeRact != null)
     {
         activeRact.Interact.Invoke();
         SceneMain.Current.InvokeEvents(AppConfig.EventKey.TIP, activeRact.Information);
     }
     else
     {
         PresentationData data = PresentationData.Allocate("<color=red>警告</color>", name + "没有配制对应的输入类型" + type, "");
         BundleUISystem.UIGroup.Open <PresentationPanel>(data);
     }
 }
示例#28
0
    //Attempts to set player to be busy with "aCaller" and pauses input, returning true if the request worked
    public bool SetCheckBusyWith(IInteract aCaller)
    {
        if (busyWith == null)
        {
            busyWith = aCaller;
        }
        //For busy with aCaller
        if (busyWith == aCaller)
        {
            PauseInput();
            Debug.Log("Busy with " + busyWith);
            return(true);
        }

        return(false);
    }
示例#29
0
 public void InteractWithObject()
 {
     if (interactScript != null)
     {
         interactScript.Interact();
         interactScript       = null;
         interactImage.sprite = null;
     }
     else
     {
         if (DGameSystem.player != null)
         {
             DGameSystem.player.GetComponent <DBattle>().Attack();
         }
     }
 }
 public void OnPickUp(Transform t) //when the player picks up an object
 {
     if (!isMoving)
     {
         audioManager.PlaySound("Whosh");
         SetInteract(t.GetComponent <IInteract>());
         GameObject obj = GetHolding().GetObject();
         physics = obj.GetComponent <IPhysics>();
         physics.DisablePhysics(guide);
         StartCoroutine(PickUp(t, timeToMove));
         if (physics.GetMarker() != null)
         {
             physics.GetMarker().SetOccupation(false);
         }
         lookAt = null;
     }
 }
示例#31
0
 public Worker(IInteract interactor, INeedClosing closer)
 {
     _interactor = interactor;
     _closer = closer;
 }