Ejemplo n.º 1
0
    private SerialTasks GetLevelStartTask()
    {
        LevelNumber.GetComponent <Text>().text = CurrentSaveInfo.CurrentLevel.ToString();
        LevelMarkLeft.GetComponent <RectTransform>().sizeDelta  = new Vector2(LevelMarkBaseLength - LevelMarkLengthDeduction * (CurrentSaveInfo.CurrentLevel / 10), LevelMarkHeight);
        LevelMarkRight.GetComponent <RectTransform>().sizeDelta = new Vector2(LevelMarkBaseLength - LevelMarkLengthDeduction * (CurrentSaveInfo.CurrentLevel / 10), LevelMarkHeight);
        GenerateUseableBubbles();

        SerialTasks LevelStartUITasks = new SerialTasks();

        ParallelTasks MarkAppearTask = new ParallelTasks();
        ParallelTasks UseableBubbleAndLevelNumebrAppearTask = new ParallelTasks();

        MarkAppearTask.Add(new UIFillTask(LevelMarkLeft, 0, 1, MarkFillTime));
        MarkAppearTask.Add(new UIFillTask(LevelMarkRight, 0, 1, MarkFillTime));

        Color levelnumbercolor = LevelNumber.GetComponent <Text>().color;


        UseableBubbleAndLevelNumebrAppearTask.Add(new ColorChangeTask(LevelNumber, Utility.ColorWithAlpha(levelnumbercolor, 0), Utility.ColorWithAlpha(levelnumbercolor, 1), LevelNumberAndUseableBubbleAppearTime, ColorChangeType.Text));
        for (int i = 0; i < UseableBubbleList.Count; i++)
        {
            Color color = UseableBubbleList[i].GetComponent <SpriteRenderer>().color;
            UseableBubbleAndLevelNumebrAppearTask.Add(new ColorChangeTask(UseableBubbleList[i], Utility.ColorWithAlpha(color, 0), Utility.ColorWithAlpha(color, 1), LevelNumberAndUseableBubbleAppearTime, ColorChangeType.Sprite));
        }

        UseableBubbleAndLevelNumebrAppearTask.Add(ActivatedLevel.GetComponent <LevelManager>().GetMapAppearTask());

        LevelStartUITasks.Add(MarkAppearTask);
        LevelStartUITasks.Add(UseableBubbleAndLevelNumebrAppearTask);

        return(LevelStartUITasks);
    }
Ejemplo n.º 2
0
    private void TeleportSlotBlocked()
    {
        var Data = GetComponent <BubbleMotionData>();

        ParallelTasks TeleportBlockedTasks = new ParallelTasks();

        SerialTasks Slot1RotateBackTasks = new SerialTasks();

        Slot1RotateBackTasks.Add(new RotationTask(TeleportSlot1.Entity, Data.TeleportSlotBlockedRotationAngle, Data.TeleportSlotBlockedRotationTime / 2));
        Slot1RotateBackTasks.Add(new RotationTask(TeleportSlot1.Entity, -Data.TeleportSlotBlockedRotationAngle, Data.TeleportSlotBlockedRotationTime / 2));


        SerialTasks Slot1ColorChange = new SerialTasks();

        Slot1ColorChange.Add(new ColorChangeTask(TeleportSlot1.Entity, TeleportSlot1.Entity.GetComponent <SlotObject>().DefaultColor, TeleportSlot1.Entity.GetComponent <SlotObject>().SelectedColor, Data.TeleportSlotBlockedRotationTime / 2, ColorChangeType.Sprite));
        Slot1ColorChange.Add(new ColorChangeTask(TeleportSlot1.Entity, TeleportSlot1.Entity.GetComponent <SlotObject>().SelectedColor, TeleportSlot1.Entity.GetComponent <SlotObject>().DefaultColor, Data.TeleportSlotBlockedRotationTime / 2, ColorChangeType.Sprite));

        SerialTasks Slot2RotateBackTasks = new SerialTasks();

        Slot2RotateBackTasks.Add(new RotationTask(TeleportSlot2.Entity, Data.TeleportSlotBlockedRotationAngle, Data.TeleportSlotBlockedRotationTime / 2));
        Slot2RotateBackTasks.Add(new RotationTask(TeleportSlot2.Entity, -Data.TeleportSlotBlockedRotationAngle, Data.TeleportSlotBlockedRotationTime / 2));

        SerialTasks Slot2ColorChange = new SerialTasks();

        Slot2ColorChange.Add(new ColorChangeTask(TeleportSlot2.Entity, TeleportSlot2.Entity.GetComponent <SlotObject>().DefaultColor, TeleportSlot2.Entity.GetComponent <SlotObject>().SelectedColor, Data.TeleportSlotBlockedRotationTime / 2, ColorChangeType.Sprite));
        Slot2ColorChange.Add(new ColorChangeTask(TeleportSlot2.Entity, TeleportSlot2.Entity.GetComponent <SlotObject>().SelectedColor, TeleportSlot2.Entity.GetComponent <SlotObject>().DefaultColor, Data.TeleportSlotBlockedRotationTime / 2, ColorChangeType.Sprite));

        TeleportBlockedTasks.Add(Slot1RotateBackTasks);
        TeleportBlockedTasks.Add(Slot2RotateBackTasks);
        TeleportBlockedTasks.Add(Slot1ColorChange);
        TeleportBlockedTasks.Add(Slot2ColorChange);

        BubbleMotionTasks.Add(TeleportBlockedTasks);
    }
Ejemplo n.º 3
0
    private IEnumerator GoToInfo()
    {
        gameState = GameState.Info;

        SetMainMenuEnable(false);

        ParallelTasks MainMenuDisappearTask = GetMainMenuDisappearTask(CreditButton);

        while (!MainMenuDisappearTask.IsFinished)
        {
            MainMenuDisappearTask.Update();
            yield return(null);
        }

        ParallelTasks InfoAppearTask = new ParallelTasks();

        InfoAppearTask.Add(Utility.GetTextAppearTask(InfoText, ButtonAppearTime));

        InfoAppearTask.Add(BackButton.GetComponent <GameButton>().GetAppearTask());

        while (!InfoAppearTask.IsFinished)
        {
            InfoAppearTask.Update();
            yield return(null);
        }

        BackButton.GetComponent <BoxCollider2D>().enabled = true;
    }
Ejemplo n.º 4
0
    public SerialTasks GetMapDisappearTask()
    {
        SerialTasks MapDisappearTask = new SerialTasks();

        ParallelTasks SlotDisappearTasks = new ParallelTasks();

        ParallelTasks BubbleDisappearTasks = new ParallelTasks();

        foreach (Transform child in AllBubble.transform)
        {
            Color color = child.GetComponent <SpriteRenderer>().color;
            BubbleDisappearTasks.Add(new ColorChangeTask(child.gameObject, Utility.ColorWithAlpha(color, 1), Utility.ColorWithAlpha(color, 0), MapUnitAppearTime, ColorChangeType.Sprite));
        }

        foreach (Transform child in AllSlot.transform)
        {
            Color color = child.GetComponent <SpriteRenderer>().color;
            SlotDisappearTasks.Add(new ColorChangeTask(child.gameObject, Utility.ColorWithAlpha(color, 1), Utility.ColorWithAlpha(color, 0), MapUnitAppearTime, ColorChangeType.Sprite));
            SlotInfo Info = child.GetComponent <SlotObject>().ConnectedSlotInfo;
            SlotDisappearTasks.Add(new TransformTask(child.gameObject, Info.Location, Info.Location * MapSlotInitPosOffsetFactor, MapUnitAppearTime));
        }

        MapDisappearTask.Add(BubbleDisappearTasks);
        MapDisappearTask.Add(SlotDisappearTasks);

        return(MapDisappearTask);
    }
Ejemplo n.º 5
0
    private ParallelTasks GetMainMenuDisappearTask(GameObject SelectedButton)
    {
        ParallelTasks MainMenuDisappearTask = new ParallelTasks();

        List <GameObject> AllMainMenuButton = new List <GameObject>();

        AllMainMenuButton.Add(PlayButton);
        AllMainMenuButton.Add(SelectLevelButton);
        AllMainMenuButton.Add(SettingButton);
        AllMainMenuButton.Add(CreditButton);

        MainMenuDisappearTask.Add(Utility.GetTextDisappearTask(Title, ButtonUnselectedDisappearTime));

        for (int i = 0; i < AllMainMenuButton.Count; i++)
        {
            if (AllMainMenuButton[i] == SelectedButton)
            {
                MainMenuDisappearTask.Add(AllMainMenuButton[i].GetComponent <GameButton>().GetSelectedDisappearTask());
            }
            else
            {
                MainMenuDisappearTask.Add(AllMainMenuButton[i].GetComponent <GameButton>().GetUnselectedDisappearTask());
            }
        }

        return(MainMenuDisappearTask);
    }
Ejemplo n.º 6
0
    private SerialTasks GetLevelEndUITask(bool ClickBackButton)
    {
        SerialTasks LevelEndUITasks = new SerialTasks();

        ParallelTasks AllTask          = new ParallelTasks();
        Color         levelnumbercolor = LevelNumber.GetComponent <Text>().color;

        if (ClickBackButton)
        {
            AllTask.Add(BackButton.GetComponent <GameButton>().GetSelectedDisappearTask());
        }
        else
        {
            AllTask.Add(BackButton.GetComponent <GameButton>().GetUnselectedDisappearTask());
        }


        AllTask.Add(new ColorChangeTask(LevelNumber, Utility.ColorWithAlpha(levelnumbercolor, 1), Utility.ColorWithAlpha(levelnumbercolor, 0), LevelNumberAndUseableBubbleAppearTime, ColorChangeType.Text));

        SerialTasks MarkDisappear = new SerialTasks();

        MarkDisappear.Add(new WaitTask(LevelNumberAndUseableBubbleAppearTime - MarkFillTime));

        ParallelTasks MarkDisappearTask = new ParallelTasks();

        MarkDisappearTask.Add(new UIFillTask(LevelMarkLeft, 1, 0, MarkFillTime));
        MarkDisappearTask.Add(new UIFillTask(LevelMarkRight, 1, 0, MarkFillTime));

        MarkDisappear.Add(MarkDisappearTask);

        AllTask.Add(MarkDisappear);

        ParallelTasks UseableCircleDisappearTasks = new ParallelTasks();

        foreach (Transform child in AllUseableBubbles.transform)
        {
            if (child.gameObject.activeSelf)
            {
                UseableCircleDisappearTasks.Add(child.GetComponent <UsableCircle>().GetDisappearTask());
            }
        }

        AllTask.Add(UseableCircleDisappearTasks);

        LevelEndUITasks.Add(AllTask);

        return(LevelEndUITasks);
    }
Ejemplo n.º 7
0
        /// <summary>
        /// 处理队列
        /// </summary>
        private void HandlingQueue()
        {
            CancellationToken token = tokenSource.Token;

            lock (_queueLock)
            {
                if (AsyncQueues.Count > 0)
                {
                    var asyncQueue = AsyncQueues.Dequeue();

                    if (asyncQueue == null)
                    {
                        return;
                    }
                    var task = Task.Factory.StartNew(() =>
                    {
                        if (token.IsCancellationRequested)
                        {
                            return;
                        }
                        //阻止当前线程
                        resetEvent.WaitOne();
                        //执行任务
                        Execute(asyncQueue.MeterInfoTask.entity);
                    }, token).ContinueWith(t =>
                    {
                        HandlingTask();
                    }, TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.ExecuteSynchronously);
                    ParallelTasks.Add(task);
                }
            }
        }
Ejemplo n.º 8
0
    private void Teleport(GameObject Obj, SlotInfo Target, ParallelTasks BubbleMovementTask)
    {
        var Data = GetComponent <BubbleMotionData>();

        ParallelTasks TeleportTask       = new ParallelTasks();
        SerialTasks   BubbleTeleportTask = new SerialTasks();

        if (Target == TeleportSlot1)
        {
            if (BubbleMovementTask != null)
            {
                BubbleTeleportTask.Add(new WaitTask(Data.MotionTime));
            }
            BubbleTeleportTask.Add(new ScaleChangeTask(Obj, Data.NormalScale, 0, Data.TeleportTime / 2));
            BubbleTeleportTask.Add(new MoveTask(Obj, TeleportSlot2.Location, TeleportSlot1.Location, Direction.Null, 0, TeleportSlot2.Pos, TeleportSlot1.Pos, TeleportSlot2.InsideBubbleType, Map, true));
            BubbleTeleportTask.Add(new ScaleChangeTask(Obj, 0, Data.ExhaustScale, Data.TeleportTime / 2));
        }
        else
        {
            if (BubbleMovementTask != null)
            {
                BubbleTeleportTask.Add(new WaitTask(Data.MotionTime));
            }
            BubbleTeleportTask.Add(new ScaleChangeTask(Obj, Data.NormalScale, 0, Data.TeleportTime / 2));
            BubbleTeleportTask.Add(new MoveTask(Obj, TeleportSlot1.Location, TeleportSlot2.Location, Direction.Null, 0, TeleportSlot1.Pos, TeleportSlot2.Pos, TeleportSlot1.InsideBubbleType, Map, true));
            BubbleTeleportTask.Add(new ScaleChangeTask(Obj, 0, Data.ExhaustScale, Data.TeleportTime / 2));
        }

        bool DuringBubbleMovement = BubbleMovementTask != null;

        TeleportTask.Add(BubbleTeleportTask);

        TeleportTask.Add(GetTeleportSlotTask(TeleportSlot1.Entity, DuringBubbleMovement));
        TeleportTask.Add(GetTeleportSlotTask(TeleportSlot2.Entity, DuringBubbleMovement));



        if (BubbleMovementTask == null)
        {
            BubbleMotionTasks.Add(TeleportTask);
        }
        else
        {
            BubbleMovementTask.Add(TeleportTask);
        }
    }
Ejemplo n.º 9
0
 private void Start()
 {
     HP = 100;
     Add_MoveTask();
     _tasks.Add(new GenerateEnemyTask(gameObject, 1, 1, 3));
     _tasks.Add(new ShootBulletTask(gameObject, false, 2));
 }
Ejemplo n.º 10
0
    private ParallelTasks GetShockWaveEmitAndFadeTasks()
    {
        ParallelTasks AllEmitAndFade = new ParallelTasks();
        GameObject    AllBubbles     = ActivatedLevel.GetComponent <LevelManager>().AllBubble;
        GameObject    AllSlots       = ActivatedLevel.GetComponent <LevelManager>().AllSlot;

        foreach (Transform child in AllBubbles.transform)
        {
            AllEmitAndFade.Add(child.GetComponent <NormalBubble>().GetShockWaveEmitTask());
        }

        foreach (Transform child in AllSlots.transform)
        {
            AllEmitAndFade.Add(child.GetComponent <SlotObject>().GetFadeTask());
        }

        return(AllEmitAndFade);
    }
Ejemplo n.º 11
0
    private IEnumerator GoToSetting()
    {
        gameState = GameState.Setting;

        SetMainMenuEnable(false);

        SettingMatchConfig();

        ParallelTasks MainMenuDisappearTask = GetMainMenuDisappearTask(SettingButton);

        while (!MainMenuDisappearTask.IsFinished)
        {
            MainMenuDisappearTask.Update();
            yield return(null);
        }

        ParallelTasks SettingAppearTask = new ParallelTasks();

        SettingAppearTask.Add(BackButton.GetComponent <GameButton>().GetAppearTask());

        SettingAppearTask.Add(Utility.GetTextAppearTask(MusicText, ButtonAppearTime));
        SettingAppearTask.Add(Utility.GetTextAppearTask(SoundEffectText, ButtonAppearTime));
        SettingAppearTask.Add(Utility.GetTextAppearTask(VibrationText, ButtonAppearTime));

        SettingAppearTask.Add(Utility.GetImageAppearTask(MusicMeter, ButtonAppearTime));
        SettingAppearTask.Add(Utility.GetImageAppearTask(MusicMeterCursor, ButtonAppearTime));
        SettingAppearTask.Add(Utility.GetImageAppearTask(SoundEffectMeter, ButtonAppearTime));
        SettingAppearTask.Add(Utility.GetImageAppearTask(SoundEffectMeterCursor, ButtonAppearTime));
        SettingAppearTask.Add(Utility.GetImageAppearTask(VibrationCheckBox, ButtonAppearTime));
        SettingAppearTask.Add(Utility.GetImageAppearTask(VibrationCheckMark, ButtonAppearTime));


        while (!SettingAppearTask.IsFinished)
        {
            SettingAppearTask.Update();
            yield return(null);
        }

        BackButton.GetComponent <BoxCollider2D>().enabled                = true;
        MusicMeterCursor.GetComponent <CircleCollider2D>().enabled       = true;
        SoundEffectMeterCursor.GetComponent <CircleCollider2D>().enabled = true;
        VibrationCheckBox.GetComponent <BoxCollider2D>().enabled         = true;
    }
Ejemplo n.º 12
0
    public static SerialTasks GetButtonSelectedDisappearTask(GameObject BorderImage, GameObject InsideContent, float StartScale, float EndScale, float InflationTime, float DeflationTime, ColorChangeType Type)
    {
        SerialTasks DisappearTask = new SerialTasks();

        ParallelTasks InflationTask = new ParallelTasks();

        InflationTask.Add(new ScaleChangeTask(BorderImage, StartScale, EndScale, InflationTime));
        if (InsideContent != null)
        {
            InflationTask.Add(new ScaleChangeTask(InsideContent, StartScale, EndScale, InflationTime));
        }

        DisappearTask.Add(InflationTask);

        ParallelTasks DeflationTask = new ParallelTasks();

        DeflationTask.Add(new ScaleChangeTask(BorderImage, EndScale, StartScale, DeflationTime));
        if (InsideContent != null)
        {
            DeflationTask.Add(new ScaleChangeTask(InsideContent, EndScale, StartScale, DeflationTime));
        }

        Color BorderImageColor = BorderImage.GetComponent <Image>().color;
        Color InsideContentColor;

        if (Type == ColorChangeType.Image)
        {
            InsideContentColor = InsideContent.GetComponent <Image>().color;
            DeflationTask.Add(new ColorChangeTask(InsideContent, ColorWithAlpha(InsideContentColor, 1), ColorWithAlpha(InsideContentColor, 0), DeflationTime, Type));
        }
        else if (Type == ColorChangeType.Text)
        {
            InsideContentColor = InsideContent.GetComponent <Text>().color;
            DeflationTask.Add(new ColorChangeTask(InsideContent, ColorWithAlpha(InsideContentColor, 1), ColorWithAlpha(InsideContentColor, 0), DeflationTime, Type));
        }

        DeflationTask.Add(new ColorChangeTask(BorderImage, ColorWithAlpha(BorderImageColor, 1), ColorWithAlpha(BorderImageColor, 0), DeflationTime, ColorChangeType.Image));


        DisappearTask.Add(DeflationTask);

        return(DisappearTask);
    }
Ejemplo n.º 13
0
    public static ParallelTasks GetTextDisappearTask(GameObject Text, float DisappearTime)
    {
        Color color = Text.GetComponent <Text>().color;

        ParallelTasks Tasks = new ParallelTasks();

        Tasks.Add(new ColorChangeTask(Text, Utility.ColorWithAlpha(color, 1), Utility.ColorWithAlpha(color, 0), DisappearTime, ColorChangeType.Text));

        return(Tasks);
    }
Ejemplo n.º 14
0
    public static ParallelTasks GetImageDisappearTask(GameObject Image, float DisappearTime)
    {
        Color color = Image.GetComponent <Image>().color;

        ParallelTasks Tasks = new ParallelTasks();

        Tasks.Add(new ColorChangeTask(Image, Utility.ColorWithAlpha(color, 1), Utility.ColorWithAlpha(color, 0), DisappearTime, ColorChangeType.Image));

        return(Tasks);
    }
Ejemplo n.º 15
0
    private IEnumerator GoToSelectedLevel()
    {
        gameState = GameState.SelectLevelMenu;

        SetMainMenuEnable(false);

        SetLevelButtonColor();

        ParallelTasks MainMenuDisappearTask = GetMainMenuDisappearTask(SelectLevelButton);

        while (!MainMenuDisappearTask.IsFinished)
        {
            MainMenuDisappearTask.Update();
            yield return(null);
        }

        ParallelTasks SelectLevelAppearTasks = new ParallelTasks();

        foreach (Transform child in AllLevelButtons.transform)
        {
            SelectLevelAppearTasks.Add(child.GetComponent <GameButton>().GetAppearTask());
        }

        foreach (Transform child in LevelSelectionArrows.transform)
        {
            SelectLevelAppearTasks.Add(child.GetComponent <GameButton>().GetAppearTask());
        }



        SelectLevelAppearTasks.Add(BackButton.GetComponent <GameButton>().GetAppearTask());

        while (!SelectLevelAppearTasks.IsFinished)
        {
            SelectLevelAppearTasks.Update();
            yield return(null);
        }

        SetSelectLevelEnable(true);

        BackButton.GetComponent <BoxCollider2D>().enabled = true;
    }
Ejemplo n.º 16
0
    private SerialTasks GetTargetSlotFilledTask(GameObject Obj)
    {
        var TargetSlotdata = Obj.GetComponent <TargetSlotObject>();

        SerialTasks TargetSlotFilledTask = new SerialTasks();

        TargetSlotFilledTask.Add(new WaitTask(TargetSlotdata.ParticleGoOutDelay));

        ParallelTasks ParticleOutTask = new ParallelTasks();

        List <InsideParticle> ParticleList = Obj.GetComponent <TargetSlotObject>().GetInsideParticles();

        for (int i = 0; i < ParticleList.Count; i++)
        {
            SerialTasks   Unit     = new SerialTasks();
            ParallelTasks UnitMove = new ParallelTasks();

            Vector3 Begin = ParticleList[i].Obj.transform.localPosition;
            Vector2 Dir   = ParticleList[i].Obj.transform.localPosition.normalized;
            Vector3 End   = (Vector2)Begin + Dir * Random.Range(TargetSlotdata.ParticleGoOutDisMin, TargetSlotdata.ParticleGoOutDisMax);
            UnitMove.Add(new TransformTask(ParticleList[i].Obj, Begin, End, TargetSlotdata.ParticleGoOutTime));

            Color color = ParticleList[i].Obj.GetComponent <SpriteRenderer>().color;

            UnitMove.Add(new ColorChangeTask(ParticleList[i].Obj, new Color(color.r, color.g, color.b, 1), new Color(color.r, color.g, color.b, 0), TargetSlotdata.ParticleGoOutTime, ColorChangeType.Sprite));
            UnitMove.Add(new ScaleChangeTask(ParticleList[i].Obj, ParticleList[i].Obj.transform.localScale.x, ParticleList[i].Obj.transform.localScale.x * 2, TargetSlotdata.ParticleGoOutTime));


            Unit.Add(new ScaleChangeTask(ParticleList[i].Obj, ParticleList[i].Obj.transform.localScale.x, 0, TargetSlotdata.ParticleGoOutTime));
            //Unit.Add(UnitMove);
            Unit.Add(new DestroySelfTask(ParticleList[i].Obj));

            ParticleOutTask.Add(Unit);
        }

        TargetSlotFilledTask.Add(ParticleOutTask);



        return(TargetSlotFilledTask);
    }
Ejemplo n.º 17
0
    private ParallelTasks GetBubblePowerUpTasks()
    {
        ParallelTasks AllPowerUp = new ParallelTasks();
        GameObject    AllBubbles = ActivatedLevel.GetComponent <LevelManager>().AllBubble;

        foreach (Transform child in AllBubbles.transform)
        {
            AllPowerUp.Add(child.GetComponent <NormalBubble>().GetShockWavePowerUpTask());
        }

        return(AllPowerUp);
    }
Ejemplo n.º 18
0
    private ParallelTasks GetBubbleEscapeTasks()
    {
        ParallelTasks AllEscape = new ParallelTasks();

        GameObject AllBubbles = ActivatedLevel.GetComponent <LevelManager>().AllBubble;

        foreach (Transform child in AllBubbles.transform)
        {
            AllEscape.Add(child.GetComponent <NormalBubble>().GetMoveOutEscapeTask());
        }

        return(AllEscape);
    }
Ejemplo n.º 19
0
    private ParallelTasks GetRecoverTasks()
    {
        ParallelTasks BubbleRecoverTasks = new ParallelTasks();

        for (int i = 0; i < Map.Count; i++)
        {
            for (int j = 0; j < Map[i].Count; j++)
            {
                if (Map[i][j] != null && Map[i][j].InsideBubbleType != BubbleType.Null && Map[i][j].InsideBubbleState != BubbleState.Stable)
                {
                    GameObject Bubble = Map[i][j].ConnectedBubble;
                    var        Data   = GetComponent <BubbleMotionData>();


                    switch (Map[i][j].InsideBubbleType)
                    {
                    case BubbleType.Disappear:
                        BubbleRecoverTasks.Add(new DisappearTask(Bubble, Data.RecoverTime, new Vector2Int(i, j), Map, BubbleType.Disappear, false));
                        Map[i][j].ConnectedBubble   = null;
                        Map[i][j].InsideBubbleType  = BubbleType.Null;
                        Map[i][j].InsideBubbleState = BubbleState.Stable;
                        break;

                    case BubbleType.Normal:
                        if (Map[i][j].InsideBubbleState == BubbleState.Exhausted)
                        {
                            BubbleRecoverTasks.Add(new RecoverTask(Bubble, Data.RecoverTime, Data.ExhaustScale, Data.NormalScale, Bubble.GetComponent <Bubble>().ExhaustColor, Bubble.GetComponent <Bubble>().NormalColor, Map, new Vector2Int(i, j), Data.DefaultEnergyColor));
                        }
                        else
                        {
                            BubbleRecoverTasks.Add(new RecoverTask(Bubble, 0, Data.NormalScale, Data.NormalScale, Bubble.GetComponent <Bubble>().NormalColor, Bubble.GetComponent <Bubble>().NormalColor, Map, new Vector2Int(i, j), Data.DefaultEnergyColor));
                        }
                        break;
                    }
                }
            }
        }
        return(BubbleRecoverTasks);
    }
Ejemplo n.º 20
0
    private SerialTasks GetTeleportSlotTask(GameObject Obj, bool DuringBubbleMovement)
    {
        var         Data             = GetComponent <BubbleMotionData>();
        SerialTasks TeleportSlotTask = new SerialTasks();



        if (DuringBubbleMovement)
        {
            TeleportSlotTask.Add(new WaitTask(Data.MotionTime));
        }

        ParallelTasks Teleport = new ParallelTasks();

        SerialTasks ColorChangeTasks = new SerialTasks();

        ColorChangeTasks.Add(new ColorChangeTask(Obj, Obj.GetComponent <SlotObject>().DefaultColor, Obj.GetComponent <SlotObject>().SelectedColor, Data.TeleportTime / 2, ColorChangeType.Sprite));
        ColorChangeTasks.Add(new ColorChangeTask(Obj, Obj.GetComponent <SlotObject>().SelectedColor, Obj.GetComponent <SlotObject>().DefaultColor, Data.TeleportTime / 2, ColorChangeType.Sprite));

        Teleport.Add(ColorChangeTasks);
        Teleport.Add(new RotationTask(Obj, 90, Data.TeleportTime));

        TeleportSlotTask.Add(Teleport);

        ParallelTasks ScaleRotationChangeFirstHalf = new ParallelTasks();

        ScaleRotationChangeFirstHalf.Add(new RotationTask(Obj, 90, Data.TeleportTime / 2));
        //ScaleRotationChangeFirstHalf.Add();

        //TeleportSlotTask.Add(ScaleRotationChangeFirstHalf);

        ParallelTasks ScaleRotationChangeSecondHalf = new ParallelTasks();

        ScaleRotationChangeSecondHalf.Add(new RotationTask(Obj, 90, Data.TeleportTime / 2));
        ScaleRotationChangeSecondHalf.Add(new ColorChangeTask(Obj, Obj.GetComponent <SlotObject>().SelectedColor, Obj.GetComponent <SlotObject>().DefaultColor, 0, ColorChangeType.Sprite));
        //TeleportSlotTask.Add(ScaleRotationChangeSecondHalf);

        return(TeleportSlotTask);
    }
Ejemplo n.º 21
0
    public static ParallelTasks GetButtonAppearTask(GameObject BorderImage, GameObject InsideContent, ColorChangeType Type, float AppearTime)
    {
        ParallelTasks AppearTask = new ParallelTasks();

        Color BorderImageColor = BorderImage.GetComponent <Image>().color;
        Color InsideContentColor;

        if (Type == ColorChangeType.Image)
        {
            InsideContentColor = InsideContent.GetComponent <Image>().color;
            AppearTask.Add(new ColorChangeTask(InsideContent, ColorWithAlpha(InsideContentColor, 0), ColorWithAlpha(InsideContentColor, 1), AppearTime, Type));
        }
        else if (Type == ColorChangeType.Text)
        {
            InsideContentColor = InsideContent.GetComponent <Text>().color;
            AppearTask.Add(new ColorChangeTask(InsideContent, ColorWithAlpha(InsideContentColor, 0), ColorWithAlpha(InsideContentColor, 1), AppearTime, Type));
        }

        AppearTask.Add(new ColorChangeTask(BorderImage, ColorWithAlpha(BorderImageColor, 0), ColorWithAlpha(BorderImageColor, 1), AppearTime, ColorChangeType.Image));

        return(AppearTask);
    }
Ejemplo n.º 22
0
        /// <summary>
        /// M3u8下载
        /// </summary>
        /// <param name="threads">线程数</param>
        /// <param name="savePath">保存文件</param>
        /// <param name="workPath">工作目录</param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        bool DownUrlByM3u8(int threads, string savePath, string workPath, out string errmsg)
        {
            //解析M3u8
            Parser parser = new Parser
            {
                DownName = _Name,
                M3u8Url  = uri.AbsoluteUri,
                DownDir  = workPath
            };
            string Err;

            if (parser.Parse(out Err))   //开始解析
            {
                if (File.Exists(parser.jsonSavePath))
                {
                    JObject initJson = JObject.Parse(File.ReadAllText(parser.jsonSavePath));
                    bool    isVOD    = Convert.ToBoolean(initJson["m3u8Info"]["vod"].ToString());

                    JArray parts    = JArray.Parse(initJson["m3u8Info"]["segments"].ToString()); //大分组
                    string segCount = initJson["m3u8Info"]["count"].ToString();
                    string oriCount = initJson["m3u8Info"]["originalCount"].ToString();          //原始分片数量

                    int    total        = Convert.ToInt32(segCount);
                    int    PartsCount   = parts.Count;
                    string segsPadZero  = string.Empty.PadRight(oriCount.Length, '0');
                    string partsPadZero = string.Empty.PadRight(Convert.ToString(parts.Count).Length, '0');
                    TotalCount = total;
                    //点播
                    if (isVOD)
                    {
                        List <FilesResult> files = new List <FilesResult>();

                        workPath.CreateDirectory(true);//新建文件夹

                        #region 任务分配

                        //构造包含所有分片的新的segments
                        JArray segments = new JArray();
                        for (int i = 0; i < parts.Count; i++)
                        {
                            var tmp = JArray.Parse(parts[i].ToString());
                            for (int j = 0; j < tmp.Count; j++)
                            {
                                JObject t = (JObject)tmp[j];
                                t.Add("part", i);
                                segments.Add(t);
                            }
                        }

                        bool isVTT = false;
                        for (int i = 0; i < segments.Count; i++)
                        {
                            JToken info  = segments[i];
                            string TsUrl = info["segUri"].Value <string>();
                            //VTT字幕
                            if (isVTT == false && TsUrl.Trim('\"').EndsWith(".vtt"))
                            {
                                isVTT = true;
                            }
                            string Method = info["method"].Value <string>();
                            string Iv = null;
                            long   StartByte = 0, ExpectByte = 0;
                            if (Method != "NONE")
                            {
                                Iv = info["iv"].Value <string>();
                            }
                            try
                            {
                                ExpectByte = info["expectByte"].Value <long>();
                            }
                            catch { }
                            try
                            {
                                StartByte = info["startByte"].Value <long>();
                            }
                            catch { }

                            string Dir = workPath + "Part_" + info["part"].Value <int>().ToString(partsPadZero) + "\\";

                            Dir.CreateDirectory(true);

                            string filename_temp = info["index"].Value <int>().ToString(segsPadZero) + ".ts";
                            files.Add(new FilesResult
                            {
                                index          = i,
                                tsurl          = TsUrl,
                                path           = Dir + filename_temp,
                                start_position = StartByte,
                                end_position   = ExpectByte,
                            });
                            lock (DownSizeTemp)
                            {
                                DownSizeTemp.Add(i, 0);
                            }
                        }
                        #endregion

                        SetState(DownState.Downloading);
                        TestTime(true);
                        bool isComplete = false;


                        Action _action = () =>
                        {
                            foreach (FilesResult item in files)
                            {
                                lock (files)
                                {
                                    //int counts = files.Count(ab => ab.run);
                                    if (files.Count(ab => ab.run) > threads)
                                    {
                                        resetEvents.Reset();//暂停
                                    }
                                }
                                resetEvents.WaitOne();

                                double _downvalueTemp = 0;
                                item.run = item.runTask = true;
                                Action _actions = () =>
                                {
                                    if (tokenSource.Token.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    //阻止当前线程
                                    resetEvent.WaitOne();


                                    Uri TSuri = new Uri(item.tsurl);

                                    int ErrCount = 0;
                                    while (item.runTask)
                                    {
                                        try
                                        {
                                            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(TSuri);
                                            request.Host      = TSuri.Host;
                                            request.Accept    = "*/*";
                                            request.UserAgent = "Mozilla/5.0";
                                            request.Method    = "GET";
                                            if (SystemSettings.DownloadTimeOut > 0)
                                            {
                                                request.Timeout = SystemSettings.DownloadTimeOut;
                                            }
                                            request.ReadWriteTimeout  = request.Timeout; //重要
                                            request.AllowAutoRedirect = true;
                                            request.KeepAlive         = false;

                                            using (HttpWebResponse p = (HttpWebResponse)request.GetResponse())
                                            {
                                                lock (TotalSizeTemp)
                                                {
                                                    if (!TotalSizeTemp.ContainsKey(item.index))
                                                    {
                                                        using (FileStream file = new FileStream(item.path, FileMode.OpenOrCreate))
                                                        {
                                                            long fileLong = p.ContentLength;
                                                            if (fileLong > 0 && file.Length >= fileLong)
                                                            {
                                                                _downvalueTemp += fileLong;
                                                                lock (DownSizeTemp)
                                                                {
                                                                    DownSizeTemp[item.index] = fileLong;
                                                                }

                                                                TotalSizeTemp.Add(item.index, fileLong);

                                                                DownCount++;

                                                                SetValue();
                                                                return;
                                                            }
                                                        }
                                                    }
                                                }
                                                using (FileStream file = new FileStream(item.path, FileMode.Create))
                                                {
                                                    if (item.start_position > 0 && item.end_position > 0)
                                                    {
                                                        request.AddRange((long)item.start_position, (long)item.end_position);
                                                    }
                                                    lock (TotalSizeTemp)
                                                    {
                                                        if (!TotalSizeTemp.ContainsKey(item.index))
                                                        {
                                                            TotalSizeTemp.Add(item.index, p.ContentLength);
                                                        }
                                                    }
                                                    using (Stream stream = p.GetResponseStream())
                                                    {
                                                        byte[] _cache = new byte[SystemSettings.DownloadCacheCount];
                                                        int    osize  = stream.Read(_cache, 0, _cache.Length);


                                                        bool isRun = true;
                                                        while (isRun)
                                                        {
                                                            if (osize > 0)
                                                            {
                                                                if (tokenSource.Token.IsCancellationRequested)
                                                                {
                                                                    return;
                                                                }
                                                                //阻止当前线程
                                                                resetEvent.WaitOne();
                                                                _downvalueTemp += osize;
                                                                lock (DownSizeTemp)
                                                                {
                                                                    DownSizeTemp[item.index] = _downvalueTemp;
                                                                }
                                                                SetValue();
                                                                file.Write(_cache, 0, osize);
                                                                osize = stream.Read(_cache, 0, _cache.Length);
                                                            }
                                                            else
                                                            {
                                                                isRun = false;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            item.complete = true;
                                            DownCount++;
                                            item.runTask = false;
                                        }
                                        catch
                                        {
                                            if (isStop)
                                            {
                                                item.runTask = false;
                                                return;
                                            }
                                            ErrCount++;

                                            _downvalueTemp = 0;
                                            lock (DownSizeTemp)
                                            {
                                                DownSizeTemp[item.index] = 0;
                                            }
                                            SetValue();
                                            //System.Diagnostics.Debug.WriteLine("序号:" + item.index + "|次数:" + ErrCount);

                                            if (ErrCount > SystemSettings.DownloadRetryCount)
                                            {
                                                item.runTask = false;
                                            }
                                        }
                                    }
                                };

                                var task = Task.Run(_actions, tokenSource.Token).ContinueWith(t =>
                                {
                                    item.run = false;
                                    lock (files)
                                    {
                                        int tackCount = files.Count(ab => ab.run);
                                        if (tackCount < threads)
                                        {
                                            resetEvents.Set();//继续
                                        }
                                    }
                                }, TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.ExecuteSynchronously);
                                ParallelTasks.Add(task);

                                resetEvents.WaitOne();
                            }
                            _task.ContinueWhenAll(ParallelTasks.ToArray(), (action =>
                            {
                                isdown = false;
                                if (tokenSource.Token.IsCancellationRequested)
                                {
                                    return;
                                }
                                List <string> _files = new List <string>();
                                lock (files)
                                {
                                    foreach (FilesResult item in files)
                                    {
                                        if (!item.complete)
                                        {
                                            return;
                                        }
                                        _files.Add(item.path);
                                    }
                                }

                                bool externalAudio = false, externalSub = false;
                                string externalAudioUrl = null, externalSubUrl = null;

                                try
                                {
                                    if (initJson["m3u8Info"]["audio"].ToString() != "")
                                    {
                                        externalAudio = true;
                                    }
                                    externalAudioUrl = initJson["m3u8Info"]["audio"].ToString();
                                    System.Diagnostics.Debug.WriteLine("识别到外挂音频轨道");
                                }
                                catch { }
                                try
                                {
                                    if (initJson["m3u8Info"]["sub"].ToString() != "")
                                    {
                                        externalSub = true;
                                    }
                                    externalSubUrl = initJson["m3u8Info"]["sub"].ToString();
                                    System.Diagnostics.Debug.WriteLine("识别到外挂字幕轨道");
                                }
                                catch { }
                                CombineMultipleFilesByM3u8(savePath, PartsCount, workPath, partsPadZero, externalAudio, externalAudioUrl, externalSub, externalSubUrl);

                                SetMaxValue();
                                while (isTimeTask)
                                {
                                    Thread.Sleep(500);
                                }
                                //Thread.Sleep(500);
                                Directory.Delete(workPath, true);
                                isComplete = true;
                                SetState(DownState.Complete);
                            })).Wait();
                        };
                        _task.StartNew(_action).Wait();

                        if (isComplete)
                        {
                            errmsg = null;
                            return(true);
                        }
                        else
                        {
                            SetState(DownState.Fail);
                            errmsg = "文件下载失败";
                            return(false);
                        }
                    }
                    else
                    {
                        SetState(DownState.Fail);
                        errmsg = "无法下载直播";
                        return(false);
                    }
                }
                else
                {
                    SetState(DownState.Fail);
                    errmsg = "M3u8解析失败:地址无效";
                    return(false);
                }
            }
            else
            {
                SetState(DownState.Fail);
                errmsg = "M3u8解析失败";
                return(false);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 普通下载
        /// </summary>
        /// <param name="threads">线程数</param>
        /// <param name="savePath">保存文件</param>
        /// <param name="workPath">工作目录</param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        bool DownUrlByPlain(int threads, string savePath, string workPath, out string errmsg)
        {
            SetState(DownState.Downloading);
            workPath.CreateDirectory(true);//新建文件夹

            if (_Length > 0 || _Length == -1)
            {
                SetMaxValue(_Length);

                List <FilesResult> files = new List <FilesResult>();

                #region 任务分配

                double _down_length = _MaxValue;
                int    _taskcount   = 1;
                if (canSeek && _MaxValue > 0 && _MaxValue > 2097152)
                {
                    _down_length = 2097152;
                    _taskcount   = (int)Math.Ceiling(_MaxValue / _down_length);//任务分块
                }
                lock (DownSizeTemp)
                {
                    for (int i = 0; i < _taskcount; i++)
                    {
                        double _s = _down_length * i;
                        double _e = _down_length;
                        if ((_s + _down_length) > _MaxValue)
                        {
                            _e = _down_length - ((_s + _down_length) - _MaxValue);
                        }

                        string filename_temp = $"{i}_{_s}_{_s + _e}.tsdownloading";
                        files.Add(new FilesResult
                        {
                            index          = i,
                            path           = workPath + filename_temp,
                            start_position = _s,
                            end_position   = _e
                        });

                        DownSizeTemp.Add(i, 0);
                    }
                }

                #endregion

                TestTime(false);
                bool   isComplete = false;
                Action _action    = () =>
                {
                    foreach (FilesResult item in files)
                    {
                        lock (files)
                        {
                            if (files.Count(ab => ab.run) > threads)
                            {
                                resetEvents.Reset();//暂停
                            }
                        }
                        resetEvents.WaitOne();

                        double _downvalueTemp = 0;
                        item.run = item.runTask = true;
                        Action _actions = () =>
                        {
                            if (tokenSource.Token.IsCancellationRequested)
                            {
                                return;
                            }
                            //阻止当前线程
                            resetEvent.WaitOne();

                            int ErrCount = 0;
                            while (item.runTask)
                            {
                                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
                                request.Host      = uri.Host;
                                request.Accept    = "*/*";
                                request.UserAgent = "Mozilla/5.0";
                                request.Method    = "GET";
                                if (SystemSettings.DownloadTimeOut > 0)
                                {
                                    request.Timeout = SystemSettings.DownloadTimeOut;
                                }
                                request.ReadWriteTimeout  = request.Timeout; //重要
                                request.AllowAutoRedirect = true;
                                request.KeepAlive         = false;
                                try
                                {
                                    long fileLong = 0;

                                    using (FileStream file = new FileStream(item.path, FileMode.OpenOrCreate))
                                    {
                                        fileLong = file.Length;
                                        if (item.end_position > 0 && file.Length >= item.end_position)
                                        {
                                            _downvalueTemp += fileLong;
                                            //_downvalue += fileLong;
                                            lock (DownSizeTemp)
                                            {
                                                DownSizeTemp[item.index] = fileLong;
                                            }

                                            SetValue();
                                            item.complete = true;
                                            return;
                                        }
                                        else if (!canSeek)
                                        {
                                            file.Close();
                                            fileLong = 0;
                                            File.Delete(item.path);
                                        }
                                    }


                                    using (FileStream file = new FileStream(item.path, FileMode.OpenOrCreate))
                                    {
                                        if (canSeek)
                                        {
                                            request.AddRange((long)(item.start_position + file.Length), (long)(item.start_position + item.end_position));
                                        }
                                        using (HttpWebResponse p = (HttpWebResponse)request.GetResponse())
                                        {
                                            using (Stream stream = p.GetResponseStream())
                                            {
                                                if (fileLong > 0)
                                                {
                                                    file.Seek(fileLong, SeekOrigin.Begin);

                                                    _downvalueTemp += fileLong;
                                                    //_downvalue += fileLong;
                                                    lock (DownSizeTemp)
                                                    {
                                                        DownSizeTemp[item.index] = fileLong;
                                                    }
                                                    SetValue();
                                                }
                                                byte[] _cache = new byte[SystemSettings.DownloadCacheCount];
                                                int    osize  = stream.Read(_cache, 0, _cache.Length);
                                                bool   isRun  = true;
                                                while (isRun)
                                                {
                                                    if (osize > 0)
                                                    {
                                                        if (tokenSource.Token.IsCancellationRequested)
                                                        {
                                                            return;
                                                        }
                                                        //阻止当前线程
                                                        resetEvent.WaitOne();


                                                        _downvalueTemp += osize;
                                                        //_downvalue += osize;
                                                        lock (DownSizeTemp)
                                                        {
                                                            DownSizeTemp[item.index] = _downvalueTemp;
                                                        }
                                                        SetValue();

                                                        file.Write(_cache, 0, osize);
                                                        osize = stream.Read(_cache, 0, _cache.Length);
                                                    }
                                                    else
                                                    {
                                                        isRun = false;
                                                    }
                                                }
                                                //file.Seek(0, SeekOrigin.Begin);
                                            }
                                        }
                                    }
                                    item.complete = true;
                                }
                                catch
                                {
                                    request.Abort();
                                    if (isStop)
                                    {
                                        item.runTask = false;
                                        return;
                                    }
                                    ErrCount++;

                                    _downvalueTemp = 0;
                                    lock (DownSizeTemp)
                                    {
                                        DownSizeTemp[item.index] = 0;
                                    }
                                    SetValue();

                                    //System.Diagnostics.Debug.WriteLine("序号:" + item.index + "|次数:" + ErrCount);
                                    if (ErrCount > SystemSettings.DownloadRetryCount)
                                    {
                                        item.runTask = false;
                                    }
                                }
                            }
                        };
                        var task = Task.Run(_actions, tokenSource.Token).ContinueWith(t =>
                        {
                            item.run = false;
                            lock (files)
                            {
                                int tackCount = files.Count(ab => ab.run);
                                if (tackCount < threads)
                                {
                                    resetEvents.Set();//继续
                                }
                            }
                        }, TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.ExecuteSynchronously);
                        ParallelTasks.Add(task);

                        resetEvents.WaitOne();
                    }
                    _task.ContinueWhenAll(ParallelTasks.ToArray(), (action =>
                    {
                        isdown = false;
                        if (tokenSource.Token.IsCancellationRequested)
                        {
                            return;
                        }
                        while (isTimeTask)
                        {
                            Thread.Sleep(500);
                        }
                        List <string> _files = new List <string>();
                        lock (files)
                        {
                            foreach (FilesResult item in files)
                            {
                                if (!item.complete)
                                {
                                    return;
                                }
                                _files.Add(item.path);
                            }
                        }

                        Global.CombineMultipleFilesIntoSingleFile(_files, savePath);
                        Directory.Delete(workPath, true);
                        isComplete = true;
                        SetState(DownState.Complete);
                    })).Wait();
                };
                _task.StartNew(_action).Wait();
                if (isComplete)
                {
                    errmsg = null;
                    return(true);
                }
                else
                {
                    SetState(DownState.Fail);
                    errmsg = "文件下载失败";
                    return(false);
                }
            }
            else
            {
                SetState(DownState.Fail);
                errmsg = "文件长度异常";
                return(false);
            }
        }
Ejemplo n.º 24
0
    public SerialTasks GetMapAppearTask()
    {
        MapAppearTask = new SerialTasks();

        List <SlotInfo> AllSlotInfo       = new List <SlotInfo>();
        List <int>      AllSlotLayer      = new List <int>();
        List <SlotInfo> AllSlotWithBubble = new List <SlotInfo>();

        Vector2 MapCenter = new Vector2((Map.Count - 1) / 2.0f, (Map[0].Count - 1) / 2.0f);

        for (int i = 0; i < Map.Count; i++)
        {
            for (int j = 0; j < Map[i].Count; j++)
            {
                if (Map[i][j] != null)
                {
                    Color SlotColor = Map[i][j].Entity.GetComponent <SpriteRenderer>().color;
                    Map[i][j].Entity.GetComponent <SpriteRenderer>().color = Utility.ColorWithAlpha(SlotColor, 0);
                    Map[i][j].Entity.transform.localPosition = Map[i][j].Location * MapSlotInitPosOffsetFactor;
                    if (Map[i][j].InsideBubbleType != BubbleType.Null)
                    {
                        AllSlotWithBubble.Add(Map[i][j]);
                        Color BubbleColor = Map[i][j].ConnectedBubble.GetComponent <SpriteRenderer>().color;
                        Map[i][j].ConnectedBubble.GetComponent <SpriteRenderer>().color = Utility.ColorWithAlpha(BubbleColor, 0);
                    }

                    AllSlotInfo.Add(Map[i][j]);

                    int XLayer;
                    int YLayer;

                    if (Map.Count % 2 == 1)
                    {
                        XLayer = Mathf.RoundToInt(Mathf.Abs(i - MapCenter.x));
                    }
                    else
                    {
                        XLayer = Mathf.RoundToInt(Mathf.Abs(i - MapCenter.x) + 0.5f);
                    }

                    if (Map[i].Count % 2 == 1)
                    {
                        YLayer = Mathf.RoundToInt(Mathf.Abs(j - MapCenter.y));
                    }
                    else
                    {
                        YLayer = Mathf.RoundToInt(Mathf.Abs(j - MapCenter.y) + 0.5f);
                    }

                    AllSlotLayer.Add(Mathf.Max(XLayer, YLayer));
                }
            }
        }

        List <List <SlotInfo> > SortedSlotInfo  = new List <List <SlotInfo> >();
        List <List <int> >      SortedSlotLayer = new List <List <int> >();

        for (int i = 0; i < AllSlotLayer.Count; i++)
        {
            for (int j = 0; j < AllSlotLayer.Count - i - 1; j++)
            {
                if (AllSlotLayer[j] < AllSlotLayer[j + 1])
                {
                    int temp = AllSlotLayer[j];
                    AllSlotLayer[j]     = AllSlotLayer[j + 1];
                    AllSlotLayer[j + 1] = temp;

                    SlotInfo S = AllSlotInfo[j];
                    AllSlotInfo[j]     = AllSlotInfo[j + 1];
                    AllSlotInfo[j + 1] = S;
                }
            }

            if (SortedSlotLayer.Count == 0 || SortedSlotLayer[SortedSlotLayer.Count - 1][SortedSlotLayer[SortedSlotLayer.Count - 1].Count - 1] < AllSlotLayer[AllSlotLayer.Count - i - 1])
            {
                SortedSlotLayer.Add(new List <int>());
                SortedSlotLayer[SortedSlotLayer.Count - 1].Add(AllSlotLayer[AllSlotLayer.Count - i - 1]);
                SortedSlotInfo.Add(new List <SlotInfo>());
                SortedSlotInfo[SortedSlotInfo.Count - 1].Add(AllSlotInfo[AllSlotInfo.Count - i - 1]);
            }
            else
            {
                SortedSlotLayer[SortedSlotLayer.Count - 1].Add(AllSlotLayer[AllSlotLayer.Count - i - 1]);
                SortedSlotInfo[SortedSlotInfo.Count - 1].Add(AllSlotInfo[AllSlotInfo.Count - i - 1]);
            }
        }

        float         Delay         = 0;
        ParallelTasks AllSlotAppear = new ParallelTasks();

        for (int i = 0; i < SortedSlotInfo.Count; i++)
        {
            int num = SortedSlotInfo[i].Count;

            List <SlotInfo> RearrangedSlotInfo = new List <SlotInfo>();
            List <int>      RearrangedLayer    = new List <int>();

            for (int j = 0; j < num; j++)
            {
                int index = Random.Range(0, SortedSlotInfo[i].Count);
                RearrangedSlotInfo.Add(SortedSlotInfo[i][index]);
                RearrangedLayer.Add(SortedSlotLayer[i][index]);
                SortedSlotInfo[i].RemoveAt(index);
                SortedSlotLayer[i].RemoveAt(index);
            }

            SortedSlotInfo[i].Clear();
            SortedSlotLayer[i].Clear();

            SortedSlotInfo[i]  = RearrangedSlotInfo;
            SortedSlotLayer[i] = RearrangedLayer;

            ParallelTasks LayerSlotTasks = new ParallelTasks();


            for (int j = 0; j < SortedSlotInfo[i].Count; j++)
            {
                ParallelTasks SlotTask = new ParallelTasks();
                SlotTask.Add(new AppearTask(SortedSlotInfo[i][j].Entity, MapUnitAppearTime, false, SortedSlotInfo[i][j].Pos));
                SlotTask.Add(new TransformTask(SortedSlotInfo[i][j].Entity, SortedSlotInfo[i][j].Location * MapSlotInitPosOffsetFactor, SortedSlotInfo[i][j].Location, MapUnitAppearTime));

                if (j > 0)
                {
                    if (Random.Range(0.0f, 1.0f) < MapAppearUnitGapProbability)
                    {
                        Delay += Random.Range(MapAppearUnitGapMinMax.x, MapAppearUnitGapMinMax.y);
                    }
                }

                SerialTasks temp = new SerialTasks();
                temp.Add(new WaitTask(Delay));
                temp.Add(SlotTask);

                LayerSlotTasks.Add(temp);
            }

            AllSlotAppear.Add(LayerSlotTasks);
        }


        ParallelTasks AllBubbleAppear = new ParallelTasks();

        for (int i = 0; i < AllSlotWithBubble.Count; i++)
        {
            AllBubbleAppear.Add(new AppearTask(AllSlotWithBubble[i].ConnectedBubble, MapUnitAppearTime, false, AllSlotWithBubble[i].Pos));
        }

        MapAppearTask.Add(AllSlotAppear);
        MapAppearTask.Add(AllBubbleAppear);

        return(MapAppearTask);
    }
Ejemplo n.º 25
0
    private void PlaceBubble(GameObject UseableBubble, Vector2Int Pos, BubbleType Type)
    {
        ChangeInfoList.Add(new List <BubbleChangeInfo>());

        OriginBubblePosDic.Clear();
        ChangedBubblePosDic.Clear();

        for (int i = 0; i < Map.Count; i++)
        {
            for (int j = 0; j < Map[i].Count; j++)
            {
                if (Map[i][j] != null && Map[i][j].InsideBubbleType != BubbleType.Null)
                {
                    OriginBubblePosDic.Add(Map[i][j].ConnectedBubble, new Vector2Int(i, j));
                    ChangedBubblePosDic.Add(Map[i][j].ConnectedBubble, new Vector2Int(i, j));
                }
            }
        }

        Vector3 GeneratePos = UseableBubble.transform.position;

        switch (Type)
        {
        case BubbleType.Disappear:
            Map[Pos.x][Pos.y].ConnectedBubble = (GameObject)Instantiate(DisappearBubblePrefab, GeneratePos, Quaternion.Euler(0, 0, 0));
            break;

        case BubbleType.Normal:
            Map[Pos.x][Pos.y].ConnectedBubble = (GameObject)Instantiate(NormalBubblePrefab, GeneratePos, Quaternion.Euler(0, 0, 0));
            break;
        }


        Map[Pos.x][Pos.y].InsideBubbleType  = Type;
        Map[Pos.x][Pos.y].InsideBubbleState = BubbleState.Activated;

        Map[Pos.x][Pos.y].ConnectedBubble.GetComponent <Bubble>().State = BubbleState.Activated;
        Map[Pos.x][Pos.y].ConnectedBubble.transform.Find("ActivateEffect").GetComponent <ParticleSystem>().Play();
        Map[Pos.x][Pos.y].ConnectedBubble.transform.parent = AllBubble.transform;

        Map[Pos.x][Pos.y].ConnectedBubble.transform.localScale = Vector3.one * PlaceScale;

        if (Map[Pos.x][Pos.y].slotType == SlotType.Target && Type == BubbleType.Normal)
        {
            Map[Pos.x][Pos.y].Entity.GetComponent <TargetSlotObject>().SetBubbleInside(true);
            Map[Pos.x][Pos.y].Entity.GetComponent <TargetSlotObject>().ClearInsideParticleInfo();
        }

        var Data = GetComponent <BubbleMotionData>();

        Vector3 Start = Map[Pos.x][Pos.y].ConnectedBubble.transform.localPosition;
        Vector3 End   = Map[Pos.x][Pos.y].Location;

        ParallelTasks PlaceTask = new ParallelTasks();

        PlaceTask.Add(new TransformTask(Map[Pos.x][Pos.y].ConnectedBubble, Start, End, DropMoveTime));
        PlaceTask.Add(new ScaleChangeTask(Map[Pos.x][Pos.y].ConnectedBubble, PlaceScale, GetComponent <BubbleMotionData>().NormalScale, DropMoveTime));
        BubbleMotionTasks.Add(PlaceTask);

        bool TeleportAffected = false;

        if (Map[Pos.x][Pos.y] == TeleportSlot1)
        {
            if (TeleportSlot2.InsideBubbleType == BubbleType.Null)
            {
                GameObject Bubble = Map[Pos.x][Pos.y].ConnectedBubble;
                Teleport(Bubble, TeleportSlot2, null);
                Pos = TeleportSlot2.Pos;
                TeleportAffected = true;
            }
            else
            {
                TeleportSlotBlocked();
                BubbleMotionTasks.Add(new WaitTask(MotionInterval));
            }
        }
        else if (Map[Pos.x][Pos.y] == TeleportSlot2)
        {
            if (TeleportSlot1.InsideBubbleType == BubbleType.Null)
            {
                GameObject Bubble = Map[Pos.x][Pos.y].ConnectedBubble;
                Teleport(Bubble, TeleportSlot1, null);
                Pos = TeleportSlot1.Pos;
                TeleportAffected = true;
            }
            else
            {
                TeleportSlotBlocked();
                BubbleMotionTasks.Add(new WaitTask(MotionInterval));
            }
        }

        ChangeInfoList[ChangeInfoList.Count - 1].Add(new BubbleChangeInfo(Map[Pos.x][Pos.y].ConnectedBubble, Type, true, UseableBubble, Pos, Pos, Map[Pos.x][Pos.y].Location, Map[Pos.x][Pos.y].Location));

        List <Vector2Int> PosList = new List <Vector2Int>();

        if (!TeleportAffected)
        {
            PosList.Add(Pos);
        }
        else
        {
            BubbleMotionTasks.Add(new WaitTask(RoundEndInterval));
        }


        BubbleInflate(PosList, true, TeleportAffected);

        foreach (GameObject Bubble in OriginBubblePosDic.Keys)
        {
            Vector2Int From     = OriginBubblePosDic[Bubble];
            Vector2Int To       = ChangedBubblePosDic[Bubble];
            Vector3    BeginPos = Map[From.x][From.y].Location;
            Vector3    EndPos   = Map[To.x][To.y].Location;
            ChangeInfoList[ChangeInfoList.Count - 1].Add(new BubbleChangeInfo(Bubble, Bubble.GetComponent <Bubble>().Type, false, null, From, To, BeginPos, EndPos));
        }
    }
Ejemplo n.º 26
0
    private void SetBubbleMovement(List <Vector2Int> PosList, Dictionary <GameObject, Vector2Int> ActivateDic)
    {
        if (PosList.Count == 0)
        {
            return;
        }

        ParallelTasks BackMovementSet = new ParallelTasks();

        ParallelTasks BubbleInflateMoveBlocked = new ParallelTasks();

        List <List <int> > PosTarget = new List <List <int> >();

        List <MoveInfo> Moves = new List <MoveInfo>();

        var Data = GetComponent <BubbleMotionData>();

        for (int i = 0; i < Map.Count; i++)
        {
            PosTarget.Add(new List <int>());
            for (int j = 0; j < Map[i].Count; j++)
            {
                PosTarget[i].Add(0);
            }
        }

        for (int i = 0; i < PosList.Count; i++)
        {
            GameObject Bubble = Map[PosList[i].x][PosList[i].y].ConnectedBubble;

            List <bool> ShootParticles = new List <bool>();
            for (int j = 0; j < 4; j++)
            {
                ShootParticles.Add(false);
            }

            NearByPushAvailable(PosList[i], ShootParticles, Moves);

            BubbleInflateMoveBlocked.Add(new ReleaseTask(Bubble, Data.MotionTime, Data.NormalScale, Data.ExhaustScale, Bubble.GetComponent <Bubble>().NormalColor, Bubble.GetComponent <Bubble>().ExhaustColor, Map, PosList[i], ShootParticles));
        }

        for (int k = 0; k < Moves.Count; k++)
        {
            int x = Moves[k].TargetPos.x;
            int y = Moves[k].TargetPos.y;

            if (!(x < 0 || y < 0 || x >= Map.Count || y >= Map[x].Count || Map[x][y] == null))
            {
                PosTarget[x][y]++;
            }
        }

        PosList.Clear();

        bool Slot1Active = false;
        bool Slot2Active = false;

        Dictionary <GameObject, Vector2Int> AffectedBubblePosDic = new Dictionary <GameObject, Vector2Int>();


        if (Moves.Count > 0)
        {
            BubbleInflateMoveBlocked.Add(new PlaySoundTask(gameObject, GetComponents <AudioSource>()[1]));
        }

        for (int k = 0; k < Moves.Count; k++)
        {
            Vector2 dir;
            switch (Moves[k].direction)
            {
            case Direction.Left:
                dir = Vector2.left;
                break;

            case Direction.Right:
                dir = Vector2.right;
                break;

            case Direction.Up:
                dir = Vector2.up;
                break;

            case Direction.Down:
                dir = Vector2.down;
                break;

            default:
                dir = Vector2.zero;
                break;
            }

            int x = Moves[k].TargetPos.x;
            int y = Moves[k].TargetPos.y;

            GameObject Bubble = Map[Moves[k].CurrentPos.x][Moves[k].CurrentPos.y].ConnectedBubble;

            Vector2Int Target = Moves[k].TargetPos;

            if (x < 0 || y < 0 || x >= Map.Count || y >= Map[x].Count || Map[x][y] == null || Map[x][y].InsideBubbleType != BubbleType.Null)
            {
                ParallelTasks BubbleBlocked = new ParallelTasks();

                BubbleBlocked.Add(GetEnergyFillTask(Bubble));
                BubbleBlocked.Add(new BlockedTask(Bubble, Moves[k].CurrentLocation, dir, Moves[k].direction, Data.BlockedDis, Data.MotionTime, Moves[k].CurrentPos, Map));

                BubbleInflateMoveBlocked.Add(BubbleBlocked);

                Target = Moves[k].CurrentPos;
            }
            else
            {
                if (PosTarget[x][y] > 1)
                {
                    if (ActivateDic.ContainsKey(Bubble))
                    {
                        ActivateDic[Bubble] = Moves[k].CurrentPos;
                    }
                    else
                    {
                        ActivateDic.Add(Bubble, Moves[k].CurrentPos);
                    }

                    ParallelTasks BubbleBlocked = new ParallelTasks();

                    BubbleBlocked.Add(GetEnergyFillTask(Bubble));
                    BubbleBlocked.Add(new BlockedTask(Bubble, Moves[k].CurrentLocation, dir, Moves[k].direction, Data.ConflictBlockedDis, Data.MotionTime, Moves[k].CurrentPos, Map));

                    BubbleInflateMoveBlocked.Add(BubbleBlocked);

                    Target = Moves[k].CurrentPos;
                }
                else
                {
                    if (ActivateDic.ContainsKey(Bubble))
                    {
                        ActivateDic[Bubble] = Moves[k].TargetPos;
                    }
                    else
                    {
                        ActivateDic.Add(Bubble, Moves[k].TargetPos);
                    }

                    ParallelTasks BubbleMove = new ParallelTasks();

                    BubbleMove.Add(GetEnergyFillTask(Bubble));
                    BubbleMove.Add(new MoveTask(Bubble, Moves[k].CurrentLocation, Moves[k].TargetLocation, Moves[k].direction, Data.MotionTime, Moves[k].CurrentPos, Moves[k].TargetPos, Bubble.GetComponent <Bubble>().Type, Map));
                    if (Map[Moves[k].TargetPos.x][Moves[k].TargetPos.y].slotType == SlotType.Target)
                    {
                        BubbleMove.Add(GetTargetSlotFilledTask(Map[Moves[k].TargetPos.x][Moves[k].TargetPos.y].Entity));
                        Map[Moves[k].TargetPos.x][Moves[k].TargetPos.y].Entity.GetComponent <TargetSlotObject>().ClearInsideParticleInfo();
                        Map[Moves[k].TargetPos.x][Moves[k].TargetPos.y].Entity.GetComponent <TargetSlotObject>().SetBubbleInside(true);
                    }
                    else if (Map[Moves[k].CurrentPos.x][Moves[k].CurrentPos.y].slotType == SlotType.Target)
                    {
                        Map[Moves[k].CurrentPos.x][Moves[k].CurrentPos.y].Entity.GetComponent <TargetSlotObject>().SetBubbleInside(false);
                    }

                    BubbleInflateMoveBlocked.Add(BubbleMove);

                    ChangedBubblePosDic[Bubble] = Moves[k].TargetPos;
                }
            }

            if (AffectedBubblePosDic.ContainsKey(Bubble))
            {
                AffectedBubblePosDic[Bubble] = Target;
            }
            else
            {
                AffectedBubblePosDic.Add(Bubble, Target);
            }

            if (ActivateDic.ContainsKey(Bubble))
            {
                ActivateDic[Bubble] = Target;
            }
            else
            {
                ActivateDic.Add(Bubble, Target);
            }

            Vector2Int v = AffectedBubblePosDic[Bubble];

            if (Map[v.x][v.y] == TeleportSlot1)
            {
                Slot1Active = true;
            }

            if (Map[v.x][v.y] == TeleportSlot2)
            {
                Slot2Active = true;
            }
        }

        BubbleMotionTasks.Add(BubbleInflateMoveBlocked);

        if (Slot1Active && !Slot2Active || !Slot1Active && Slot2Active)
        {
            if (Slot1Active)
            {
                if (TeleportSlot2.InsideBubbleType == BubbleType.Null)
                {
                    GameObject Bubble = TeleportSlot1.ConnectedBubble;

                    if (ActivateDic.ContainsKey(Bubble))
                    {
                        ActivateDic.Remove(Bubble);
                    }

                    AffectedBubblePosDic.Remove(Bubble);
                    PosList.Add(TeleportSlot2.Pos);

                    ChangedBubblePosDic[Bubble] = TeleportSlot2.Pos;

                    Teleport(TeleportSlot1.ConnectedBubble, TeleportSlot2, BubbleInflateMoveBlocked);
                }
                else
                {
                    TeleportSlotBlocked();
                }
            }
            else if (Slot2Active)
            {
                if (TeleportSlot1.InsideBubbleType == BubbleType.Null)
                {
                    GameObject Bubble = TeleportSlot2.ConnectedBubble;

                    if (ActivateDic.ContainsKey(Bubble))
                    {
                        ActivateDic.Remove(Bubble);
                    }

                    AffectedBubblePosDic.Remove(Bubble);
                    PosList.Add(TeleportSlot1.Pos);

                    ChangedBubblePosDic[Bubble] = TeleportSlot1.Pos;

                    Teleport(TeleportSlot2.ConnectedBubble, TeleportSlot1, BubbleInflateMoveBlocked);
                }
                else
                {
                    TeleportSlotBlocked();
                }
            }
        }
        else if (Slot1Active && Slot2Active)
        {
            TeleportSlotBlocked();
        }
    }
Ejemplo n.º 27
0
    private IEnumerator RollBack()
    {
        GameManager.levelState = LevelState.RollBack;

        List <BubbleChangeInfo> list = ChangeInfoList[ChangeInfoList.Count - 1];

        ParallelTasks RollBackTask = new ParallelTasks();

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].Placed)
            {
                switch (list[i].Type)
                {
                case BubbleType.Normal:
                    RollBackTask.Add(new DisappearTask(list[i].Bubble, RollBackTime / 2, list[i].To, Map, list[i].Type, true));
                    break;
                }

                if (Map[list[i].From.x][list[i].From.y].slotType == SlotType.Target)
                {
                    Map[list[i].From.x][list[i].From.y].Entity.GetComponent <TargetSlotObject>().SetBubbleInside(false);
                }

                Color color = list[i].UseableBubble.GetComponent <SpriteRenderer>().color;
                list[i].UseableBubble.SetActive(true);
                RollBackTask.Add(new ColorChangeTask(list[i].UseableBubble, Utility.ColorWithAlpha(color, 0), Utility.ColorWithAlpha(color, 1), RollBackTime / 2, ColorChangeType.Sprite));
            }
            else
            {
                if (list[i].From.x != list[i].To.x || list[i].From.y != list[i].To.y)
                {
                    SerialTasks serialTasks = new SerialTasks();
                    serialTasks.Add(new DisappearTask(list[i].Bubble, RollBackTime / 2, list[i].To, Map, list[i].Type, false));
                    serialTasks.Add(new TransformTask(list[i].Bubble, list[i].EndPos, list[i].BeginPos, 0));
                    serialTasks.Add(new AppearTask(list[i].Bubble, RollBackTime / 2, true, list[i].From, Map, list[i].Type));
                    RollBackTask.Add(serialTasks);

                    if (Map[list[i].To.x][list[i].To.y].slotType == SlotType.Target)
                    {
                        Map[list[i].To.x][list[i].To.y].Entity.GetComponent <TargetSlotObject>().SetBubbleInside(false);
                    }

                    if (Map[list[i].From.x][list[i].From.y].slotType == SlotType.Target)
                    {
                        Map[list[i].From.x][list[i].From.y].Entity.GetComponent <TargetSlotObject>().ClearInsideParticleInfo();
                        Map[list[i].From.x][list[i].From.y].Entity.GetComponent <TargetSlotObject>().SetBubbleInside(true);
                    }
                }
            }
        }


        while (!RollBackTask.IsFinished)
        {
            RollBackTask.Update();
            yield return(null);
        }


        ChangeInfoList.Remove(list);
        GameManager.levelState = LevelState.Play;
    }
Ejemplo n.º 28
0
    private IEnumerator LoadLevel(int index, LoadLevelType Type, GameObject LevelButton = null)
    {
        switch (Type)
        {
        case LoadLevelType.FromMainMenu:

            SetMainMenuEnable(false);

            ParallelTasks MainMenuDisappearTask = GetMainMenuDisappearTask(PlayButton);

            while (!MainMenuDisappearTask.IsFinished)
            {
                MainMenuDisappearTask.Update();
                yield return(null);
            }


            break;

        case LoadLevelType.FromSelectionMenu:

            BackButton.GetComponent <BoxCollider2D>().enabled = false;
            SetSelectLevelEnable(false);

            ParallelTasks LevelButtonDisappearTasks = new ParallelTasks();

            foreach (Transform child in AllLevelButtons.transform)
            {
                if (child.gameObject == LevelButton)
                {
                    LevelButtonDisappearTasks.Add(child.GetComponent <GameButton>().GetSelectedDisappearTask());
                }
                else
                {
                    LevelButtonDisappearTasks.Add(child.GetComponent <GameButton>().GetUnselectedDisappearTask());
                }
            }

            foreach (Transform child in LevelSelectionArrows.transform)
            {
                LevelButtonDisappearTasks.Add(child.GetComponent <GameButton>().GetUnselectedDisappearTask());
            }

            LevelButtonDisappearTasks.Add(BackButton.GetComponent <GameButton>().GetUnselectedDisappearTask());

            while (!LevelButtonDisappearTasks.IsFinished)
            {
                LevelButtonDisappearTasks.Update();
                yield return(null);
            }

            break;

        case LoadLevelType.LevelFinish:

            BackButton.GetComponent <BoxCollider2D>().enabled = false;

            levelState = LevelState.Clear;

            SerialTasks LevelEndTasks = new SerialTasks();

            LevelEndTasks.Add(GetLevelEndUITask(false));
            LevelEndTasks.Add(new WaitTask(PerformLevelFinishEffectWaitTime));
            LevelEndTasks.Add(GetBubblePowerUpTasks());
            LevelEndTasks.Add(GetShockWaveEmitAndFadeTasks());
            LevelEndTasks.Add(GetBubbleMoveOutPrepareTasks());

            while (!LevelEndTasks.IsFinished)
            {
                LevelEndTasks.Update();
                yield return(null);
            }

            LevelEndTasks.Clear();

            LevelEndTasks.Add(GetBubbleEscapeTasks());
            LevelEndTasks.Add(new WaitTask(StartNewLevelWaitTime));

            while (!LevelEndTasks.IsFinished)
            {
                LevelEndTasks.Update();
                yield return(null);
            }

            ClearUseableBubbles();

            break;
        }


        if (index <= MaxLevelIndex)
        {
            levelState = LevelState.SetUp;

            if (CurrentSaveInfo.CurrentLevel >= MinLevelIndex && Type == LoadLevelType.LevelFinish)
            {
                SortedLevelList[CurrentSaveInfo.CurrentLevel - MinLevelIndex].SetActive(false);
                Destroy(SortedLevelList[CurrentSaveInfo.CurrentLevel - MinLevelIndex]);
                SortedLevelList[CurrentSaveInfo.CurrentLevel - MinLevelIndex] = CopiedLevel;
            }

            CopiedLevel = Instantiate(SortedLevelList[index - MinLevelIndex]);
            CopiedLevel.transform.parent = AllLevel.transform;
            CopiedLevel.SetActive(false);
            SortedLevelList[index - MinLevelIndex].SetActive(true);
            ActivatedLevel = SortedLevelList[index - MinLevelIndex];

            if (Type == LoadLevelType.LevelFinish)
            {
                CurrentSaveInfo.LevelFinished[CurrentSaveInfo.CurrentLevel - 1] = true;
            }
            CurrentSaveInfo.CurrentLevel = index;
            SaveProgress();

            EventManager.instance.Fire(new LevelLoaded(CurrentSaveInfo.CurrentLevel));

            SerialTasks LevelStartUITasks = GetLevelStartTask();

            while (!LevelStartUITasks.IsFinished)
            {
                LevelStartUITasks.Update();
                yield return(null);
            }

            levelState = LevelState.Play;

            EventManager.instance.Fire(new FinishLoadLevel(CurrentSaveInfo.CurrentLevel));

            ParallelTasks BackButtonAppearTask = BackButton.GetComponent <GameButton>().GetAppearTask();

            while (!BackButtonAppearTask.IsFinished)
            {
                BackButtonAppearTask.Update();
                yield return(null);
            }

            BackButton.GetComponent <BoxCollider2D>().enabled = true;
        }
    }
Ejemplo n.º 29
0
    private IEnumerator BackToSelectionMenu()
    {
        gameState = GameState.SelectLevelMenu;

        BackButton.GetComponent <BoxCollider2D>().enabled = false;

        levelState = LevelState.Clear;

        SetLevelButtonColor();

        ParallelTasks ClearLevelTasks = new ParallelTasks();

        SerialTasks LevelEndUITask = GetLevelEndUITask(true);

        ClearLevelTasks.Add(LevelEndUITask);

        SerialTasks MapDisappearTask = ActivatedLevel.GetComponent <LevelManager>().GetMapDisappearTask();

        ClearLevelTasks.Add(MapDisappearTask);

        while (!ClearLevelTasks.IsFinished)
        {
            ClearLevelTasks.Update();
            yield return(null);
        }

        yield return(new WaitForSeconds(BackToMenuSelectionMenuAppearGap));

        ParallelTasks LevelButtonAppearTasks = new ParallelTasks();

        foreach (Transform child in AllLevelButtons.transform)
        {
            LevelButtonAppearTasks.Add(child.GetComponent <GameButton>().GetAppearTask());
        }

        foreach (Transform child in LevelSelectionArrows.transform)
        {
            LevelButtonAppearTasks.Add(child.GetComponent <GameButton>().GetAppearTask());
        }

        LevelButtonAppearTasks.Add(BackButton.GetComponent <GameButton>().GetAppearTask());

        while (!LevelButtonAppearTasks.IsFinished)
        {
            LevelButtonAppearTasks.Update();
            yield return(null);
        }

        BackButton.GetComponent <BoxCollider2D>().enabled = true;


        ClearUseableBubbles();

        SortedLevelList[CurrentSaveInfo.CurrentLevel - MinLevelIndex].SetActive(false);
        Destroy(SortedLevelList[CurrentSaveInfo.CurrentLevel - MinLevelIndex]);
        SortedLevelList[CurrentSaveInfo.CurrentLevel - MinLevelIndex] = CopiedLevel;

        gameState = GameState.SelectLevelMenu;

        SetSelectLevelEnable(true);
    }
Ejemplo n.º 30
0
    private IEnumerator BackToMainMenu(GameState OriginalState)
    {
        gameState = GameState.MainMenu;

        BackButton.GetComponent <BoxCollider2D>().enabled = false;

        switch (OriginalState)
        {
        case GameState.SelectLevelMenu:
            SetSelectLevelEnable(false);

            ParallelTasks SelectLevelDisappearTask = new ParallelTasks();

            foreach (Transform child in AllLevelButtons.transform)
            {
                SelectLevelDisappearTask.Add(child.GetComponent <GameButton>().GetUnselectedDisappearTask());
            }

            foreach (Transform child in LevelSelectionArrows.transform)
            {
                SelectLevelDisappearTask.Add(child.GetComponent <GameButton>().GetUnselectedDisappearTask());
            }

            SelectLevelDisappearTask.Add(BackButton.GetComponent <GameButton>().GetSelectedDisappearTask());

            while (!SelectLevelDisappearTask.IsFinished)
            {
                SelectLevelDisappearTask.Update();
                yield return(null);
            }
            break;

        case GameState.Info:
            ParallelTasks InfoDisappearTask = new ParallelTasks();

            InfoDisappearTask.Add(BackButton.GetComponent <GameButton>().GetSelectedDisappearTask());
            InfoDisappearTask.Add(Utility.GetTextDisappearTask(InfoText, ButtonUnselectedDisappearTime));

            while (!InfoDisappearTask.IsFinished)
            {
                InfoDisappearTask.Update();
                yield return(null);
            }

            break;

        case GameState.Setting:

            MusicMeterCursor.GetComponent <CircleCollider2D>().enabled       = false;
            SoundEffectMeterCursor.GetComponent <CircleCollider2D>().enabled = false;
            VibrationCheckBox.GetComponent <BoxCollider2D>().enabled         = false;

            SaveConfig();


            ParallelTasks SettingDisappearTask = new ParallelTasks();

            SettingDisappearTask.Add(BackButton.GetComponent <GameButton>().GetSelectedDisappearTask());

            SettingDisappearTask.Add(Utility.GetTextDisappearTask(MusicText, ButtonUnselectedDisappearTime));
            SettingDisappearTask.Add(Utility.GetTextDisappearTask(SoundEffectText, ButtonUnselectedDisappearTime));
            SettingDisappearTask.Add(Utility.GetTextDisappearTask(VibrationText, ButtonUnselectedDisappearTime));

            SettingDisappearTask.Add(Utility.GetImageDisappearTask(MusicMeter, ButtonUnselectedDisappearTime));
            SettingDisappearTask.Add(Utility.GetImageDisappearTask(MusicMeterCursor, ButtonUnselectedDisappearTime));
            SettingDisappearTask.Add(Utility.GetImageDisappearTask(SoundEffectMeter, ButtonUnselectedDisappearTime));
            SettingDisappearTask.Add(Utility.GetImageDisappearTask(SoundEffectMeterCursor, ButtonUnselectedDisappearTime));
            SettingDisappearTask.Add(Utility.GetImageDisappearTask(VibrationCheckBox, ButtonUnselectedDisappearTime));
            SettingDisappearTask.Add(Utility.GetImageDisappearTask(VibrationCheckMark, ButtonUnselectedDisappearTime));

            while (!SettingDisappearTask.IsFinished)
            {
                SettingDisappearTask.Update();
                yield return(null);
            }

            break;
        }



        ParallelTasks MainMenuAppearTask = new ParallelTasks();

        MainMenuAppearTask.Add(Utility.GetTextAppearTask(Title, ButtonAppearTime));

        MainMenuAppearTask.Add(PlayButton.GetComponent <GameButton>().GetAppearTask());
        MainMenuAppearTask.Add(SelectLevelButton.GetComponent <GameButton>().GetAppearTask());
        MainMenuAppearTask.Add(SettingButton.GetComponent <GameButton>().GetAppearTask());
        MainMenuAppearTask.Add(CreditButton.GetComponent <GameButton>().GetAppearTask());

        while (!MainMenuAppearTask.IsFinished)
        {
            MainMenuAppearTask.Update();
            yield return(null);
        }

        SetMainMenuEnable(true);
    }