Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
0
    public SerialTasks GetShockWavePowerUpTask()
    {
        SerialTasks PowerUpTask = new SerialTasks();

        PowerUpTask.Add(new ShockWavePowerUpTask(gameObject, PowerUpEffectPrefab, ShockWave, PowerUpSelfScale, PowerUpTime, PowerUpInterval, PowerUpNumber));
        PowerUpTask.Add(new WaitTask(PowerUpShockWaveGap));

        return(PowerUpTask);
    }
Ejemplo n.º 5
0
    private SerialTasks GetEnergyFillTask(GameObject Obj)
    {
        var Data = GetComponent <BubbleMotionData>();

        Color TargetColor = Data.DefaultEnergyColor;

        SerialTasks EnergyFillTask = new SerialTasks();

        EnergyFillTask.Add(new ColorChangeTask(Obj, Obj.GetComponent <Bubble>().NormalColor, TargetColor, Data.MotionTime / 2, ColorChangeType.Sprite));
        EnergyFillTask.Add(new ColorChangeTask(Obj, TargetColor, Obj.GetComponent <Bubble>().NormalColor, Data.MotionTime / 2, ColorChangeType.Sprite));

        return(EnergyFillTask);
    }
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
    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.º 8
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.º 9
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.º 10
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.º 11
0
    public SerialTasks GetMoveOutPrepareTask()
    {
        SerialTasks MoveOutPrepareTask = new SerialTasks();

        List <Vector2> IntersectionList  = new List <Vector2>();
        List <float>   IntersectionAngle = new List <float>();

        float halfheight = Camera.main.orthographicSize;
        float halfwidth  = Camera.main.orthographicSize * Camera.main.pixelWidth / Camera.main.pixelHeight;

        bool cut = transform.position.x + MoveOutMinDis > halfwidth;

        Utility.CircleGetIntersection(IntersectionList, transform.position, MoveOutMinDis, true, -halfwidth, -halfheight, halfheight);
        Utility.CircleGetIntersection(IntersectionList, transform.position, MoveOutMinDis, true, halfwidth, -halfheight, halfheight);
        Utility.CircleGetIntersection(IntersectionList, transform.position, MoveOutMinDis, false, -halfheight, -halfwidth, halfwidth);
        Utility.CircleGetIntersection(IntersectionList, transform.position, MoveOutMinDis, false, halfheight, -halfwidth, halfwidth);

        MoveOutBasicDirection = Utility.GetRandomDirectionOfCuttedCircle(IntersectionList, transform.position, cut);

        MoveOutPrepareTask.Add(new MoveOutBackAccelerationTask(gameObject, MoveBackDis, MoveBackTime, MoveOutBasicDirection, PowerUpSelfInflatedScale));
        MoveOutPrepareTask.Add(new MoveOutBackDecelerationTask(gameObject, MoveBackDis, MoveBackTime, MoveOutBasicDirection, PowerUpSelfInflatedScale));

        return(MoveOutPrepareTask);
    }
Ejemplo n.º 12
0
    public SerialTasks GetMoveOutEscapeTask()
    {
        SerialTasks MoveOutEscape = new SerialTasks();

        int layermask = 1 << LayerMask.NameToLayer("Border");

        RaycastHit2D Hit = Physics2D.Raycast(transform.position, MoveOutBasicDirection, RayDis, layermask);

        Vector2 StartPoint = transform.position;
        Vector2 EndPoint   = Hit.point;

        if (Hit.collider.gameObject.name == "Up" || Hit.collider.gameObject.name == "Down")
        {
            EndPoint += MoveOutBasicDirection * Mathf.Abs(1 / MoveOutBasicDirection.y) * Size / 2;
        }
        else
        {
            EndPoint += MoveOutBasicDirection * Mathf.Abs(1 / MoveOutBasicDirection.x) * Size / 2;
        }


        Vector2 MidPoint = Vector3.Lerp(StartPoint, EndPoint, Random.Range(MoveOutMidPointHorizontalPercentageMinMax.x, MoveOutMidPointHorizontalPercentageMinMax.y));

        if (Hit.collider.gameObject.name == "Up")
        {
            if (MoveOutBasicDirection.x > 0)
            {
                MidPoint += (Vector2)(Quaternion.Euler(0, 0, 90) * MoveOutBasicDirection) * Random.Range(MoveOutMidPointVerticalOffsetMinMax.x, MoveOutMidPointVerticalOffsetMinMax.y);
            }
            else
            {
                MidPoint += (Vector2)(Quaternion.Euler(0, 0, -90) * MoveOutBasicDirection) * Random.Range(MoveOutMidPointVerticalOffsetMinMax.x, MoveOutMidPointVerticalOffsetMinMax.y);
            }
        }
        else if (Hit.collider.gameObject.name == "Down")
        {
            if (MoveOutBasicDirection.x > 0)
            {
                MidPoint += (Vector2)(Quaternion.Euler(0, 0, -90) * MoveOutBasicDirection) * Random.Range(MoveOutMidPointVerticalOffsetMinMax.x, MoveOutMidPointVerticalOffsetMinMax.y);
            }
            else
            {
                MidPoint += (Vector2)(Quaternion.Euler(0, 0, 90) * MoveOutBasicDirection) * Random.Range(MoveOutMidPointVerticalOffsetMinMax.x, MoveOutMidPointVerticalOffsetMinMax.y);
            }
        }
        else if (Hit.collider.gameObject.name == "Left")
        {
            if (MoveOutBasicDirection.y > 0)
            {
                MidPoint += (Vector2)(Quaternion.Euler(0, 0, 90) * MoveOutBasicDirection) * Random.Range(MoveOutMidPointVerticalOffsetMinMax.x, MoveOutMidPointVerticalOffsetMinMax.y);
            }
            else
            {
                MidPoint += (Vector2)(Quaternion.Euler(0, 0, -90) * MoveOutBasicDirection) * Random.Range(MoveOutMidPointVerticalOffsetMinMax.x, MoveOutMidPointVerticalOffsetMinMax.y);
            }
        }
        else
        {
            if (MoveOutBasicDirection.y > 0)
            {
                MidPoint += (Vector2)(Quaternion.Euler(0, 0, -90) * MoveOutBasicDirection) * Random.Range(MoveOutMidPointVerticalOffsetMinMax.x, MoveOutMidPointVerticalOffsetMinMax.y);
            }
            else
            {
                MidPoint += (Vector2)(Quaternion.Euler(0, 0, 90) * MoveOutBasicDirection) * Random.Range(MoveOutMidPointVerticalOffsetMinMax.x, MoveOutMidPointVerticalOffsetMinMax.y);
            }
        }

        float MoveOutTime = Random.Range(MoveOutTimeMinMax.x, MoveOutTimeMinMax.y);

        MoveOutEscape.Add(new MoveOutEscapeTask(gameObject, StartPoint, EndPoint, MidPoint, MoveOutTime, MoveOutMaxTimeScale, MoveOutAcTimePercentage));

        return(MoveOutEscape);
    }
Ejemplo n.º 13
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.º 14
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.º 15
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.º 16
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;
    }