void Update()
        {
            if (targetHero == null)
            {
                return;
            }

            for (int i = 0; i < (int)E_ControlParam.MAX; i++)
            {
                ct[i].text = targetHero.GetReUseRemainTime((E_ControlParam)i).ToString();
            }
            for (int i = 0; i < (int)E_ControlParam.MAX; i++)
            {
                heroControlBtnsScreen[
                    ((int)E_ControlParam.MAX * (int)targetHero.HeroType)
                    + i].fillAmount = targetHero.GetReUseRemainTimeByZeroToOne((E_ControlParam)i);
            }

            hpBarUI.fillAmount = targetHero.CurrHP * maxHPDiv;

            #region 안드로이드  (터치)
#if UNITY_ANDROID
            TestTouches();

            if (Input.touchCount == 0)
            {
                moveContTouch.DeActivate();
                rotateContTouch.DeActivate();
                cont.transform.position  = contBack.transform.position;
                charactorMoveV           = Vector3.zero;
                rcont.transform.position = rcontBack.transform.position;
                charactorRotateV         = Vector3.zero;

                targetHero.MoveHero(charactorMoveV);    //무빙은 계속 쏴줘야함.

                return;
            }

            Touch[] touches = Input.touches;

            for (int i = 0; i < touches.Length; i++)
            {
                Touch      touch    = touches[i];
                TouchPhase phase    = touch.phase;
                int        fingerID = touch.fingerId;
                Vector3    touchPos = touch.position;

                switch (phase)
                {
                case TouchPhase.Began:
                    if (moveController.IsInThisContPos(touchPos))
                    {
                        moveContTouch.Activate(fingerID);
                    }
                    else if (rotateController.IsInThisContPos(touchPos))
                    {
                        rotateContTouch.Activate(fingerID);
                    }
                    break;

                case TouchPhase.Moved:
                case TouchPhase.Stationary:
                    if (moveContTouch.activated && moveContTouch.IsThisTouchFID(fingerID))
                    {
                        moveContTouch.touchedPos = touchPos;
                    }
                    if (rotateContTouch.activated && rotateContTouch.IsThisTouchFID(fingerID))
                    {
                        rotateContTouch.touchedPos = touchPos;
                    }

                    break;

                case TouchPhase.Ended:
                case TouchPhase.Canceled:
                    if (moveContTouch.IsThisTouchFID(fingerID))
                    {
                        moveContTouch.DeActivate();
                    }
                    if (rotateContTouch.IsThisTouchFID(fingerID))
                    {
                        rotateContTouch.DeActivate();
                    }
                    break;
                }


                /*
                 * if (EventSystem.current.IsPointerOverGameObject(touches[i].fingerId) &&
                 *  touches[i].phase == TouchPhase.Began)   //게임 오브젝트에 올려진 터치의 시작이라면.
                 * {
                 * //  Vector3 worldTouchedPos = Camera.main.ScreenToWorldPoint(touches[i].position);
                 *  if ( moveController.IsInThisContPos(touches[i].position))// moveContBound.Contains(worldTouchedPos))
                 *  {
                 *      //무브 컨트롤러에 처음 올려진 터치.
                 *      moveContTouch.Activate(touches[i].fingerId);
                 *  }
                 *  else if (rotateController.IsInThisContPos(touches[i].position))
                 *  {
                 *      //로테이트 컨트롤러에 처음 올려진 터치.
                 *      rotateContTouch.Activate(touches[i].fingerId);
                 *  }
                 * }
                 * if (touches[i].phase == TouchPhase.Ended)
                 * {
                 *  if (moveContTouch.IsThisTouchFID(touches[i].fingerId))
                 *  {
                 *      moveContTouch.DeActivate();
                 *  }
                 *  else if (rotateContTouch.IsThisTouchFID(touches[i].fingerId))
                 *  {
                 *      rotateContTouch.DeActivate();
                 *  }
                 * }
                 */
            }

            On_MoveContAndroid();
            targetHero.MoveHero(charactorMoveV);

            On_RotateContAndroid();
            targetHero.RotateHero(charactorRotateV);
            //나중에 전사가 필요할듯.
            //targetHero.RotateHero(new Vector3(rotateV.x / Screen.width, rotateV.y / Screen.height, 0));
#endif
            #endregion

            /*
             #region 에디터
             *
             * //#if UNITY_EDITOR
             * //임시로 하는 것 뿐임.
             * targetHero.MoveHero(charactorMoveV);
             *
             * if (Input.GetMouseButtonDown(0) && !contTouched)
             * {
             *  if (mouseTouched == Vector3.zero)
             *  {
             *      mouseTouched = Input.mousePosition;
             *      return;
             *  }
             * }
             * else if (Input.GetMouseButtonUp(0) && !contTouched)
             * {
             *  mouseTouched = Vector3.zero;
             * }
             * else if (Input.GetMouseButton(0) && !contTouched)
             * {
             *
             *  //  Debug.Log("마우스 이동중2");
             *
             *  Vector3 mousePos = Input.mousePosition;
             *  Vector3 rotateV = mousePos - mouseTouched;
             *  // targetHero.transform.Rotate(new Vector3(0, rotateV.x / Screen.width, 0), Space.Self);
             *  targetHero.RotateHero(new Vector3(rotateV.x/Screen.width, rotateV.y / Screen.height, 0));
             * }
             * //#endif
             #endregion
             */
        }
Exemple #2
0
        void Update()
        {
            if (targetHero == null)
            {
                return;
            }

            for (int i = 0; i < (int)E_ControlParam.MAX; i++)
            {
                heroControlBtnsScreen[
                    ((int)E_ControlParam.MAX * (int)targetHero.HeroType)
                    + i].fillAmount = targetHero.GetReUseRemainTimeByZeroToOne((E_ControlParam)i);
            }

            hpBarUI.fillAmount = targetHero.CurrHP * maxHPDiv;

            stunNotice.SetActive(targetHero.IsSetBadState(E_BadState.Stun));

#if UNITY_STANDALONE_WIN
            #region 윈도우즈 컨트롤
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Instantiate(ESCCanvasGOPrefab);
                SetCursorLock(false);
                return;
            }

            if (Input.GetMouseButtonDown(1))    //오른쪽 클릭으로 마우스 브레이크.
            {
                SetCursorLock(!IsSetCursorLock());
            }

            if (IsSetCursorLock())
            {
                float xMove = Input.GetAxis("Horizontal");
                float zMove = Input.GetAxis("Vertical");

                float xRotate = Input.GetAxis("Mouse X");
                float yRotate = Input.GetAxis("Mouse Y");
                charactorMoveV   = new Vector3(xMove, 0, zMove);
                charactorRotateV = new Vector3(xRotate, yRotate * -1, 0);

                targetHero.MoveHero(charactorMoveV);
                targetHero.RotateHero(charactorRotateV);

                if (Input.GetMouseButton(0))
                {
                    OnClick_NormalAttack();
                }
                if (Input.GetKeyDown(KeyCode.R))
                {
                    OnClick_Reload();
                }
                if (Input.GetKeyDown(KeyCode.E))
                {
                    OnClick_FirstSkill();
                }
                if (Input.GetKeyDown(KeyCode.LeftShift))
                {
                    OnClick_SecondSkill();
                }
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    OnClick_Ultimate();
                }
            }
            else
            {
                targetHero.MoveHero(Vector3.zero);
                return;
            }
            #endregion
#endif
        }