示例#1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag.Equals(tag))
     {
         target?.SendMessage("connected", true);
     }
 }
    private void _CastForInteractables()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, MAX_DISTANCE, interactablesLayers))
        {
            // GameObject detected in front of the camera.
            if (_gazedAtObject != hit.transform.gameObject)
            {
                //  Debug.Log("New gazed object: " + hit.transform.gameObject.name);

                _gazedAtObject?.SendMessage("PointerExit");
                _gazedAtObject = hit.transform.gameObject;
                _gazedAtObject.SendMessage("PointerEnter");
            }
        }
        else
        {
            // No GameObject detected in front of the camera.
            // This line is necessary to cancel a pending gaze before it's complete
            // (when looking at a button only briefly, this line will cancel the gaze)
            _gazedAtObject?.SendMessage("PointerExit", SendMessageOptions.DontRequireReceiver);
            _gazedAtObject = null;
        }
    }
示例#3
0
    private void Update()
    {
        if (raycastEveryUpdate)
        {
            _CastForInteractables();
        }

        if (IsTriggerPressed())
        {
            _gazedAtObject?.SendMessage("PointerClick");
            OnClick();
        }

#if !UNITY_EDITOR
        if (Api.IsCloseButtonPressed)
        {
            ApplicationQuit();
        }

        if (Api.IsGearButtonPressed)
        {
            Api.ScanDeviceParams();
        }

        if (Api.HasNewDeviceParams())
        {
            Api.ReloadDeviceParams();
        }
#endif
    }
示例#4
0
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    public void Update()
    {
        // Casts ray towards camera's forward direction, to detect if a GameObject is being gazed
        // at.
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, _maxDistance))
        {
            // GameObject detected in front of the camera.
            if (_gazedAtObject != hit.transform.gameObject)
            {
                // New GameObject.
                _gazedAtObject?.SendMessage("OnPointerExit");
                _gazedAtObject = hit.transform.gameObject;
                _gazedAtObject?.SendMessage("OnPointerEnter");
            }
        }
        else
        {
            // No GameObject detected in front of the camera.
            _gazedAtObject?.SendMessage("OnPointerExit");
            _gazedAtObject = null;
        }

        // Checks for screen touches.
        if (Google.XR.Cardboard.Api.IsTriggerPressed)
        {
            _gazedAtObject?.SendMessage("OnPointerClick");
        }
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        // Determine if something is in front of camera or not
        RaycastHit hit;

        Debug.DrawRay(transform.position, transform.forward * max_distance, Color.red);
        try // try to cast ray on object
        {
            if (Physics.Raycast(transform.position, transform.forward, out hit, max_distance))
            {
                // New game object detected
                if (target_object != hit.transform.gameObject)
                {
                    target_object?.SendMessage("OnPointerExit"); // send exit message to previous game object
                    target_object = hit.transform.gameObject;    // set target object
                    target_object.SendMessage("OnPointerEnter"); // send enter message to new game object
                    StartGaze();                                 // start gaze timer
                }
            }

            // No object detected
            else
            {
                target_object?.SendMessage("OnPointerExit"); // send exit message to current game object
                target_object = null;                        // clear target object of any game object
                StopGaze();                                  // stop gaze timer
            }
        }

        // if missing reference error occurs
        catch (MissingReferenceException)
        {
            target_object = null; // null out
        }

        // if screen is tapped or viewer trigger pressed
        if (Google.XR.Cardboard.Api.IsTriggerPressed == true || gaze_timer_percentage >= 1)
        {
            target_object.SendMessage("OnPointerClick"); // send click message to current game object
            StopGaze();                                  // stop gaze timer
        }

        if (Google.XR.Cardboard.Api.IsCloseButtonPressed)
        {
            Application.Quit();
        }

        // when gaze timer starts
        if (gaze_status)
        {
            gaze_timer                 += Time.deltaTime;               // set time spent
            gaze_timer_percentage       = gaze_timer / gaze_time_limit; // set percentage of time spent gazing
            cross_hair_timer.fillAmount = gaze_timer_percentage;        // fill cross hair timer by percentage
        }
    }
示例#6
0
    // Update is called once per frame
    private void Update()
    {
        // Handling where the user is looking at.
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, maxDistance))
        {
            _lookingWhere = hit.point;
            if (_lookingAt != hit.transform.gameObject)
            {
                _lookingAt?.SendMessage("OnPointerExit", SendMessageOptions.DontRequireReceiver);
                _lookingAt = hit.transform.gameObject;
                _lookingAt.SendMessage("OnPointerEnter", SendMessageOptions.DontRequireReceiver);
            }
            targetIndicator.gameObject.SetActive(true);
            targetIndicator.transform.position = hit.point;
            targetIndicator.SetMaterial(!hit.transform.gameObject.CompareTag("Untagged"));
        }
        else
        {
            _lookingAt?.SendMessage("OnPointerExit", SendMessageOptions.DontRequireReceiver);
            _lookingAt = null;
            targetIndicator.gameObject.SetActive(false);
        }

        if (Google.XR.Cardboard.Api.IsTriggerPressed)
        {
            if (_lookingAt != null)
            {
                if (_lookingAt.CompareTag("Floor"))
                {
                    teleport.Move(_lookingWhere);
                }
                if (_lookingAt.CompareTag("Interactable"))
                {
                    _lookingAt.SendMessage("Interact", SendMessageOptions.DontRequireReceiver);
                }
                if (_lookingAt.CompareTag("Item"))
                {
                    if (_itemInHand != null)
                    {
                        DropItem();
                    }
                    GrabItem();
                }
            }
        }

        // Holding an item
        if (_itemInHand != null)
        {
            _itemInHand.transform.position = hand.position;
            _itemInHand.transform.rotation = hand.rotation;
        }
    }
示例#7
0
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    public void Update()
    {
        // Casts ray towards camera's forward direction, to detect if a GameObject is being gazed
        // at.
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, _maxDistance))
        {
            // GameObject detected in front of the camera.
            if (_gazedAtObject != hit.transform.gameObject)
            {
                // New GameObject.
                _gazedAtObject?.SendMessage("OnPointerExit");
                _gazedAtObject = hit.transform.gameObject;
                _gazedAtObject.SendMessage("OnPointerEnter");
            }
        }
        else
        {
            // No GameObject detected in front of the camera.
            // AltReality: Set SendMessageOptions to be DontRequireReceiver, to get rid of error
            _gazedAtObject?.SendMessage("OnPointerExit", SendMessageOptions.DontRequireReceiver);
            _gazedAtObject = null;
        }

        // Checks for screen touches.
        //if (Google.XR.Cardboard.Api.IsTriggerPressed)
        //{
        //    _gazedAtObject?.SendMessage("OnPointerClick");
        //}

        // AltReality: use Input.GetTouch() so can detect touch
        // when both VR mode or non VR mode
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began)
            {
                _gazedAtObject?.SendMessage("OnPointerClick");
            }
        }

        // AltReality: add mouse click support
#if UNITY_EDITOR
        if (Input.GetMouseButtonDown(0))
        {
            _gazedAtObject?.SendMessage("OnPointerClick");
        }
#endif
    }
        public void OnFindMatch()
        {
            manager.matchMaker.ListMatches(0,20, "", manager.OnMatchList);
            //Debug.Log ("====================================================================");
            int i = 1;
            if (manager.matches != null) {

                foreach (var match in manager.matches) {
                    //Debug.Log ("MATCH\n " + match.networkId.ToString ());
                    bool alreadyExists = false;
                    foreach ( GameObject button in GameObject.FindGameObjectsWithTag ("room button")){

                        if (button.name == i.ToString () + ")" + match.networkId.ToString ()) {
                            alreadyExists = true;
                        }
                        //Debug.Log (button.name + "    " + alreadyExists);
                        //Debug.Log ("Match: " + match.networkId.ToString () + "    Checking Button: " + button.name + alreadyExists);
                    }
                    if (!alreadyExists) {
                        string[] thisMatch = new string[] { match.name, i.ToString (), match.networkId.ToString () };

                        canv = GameObject.Find ("Canvas");
                        canv.SendMessage ("CreateMatchButton", thisMatch);
                        //Debug.Log ("xxxxxxxxxxxxxxxxxx Creating Button: " + match.name);
                    }
                    i++;
                }
            }
        }
示例#9
0
        public void CanBroadcastFromGameObjects()
        {
            var gameObject = new GameObject();
            var receiver = new TestComponent();
            gameObject.AddComponent(receiver);
            Scene.Current.AddObject(gameObject);

            gameObject.SendMessage(new TestGameMessage(), gameObject);

            Assert.IsTrue(receiver.MessageHandled);
        }
    private void _CastForInteractables()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, MAX_DISTANCE, interactablesLayers))
        {
            // GameObject detected in front of the camera.
            if (_gazedAtObject != hit.transform.gameObject)
            {
                Debug.Log("New gazed object: " + hit.transform.gameObject.name);

                _gazedAtObject?.SendMessage("PointerExit");
                _gazedAtObject = hit.transform.gameObject;
                _gazedAtObject.SendMessage("PointerEnter");
            }
        }
        else
        {
            // No GameObject detected in front of the camera.
            _gazedAtObject?.SendMessage("PointerExit");
            _gazedAtObject = null;
        }
    }
示例#11
0
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    public void Update()
    {
        // Casts ray towards camera's forward direction, to detect if a GameObject is being gazed
        // at.
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, _maxDistance))
        {
            if (_gazedAtObject != hit.transform.gameObject)
            {
                // New GameObject.
                // _gazedAtObject?.SendMessage("OnPointerExit");
                _gazedAtObject = hit.transform.gameObject;

                if ((hit.collider.CompareTag("Weapon") || hit.collider.CompareTag("VirtualButton")) && !_gazedAtObject.CompareTag("Bounds"))
                {
                    _gazedAtObject.SendMessage("OnPointerEnter");
                }
            }
        }
        else
        {
            // No GameObject detected in front of the camera.
            if (_gazedAtObject != null && !_gazedAtObject.CompareTag("Bounds"))
            {
                _gazedAtObject?.SendMessage("OnPointerExit");
            }
            _gazedAtObject = null;
        }

        // Checks for screen touches.
        if (Google.XR.Cardboard.Api.IsTriggerPressed)
        {
            _gazedAtObject?.SendMessage("OnPointerClick");
        }
    }
示例#12
0
        public void CanRegisterMultipleComponentsOnTheSameGameObjectForTargettedDelivery()
        {
            var gameObject = new GameObject();
            var testComponent = new TestComponent();
            var testComponent2 = new TestComponent2();

            gameObject.AddComponent(testComponent);
            gameObject.AddComponent(testComponent2);

            Scene.Current.AddObject(gameObject);

            gameObject.SendMessage(new TestGameMessage(), gameObject);

            Assert.True(testComponent.MessageHandled);
            Assert.True(testComponent2.MessageHandled);
        }
示例#13
0
    private void HandleDoorVisual(bool openedDoor, bool closedDoor, bool dontCalculateAStarColliders)
    {
        foreach (GameObject door in _openedDoors)
        {
            door.SetActive(openedDoor);
        }

        foreach (GameObject door in _closedDoors)
        {
            door.SetActive(closedDoor);
        }

        if (!dontCalculateAStarColliders)
        {
            _SAP2D?.SendMessage("CalculateColliders");
        }
    }
示例#14
0
 /// <summary>
 /// Update is called once per frame.
 /// </summary>
 public void Update()
 {
     // Casts ray towards camera's forward direction, to detect if a GameObject is being gazed
     // at.
     if (Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, maxDistance))
     {
         // GameObject detected in front of the camera.
         if (_gazedAtObject != hit.transform.gameObject)
         {
             if (hit.transform.gameObject.CompareTag("Buttons"))
             {
                 // New GameObject.
                 _gazedAtObject?.SendMessage("OnPointerExit", new GvrPointerEventData(null));
                 _gazedAtObject = hit.transform.gameObject;
                 _gazedAtObject?.SendMessage("OnPointerEnter", new GvrPointerEventData(null));
             }
         }
     }
示例#15
0
    public void SizeRequested(GameObject Objectum)
    {
        Vector2 saizo = new Vector2(SizeX, SizeY);

        Objectum.SendMessage("GetSize", saizo);
    }
示例#16
0
    public void Update()
    {
        // Casts ray towards camera's forward direction,
        //to detect if a GameObject is being gazed at.
        RaycastHit hit;

        if (Physics.Raycast(
                transform.position, transform.forward, out hit, _maxDistance))
        {
            // GameObject detected in front of the camera.
            if (_gazedAtObject != hit.transform.gameObject)
            {
                if (isDebugLogging)
                {
                    DebugPrinter.Print("VR: GameObject detected.");
                }

                // New GameObject
                _gazedAtObject?.SendMessage(
                    "OnPointerExit",
                    pointerEventData,
                    SendMessageOptions.DontRequireReceiver);

                _gazedAtObject = hit.transform.gameObject;
                _gazedAtObject?.SendMessage(
                    "OnPointerEnter",
                    pointerEventData,
                    SendMessageOptions.DontRequireReceiver);

                SetReticleDetected(true);
            }
        }
        else
        {
            if (isDebugLogging)
            {
                DebugPrinter.Print("VR: !!! No GameObject detected.");
            }

            _gazedAtObject?.SendMessage(
                "OnPointerExit",
                pointerEventData,
                SendMessageOptions.DontRequireReceiver);

            _gazedAtObject = null;

            SetReticleDetected(false);
        }

#if UNITY_EDITOR
        // Checks for mouse touches.
        if (Input.GetMouseButtonDown(0))
        {
#else
        // Checks for screen touches.
        if (Google.XR.Cardboard.Api.IsTriggerPressed)
        {
#endif

            if (isDebugLogging)
            {
                DebugPrinter.Print("VR: OnPointerClick.");
            }

            _gazedAtObject?.SendMessage(
                "OnPointerClick",
                pointerEventData,
                SendMessageOptions.DontRequireReceiver);
        }
    }
示例#17
0
 protected override void UseItem(GameObject col, int Size)
 {
     col.SendMessage("HealtUp", Size);
 }
示例#18
0
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    public void Update()
    {
        // Casts ray towards camera's forward direction, to detect if a GameObject is being gazed
        // at.
        RaycastHit hit;

#if UNITY_EDITOR
        // Bit shift the index of the layer (8) to get a bit mask
        Vector3 mouse     = Input.mousePosition;
        Ray     castPoint = Camera.main.ScreenPointToRay(mouse);

        if (Physics.Raycast(castPoint, out hit, Mathf.Infinity))
        {
            Debug.Log(hit.transform.tag);

            // GameObject detected in front of the camera.
            if (m_GazedAtObject != hit.transform.gameObject)
            {
                switch (hit.transform.tag)
                {
                case "interactive":
                    m_GazedAtObject?.SendMessage("OnPointerExit");
                    m_GazedAtObject = hit.transform.gameObject;
                    break;

                case "areaObject":
                    m_GazedAtObject?.SendMessage("OnPointerExit");
                    m_GazedAtObject = hit.transform.gameObject;

                    break;

                default:
                    break;
                }
            }
            else
            {
                if (!selecObj)
                {
                    onPointerObserver();
                }
                switch (hit.transform.tag)
                {
                case "interactive":
                    m_GazedAtObject?.SendMessage("OnPointerEnter");
                    break;

                case "areaObject":
                    if (selecObj)
                    {
                        m_GazedAtObject?.SendMessage("OnPointerEnter", this.transform);
                    }
                    break;

                default:
                    break;
                }
            }
        }
        else
        {
            m_GazedAtObject?.SendMessage("OnPointerExit");
            m_GazedAtObject = null;
        }
        if (Input.GetMouseButtonDown(0))
        {
            OnPointerClick(m_GazedAtObject);
            m_GazedAtObject = null;
        }
#elif UNITY_ANDROID
        if (Physics.Raycast(transform.position, transform.forward, out hit, k_MaxDistance))
        {
            // GameObject detected in front of the camera.
            if (m_GazedAtObject != hit.transform.gameObject)
            {
                onPointerObserver();
                switch (hit.transform.tag)
                {
                case "interactive":
                    m_GazedAtObject?.SendMessage("OnPointerExit");
                    m_GazedAtObject = hit.transform.gameObject;
                    m_GazedAtObject?.SendMessage("OnPointerEnter");
                    break;

                case "areaObject":
                    m_GazedAtObject?.SendMessage("OnPointerExit");
                    m_GazedAtObject = hit.transform.gameObject;
                    break;

                default:
                    break;
                }
            }
            else
            {
                if (!selecObj)
                {
                    onPointerObserver();
                }
                switch (hit.transform.tag)
                {
                case "interactive":
                    m_GazedAtObject?.SendMessage("OnPointerEnter");
                    break;

                case "areaObject":
                    if (selecObj)
                    {
                        m_GazedAtObject?.SendMessage("OnPointerEnter", this.transform);
                    }
                    break;

                default:
                    break;
                }
            }
        }
        else
        {
            // No GameObject detected in front of the camera.
            m_GazedAtObject?.SendMessage("OnPointerExit");
            m_GazedAtObject = null;
        }
        // Checks for screen touches.
        if (Google.XR.Cardboard.Api.IsTriggerPressed)
        {
            OnPointerClick(m_GazedAtObject);
            m_GazedAtObject = null;
        }
#endif
    }
示例#19
0
        public void HandlesReentrancy()
        {
            var gameObject = new GameObject();
            var testComponent = new TestComponent();
            var testComponent2 = new ComponentThatCallsSendMessageInsideHandleMessage();

            gameObject.AddComponent(testComponent);
            gameObject.AddComponent(testComponent2);

            Scene.Current.AddObject(gameObject);

            gameObject.SendMessage(new TestGameMessageTwo(), gameObject);

            Assert.True(testComponent.MessageHandled);
            Assert.True(testComponent2.MessageHandled);
        }
    /// <summary>
    /// Update the tweening factor and call the virtual update function.
    /// </summary>

    void Update()
    {
        float delta = ignoreTimeScale ? RealTime.deltaTime : Time.deltaTime;
        float time  = ignoreTimeScale ? RealTime.time : Time.time;

        if (!mStarted)
        {
            mStarted   = true;
            mStartTime = time + delay;
        }

        if (time < mStartTime)
        {
            return;
        }

        // Advance the sampling factor
        mFactor += amountPerDelta * delta;

        // Loop style simply resets the play factor after it exceeds 1.
        if (style == Style.Loop)
        {
            if (mFactor > 1f)
            {
                mFactor -= Mathf.Floor(mFactor);
            }
        }
        else if (style == Style.PingPong)
        {
            // Ping-pong style reverses the direction
            if (mFactor > 1f)
            {
                mFactor         = 1f - (mFactor - Mathf.Floor(mFactor));
                mAmountPerDelta = -mAmountPerDelta;
            }
            else if (mFactor < 0f)
            {
                mFactor         = -mFactor;
                mFactor        -= Mathf.Floor(mFactor);
                mAmountPerDelta = -mAmountPerDelta;
            }
        }

        // If the factor goes out of range and this is a one-time tweening operation, disable the script
        if ((style == Style.Once) && (duration == 0f || mFactor > 1f || mFactor < 0f))
        {
            mFactor = Mathf.Clamp01(mFactor);
            Sample(mFactor, true);

            if (current == null)
            {
                UITweener before = current;
                current = this;

                if (onFinished != null)
                {
                    mTemp      = onFinished;
                    onFinished = new List <EventDelegate>();

                    // Notify the listener delegates
                    EventDelegate.Execute(mTemp);

                    // Re-add the previous persistent delegates
                    for (int i = 0; i < mTemp.Count; ++i)
                    {
                        EventDelegate ed = mTemp[i];
                        if (ed != null && !ed.oneShot)
                        {
                            EventDelegate.Add(onFinished, ed, ed.oneShot);
                        }
                    }
                    mTemp = null;
                }

                // Deprecated legacy functionality support
                if (eventReceiver != null && !string.IsNullOrEmpty(callWhenFinished))
                {
                    eventReceiver.SendMessage(callWhenFinished, this, SendMessageOptions.DontRequireReceiver);
                }

                current = before;
            }

            // Disable this script unless the function calls above changed something
            if (duration == 0f || (mFactor == 1f && mAmountPerDelta > 0f || mFactor == 0f && mAmountPerDelta < 0f))
            {
                enabled = false;
            }
        }
        else
        {
            Sample(mFactor, false);
        }
    }
示例#21
0
    /// <summary>
    /// Update the visible slider.
    /// </summary>

    void Set(float input, bool force)
    {
        if (!mInitDone)
        {
            Init();
        }

        // Clamp the input
        float val = Mathf.Clamp01(input);

        if (val < 0.001f)
        {
            val = 0f;
        }

        float prevStep = sliderValue;

        // Save the raw value
        rawValue = val;

        // Take steps into account
        float stepValue = sliderValue;

        // If the stepped value doesn't match the last one, it's time to update
        if (force || prevStep != stepValue)
        {
            Vector3 scale = mSize;

#if UNITY_EDITOR
            if (Application.isPlaying)
            {
                if (direction == Direction.Horizontal)
                {
                    scale.x *= stepValue;
                }
                else
                {
                    scale.y *= stepValue;
                }
            }
#else
            if (direction == Direction.Horizontal)
            {
                scale.x *= stepValue;
            }
            else
            {
                scale.y *= stepValue;
            }
#endif

#if UNITY_EDITOR
            if (Application.isPlaying)
#endif
            {
                if (mFGFilled != null && mFGFilled.type == UISprite.Type.Filled)
                {
                    mFGFilled.fillAmount = stepValue;
                }
                else if (foreground != null)
                {
                    mFGTrans.localScale = scale;

                    if (mFGWidget != null)
                    {
                        if (stepValue > 0.001f)
                        {
                            mFGWidget.enabled = true;
                            mFGWidget.MarkAsChanged();
                        }
                        else
                        {
                            mFGWidget.enabled = false;
                        }
                    }
                }
            }

            if (thumb != null)
            {
                Vector3 pos = thumb.localPosition;

                if (mFGFilled != null && mFGFilled.type == UISprite.Type.Filled)
                {
                    if (mFGFilled.fillDirection == UISprite.FillDirection.Horizontal)
                    {
                        pos.x = mFGFilled.invert ? mSize.x - scale.x : scale.x;
                    }
                    else if (mFGFilled.fillDirection == UISprite.FillDirection.Vertical)
                    {
                        pos.y = mFGFilled.invert ? mSize.y - scale.y : scale.y;
                    }
                    else
                    {
                        Debug.LogWarning("Slider thumb is only supported with Horizontal or Vertical fill direction", this);
                    }
                }
                else if (direction == Direction.Horizontal)
                {
                    pos.x = scale.x;
                }
                else
                {
                    pos.y = scale.y;
                }
                thumb.localPosition = pos;
            }

            current = this;

            if (eventReceiver != null && !string.IsNullOrEmpty(functionName) && Application.isPlaying)
            {
                eventReceiver.SendMessage(functionName, stepValue, SendMessageOptions.DontRequireReceiver);
            }
            if (onValueChange != null)
            {
                onValueChange(stepValue);
            }
            current = null;
        }
    }
示例#22
0
 public void spanCamera(Vector3 span)     //span = new Vector3(location.x, location.y, scale)
 {
     cam.SendMessage("SpanScene", span);
 }
示例#23
0
 void Start()
 {
     //向本脚本所属的游戏对象发送ShowNumber消息并传递参数100
     receiver.SendMessage("ShowNumber", 100, SendMessageOptions.DontRequireReceiver);
 }
        protected virtual void SetupTarget()
        {
            if (targetTF != null && targetTF.gameObject.layer == LayerMask.NameToLayer("UI"))               // Only do for UI

            {
                _targetParentTF = targetTF.parent;
                RectTransform targetRT = targetTF.GetComponent <RectTransform>();
                _targetSiblingIndex = targetRT.GetSiblingIndex();

                if (cloneTarget && _targetCloneGO == null)                   // Position the target clone to target's position
                {
                    _targetCloneGO = targetTF.parent.gameObject.AddChild(targetTF.gameObject);
                    RectTransform targetCloneRT = _targetCloneGO.GetComponent <RectTransform>();
                    if (targetCloneRT != null)
                    {
                        targetCloneRT.SetSiblingIndex(_targetSiblingIndex);
                        targetCloneRT.sizeDelta = targetRT.sizeDelta;
                    }
                }

                // Move target to tutorial panel
                if (targetRT != null)
                {
                    Transform transformToMoveInTutorialPanel = targetTF;
                    if (putCloneToTutorialPanelInstead)
                    {
                        transformToMoveInTutorialPanel = _targetCloneGO.transform;
                        // Add canvas sorting
                        Canvas canvas = transformToMoveInTutorialPanel.GetComponent <Canvas>();
                        if (canvas != null)
                        {
                            canvas.sortingOrder += 1000;
                        }
                        // Remove TweenOnEnable
                        TweenOnEnable tweenOnEnable = transformToMoveInTutorialPanel.GetComponent <TweenOnEnable>();

                        if (tweenOnEnable != null)
                        {
                            tweenOnEnable.ForceCancelTween();
                            Destroy(tweenOnEnable);
                        }
                    }
                    transformToMoveInTutorialPanel.SetParent(tutorialPanel.transform, true);

                    RectTransform rectTransformToMoveInTutorialPanel = transformToMoveInTutorialPanel.GetComponent <RectTransform>();
                    rectTransformToMoveInTutorialPanel.SetSiblingIndex(1);                     // Just after background mask

                    // Set if target should catch raycasts and store original state
                    Graphic graphicToMoveInTutorialPanel = rectTransformToMoveInTutorialPanel.GetComponent <Graphic>();
                    if (graphicToMoveInTutorialPanel != null)
                    {
                        _cachedRaycastTarget = graphicToMoveInTutorialPanel.raycastTarget;
                        graphicToMoveInTutorialPanel.raycastTarget = targetCanCatchRaycast;
                    }

                    // Make sure it sets it to the right width.
                    if (cloneTarget && _targetCloneGO != null)                       // Position the target clone to target's position
                    {
                        RectTransform subTf  = (putCloneToTutorialPanelInstead) ? _targetCloneGO.GetComponent <RectTransform>() : targetTF.GetComponent <RectTransform>();
                        RectTransform coreTf = (putCloneToTutorialPanelInstead) ? targetTF.GetComponent <RectTransform>() : _targetCloneGO.GetComponent <RectTransform>();

                        LayoutGroup parentGroup = coreTf.GetComponentInParent <LayoutGroup>();
                        if (parentGroup != null)
                        {
                            LayoutRebuilder.ForceRebuildLayoutImmediate(parentGroup.GetComponent <RectTransform>());
                        }

                        subTf.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, coreTf.rect.width);
                        subTf.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, coreTf.rect.height);
                    }

                    // Try copy the data from target to clone
                    _targetCloneGO?.SendMessage("CopyFrom", targetTF.gameObject, SendMessageOptions.DontRequireReceiver);
                }
            }

            foreach (Button b in _disableButtons)
            {
                if (b != null)
                {
                    b.interactable = false;
                }
            }
        }
示例#25
0
 public void ToOpenDoor()
 {
     door.SendMessage("MegaCubeToOpen");
 }
        //-------------------------------------------------
        void FixedUpdate()
        {
            if (attachMode == AttachMode.Force)
            {
                for (int i = 0; i < holdingHands.Count; i++)
                {
                    Vector3 targetPoint   = holdingBodies[i].transform.TransformPoint(holdingPoints[i]);
                    Vector3 vdisplacement = holdingHands[i].transform.position - targetPoint;

                    holdingBodies[i].AddForceAtPosition(attachForce * vdisplacement, targetPoint, ForceMode.Acceleration);
                    holdingBodies[i].AddForceAtPosition(-attachForceDamper * holdingBodies[i].GetPointVelocity(targetPoint), targetPoint, ForceMode.Acceleration);
                }
            }
            for (int i = 0; i < holdingHands.Count; i++)
            {
                if (holdingHands.IndexOf(holdingHands[i].otherHand) == -1 && holdingHands[i].gameObject.tag == "RightHand")               // other hand not holding this
                {
                    Hand otherHand = holdingHands[i].otherHand;
                    if (otherHand.currentAttachedObject)                                          // and holding a thing
                    {
                        var attpArray     = GameObject.FindGameObjectsWithTag("AttachmentPoint");
                        var sideattpArray = GameObject.FindGameObjectsWithTag("SideAttachmentPoint");
                        foreach (GameObject item in attpArray)
                        {
                            attachmentPoints.Add(item);
                        }
                        foreach (GameObject item in sideattpArray)
                        {
                            sideAttachmentPoints.Add(item);
                        }
                        for (int j = 0; j < attachmentPoints.Count; j++)
                        {
                            GameObject attachmentPoint = attachmentPoints[j];
                            if (ObjectInRigidbodies(attachmentPoint.transform.parent.parent.gameObject))
                            {
                                attachmentPointsHere.Add(attachmentPoint);
                            }
                            else if (attachmentPoint.transform.parent.parent.gameObject == otherHand.currentAttachedObject)
                            {
                                attachmentPointsOther.Add(attachmentPoint);
                            }
                        }
                        for (int j = 0; j < sideAttachmentPoints.Count; j++)
                        {
                            GameObject sideAttachmentPoint = sideAttachmentPoints[j];
                            if (ObjectInRigidbodies(sideAttachmentPoint.transform.parent.parent.gameObject))
                            {
                                sideAttachmentPointsHere.Add(sideAttachmentPoint);
                            }
                            else if (sideAttachmentPoint.transform.parent.parent.gameObject == otherHand.currentAttachedObject)
                            {
                                sideAttachmentPointsOther.Add(sideAttachmentPoint);
                            }
                        }
                        float      closestDistance = float.MaxValue;
                        GameObject closestHere     = null;
                        GameObject closestOther    = null;
                        bool       isSide          = false;
                        for (int j = 0; j < attachmentPointsHere.Count; j++)
                        {
                            for (int k = 0; k < attachmentPointsOther.Count; k++)
                            {
                                float distance = Vector3.Distance(attachmentPointsHere[j].transform.position, attachmentPointsOther[k].transform.position);
                                if (distance < closestDistance)
                                {
                                    closestDistance = distance;
                                    closestHere     = attachmentPointsHere[j];
                                    closestOther    = attachmentPointsOther[k];
                                }
                            }
                        }
                        for (int j = 0; j < sideAttachmentPointsHere.Count; j++)
                        {
                            for (int k = 0; k < sideAttachmentPointsOther.Count; k++)
                            {
                                float distance = Vector3.Distance(sideAttachmentPointsHere[j].transform.position, sideAttachmentPointsOther[k].transform.position);
                                if (distance < closestDistance)
                                {
                                    closestDistance = distance;
                                    closestHere     = sideAttachmentPointsHere[j];
                                    closestOther    = sideAttachmentPointsOther[k];
                                    isSide          = true;
                                }
                            }
                        }
                        if (closestDistance < 0.01 && (!isSide || connectedDrill))
                        {
                            // alignment step?
                            GameObject otherPart = closestOther.transform.parent.parent.gameObject;
                            FixedJoint APJoint   = closestHere.transform.parent.parent.gameObject.AddComponent <FixedJoint>();
                            APJoint.connectedBody = otherPart.GetComponent <Rigidbody>();
                            otherHand.SendMessage("DetachObject", otherHand.currentAttachedObject);

                            GameObject thisRocket = ObjectRocket(this.gameObject);
                            GameObject thatRocket = ObjectRocket(otherPart);
                            if (thisRocket == null && thatRocket == null)
                            {
                                var preRockets           = GameObject.FindGameObjectsWithTag("Rocket");
                                var preLaunchableRockets = GameObject.FindGameObjectsWithTag("LaunchableRocket");
                                var beforeRockets        = new GameObject[preRockets.Length + preLaunchableRockets.Length];
                                preRockets.CopyTo(beforeRockets, 0);
                                preLaunchableRockets.CopyTo(beforeRockets, preRockets.Length);
                                Instantiate(rocketPrefab, closestHere.transform.position, Quaternion.identity);
                                var postRockets           = GameObject.FindGameObjectsWithTag("Rocket");
                                var postLaunchableRockets = GameObject.FindGameObjectsWithTag("LaunchableRocket");
                                var afterRockets          = new GameObject[postRockets.Length + postLaunchableRockets.Length];
                                postRockets.CopyTo(afterRockets, 0);
                                postLaunchableRockets.CopyTo(afterRockets, postRockets.Length);
                                GameObject newRocket = OddOneOut(beforeRockets, afterRockets);
                                newRocket.SendMessage("AddPart", this.gameObject);
                                newRocket.SendMessage("AddPart", otherPart);
                            }
                            else if (thisRocket == null)
                            {
                                thatRocket.SendMessage("AddPart", this.gameObject);
                            }
                            else if (thatRocket == null)
                            {
                                thisRocket.SendMessage("AddPart", otherPart);
                            }
                            else
                            {
                                thisRocket.SendMessage("AddRocket", thatRocket);
                            }
                        }
                        attachmentPoints.Clear();
                        attachmentPointsHere.Clear();
                        attachmentPointsOther.Clear();
                    }
                }

                if (holdingHands[i].IsGrabEnding(this.gameObject))
                {
                    PhysicsDetach(holdingHands[i]);
                }
            }
        }
示例#27
0
    void Inputs()
    {
        if (Input.GetKey(KeyCode.A) && transform.position.x > -9.3)
        {
            rb.velocity = new Vector2(-xMovement, rb.velocity.y);
        }
        if (Input.GetKey(KeyCode.D) && transform.position.x < 9.3)
        {
            rb.velocity = new Vector2(xMovement, rb.velocity.y);
        }
        if (Input.GetKey(KeyCode.W) && Jumped == false)
        {
            rb.velocity = new Vector2(rb.velocity.x, jumpForce);
            Jumped      = true;
        }
        if (Input.GetKey(KeyCode.S) && !isGrounded)
        {
            Jumped = true;
            StartCoroutine("Fall");
            falling = true;
        }
        if (!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))
        {
            rb.velocity = new Vector2(0.0f, rb.velocity.y);
        }
        if (Input.GetMouseButtonDown(0))
        {
            if (boxes.Count > 0 && !held)
            {
                check = FindClosestBox();
                Debug.Log(check);
                if ((check.transform.position - transform.position).sqrMagnitude < 4 * 4)
                {
                    check.SendMessage("PickedUp", gameObject);
                    held     = true;
                    typeHeld = false;
                }
            }

            else if (held)
            {
                check.SendMessage("PutDown", gameObject);
                held = false;
            }
        }
        else if (Input.GetMouseButtonDown(1))
        {
            if (throwables.Count > 0 && !held)
            {
                checkThrowable = findClosestThrowable();

                if ((checkThrowable.transform.position - transform.position).sqrMagnitude < 4 * 4)
                {
                    checkThrowable.SendMessage("PickedUp", gameObject);
                    held       = true;
                    typeHeld   = true;
                    lr.enabled = true;
                }
            }
            else if (!typeHeld && held)
            {
                check.SendMessage("SpawnBall", item);
            }
        }
        if (Input.GetMouseButtonUp(1) && checkThrowable != null)
        {
            if (lifted)
            {
                direction = direction.normalized;
                //direction *= force;

                checkThrowable.SendMessage("thrown", direction);
                checkThrowable = null;
                held           = false;

                lr.enabled = false;
                lifted     = false;
            }
            else
            {
                lifted = true;
            }
        }
    }
示例#28
0
 // Update is called once per frame
 void FixedUpdate()
 {
     //go forward to next location
     if (goForward)
     {
         if ((path[pathIndex] - (Vector2)gameObject.transform.position).magnitude < 0.01f)
         {
             if (loops)
             {
                 pathIndex = (pathIndex + 1) % path.Length;
             }
             else
             {
                 if (goToIndex && pathIndex == destinationIndex)
                 {
                     destinationReached = true;
                     reachDestination();
                 }
                 else if (pathIndex < path.Length - 1)
                 {
                     pathIndex = pathIndex + 1;
                 }
                 else
                 {
                     destinationReached = true;
                     reachDestination();
                 }
             }
         }
         if (!destinationReached)
         {
             Vector2 direction = path[pathIndex] - (Vector2)gameObject.transform.position;
             velocity = direction.normalized * forwardSpeed;
             Vector2 offset = Vector2.ClampMagnitude(velocity * Time.deltaTime, direction.magnitude);
             velocity       = offset / Time.deltaTime;
             rb2d.position += velocity * Time.deltaTime;
             if (hasPlayer)
             {
                 player.SendMessage("SetPlatformVelocity", velocity);
             }
         }
     }
     //otherwise, go backwards to next location
     else if (goBackward)
     {
         if ((path[pathIndex] - (Vector2)gameObject.transform.position).magnitude < 0.01f)
         {
             if (loops)
             {
                 pathIndex = pathIndex - 1;
                 if (pathIndex < 0)
                 {
                     pathIndex = path.Length - 1;
                 }
             }
             else
             {
                 if (goToIndex && pathIndex == destinationIndex)
                 {
                     destinationReached = true;
                 }
                 else if (pathIndex > 0)
                 {
                     pathIndex = pathIndex - 1;
                 }
                 else
                 {
                     destinationReached = true;
                 }
             }
         }
         if (!destinationReached)
         {
             Vector2 direction = path[pathIndex] - (Vector2)gameObject.transform.position;
             velocity = direction.normalized * backwardSpeed;
             Vector2 offset = Vector2.ClampMagnitude(velocity * Time.deltaTime, direction.magnitude);
             velocity       = offset / Time.deltaTime;
             rb2d.position += velocity * Time.deltaTime;
             if (hasPlayer)
             {
                 player.SendMessage("SetPlatformVelocity", velocity);
             }
         }
     }
 }
示例#29
0
    void RaiseEvent(MessageName msg)
    {
        if (interaction == InteractionType.Event)
        {
            if (!useBroadcast)
            {
                switch (msg)
                {
                case MessageName.On_ButtonDown:
                    if (On_ButtonDown != null)
                    {
                        On_ButtonDown(gameObject.name);
                    }
                    break;

                case MessageName.On_ButtonUp:
                    if (On_ButtonUp != null)
                    {
                        On_ButtonUp(gameObject.name);
                    }
                    break;

                case MessageName.On_ButtonPress:

                    if (On_ButtonPress != null)
                    {
                        On_ButtonPress(gameObject.name);
                    }
                    break;
                }
            }
            else
            {
                string method = msg.ToString();

                if (msg == MessageName.On_ButtonDown && downMethodName != "" && useSpecificalMethod)
                {
                    method = downMethodName;
                }

                if (msg == MessageName.On_ButtonPress && pressMethodName != "" && useSpecificalMethod)
                {
                    method = pressMethodName;
                }

                if (msg == MessageName.On_ButtonUp && upMethodName != "" && useSpecificalMethod)
                {
                    method = upMethodName;
                }
                if (receiverGameObject != null)
                {
                    switch (messageMode)
                    {
                    case Broadcast.BroadcastMessage:
                        receiverGameObject.BroadcastMessage(method, name, SendMessageOptions.DontRequireReceiver);
                        break;

                    case Broadcast.SendMessage:
                        receiverGameObject.SendMessage(method, name, SendMessageOptions.DontRequireReceiver);
                        break;

                    case Broadcast.SendMessageUpwards:
                        receiverGameObject.SendMessageUpwards(method, name, SendMessageOptions.DontRequireReceiver);
                        break;
                    }
                }
                else
                {
                    Debug.LogError("Button : " + gameObject.name + " : you must setup receiver gameobject");
                }
            }
        }
    }
示例#30
0
    public void ArrowCheck(string InputArrow)
    {
        GameObject[] temp = GameObject.FindGameObjectsWithTag("Arrows");

        switch (InputArrow)
        {
        //Normal Arrow check
        case "UpArrow":
            if (Input.GetKey(KeyCode.UpArrow) || SlideCheck() == "Up")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Combo_Count").SendMessage("IncreaseCount");
                ArrowSequence[4].SendMessage("DestroyArrow");

                PlayerObj.SendMessage("UpAttack");

                MakeArrow(Random.Range(0, 12));
            }
            else if (Input.GetKey(KeyCode.DownArrow) ||
                     Input.GetKey(KeyCode.RightArrow) ||
                     Input.GetKey(KeyCode.LeftArrow) ||
                     SlideCheck() == "Down" ||
                     SlideCheck() == "Right" ||
                     SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        case "LeftArrow":
            if (Input.GetKey(KeyCode.LeftArrow) || SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Combo_Count").SendMessage("IncreaseCount");
                ArrowSequence[4].SendMessage("DestroyArrow");

                PlayerObj.SendMessage("SideAttack");

                MakeArrow(Random.Range(0, 12));
            }
            else if (Input.GetKey(KeyCode.DownArrow) ||
                     Input.GetKey(KeyCode.RightArrow) ||
                     Input.GetKey(KeyCode.UpArrow) ||
                     SlideCheck() == "Down" ||
                     SlideCheck() == "Right" ||
                     SlideCheck() == "Up")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        case "DownArrow":
            if (Input.GetKey(KeyCode.DownArrow) || SlideCheck() == "Down")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Combo_Count").SendMessage("IncreaseCount");
                ArrowSequence[4].SendMessage("DestroyArrow");

                PlayerObj.SendMessage("DownAttack");

                MakeArrow(Random.Range(0, 12));
            }
            else if (Input.GetKey(KeyCode.UpArrow) ||
                     Input.GetKey(KeyCode.RightArrow) ||
                     Input.GetKey(KeyCode.LeftArrow) ||
                     SlideCheck() == "Up" ||
                     SlideCheck() == "Right" ||
                     SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        case "RightArrow":
            if (Input.GetKey(KeyCode.RightArrow) || SlideCheck() == "Right")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Combo_Count").SendMessage("IncreaseCount");
                ArrowSequence[4].SendMessage("DestroyArrow");

                PlayerObj.SendMessage("SideAttack");

                MakeArrow(Random.Range(0, 12));
            }
            else if (Input.GetKey(KeyCode.DownArrow) ||
                     Input.GetKey(KeyCode.UpArrow) ||
                     Input.GetKey(KeyCode.LeftArrow) ||
                     SlideCheck() == "Down" ||
                     SlideCheck() == "Up" ||
                     SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;



        //Double Arrow Check//

        case "DoubleUpArrow":
            if (Input.GetKey(KeyCode.UpArrow) || SlideCheck() == "Up")
            {
                if (ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed == true)
                {
                    GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                    GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                    GameObject.Find("Combo_Count").SendMessage("IncreaseCount");

                    ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed = false;
                    ArrowSequence[4].SendMessage("DestroyArrow");

                    PlayerObj.SendMessage("UpAttack");
                    Destroy(Instantiate(DoubleAttackEffect), 0.5f);

                    MakeArrow(Random.Range(0, 12));
                }
                else
                {
                    ArrowSequence[4].SendMessage("ChangeDAImage", "DoubleUpArrow");
                    ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed = true;
                }
            }
            else if (Input.GetKey(KeyCode.DownArrow) ||
                     Input.GetKey(KeyCode.RightArrow) ||
                     Input.GetKey(KeyCode.LeftArrow) ||
                     SlideCheck() == "Down" ||
                     SlideCheck() == "Right" ||
                     SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        case "DoubleLeftArrow":
            if (Input.GetKey(KeyCode.LeftArrow) || SlideCheck() == "Left")
            {
                if (ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed == true)
                {
                    GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                    GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                    GameObject.Find("Combo_Count").SendMessage("IncreaseCount");

                    ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed = false;
                    ArrowSequence[4].SendMessage("DestroyArrow");

                    PlayerObj.SendMessage("SideAttack");
                    Destroy(Instantiate(DoubleAttackEffect), 0.5f);

                    MakeArrow(Random.Range(0, 12));
                }
                else
                {
                    ArrowSequence[4].SendMessage("ChangeDAImage", "DoubleLeftArrow");
                    ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed = true;
                }
            }
            else if (Input.GetKey(KeyCode.DownArrow) ||
                     Input.GetKey(KeyCode.RightArrow) ||
                     Input.GetKey(KeyCode.UpArrow) ||
                     SlideCheck() == "Down" ||
                     SlideCheck() == "Right" ||
                     SlideCheck() == "Up")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        case "DoubleDownArrow":
            if (Input.GetKey(KeyCode.DownArrow) || SlideCheck() == "Down")
            {
                if (ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed == true)
                {
                    GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                    GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                    GameObject.Find("Combo_Count").SendMessage("IncreaseCount");

                    ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed = false;
                    ArrowSequence[4].SendMessage("DestroyArrow");

                    PlayerObj.SendMessage("DownAttack");
                    Destroy(Instantiate(DoubleAttackEffect), 0.5f);

                    MakeArrow(Random.Range(0, 12));
                }
                else
                {
                    ArrowSequence[4].SendMessage("ChangeDAImage", "DoubleDownArrow");
                    ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed = true;
                }
            }
            else if (Input.GetKey(KeyCode.UpArrow) ||
                     Input.GetKey(KeyCode.RightArrow) ||
                     Input.GetKey(KeyCode.LeftArrow) ||
                     SlideCheck() == "Up" ||
                     SlideCheck() == "Right" ||
                     SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        case "DoubleRightArrow":
            if (Input.GetKey(KeyCode.RightArrow) || SlideCheck() == "Right")
            {
                if (ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed == true)
                {
                    GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                    GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                    GameObject.Find("Combo_Count").SendMessage("IncreaseCount");

                    ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed = false;
                    ArrowSequence[4].SendMessage("DestroyArrow");

                    PlayerObj.SendMessage("SideAttack");
                    Destroy(Instantiate(DoubleAttackEffect), 0.5f);

                    MakeArrow(Random.Range(0, 12));
                }
                else
                {
                    ArrowSequence[4].SendMessage("ChangeDAImage", "DoubleRightArrow");
                    ArrowSequence[4].gameObject.GetComponent <ArrowControl>().IsSuccessed = true;
                }
            }
            else if (Input.GetKey(KeyCode.DownArrow) ||
                     Input.GetKey(KeyCode.UpArrow) ||
                     Input.GetKey(KeyCode.LeftArrow) ||
                     SlideCheck() == "Down" ||
                     SlideCheck() == "Up" ||
                     SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        //Reverse Arrow Check//
        case "ReverseUpArrow":
            if (Input.GetKey(KeyCode.DownArrow) || SlideCheck() == "Down")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Combo_Count").SendMessage("IncreaseCount");
                ArrowSequence[4].SendMessage("DestroyArrow");

                PlayerObj.SendMessage("UpAttack");

                MakeArrow(Random.Range(0, 12));
            }
            else if (Input.GetKey(KeyCode.UpArrow) ||
                     Input.GetKey(KeyCode.RightArrow) ||
                     Input.GetKey(KeyCode.LeftArrow) ||
                     SlideCheck() == "Up" ||
                     SlideCheck() == "Right" ||
                     SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        case "ReverseLeftArrow":
            if (Input.GetKey(KeyCode.RightArrow) || SlideCheck() == "Right")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Combo_Count").SendMessage("IncreaseCount");
                ArrowSequence[4].SendMessage("DestroyArrow");

                PlayerObj.SendMessage("SideAttack");

                MakeArrow(Random.Range(0, 12));
            }
            else if (Input.GetKey(KeyCode.DownArrow) ||
                     Input.GetKey(KeyCode.LeftArrow) ||
                     Input.GetKey(KeyCode.UpArrow) ||
                     SlideCheck() == "Down" ||
                     SlideCheck() == "Left" ||
                     SlideCheck() == "Up")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        case "ReverseDownArrow":
            if (Input.GetKey(KeyCode.UpArrow) || SlideCheck() == "Up")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Combo_Count").SendMessage("IncreaseCount");
                ArrowSequence[4].SendMessage("DestroyArrow");

                PlayerObj.SendMessage("DownAttack");

                MakeArrow(Random.Range(0, 12));
            }
            else if (Input.GetKey(KeyCode.DownArrow) ||
                     Input.GetKey(KeyCode.RightArrow) ||
                     Input.GetKey(KeyCode.LeftArrow) ||
                     SlideCheck() == "Down" ||
                     SlideCheck() == "Right" ||
                     SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;

        case "ReverseRightArrow":
            if (Input.GetKey(KeyCode.LeftArrow) || SlideCheck() == "Left")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Fever_Gauge").SendMessage("SlideSuccess");
                GameObject.Find("Combo_Count").SendMessage("IncreaseCount");
                ArrowSequence[4].SendMessage("DestroyArrow");

                PlayerObj.SendMessage("SideAttack");

                MakeArrow(Random.Range(0, 12));
            }
            else if (Input.GetKey(KeyCode.DownArrow) ||
                     Input.GetKey(KeyCode.UpArrow) ||
                     Input.GetKey(KeyCode.RightArrow) ||
                     SlideCheck() == "Down" ||
                     SlideCheck() == "Up" ||
                     SlideCheck() == "Right")
            {
                GameObject.Find("Timer_Gauge").SendMessage("SlideFail");
                GameObject.Find("Fever_Gauge").SendMessage("SlideFail");
                GameObject.Find("Combo_Count").SendMessage("ResetCount");
                isLocked = true;
                for (int i = 0; i < 4; i++)
                {
                    temp[i].SendMessage("Locked");
                }
            }
            break;
        }
    }
示例#31
0
 private void OnTriggerEnter(Collider other)
 {
     futryna.SendMessage(massage);
 }
    // Update is called once per frame

    void Update()
    {
#if UNITY_EDITOR
        if (Input.GetMouseButton(0) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0))
        {
            touchesOld = new GameObject[touchList.Count];
            touchList.CopyTo(touchesOld);


            Ray ray = cam.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, touchInputMask))
            {
                GameObject recipient = hit.transform.gameObject;
                touchList.Add(recipient);

                if (Input.GetMouseButtonDown(0))
                {
                    recipient.SendMessage("OnTouchDown", hit.point, SendMessageOptions.DontRequireReceiver);
                    Debug.Log("Mouse Input Handler Click:");
                }
                if (Input.GetMouseButtonUp(0))
                {
                    recipient.SendMessage("OnTouchUp", hit.point, SendMessageOptions.DontRequireReceiver);
                    Debug.Log("Mouse Input Handler Released:");
                }
                if (Input.GetMouseButton(0))
                {
                    recipient.SendMessage("OnTouchStay", hit.point, SendMessageOptions.DontRequireReceiver);
                }
            }

            foreach (GameObject g in touchesOld)
            {
                if (!touchList.Contains(g))
                {
                    g.SendMessage("OnTouchExit", hit.point, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
#endif

        if (Input.touchCount > 0)
        {
            touchesOld = new GameObject[touchList.Count];
            touchList.CopyTo(touchesOld);


            foreach (Touch touch in Input.touches)
            {
                Ray ray = cam.ScreenPointToRay(touch.position);

                if (Physics.Raycast(ray, out hit, touchInputMask))
                {
                    GameObject recipient = hit.transform.gameObject;
                    touchList.Add(recipient);

                    if (touch.phase == TouchPhase.Began)
                    {
                        recipient.SendMessage("OnTouchDown", hit.point, SendMessageOptions.DontRequireReceiver);
                    }
                    if (touch.phase == TouchPhase.Ended)
                    {
                        recipient.SendMessage("OnTouchUp", hit.point, SendMessageOptions.DontRequireReceiver);
                    }
                    if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved)
                    {
                        recipient.SendMessage("OnTouchStay", hit.point, SendMessageOptions.DontRequireReceiver);
                    }
                    if (touch.phase == TouchPhase.Canceled)
                    {
                        recipient.SendMessage("OnTouchExit", hit.point, SendMessageOptions.DontRequireReceiver);
                    }
                }
            }

            foreach (GameObject g in touchesOld)
            {
                if (!touchList.Contains(g))
                {
                    g.SendMessage("OnTouchExit", hit.point, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    }
示例#33
0
        public void WhenMessageMarkedAsHandledMessageNotSentToFurtherGameObjects()
        {
            var firstObject = new GameObject();
            var firstReceiver = new HandledTestComponent();
            firstObject.AddComponent(firstReceiver);
            Scene.Current.AddObject(firstObject);

            var secondObject = new GameObject();
            var secondReceiver = new HandledTestComponent();
            secondObject.AddComponent(secondReceiver);
            Scene.Current.AddObject(secondObject);

            firstObject.SendMessage(new TestGameMessage(), null);

            Assert.IsTrue(firstReceiver.MessageHandled ^ secondReceiver.MessageHandled);
        }
示例#34
0
    void Update()
    {
        // Check if running in unity
#if UNITY_EDITOR
        if (Input.GetMouseButton(0) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0))
        {
            touchesOld = new GameObject[touchList.Count];
            touchList.CopyTo(touchesOld);
            touchList.Clear();
            Ray ray = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);
            Debug.DrawRay(ray.origin, ray.direction * 100, Color.yellow);

            ////Checks if any UI or other elements are in the way, if true then cancel the raycast method
            //if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject() ) {
            //    return;
            //}


            if (Physics.Raycast(ray, out hit, distance, touchInputMask))
            {
                GameObject recipient = hit.transform.gameObject;
                touchList.Add(recipient);

                if (Input.GetMouseButtonDown(0))
                {
                    recipient.SendMessage("OnTouchDown", SendMessageOptions.DontRequireReceiver);
                }
                if (Input.GetMouseButtonUp(0))
                {
                    recipient.SendMessage("OnTouchUp", SendMessageOptions.DontRequireReceiver);
                }
                if (Input.GetMouseButton(0))
                {
                    recipient.SendMessage("OnTouchStay", SendMessageOptions.DontRequireReceiver);
                }
            }
            foreach (GameObject g in touchesOld)
            {
                if (!touchList.Contains(g))
                {
                    g.SendMessage("OnTouchExit", SendMessageOptions.DontRequireReceiver);
                }
            }
        }
#endif
        // If running in Android SDK
        if (Input.touchCount > 0)
        {
            touchesOld = new GameObject[touchList.Count];
            touchList.CopyTo(touchesOld);
            touchList.Clear();

            foreach (Touch touch in Input.touches)
            {
                Ray ray = GetComponent <Camera>().ScreenPointToRay(touch.position);
                if (Physics.Raycast(ray, out hit, distance, touchInputMask))
                {
                    GameObject recipient = hit.transform.gameObject;
                    touchList.Add(recipient);

                    ////Checks if any UI or other elements are in the way, if true then cancel the raycast method
                    //if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) {
                    //    return;
                    //}


                    if (touch.phase == TouchPhase.Began)
                    {
                        recipient.SendMessage("OnTouchDown", SendMessageOptions.DontRequireReceiver);
                    }
                    if (touch.phase == TouchPhase.Ended)
                    {
                        recipient.SendMessage("OnTouchUp", SendMessageOptions.DontRequireReceiver);
                    }
                    if (touch.phase == TouchPhase.Stationary)
                    {
                        recipient.SendMessage("OnTouchStay", SendMessageOptions.DontRequireReceiver);
                    }
                    if (touch.phase == TouchPhase.Stationary)
                    {
                        recipient.SendMessage("OnTouchExit", SendMessageOptions.DontRequireReceiver);
                    }
                }
            }
            foreach (GameObject g in touchesOld)
            {
                if (!touchList.Contains(g))
                {
                    g.SendMessage("OnTouchExit", SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    }
示例#35
0
 /// <summary>
 /// 接受安卓传过来的品质分级(如:messagee=1,则品质为1级);
 /// </summary>
 /// <param name='message'>
 /// Message.
 /// </param>
 public void getGAMEQuality(string message)
 {
     qm.SendMessage("returnAndroid", message, SendMessageOptions.DontRequireReceiver);
 }