Example #1
0
    private Level CreateLevel()
    {
        Level level = new Level();

        level.ScoreFor1Star = 0;
        level.ScoreFor2Star = 0;
        level.ScoreFor3Star = 0;

        for (int i = 0; i < ParentObject.Background.transform.childCount; i++)
        {
            if (ParentObject.Background.transform.GetChild(i).gameObject.activeInHierarchy)
            {
                level.Place = ParentObject.Background.transform.GetChild(i).gameObject.name;
            }
        }
        for (int i = 0; i < ParentObject.Rubbish.transform.childCount; i++)
        {
            RubbishController controller = ParentObject.Rubbish.transform.GetChild(i).gameObject.GetComponent <RubbishController>();
            level.Rubbishes.Add(new Sampah(controller.PackageName, controller.Size, controller.transform.GetComponent <RectTransform>().localPosition, controller.Rotation, controller.RotationSpeed));
        }
        for (int i = 0; i < ParentObject.Barrier.transform.childCount; i++)
        {
            BarrierController controller = ParentObject.Barrier.transform.GetChild(i).gameObject.GetComponent <BarrierController>();
            level.Barriers.Add(new Penghalang(controller.PackageName, controller.Name, controller.transform.GetComponent <RectTransform>().localPosition, controller.Rotation, controller.RotationSpeed));
        }
        for (int i = 0; i < ParentObject.Bubble.transform.childCount; i++)
        {
            ItemGelembungController controller = ParentObject.Bubble.transform.GetChild(i).gameObject.GetComponent <ItemGelembungController>();
            level.Bubbles.Add(new Gelembung(controller.PackageName, controller.Type));
        }
        return(level);
    }
 private void DeactiveBubbleShooter()
 {
     if (this.isAllBubbleOut())
     {
         ShootButton.GetComponent <Button>().interactable = false;
         ShotButtonWhiteBubble.SetActive(false);
         ShotButtonRedBubble.SetActive(false);
         ShotButtonOrangeBubble.SetActive(false);
     }
     else
     {
         ShootButton.GetComponent <Button>().interactable = true;
         GameObject itemPreview = ParentObject.BubblePreview.transform.GetChild(0).gameObject;
         ItemGelembungController itemGelembungController = itemPreview.GetComponent <ItemGelembungController>();
         if (itemGelembungController.Type == BubbleType.White)
         {
             ShotButtonWhiteBubble.SetActive(true);
             ShotButtonRedBubble.SetActive(false);
             ShotButtonOrangeBubble.SetActive(false);
         }
         else if (itemGelembungController.Type == BubbleType.Red)
         {
             ShotButtonWhiteBubble.SetActive(false);
             ShotButtonRedBubble.SetActive(true);
             ShotButtonOrangeBubble.SetActive(false);
         }
         else if (itemGelembungController.Type == BubbleType.Orange)
         {
             ShotButtonWhiteBubble.SetActive(false);
             ShotButtonRedBubble.SetActive(false);
             ShotButtonOrangeBubble.SetActive(true);
         }
     }
 }
Example #3
0
    public void Ok()
    {
        BtnShoot.SetActive(true);
        isShowing = false;
        List <Gelembung> listOfBubbble = new List <Gelembung>();
        string           bubbleString  = "";

        for (int i = 0; i < bubblePreview.transform.childCount; i++)
        {
            ItemGelembungController controller = bubblePreview.transform.GetChild(i).gameObject.GetComponent <ItemGelembungController>();
            listOfBubbble.Add(new Gelembung(controller.PackageName, controller.Type));
            bubbleString += controller.Type.ToString();
        }
        string command = "{";

        command += "action:PlAY_LEVEL";
        command += ",place:" + dataLevel.Place;
        command += ",level:" + dataLevel.Level;
        command += ",bubbleUsed:" + bubbleString;
        command += ",status:CHOOSE_BUBBLE";
        command += "}";
        ServerStatistic.DoRequest(command);
        callback(listOfBubbble);
        GetComponent <Animator>().SetTrigger("Hide");
    }
 public void OnDrop(BaseEventData eventData)
 {
     for (int i = 0; i < BubblePreview.transform.childCount; i++)
     {
         DropBubbleHandler       dropHandler   = BubblePreview.transform.GetChild(i).GetComponent <DropBubbleHandler>();
         ItemGelembungController itemGelembung = BubblePreview.transform.GetChild(i).GetComponent <ItemGelembungController>();
         if (dropHandler && itemGelembung.Define == false)
         {
             dropHandler.OnDrop(eventData);
             break;
         }
     }
 }
Example #5
0
 public void BeUndefine()
 {
     if (chooseBubbleController)
     {
         ItemGelembungController itemGelembung = GetComponent <ItemGelembungController>();
         if (itemGelembung.Define)
         {
             itemGelembung.Define = false;
             itemGelembung.GetComponent <Image>().sprite = undefineSprite;
             if (itemGelembung.Type == BubbleType.White)
             {
                 chooseBubbleController.WhiteQuantity++;
             }
             else if (itemGelembung.Type == BubbleType.Red)
             {
                 chooseBubbleController.RedQuantity++;
             }
             else if (itemGelembung.Type == BubbleType.Orange)
             {
                 chooseBubbleController.OrangeQuantity++;
             }
         }
     }
     else if (reloadPopupController)
     {
         ItemGelembungController itemGelembung = GetComponent <ItemGelembungController>();
         if (itemGelembung.Define)
         {
             itemGelembung.Define = false;
             itemGelembung.GetComponent <Image>().sprite = undefineSprite;
             if (itemGelembung.Type == BubbleType.White)
             {
                 reloadPopupController.WhiteBubbleStock++;
             }
             else if (itemGelembung.Type == BubbleType.Red)
             {
                 reloadPopupController.RedBubbleStock++;
             }
             else if (itemGelembung.Type == BubbleType.Orange)
             {
                 reloadPopupController.OrangeBubbleStock++;
             }
         }
     }
 }
    public void Yes()
    {
        BtnShoot.SetActive(true);
        List <Gelembung> daftarGelembung = new List <Gelembung> ();

        for (int i = 0; i < PanelPreview.transform.childCount; i++)
        {
            ItemGelembungController controller = PanelPreview.transform.GetChild(i).gameObject.GetComponent <ItemGelembungController>();
            if (controller.Define)
            {
                daftarGelembung.Add(new Gelembung(controller.PackageName, controller.Type));
            }
        }

        UseBubble(daftarGelembung);
        callbackYes(daftarGelembung);
        Hide();
    }
Example #7
0
 public void Save()
 {
     if (fieldName.text != "")
     {
         loadingMessage.SetActive(true);
         if (dataLevel != null)
         {
             dataLevel.Name    = fieldName.text;
             dataLevel.Creator = "NED Studio";
             dataLevel.Bubbles.Clear();
             for (int i = 0; i < bubblePreview.transform.childCount; i++)
             {
                 ItemGelembungController controller = bubblePreview.transform.GetChild(i).gameObject.GetComponent <ItemGelembungController>();
                 dataLevel.Bubbles.Add(new Gelembung(controller.PackageName, controller.Type, controller.Define));
             }
             dataLevel.Save();
         }
         else if (dataStaticLevel != null)
         {
             dataStaticLevel.Name    = fieldName.text;
             dataStaticLevel.Creator = "NED Studio";
             dataStaticLevel.Bubbles.Clear();
             for (int i = 0; i < bubblePreview.transform.childCount; i++)
             {
                 ItemGelembungController controller = bubblePreview.transform.GetChild(i).gameObject.GetComponent <ItemGelembungController>();
                 dataStaticLevel.Bubbles.Add(new Gelembung(controller.PackageName, controller.Type, controller.Define));
             }
             dataStaticLevel.ScoreFor1Star = int.Parse(StarScoreField.Star1.text);
             dataStaticLevel.ScoreFor2Star = int.Parse(StarScoreField.Star2.text);
             dataStaticLevel.ScoreFor3Star = int.Parse(StarScoreField.Star3.text);
             dataStaticLevel.SaveLevel();
         }
         Application.LoadLevel(SceneName.LevelEditorCreate.ToString());
     }
     else
     {
         OnNameChange(fieldName.text);
     }
 }
 public bool PrepareShooting()
 {
     if (!isPreparation)
     {
         isPreparation = true;
         Size          = BubbleController.BubbleSize.One;
         ItemGelembungController itemGelembungController = BubbleStock.transform.GetChild(0).gameObject.GetComponent <ItemGelembungController>();
         if (itemGelembungController.Type == BubbleType.White)
         {
             BubblePreviewWhite.transform.localScale = Scale.One;
         }
         else if (itemGelembungController.Type == BubbleType.Red)
         {
             BubblePreviewRed.transform.localScale = Scale.One;
         }
         else if (itemGelembungController.Type == BubbleType.Orange)
         {
             BubblePreviewOrange.transform.localScale = Scale.One;
         }
         Invoke("NextBubble", transisionTime);
         return(true);
     }
     return(false);
 }
    public void DeleteCallback(ItemGelembungController itemGel)
    {
        if (itemGel.Type == BubbleType.White)
        {
            WhiteBubbleStock++;
            TextWhiteBubble.text = WhiteBubbleStock.ToString();
        }
        else if (itemGel.Type == BubbleType.Red)
        {
            RedBubbleStock++;
            TextRedBubble.text = WhiteBubbleStock.ToString();
        }
        else if (itemGel.Type == BubbleType.Orange)
        {
            OrangeBubbleStock++;
            TextOrangeBubble.text = WhiteBubbleStock.ToString();
        }

        ReloadButton.interactable = PanelPreview.transform.childCount > 0;

        WhiteBubbleButton.SetActive(!(WhiteBubbleStock == 0));
        RedBubbleButton.SetActive(!(WhiteBubbleStock == 0));
        OrangeBubbleButton.SetActive(!(WhiteBubbleStock == 0));
    }
    public void InstansiateBubble(BubbleController.BubbleSize size, Vector2 position)
    {
        GameObject itemPreview = ParentObject.BubblePreview.transform.GetChild(0).gameObject;
        ItemGelembungController itemGelembungController = itemPreview.GetComponent <ItemGelembungController>();

        for (int i = 0; i < Bubbles.Length; i++)
        {
            if (itemGelembungController.PackageName == Bubbles[i].PackageName)
            {
                if (itemGelembungController.Type == BubbleType.White)
                {
                    GameObject objek = (GameObject)Instantiate(Bubbles[i].White);
                    objek.transform.position = position;
                    objek.GetComponent <BubbleController>().Size = size;
                    objek.transform.SetParent(ParentObject.Bubble.transform);
                    Destroy(itemPreview);
                }
                else if (itemGelembungController.Type == BubbleType.Red)
                {
                    GameObject objek = (GameObject)Instantiate(Bubbles[i].Red);
                    objek.transform.position = position;
                    objek.GetComponent <BubbleController>().Size = size;
                    objek.transform.SetParent(ParentObject.Bubble.transform);
                    Destroy(itemPreview);
                }
                else if (itemGelembungController.Type == BubbleType.Orange)
                {
                    GameObject objek = (GameObject)Instantiate(Bubbles[i].Orange);
                    objek.transform.position = position;
                    objek.GetComponent <BubbleController>().Size = size;
                    objek.transform.SetParent(ParentObject.Bubble.transform);
                    Destroy(itemPreview);
                }
            }
        }
    }
    public void PrevBubble()
    {
        SizeInInt--;
        ItemGelembungController itemGelembungController = BubbleStock.transform.GetChild(0).gameObject.GetComponent <ItemGelembungController>();

        if (Size == BubbleController.BubbleSize.One)
        {
            if (itemGelembungController.Type == BubbleType.White)
            {
                BubblePreviewWhite.transform.localScale = Scale.One;
            }
            else if (itemGelembungController.Type == BubbleType.Red)
            {
                BubblePreviewRed.transform.localScale = Scale.One;
            }
            else if (itemGelembungController.Type == BubbleType.Orange)
            {
                BubblePreviewOrange.transform.localScale = Scale.One;
            }
        }
        else if (Size == BubbleController.BubbleSize.Two)
        {
            if (itemGelembungController.Type == BubbleType.White)
            {
                BubblePreviewWhite.transform.localScale = Scale.Two;
            }
            else if (itemGelembungController.Type == BubbleType.Red)
            {
                BubblePreviewRed.transform.localScale = Scale.Two;
            }
            else if (itemGelembungController.Type == BubbleType.Orange)
            {
                BubblePreviewOrange.transform.localScale = Scale.Two;
            }
        }
        else if (Size == BubbleController.BubbleSize.Three)
        {
            if (itemGelembungController.Type == BubbleType.White)
            {
                BubblePreviewWhite.transform.localScale = Scale.Three;
            }
            else if (itemGelembungController.Type == BubbleType.Red)
            {
                BubblePreviewRed.transform.localScale = Scale.Three;
            }
            else if (itemGelembungController.Type == BubbleType.Orange)
            {
                BubblePreviewOrange.transform.localScale = Scale.Three;
            }
        }
        else if (Size == BubbleController.BubbleSize.Four)
        {
            if (itemGelembungController.Type == BubbleType.White)
            {
                BubblePreviewWhite.transform.localScale = Scale.Four;
            }
            else if (itemGelembungController.Type == BubbleType.Red)
            {
                BubblePreviewRed.transform.localScale = Scale.Four;
            }
            else if (itemGelembungController.Type == BubbleType.Orange)
            {
                BubblePreviewOrange.transform.localScale = Scale.Four;
            }
        }
        else if (Size == BubbleController.BubbleSize.Five)
        {
            if (itemGelembungController.Type == BubbleType.White)
            {
                BubblePreviewWhite.transform.localScale = Scale.Five;
            }
            else if (itemGelembungController.Type == BubbleType.Red)
            {
                BubblePreviewRed.transform.localScale = Scale.Five;
            }
            else if (itemGelembungController.Type == BubbleType.Orange)
            {
                BubblePreviewOrange.transform.localScale = Scale.Five;
            }
        }

        if (Size != BubbleController.BubbleSize.One)
        {
            Invoke("PrevBubble", transisionTime);
        }
        else
        {
            Invoke("NextBubble", transisionTime);
        }
    }
Example #12
0
    public void OnDrop(BaseEventData eventData)
    {
        BeUndefine();

        if (chooseBubbleController)
        {
            ItemGelembungController itemGelembung = GetComponent <ItemGelembungController>();

            ItemGelembungController itemGelembungDragged = DragAndInstansiate.itemBeingDragged.GetComponent <ItemGelembungController>();
            if (itemGelembungDragged.Type == BubbleType.White && chooseBubbleController.WhiteQuantity > 0)
            {
                itemGelembung.Type        = itemGelembungDragged.Type;
                itemGelembung.PackageName = itemGelembungDragged.PackageName;
                itemGelembung.Define      = true;
                itemGelembung.GetComponent <Image>().sprite = itemGelembungDragged.GetComponent <Image>().sprite;
                chooseBubbleController.WhiteQuantity--;
                Destroy(DragAndInstansiate.itemBeingDragged);
                DragAndInstansiate.itemBeingDragged = null;
            }
            else if (itemGelembungDragged.Type == BubbleType.Red && chooseBubbleController.RedQuantity > 0)
            {
                itemGelembung.Type        = itemGelembungDragged.Type;
                itemGelembung.PackageName = itemGelembungDragged.PackageName;
                itemGelembung.Define      = true;
                itemGelembung.GetComponent <Image>().sprite = itemGelembungDragged.GetComponent <Image>().sprite;
                chooseBubbleController.RedQuantity--;
                Destroy(DragAndInstansiate.itemBeingDragged);
                DragAndInstansiate.itemBeingDragged = null;
            }
            else if (itemGelembungDragged.Type == BubbleType.Orange && chooseBubbleController.OrangeQuantity > 0)
            {
                itemGelembung.Type        = itemGelembungDragged.Type;
                itemGelembung.PackageName = itemGelembungDragged.PackageName;
                itemGelembung.Define      = true;
                itemGelembung.GetComponent <Image>().sprite = itemGelembungDragged.GetComponent <Image>().sprite;
                chooseBubbleController.OrangeQuantity--;
                Destroy(DragAndInstansiate.itemBeingDragged);
                DragAndInstansiate.itemBeingDragged = null;
            }
        }
        else if (reloadPopupController)
        {
            ItemGelembungController itemGelembung = GetComponent <ItemGelembungController>();

            ItemGelembungController itemGelembungDragged = DragAndInstansiate.itemBeingDragged.GetComponent <ItemGelembungController>();
            if (itemGelembungDragged.Type == BubbleType.White && reloadPopupController.WhiteBubbleStock > 0)
            {
                itemGelembung.Type        = itemGelembungDragged.Type;
                itemGelembung.PackageName = itemGelembungDragged.PackageName;
                itemGelembung.Define      = true;
                itemGelembung.GetComponent <Image>().sprite = itemGelembungDragged.GetComponent <Image>().sprite;
                reloadPopupController.WhiteBubbleStock--;
                Destroy(DragAndInstansiate.itemBeingDragged);
                DragAndInstansiate.itemBeingDragged = null;
            }
            else if (itemGelembungDragged.Type == BubbleType.Red && reloadPopupController.RedBubbleStock > 0)
            {
                itemGelembung.Type        = itemGelembungDragged.Type;
                itemGelembung.PackageName = itemGelembungDragged.PackageName;
                itemGelembung.Define      = true;
                itemGelembung.GetComponent <Image>().sprite = itemGelembungDragged.GetComponent <Image>().sprite;
                reloadPopupController.RedBubbleStock--;
                Destroy(DragAndInstansiate.itemBeingDragged);
                DragAndInstansiate.itemBeingDragged = null;
            }
            else if (itemGelembungDragged.Type == BubbleType.Orange && reloadPopupController.OrangeBubbleStock > 0)
            {
                itemGelembung.Type        = itemGelembungDragged.Type;
                itemGelembung.PackageName = itemGelembungDragged.PackageName;
                itemGelembung.Define      = true;
                itemGelembung.GetComponent <Image>().sprite = itemGelembungDragged.GetComponent <Image>().sprite;
                reloadPopupController.OrangeBubbleStock--;
                Destroy(DragAndInstansiate.itemBeingDragged);
                DragAndInstansiate.itemBeingDragged = null;
            }
        }
    }