示例#1
0
        private void ResetGuide(GameObject guide)
        {
            VisibilitySwitch.SetVisibility(guide, false);

            foreach (Transform child in guide.transform)
            {
                var gmc = child.GetComponent <GuideMarkController>();
                gmc.Reset();
            }
        }
示例#2
0
 void Start()
 {
     skipButton.OnClick += (id) => {
         Jump();
     };
     if (loadingSign != null)
     {
         VisibilitySwitch.SetVisibility(loadingSign, false);
     }
 }
示例#3
0
        private void ReleaseAndSet(FlipState newState)
        {
            heldCoin.Release();
            heldCoin  = null;
            flipState = newState;

            VisibilitySwitch.SetVisibility(fingerTrack, false);

            ResetGuide(guideLeft);
            ResetGuide(guideRight);
        }
示例#4
0
        void Start()
        {
            VisibilitySwitch.SetVisibility(fingerTrack, false);
            state = new GameState();

            SetLevel(CurrentLevel);
            if (PlayingTutorial)
            {
                StartTutorial();
            }
            Resources.UnloadUnusedAssets();
        }
示例#5
0
 public void Execute(string cmd)
 {
     switch (cmd)
     {
     case "Tutorial":
         Debug.Log("Start Tutorial");
         GameController.startLevel = Level.TutorialLevel();
         VisibilitySwitch.SetVisibility(GameObject.Find("Loading"), true);
         EffectsManager.Instance.PlayEvent(EffectsManager.AudioEvent.GameStarted);
         EffectsManager.Instance.FadeOutMusic(() => { SceneManager.LoadSceneAsync("GameScene"); });
         break;
     }
 }
示例#6
0
        private void ShowNow()
        {
            Debug.Log("ShowNow, closed: " + closed);
            if (closed)
            {
                return;
            }

            if (current != null)
            {
                current.CloseNow();
            }
            current = this;

            VisibilitySwitch.SetVisibility(gameObject, true);
        }
示例#7
0
        public void CloseNow()
        {
            Debug.LogFormat("CloseNow, was closed?: {0}", closed);
            if (closed)
            {
                return;
            }

            closed = true;
            if (current == this)
            {
                current = null;
            }
            CancelInvoke("CloseNow");

            VisibilitySwitch.SetVisibility(gameObject, false);
            Destroy(gameObject);
        }
示例#8
0
        internal void Hint(Move move)
        {
            FlippingTime = FlippingTime * HintFlipTimeMultiplier;
            CurrentMove  = move;
            StartRotation();

            effectsManager.PlayEvent(EffectsManager.AudioEvent.Hint);

            VisibilitySwitch.SetVisibility(fingerTrack, true);

            fingerTrack.transform.position = coins[CurrentMove.pos].transform.position + new Vector3(0, RotateDirection, 1);
            rotationController.AttachFingerTracking(fingerTrack);

            heldCoin = coins[CurrentMove.pos].GetComponentInChildren <CoinController>();
            heldCoin.Hold();
            currentRotationAngle = 1;

            flipState = FlipState.Hinting;
        }
示例#9
0
        public void Jump()
        {
            if (jumped)
            {
                return;
            }
            jumped = true;

            if (JumpRequested != null)
            {
                JumpRequested();
            }

            if (loadingSign != null)
            {
                VisibilitySwitch.SetVisibility(loadingSign, true);
            }
            Invoke("DoJump", 0.1f);
        }
示例#10
0
        void SetupGuide(Move move, GameObject guide)
        {
            int     first     = Current.FirstCoinAffectedIndex(move);
            int     n         = Current.NumCoinsAffected(move);
            var     firstPos  = coins[first].transform.position;
            var     lastPos   = coins[first + n - 1].transform.position;
            Vector3 centerPos = (firstPos + lastPos) / 2;

            var coinBound      = coins[move.pos].GetComponent <Renderer>().bounds;
            var otherCoinBound = coins[(move.pos == first) ? (first + n - 1) : first].GetComponent <Renderer>().bounds;
            var arcStart       = coinBound.center + (new Vector3(0, coinBound.extents.y, 0));
//            var arcEnd = otherCoinBound.center + (new Vector3(0, -otherCoinBound.extents.y, 0));

            var diffW = (arcStart - centerPos);

            diffW.z = 0;
            float scale = 2 * diffW.magnitude / (coinBound.extents.y);
            float angle = Vector3.Angle(diffW, new Vector3(1, 0, 0)) - 90;

            centerPos.z = -2;

            guide.transform.position   = centerPos;
            guide.transform.localScale = new Vector3(scale * (int)move.side, scale, scale);
            guide.transform.rotation   = Quaternion.Euler(0, 0, angle);

            float speedFactor = 1 - (n / Current.Count) * 0.25f;

            foreach (Transform child in guide.transform)
            {
                child.localScale = guideMarkScale / scale;
                var gmc = child.GetComponent <GuideMarkController>();
                gmc.Show();
                gmc.Speed *= speedFactor;
            }

            VisibilitySwitch.SetVisibility(guide, true);
        }
示例#11
0
 void Start()
 {
     VisibilitySwitch.SetVisibility(loading, false);
 }
示例#12
0
        /// <summary>
        /// Processes an in-between move in a touch/hold operation
        /// </summary>
        /// <param name="position"></param>
        private void ProcessInputMove(Vector2 position)
        {
            if ((flipState != FlipState.Holding && flipState != FlipState.MovingCoin) || heldCoin == null)
            {
                return;
            }

            var coinBound = heldCoin.InitialBound;

            // TODO: check if it's really needed to use the None Side here, or it could be prevented -- Seu
            Side direction = coinBound.xMin > position.x ? Side.Left : ((coinBound.xMax < position.x) ? Side.Right : Side.None);

            switch (flipState)
            {
            case FlipState.Holding:
                if (direction == Side.None)
                {
                    break;
                }
                int coinNumber = Array.IndexOf(coins, heldCoin.gameObject);
                CurrentMove = new Move((byte)coinNumber, direction);
                StartRotation();

                int first        = Current.FirstCoinAffectedIndex(CurrentMove);
                int num          = Current.NumCoinsAffected(CurrentMove);
                var endCoinIndex = first + (CurrentMove.side == Side.Left ? 0 : num - 1);

                var endCoin   = coins[endCoinIndex];
                var endBounds = endCoin.GetComponent <Renderer>().bounds;
                var v         = new Vector2(endBounds.center.x, endBounds.center.y - endBounds.extents.y);

                fingerTrack.transform.position = new Vector3(v.x, v.y, -4);
                VisibilitySwitch.SetVisibility(fingerTrack, true);
                VisibilitySwitch.SetVisibility(guideLeft, CurrentMove.side == Side.Left);
                VisibilitySwitch.SetVisibility(guideRight, CurrentMove.side == Side.Right);

                flipState = FlipState.MovingCoin;

                // if reached this point, we are in moving already so fall through
                goto case FlipState.MovingCoin;

            case FlipState.MovingCoin:

                if (direction == CurrentMove.side)
                {
                    currentRotationAngle = Vector3.Angle(rotationScreenCenter - startTouchPosition, rotationScreenCenter - position);
                }
                else
                {
                    if (position.y > rotationScreenCenter.y && currentRotationAngle < 30)
                    {
                        currentRotationAngle = 0;
                    }
                    else if (position.y < rotationScreenCenter.y && currentRotationAngle > 90)
                    {
                        ReleaseAndSet(FlipState.FinishingFlip);
                    }
                    else
                    {
                        ReleaseAndSet(FlipState.Resetting);
                    }
                }
                break;
            }
        }
示例#13
0
 public void Hide()
 {
     VisibilitySwitch.SetVisibility(gameObject, false);
 }
示例#14
0
        public void SetLevel(Level level, Vector3 from, Vector3 coord, float animTime)
        {
            var tr = TextResource.Get("menu").Filter("menu.play");

            trDialog = TextResource.Get("dialog").Filter("dialog");

            var manager = LevelManager.Instance;

            generator.GeneratePuzzle(level.solved, level);
            var levelState = manager.GetLevelState(level.Ref);

            clickButton.OnClick += (id) => {
                switch (levelState)
                {
                case SolvedState.Unsolved: Play(level); break;

                case SolvedState.Finished: ShowDialogId(level, "Finished"); break;

                case SolvedState.Mastered:
                    goto case SolvedState.Unsolved;
                }
            };
            VisibilitySwitch.SetVisibility(locked, level.Locked);
            if (level.Locked)
            {
                var tm = locked.GetComponentInChildren <TextMesh>();
                tm.text = string.Format(tr["StarsToUnlock"], level.starsRequired - manager.Stars);
            }

            var stats = LevelManager.Instance.GetLevelStats(level.Ref);

            if (stats.NumUnsolved == stats.Total)
            {
                levelStateBar.gameObject.SetActive(false);
            }
            else
            {
                levelStateBar.SetStats(stats);
            }
            numPuzzles.text = levelState == SolvedState.Mastered ? tr["Random"] :
                              string.Format("{0} {1}", level.NumPuzzles, tr["Puzzles"]);
            numMoves.text =
                string.Format("{0} {1}", level.MinMoves, tr[level.MinMoves == 1 ? "Move" : "Moves"]);

            switch (levelState)
            {
            case SolvedState.Finished:
                back.GetComponent <Renderer>().material = finishedMat;
                break;

            case SolvedState.Mastered:
                back.GetComponent <Renderer>().material = masteredMat;
                break;
            }

            if (animTime > 0)
            {
                GetComponent <Animation>().AddClip(
                    new ClipBuilder()
                    .LocalPosition(from, coord, 0, animTime)
                    .LocalScale(new Vector3(0.1f, 0.1f, 0.1f), new Vector3(1, 1, 1), 0, animTime).Clip,
                    "anim");

                GetComponent <Animation>().Play("anim");
            }
            else
            {
                transform.localPosition = coord;
                transform.localScale    = new Vector3(1, 1, 1);
            }
        }
示例#15
0
 internal void Play(Level level)
 {
     GameController.startLevel = level;
     VisibilitySwitch.SetVisibility(GameObject.Find("Loading"), true);
     EffectsManager.Instance.FadeOutMusic(() => { SceneManager.LoadSceneAsync("GameScene"); });
 }