コード例 #1
0
 public void CloseInGameHelpModule()
 {
     Time.timeScale = 1F;
     Destroy(InGameHelpModule);
     PauseButtonScript.PauseMenuActive = false;
     if (ShowUserHelpCallback != null)
     {
         var callback = ShowUserHelpCallback;
         ShowUserHelpCallback = null;
         callback();
     }
 }
コード例 #2
0
 public static void ShowScalingLabel(GameObject initGameObject,bool onTop, bool leftSide, String text, Color textColor, Color shadowColor, int animateFromSize,
      int animateToSize, int step = 1, Font font = null,
     bool destroyAfterAnimation = false, LabelAnimationFinishedDelegate callback = null, int rotateAngle = 0, GameItemType? type = null)
 {
     //var wp = initGameObject.transform.position;
     var newPos = Game.Middleground.transform.InverseTransformPoint(initGameObject.transform.position);// calling it with foreground causes MaxInitialElement z index decreasing(shows under pause menu)...
     var showOn = new Vector3(newPos.x + (onTop ? 0 : ((leftSide ? -25 : 25) * initGameObject.GetComponent<SpriteRenderer>().bounds.size.x)),
         newPos.y + (onTop ? 25 * initGameObject.GetComponent<SpriteRenderer>().bounds.size.y : 0), newPos.z - 6);// 25 is default pixels per unit 100 / 2 (half of object size(which is size.y / 2, cause 1 in size = 2 units)
     if(type.HasValue)
     {
         for(int i = 0;i < PointLabels.Count;i++)
             if(PointLabels[i]._type.Value == type && PointLabels[i]._scaleState == ScaleState._none)
             {
                 PointLabels[i]._labelText.text = text;
                 PointLabels[i].transform.localPosition = showOn;
                 PointLabels[i].transform.localScale = PointLabels[i]._localScale;
                 if (PointLabels[i].Shadow != null)
                 {
                     PointLabels[i].Shadow._labelText.text = text;
                     PointLabels[i].Shadow.transform.localPosition = new Vector3(showOn.x - 3,showOn.y,showOn.z);
                     PointLabels[i].Shadow.transform.localScale = PointLabels[i]._localScale;
                 }
                 PointLabels[i]._scaleState = ScaleState._increase;
                 return;
             }
     }
     GameObject obj;
     if (type.HasValue)
         obj = Instantiate(ShortLabelPrefab) as GameObject;
     else
         obj = Instantiate(LabelPrefab) as GameObject;
     var label = obj.GetComponent<LabelShowing>();
     label._type = type;
     label.transform.SetParent(Game.Foreground.transform);
     label.ShowScalingLabel(showOn, text, textColor, shadowColor, animateFromSize, animateToSize, step, font, destroyAfterAnimation, callback, false, rotateAngle);
     if (label._type.HasValue)
         PointLabels.Add(label);
 }
コード例 #3
0
        public override void GenerateField(bool completeCurrent = false, bool mixCurrent = false, bool onlyNoMovesLabel = false, LabelAnimationFinishedDelegate callback = null)
        {
            LogFile.Message("Generating field...", true);
            if (!mixCurrent)
            {
                for (var i = FieldSize - 1; i >= 0; i--)
                {
                    var generateOnX = i % 2 == 1 ? -i : i;
                    for (var j = FieldSize - 1; j >= 0; j--)
                    {
                        var deniedList = new List<GameItemType>();
                        if (Items[i][j] != null || Items[i][j] == DisabledItem)
                            continue;
                        switch (Game.Difficulty)
                        {
                            case DifficultyLevel._medium:
                                if (ToMoveItemsCount < MaxAdditionalItemsCount && j < 4)
                                {
                                        Items[i][j] = GenerateGameItem(GameItemType._ToMoveItem, i, j, new Vector2(generateOnX, i), null, false, 12 + i * 2);//may be calculate speed or generateOn vector in another way
                                        ToMoveItemsCount++;
                                        generateOnX++;
                                        continue;
                                }
                                break;
                        }
                        if (completeCurrent)
                        {
                            LogFile.Message("New gameItem need to i:" + i + "j: " + j, true);
                            Items[i][j] = GenerateGameItem(i, j, null, new Vector2(generateOnX, i), false, 12 + i * 2);//may be calculate speed or generateOn vector in another way
                            continue;
                        }
                        //Horizontal before
                        if (i >= 2 && j < FieldSize - 2 && CheckForLine(i - 2, j + 2, LineOrientation.Horizontal, false) > 1)
                        {
                            var o = Items[i - 1][j + 1] as GameObject;
                            if (o != null)
                                deniedList.Add(o.GetComponent<GameItem>().Type);
                        }
                        //Horizontal after
                        if (i < FieldSize - 2 && j > 1 && CheckForLine(i + 1, j - 1, LineOrientation.Horizontal, false) > 1)
                        {
                            var gameObject1 = Items[i + 1][j - 1] as GameObject;
                            if (gameObject1 != null)
                                deniedList.Add(gameObject1.GetComponent<GameItem>().Type);
                        }
                        //Vertical before
                        if (i > 1 && j > 1 && CheckForLine(i - 2, j - 2, LineOrientation.Vertical, false) > 1)
                        {
                            var o1 = Items[i - 1][j - 1] as GameObject;
                            if (o1 != null)
                                deniedList.Add(o1.GetComponent<GameItem>().Type);
                        }
                        //Vertical after
                        if (i < FieldSize - 2 && j < FieldSize - 2 && CheckForLine(i + 1, j + 1, LineOrientation.Vertical, false) > 1)
                        {
                            var gameObject2 = Items[i + 1][j + 1] as GameObject;
                            if (gameObject2 != null)
                                deniedList.Add(gameObject2.GetComponent<GameItem>().Type);
                        }
                        Items[i][j] = GenerateGameItem(i, j, deniedList, new Vector2(generateOnX, i));
                    }
                }
                SavedataHelper.SaveData(SavedataObject);
            }
            else
            {
                    LogFile.Message("Mix field...", true);
                    var o = Instantiate(LabelShowing.LabelPrefab) as GameObject;
                    if (o == null) return;
                    if (!onlyNoMovesLabel)
                    {
                        PlaygroundProgressBar.ProgressBarRun = false;
                        callback = () =>
                        {
                            MixField();
                        };
                    }
                    var noMovesLabel = o.GetComponent<LabelShowing>();
                    noMovesLabel.ShowScalingLabel(new Vector3(0, -2, -4),
                             LanguageManager.Instance.GetTextValue("NoMovesTitle"), GameColors.DifficultyLevelsColors[Game.Difficulty], GameColors.DefaultDark,
                             LabelShowing.minLabelFontSize, LabelShowing.maxLabelFontSize, 2, null, true, callback, true);
                    //if (!onlyNoMovesLabel) MixField();

            }
        }
コード例 #4
0
 protected void CreateMenuHelpModule(string moduleName, LabelAnimationFinishedDelegate callback = null)
 {
     if (PlayerPrefs.HasKey(moduleName))
     {
         if (callback != null)
             callback();
         return;
     }
     var gui = GameObject.Find("/GUI");
     var manualPrefab = LanguageManager.Instance.GetPrefab("UserHelp_" + moduleName);
     if (manualPrefab == null)
         return;
     var manual = Instantiate(manualPrefab);
     var resource = Resources.Load("Prefabs/InGameHelper");
     UserHelpScript.InGameHelpModule = Instantiate(resource) as GameObject;
     if (UserHelpScript.InGameHelpModule != null)
     {
         UserHelpScript.InGameHelpModule.transform.SetParent(gui.transform);
         UserHelpScript.InGameHelpModule.transform.localScale = Vector3.one;
         UserHelpScript.InGameHelpModule.transform.localPosition = new Vector3(0, 30, -10);
         manual.transform.SetParent(UserHelpScript.InGameHelpModule.transform);
     }
     manual.transform.localScale = new Vector3(25, 25, 0);
     manual.transform.localPosition = new Vector3(0, 30, -1);
     UserHelpScript.ShowUserHelpCallback = callback;
 }
コード例 #5
0
        public override void GenerateField(bool completeCurrent = false, bool mixCurrent = false, bool onlyNoMovesLabel = false, LabelAnimationFinishedDelegate callback = null)
        {
            //if (CallbacksCount > 1) return;

            while (true)
            {
                if (!completeCurrent && !mixCurrent)
                {
                    for (var i = 0; i < FieldSize; i++)
                        for (var j = 0; j < FieldSize; j++)
                        {
                            Items[i][j] = DisabledItem;
                        }
                    completeCurrent = true;
                    continue;
                }
                if (completeCurrent)
                {
                    var availibleColumns = new Dictionary<int, int>();
                    for (var i = 0; i < FieldSize; i++)
                        for (var j = FieldSize - 1; j >= 0; j--)
                        {
                            if (Items[i][j] == null)
                                Items[i][j] = DisabledItem;

                            if (Items[i][j] == DisabledItem && !availibleColumns.ContainsKey(i))
                                availibleColumns.Add(i, j);
                        }
                    int respCol;
                    if (availibleColumns.Count == 0)
                    {
                        completeCurrent = false;
                        mixCurrent = true;
                        continue;
                    }
                    while (!availibleColumns.ContainsKey(respCol = RandomObject.Next(0, FieldSize))) { }
                    //var res1 = RandomObject.Next(0, FieldSize);
                    switch (Game.Difficulty)
                    {
                        case DifficultyLevel._medium:
                        case DifficultyLevel._hard:
                        case DifficultyLevel._veryhard:
                            if (XItemsCount < MaxAdditionalItemsCount)
                            {
                                if (RandomObject.Next(0, FieldSize) % 3 == 0)
                                {
                                    GenerateDropsModeItem(respCol, availibleColumns[respCol], GameItemType._XItem);
                                    XItemsCount++;
                                    return;
                                }
                            }
                            if (ToMoveItemsCount < MaxAdditionalItemsCount)
                            {
                                if (RandomObject.Next(0, FieldSize) % 3 == 0)
                                {
                                    if (Items[respCol][availibleColumns[respCol]] == DisabledItem)
                                        break;

                                    GenerateDropsModeItem(respCol, availibleColumns[respCol], GameItemType._ToMoveItem);
                                    ToMoveItemsCount++;
                                    return;
                                }
                            }
                            break;
                    }
                    GenerateDropsModeItem(respCol, availibleColumns[respCol]);
                }
                if (mixCurrent && !IsGameOver)
                {
                    IsGameOver = true;
                    //var labelObject = Instantiate(LabelShowing.LabelPrefab) as GameObject;
                    //if (labelObject != null)
                    //{
                    //    var gameOverLabel = labelObject.GetComponent<LabelShowing>();
                    //    gameOverLabel.transform.SetParent(transform);
                    //    gameOverLabel.ShowScalingLabel(new Vector3(0, 0, -3),
                    //        "Game over", Color.white, Color.gray, 60, 90);
                    //}
                    ////TODO: stop the game
                    GenerateGameOverMenu();
                }
                break;
            }
        }
コード例 #6
0
    public void ShowScalingLabel(Vector3 position, String text, Color textColor, Color shadowColor, int animateFromSize, int animateToSize, int step = 1, Font font = null,
        bool destroyAfterAnimation = false, LabelAnimationFinishedDelegate callback = null, bool toForeground = false, int rotateAngle = 0, Vector3? scaleTo = null)
    {
        if (toForeground)
        {
            transform.SetParent(Game.Foreground.transform);
            var z = position.z;
            position = Game.Foreground.transform.InverseTransformPoint(position);
            position.z = z;
        }

        transform.localScale = scaleTo == null ? Vector3.one : scaleTo.Value;
        _step = step;
        //animateToSize += (animateToSize - animateFromSize) % _step;

        transform.localPosition = position;

        if (rotateAngle != 0)
            transform.RotateAround(transform.position, Vector3.forward, rotateAngle);

        if(_labelText == null)
        _labelText = GetComponent<Text>();
        /*if (animateToSize < animateFromSize)
        {
            var to = animateFromSize;
            animateFromSize = animateToSize;
            animateToSize = to;
        }*/

        if (textColor != shadowColor)
        {
            var scalingLabelObject = Instantiate(LabelShowing.LabelPrefab) as GameObject;

            if (scalingLabelObject != null)
            {
                //scalingLabelObject.name = name + "(Shadow)";
                Shadow = scalingLabelObject.GetComponent<LabelShowing>();
                Shadow.transform.SetParent(transform.parent);
                Shadow.transform.localScale = transform.localScale;
                Shadow._type = _type;
                Shadow.ShowWithShadowLabel(new Vector3(position.x - (rotateAngle == 0 ? animateToSize > 50 ? 3f : 2f : 0), position.y, position.z),
                    text, textColor, textColor, animateFromSize, animateToSize, font, rotateAngle);
                animateFromSize += 1;
                animateToSize += 1;
            }
            _labelText.color = shadowColor;
        }
        else
        {
            textColor = new Color(textColor.r, textColor.g, textColor.b, 0.8f);
            _labelText.color = textColor;
        }
        _labelText.fontSize = _currentFontSize =_animateFromSize = animateFromSize;
        _scaleFontTo = animateToSize;
        _labelText.font = font ? font : Game.textFont;
        _labelText.text = text;
        _destroyAfterAnimation = destroyAfterAnimation;
        _pauseTimeout = 40 / _step;
        _animationFinished = callback;
        _localScale = transform.localScale;
    }
コード例 #7
0
 // Update is called once per frame
 void Update()
 {
     switch(_scaleState)
     {
         case ScaleState._increase:
             if (_currentFontSize >= _scaleFontTo)
             {
                 _scaleState = ScaleState._static;
                 break;
             }
             _currentFontSize += _step;
             _labelText.fontSize = _currentFontSize;
             if (Shadow != null)
             {
                 Shadow._currentFontSize += _step;
                 Shadow._labelText.fontSize = Shadow._currentFontSize;
             }
             return;
         case ScaleState._static:
             _pauseTimeout--;
             if (_pauseTimeout <= 0)
                 _scaleState = ScaleState._decrease;
             return;
         case ScaleState._decrease:
             if (_destroyAfterAnimation)
             {
                 if (_currentFontSize > _animateFromSize)
                 {
                     _currentFontSize -= _step;
                     _labelText.fontSize = _currentFontSize;
                     if (Shadow != null)
                     {
                         Shadow._currentFontSize -= _step;
                         Shadow._labelText.fontSize = Shadow._currentFontSize;
                     }
                 }
                 else
                 {
                     if (_type.HasValue)
                     {
                         _scaleState = ScaleState._none;
                         transform.localScale = Vector3.zero;
                         if (Shadow != null)
                             Shadow.transform.localScale = Vector3.zero;
                     }
                     else
                     {
                         if (Shadow != null)
                             Destroy(Shadow.gameObject);
                         Destroy(gameObject);
                     }
                     //_destroyAfterAnimation = false;
                     if (_animationFinished == null) return;
                     var callback = _animationFinished;
                     _animationFinished = null;
                     callback();
                 }
             }
             else
             {
                 if (_animationFinished == null) return;
                 var callback = _animationFinished;
                 _animationFinished = null;
                 callback();
                 _scaleState = ScaleState._none;
             }
             return;
     }
 }
コード例 #8
0
 protected void CreateInGameHelpModule(string modulePostfix, LabelAnimationFinishedDelegate callback = null)
 {
     if (PlayerPrefs.HasKey(modulePostfix))
     {
         if (callback != null)
             callback();
         return;
     }
     if (Game.Foreground == null) return;
     var manualPrefab = LanguageManager.Instance.GetPrefab("UserHelp." + modulePostfix);
     if (manualPrefab == null)
     {
         if (callback != null)
             callback();
         return;
     }
     var manual = Instantiate(manualPrefab);
     var resource = Resources.Load("Prefabs/InGameHelper");
     Time.timeScale = 0F;
     PauseButtonScript.PauseMenuActive = true;
     UserHelpScript.InGameHelpModule = Instantiate(resource) as GameObject;
     if (UserHelpScript.InGameHelpModule != null)
     {
         UserHelpScript.InGameHelpModule.transform.SetParent(Game.Foreground.transform);
         UserHelpScript.InGameHelpModule.transform.localScale = Vector3.one;
         UserHelpScript.InGameHelpModule.transform.localPosition = new Vector3(0, 0, -6);
         manual.transform.SetParent(UserHelpScript.InGameHelpModule.transform);
     }
     //manual.transform.localScale = new Vector3(45, 45, 0);
     manual.transform.localPosition = new Vector3(0, 60, -2);
     UserHelpScript.ShowUserHelpCallback = callback;
     PlayerPrefs.SetInt(modulePostfix, 1);
 }