public override void OnEnter()
 {
     AnimatedChuzzles.Clear();
     Chuzzle.DropEventHandlers();
     Chuzzle.AnimationStarted += OnAnimationStarted;
     CreateNew();
 }
Ejemplo n.º 2
0
    private void OnAnimationFinished(Chuzzle chuzzle)
    {
        chuzzle.AnimationFinished -= OnAnimationFinished;
        AnimatedChuzzles.Remove(chuzzle);

        CheckAnimationCompleted();
    }
Ejemplo n.º 3
0
 public void CheckAnimationCompleted()
 {
     if (!AnimatedChuzzles.Any())
     {
         CheckCombinations();
     }
 }
Ejemplo n.º 4
0
 public override void LateUpdateState()
 {
     if (!AnimatedChuzzles.Any())
     {
         LateUpdateState(Gamefield.Level.ActiveCells);
     }
 }
Ejemplo n.º 5
0
 public override void OnExit()
 {
     if (AnimatedChuzzles.Any())
     {
         Debug.LogError("F**K YOU FROM WIN REMOVE: " + AnimatedChuzzles.Count);
     }
 }
Ejemplo n.º 6
0
    public void OnAnimationFinished(Chuzzle chuzzle)
    {
        chuzzle.Real = chuzzle.Current = chuzzle.MoveTo;

        chuzzle.AnimationFinished -= OnAnimationFinished;
        AnimatedChuzzles.Remove(chuzzle);

        if (isAlreadyChangedState)
        {
            Debug.LogWarning("Finished in CRNC state ");
        }

        if (!AnimatedChuzzles.Any() && !isAlreadyChangedState)
        {
            Gamefield.Level.UpdateActive();

            var combinations = GamefieldUtility.FindCombinations(Gamefield.Level.ActiveChuzzles);
            if (combinations.Count > 0)
            {
                Gamefield.SwitchStateTo(Gamefield.CheckSpecialState);
            }
            else
            {
                if (!Gamefield.GameMode.IsWin && !Gamefield.GameMode.IsGameOver)
                {
                    Gamefield.SwitchStateTo(Gamefield.FieldState);
                }
                else
                {
                    Gamefield.GameMode.Check();
                }
            }
            isAlreadyChangedState = true;
        }
    }
Ejemplo n.º 7
0
 public override void OnEnter()
 {
     isAlreadyChangedState = false;
     AnimatedChuzzles.Clear();
     Chuzzle.DropEventHandlers();
     Chuzzle.AnimationStarted += OnAnimationStarted;
     CreateNew();
 }
Ejemplo n.º 8
0
 private void OnAnimationStarted(Chuzzle chuzzle)
 {
     if (!AnimatedChuzzles.Contains(chuzzle))
     {
         AnimatedChuzzles.Add(chuzzle);
         chuzzle.AnimationFinished += OnAnimationFinished;
     }
 }
Ejemplo n.º 9
0
 public override void OnExit()
 {
     if (AnimatedChuzzles.Any())
     {
         Debug.LogError("F**K YOU FROM CREATE NEW STATE: " + AnimatedChuzzles.Count);
     }
     Gamefield.NewTilesInColumns = new int[Gamefield.Level.Width];
 }
Ejemplo n.º 10
0
 public void OnAnimationFinished(Chuzzle chuzzle)
 {
     chuzzle.AnimationFinished -= OnAnimationFinished;
     AnimatedChuzzles.Remove(chuzzle);
     if (!AnimatedChuzzles.Any())
     {
         Gamefield.SwitchStateTo(Gamefield.WinCreateNewChuzzlesState);
     }
 }
Ejemplo n.º 11
0
 public override void OnExit()
 {
     if (AnimatedChuzzles.Any())
     {
         Debug.LogError("F**K you in field state: " + AnimatedChuzzles.Count);
     }
     Gamefield.GameMode.HumanTurn();
     Reset();
 }
Ejemplo n.º 12
0
    public override void OnExit()
    {
        if (AnimatedChuzzles.Any())
        {
            Debug.LogError("F**K YOU FROM REMOVE COMBINATION: " + AnimatedChuzzles.Count);
        }

        PowerUpDestroyManager.Instance.IsInDestroyState = false;
    }
Ejemplo n.º 13
0
    private void OnAnimationFinished(Chuzzle chuzzle)
    {
        chuzzle.AnimationFinished -= OnAnimationFinished;
        AnimatedChuzzles.Remove(chuzzle);

        chuzzle.Destroy(true, false);

        if (!AnimatedChuzzles.Any())
        {
            Gamefield.SwitchStateTo(Gamefield.WinCreateNewChuzzlesState);
        }
    }
Ejemplo n.º 14
0
    public override void OnEnter()
    {
        AnimatedChuzzles.Clear();
        Chuzzle.DropEventHandlers();
        Chuzzle.AnimationStarted += OnAnimationStarted;

        var combinations = GamefieldUtility.FindCombinations(Gamefield.Level.ActiveChuzzles);

        if (!CheckForSpecial(combinations))
        {
            Gamefield.SwitchStateTo(Gamefield.WinRemoveCombinationState);
        }
    }
Ejemplo n.º 15
0
    private void OnAnimationStarted(Chuzzle chuzzle)
    {
        if (isAlreadyChangedState)
        {
            Debug.LogWarning("Already changed state create new chuzzle");
            return;
        }

        if (!AnimatedChuzzles.Contains(chuzzle))
        {
            AnimatedChuzzles.Add(chuzzle);
            chuzzle.AnimationFinished += OnAnimationFinished;
        }
    }
Ejemplo n.º 16
0
    public override void OnEnter()
    {
        AnimatedChuzzles.Clear();
        Chuzzle.DropEventHandlers();
        Chuzzle.AnimationStarted += OnAnimationStarted;

        var anyCombination = GamefieldUtility.FindOnlyOneCombination(Gamefield.Level.ActiveChuzzles);

        if (anyCombination.Any())
        {
            StartCoroutine(RemoveCombinations());
        }
        else
        {
            Gamefield.SwitchStateTo(Gamefield.FieldState);
        }
    }
Ejemplo n.º 17
0
    public override void OnEnter()
    {
        AnimatedChuzzles.Clear();
        Chuzzle.DropEventHandlers();
        Chuzzle.AnimationStarted += OnAnimationStarted;
        if (!Tutorial.isActive)
        {
            CheckPossibleCombinations();
        }


        if (!Gamefield.InvaderWasDestroyed)
        {
            InvaderChuzzle.Populate(Gamefield);
        }
        Gamefield.InvaderWasDestroyed = false;
    }
Ejemplo n.º 18
0
    private IEnumerator RemoveCombinations()
    {
        var powerUpCombination = GamefieldUtility.FindOnlyOneCombinationWithCondition(Gamefield.Chuzzles,
                                                                                      GamefieldUtility.IsPowerUp);

        //if has any powerups
        if (powerUpCombination.Any())
        {
            //destroy step by step
            PowerUpDestroyManager.Instance.Destroy(powerUpCombination);

            if (!AnimatedChuzzles.Any())
            {
                Gamefield.SwitchStateTo(Gamefield.CreateNewChuzzlesState);
            }
        }
        else
        {
            var combinations = GamefieldUtility.FindCombinations(Gamefield.Chuzzles);
            //remove combinations
            foreach (var combination in combinations)
            {
                Gamefield.InvokeCombinationDestroyed(combination);

                foreach (var chuzzle in combination)
                {
                    chuzzle.Destroy(true);
                }

                if (!AnimatedChuzzles.Any())
                {
                    Gamefield.SwitchStateTo(Gamefield.CreateNewChuzzlesState);
                }
                yield return(new WaitForSeconds(0.05f));
            }
        }

        yield return(new WaitForEndOfFrame());
    }
    public void OnAnimationFinished(Chuzzle chuzzle)
    {
        chuzzle.Real = chuzzle.Current = chuzzle.MoveTo;

        chuzzle.AnimationFinished -= OnAnimationFinished;
        AnimatedChuzzles.Remove(chuzzle);

        if (!AnimatedChuzzles.Any())
        {
            Gamefield.Level.UpdateActive();

            var combinations = GamefieldUtility.FindCombinations(Gamefield.Level.ActiveChuzzles);
            if (combinations.Count > 0)
            {
                Gamefield.SwitchStateTo(Gamefield.WinCheckSpecialState);
            }
            else
            {
                Gamefield.SwitchStateTo(Gamefield.WinRemoveCombinationState);
            }
        }
    }
Ejemplo n.º 20
0
    public override void OnEnter()
    {
        AnimatedChuzzles.Clear();
        Chuzzle.DropEventHandlers();
        Chuzzle.AnimationStarted += OnAnimationStarted;

        var powerUpChuzzles = Gamefield.Level.Chuzzles.Where(GamefieldUtility.IsPowerUp).ToArray();

        foreach (var ch in powerUpChuzzles)
        {
            ch.Destroy(true);
        }

        var combinations = GamefieldUtility.FindCombinations(Gamefield.Level.ActiveChuzzles);

        if (combinations.Any())
        {
            RemoveCombinations(combinations);
        }
        else if (!powerUpChuzzles.Any())
        {
            StartCoroutine(GameModeCheck());
        }
    }