示例#1
0
    public void BuyEnergy()
    {
        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        int gemucoins = GameManager.GEMUCOINS;

        GameManager.FREECOINS += currentShopContent.Amount;
        if (GameManager.FREECOINS > GameManager.MAX_FREECOIN_FROM_TIMER)
        {
            GameManager.FREECOINS = GameManager.MAX_FREECOIN_FROM_TIMER;
        }
        PlayerPrefs.SetInt("freecoins", GameManager.FREECOINS);

        gemucoins -= (int)currentShopContent.Price;
        PlayerPrefs.SetInt(PlayerPrefHandler.keyCoin, gemucoins);
        GameManager.GEMUCOINS = gemucoins;

        guiIngame.RefreshFreeEnergyInfo();
        GL1Connector.GetInstance().DecBalance(this.gameObject, currentShopContent.Price.ToString(), "", "CMENERGY" + currentShopContent.Amount.ToString());

        RefreshInfo();

        gs.ShowDialogBox("Info", "You just bought " + currentShopContent.Amount + " Energy", false, "confirm", this.gameObject);
    }
示例#2
0
    IEnumerator CheckFalling()
    {
        if (collider == null)
        {
            yield break;
        }
        bool bChecking = true;

        while (bChecking)
        {
            if (collider)
            {
                if (collider.transform.position.y < 5)
                {
                    //Debug.LogError("falling");
                    bChecking = false;
                }
            }
            else
            {
                bChecking = false;
            }
            yield return(new WaitForSeconds(1));
        }

        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").gameObject.GetComponent <Gamestate_Gameplay>();

        if (gs)
        {
            //gs.OnDropSuccess(this.gameObject);
        }
        GameObject.Destroy(collider.gameObject);
    }
示例#3
0
    public void OnClickButton()
    {
        UIButton button = UIButton.current;

        if (button == null)
        {
            return;
        }

        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs == null)
        {
            return;
        }

        for (int i = 0; i < gs.missions.Length; i++)
        {
            Mission mission = gs.missions[i];

            if (button.transform.parent.name.Equals(mission.name))
            {
                gs.PlayMission(mission);
                break;
            }
        }

        OnClickBack();
    }
    public override void OnShow()
    {
        Gamestate_Gameplay gs = (Gamestate_Gameplay)GameObject.FindGameObjectWithTag("Gamestate").gameObject.GetComponent <Gamestate_Gameplay> ();

        if (gs)
        {
            for (int i = 0; i < gs.categories.Length; i++)
            {
                Transform trCategory = panelContainer.transform.Find("cc." + i);
                if (trCategory)
                {
                    ContentCategory cat = (ContentCategory)gs.categories[i];

                    Transform trIconContainer = trCategory.Find("Sprite");
                    for (int j = 0; j < cat.contents.Length; j++)
                    {
                        Transform trItem = trIconContainer.transform.Find("Item" + (j + 1));
                        if (trItem)
                        {
                            int iAmount = 0;
                            if (PlayerPrefs.HasKey("cc." + i + "." + j))
                            {
                                iAmount = PlayerPrefs.GetInt("cc." + i + "." + j);
                            }
                            GameManager.SetNGUILabel(trItem.transform.Find("Label Amount"), iAmount.ToString());
                        }
                    }

                    GameManager.SetNGUILabel(trCategory.Find("Label Reward"), cat.bonus + " Energy " + cat.bonusEXP + " exp");

                    ActivateColliders(trCategory.gameObject, true);
                }
            }
        }
    }
示例#5
0
    void GiveCoinToUserAfterWatchingAds()
    {
        int jmlCoinsNow = PlayerPrefs.GetInt(PlayerPrefHandler.keyCoin);

        jmlCoinsNow += 1;
        PlayerPrefs.SetInt(PlayerPrefHandler.keyCoin, jmlCoinsNow);
        GameManager.GEMUCOINS = jmlCoinsNow;
        if (CoinTimerHandler.instance)
        {
            CoinTimerHandler.instance.countCoin = jmlCoinsNow;
        }


        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs)
        {
            gs.RefreshAllInfo();
            gs.guiIngame.guiShop.RefreshInfo();
        }
        dialogBox.Show("Info", "You got 1 GemuGold.", false, "", this.gameObject);

        /*GameDataManager.instance.SendPlayResult(
        *       GameDataManager.instance.gameID.ToString(),"0",
        *       jmlCoinsNow.ToString(),
        *       GameManager.EXP.ToString(),
        *       GameManager.getLevelValue().ToString());*/
        GL1Connector.GetInstance().AddBalance(this.gameObject, "", "1", "", "ADS");
    }
    public void OnClickAddFund()
    {
        GameManager.GEMUCOINS += 200;
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay>();

        gs.RefreshAllInfo();
        GUI_Dialog.ReleaseTopCanvas();
    }
示例#7
0
    public void OnClickGrab()
    {
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs)
        {
            gs.GrabObject();
        }
    }
示例#8
0
    void OnClick()
    {
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs)
        {
            gs.ShowNotImplemented();
        }
    }
示例#9
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector2    startPos = Input.mousePosition;
            RaycastHit hit;
            Camera     cam2D = Camera.allCameras [0];
            Ray        ray   = cam2D.ScreenPointToRay(startPos);

            if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerCamController))
            {
                bTouch  = true;
                prevPos = cam2D.WorldToScreenPoint(hit.point);
            }
        }

        if (bTouch && Input.GetMouseButtonUp(0))
        {
            Vector2    startPos = Input.mousePosition;
            RaycastHit hit;
            Camera     cam2D = Camera.allCameras [0];
            Ray        ray   = cam2D.ScreenPointToRay(startPos);

            if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerCamController))
            {
                Vector3 currPos = cam2D.WorldToScreenPoint(hit.point);
                if (Mathf.Abs(prevPos.x - currPos.x) > 40)
                {
                    int iDir = 0;
                    if (prevPos.x < currPos.x)
                    {
                        iDir = 1;
                    }
                    else if (prevPos.x > currPos.x)
                    {
                        iDir = -1;
                    }
                    Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay>();
                    if (gs)
                    {
                        gs.OnSwipe(iDir);
                    }
                }
                else
                {
                    bTouch = false;
                }
            }
            else
            {
                bTouch = false;
            }
        }
    }
示例#10
0
    public void onClickBuyButton(GameObject button)
    {
        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs == null)
        {
            return;
        }

        ShopContent content = button.GetComponent <ShopContent> ();

        if (content.type == ShopContentType.IAP)
        {
            if (PlayerPrefs.HasKey("joystick." + content.uniqueID) == true)
            {
                PlayerPrefs.SetString("playerjoy", content.uniqueID);
                gs.SetJoystick(content.uniqueID);
                refreshJoystickStatus(content);
            }
            else if (PlayerPrefs.HasKey("claw." + content.uniqueID) == true)
            {
                PlayerPrefs.SetString("playerclaw", content.uniqueID);
                gs.SetClaw(content.uniqueID);
                refreshClawStatus(content);
            }
            else
            {
                currShopContent = content;
                AndroidInAppPurchaseManager.instance.purchase(currShopContent.uniqueID);
                                #if UNITY_EDITOR
                Debug.Log("purchased " + currShopContent.Name);
                                #endif
            }
        }
        else if (content.type == ShopContentType.PowerUp)
        {
            int currCoins = GameManager.GEMUCOINS;

            if (currCoins - content.Price >= 0)
            {
                currShopContent = content;
                Debug.Log("purchased " + currShopContent.Name);
                //show dialog box buy confirmation
            }
            else
            {
                //show dialog box not enough coins
                Debug.Log("not enough coins");
            }
        }

        PlayerPrefs.Save();
    }
示例#11
0
 void OnTriggerEnter(Collider collider)
 {
     //Debug.LogError ("[TriggerHole] collider=" + collider.name);
     if (collider.gameObject.layer == GameManager.LayerContent)
     {
         Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").gameObject.GetComponent <Gamestate_Gameplay>();
         if (gs)
         {
             gs.OnDropSuccess(collider.gameObject);
         }
     }
 }
示例#12
0
    public void showTimerBox()
    {
        System.TimeSpan Dur = TimerHandler.instance.DurationLeft_FreeGift;

        Debug.Log("Duration:" + Dur);

        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        gs.ShowDialogBox("No Energy", setTimerString(Dur), false, "", this.gameObject);
    }
示例#13
0
    private void OnRatePopUpClose(AndroidDialogResult result)
    {
        switch (result)
        {
        case AndroidDialogResult.RATED:
            PlayerPrefs.SetInt(PlayerPrefHandler.keyRateUs, 1);
            buttonRateUs.gameObject.SetActive(false);
            int jmlCoinsNow = PlayerPrefs.GetInt(PlayerPrefHandler.keyCoin);
            jmlCoinsNow += 5;
            PlayerPrefs.SetInt(PlayerPrefHandler.keyCoin, jmlCoinsNow);

            GL1Connector.GetInstance().AddBalance(this.gameObject, "0", "5", "", "RATE");

            /*int jmlTiketNow = PlayerPrefs.GetInt(PlayerPrefHandler.keyUserTiket);
             * jmlTiketNow += 100;
             * PlayerPrefs.SetInt(PlayerPrefHandler.keyUserTiket, jmlTiketNow);*/

            if (CoinTimerHandler.instance)
            {
                CoinTimerHandler.instance.countCoin = jmlCoinsNow;
            }

            /*GameDataManager.instance.SendPlayResult(
            *       GameDataManager.instance.gameID.ToString(),"100",
            *       jmlCoinsNow.ToString(),
            *       GameManager.EXP.ToString(),
            *       GameManager.getLevelValue().ToString());*/

            Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay>();
            if (gs)
            {
                gs.RefreshAllInfo();
                gs.guiIngame.guiShop.RefreshInfo();
            }

            dialogBox.Show("Info", "You got 5 GemuGold.", false, "", this.gameObject);

            break;

        case AndroidDialogResult.REMIND:
            break;

        case AndroidDialogResult.DECLINED:
            break;
        }

        //AN_PoupsProxy.showMessage("Result", result.ToString() + " button pressed");
    }
示例#14
0
    IEnumerator Playing()
    {
        while (transition.IsDone == false)
        {
            yield return(null);
        }

        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs)
        {
            gs.gsMode = Gamestate_Mode.Gameplay;
            gs.StartGame();
        }
        yield break;
    }
示例#15
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector2    startPos = Input.mousePosition;
            RaycastHit hit;
            Camera     cam3D = Camera.allCameras [0];
            Ray        ray   = cam3D.ScreenPointToRay(startPos);

            if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerGrabButton))
            {
                bMouseOnObject = true;
            }
        }
        if (bMouseOnObject && Input.GetMouseButtonUp(0))
        {
            Vector2    startPos = Input.mousePosition;
            RaycastHit hit;
            Camera     cam3D = Camera.allCameras [0];
            Camera     cam2D = Camera.allCameras [1];
            Ray        ray   = cam3D.ScreenPointToRay(startPos);

            if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerGrabButton))
            {
                ray = cam2D.ScreenPointToRay(startPos);
                if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerGUI))
                {
                }
                else
                {
                    Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay>();
                    if (gs && gs.grabState == GrabState.None)
                    {
                        gs.GrabObject();
                        Vector3 pos = this.transform.position;
                        pos.y = initPosY - 0.2f;
                        this.transform.position = pos;
                    }
                }
                bMouseOnObject = false;
            }
            else
            {
                bMouseOnObject = false;
            }
        }
    }
    // Use this for initialization
    public override void OnStart()
    {
        Gamestate_Gameplay gs = (Gamestate_Gameplay)GameObject.FindGameObjectWithTag("Gamestate").gameObject.GetComponent <Gamestate_Gameplay> ();

        if (gs)
        {
            for (int i = 0; i < gs.categories.Length; i++)
            {
                ContentCategory cat = gs.categories[i].GetComponent <ContentCategory>();

                if (cat.ShowInUI)
                {
                    GameObject obInst = (GameObject)Instantiate(prefabContent);
                    obInst.name                    = "cc." + i;
                    obInst.transform.parent        = panelContainer.transform;
                    obInst.transform.localScale    = new Vector3(1, 1, 1);
                    obInst.transform.localPosition = new Vector3(i * scrollView.localSize.x, 120, 0);

                    GameManager.SetNGUILabel(obInst.transform.Find("Label Name"), cat.theName);
                    GameManager.SetNGUILabel(obInst.transform.Find("Label Hidden ID"), i.ToString());

                    Transform trIconContainer = obInst.transform.Find("Sprite");
                    for (int j = 0; j < cat.contents.Length; j++)
                    {
                        Transform trItem = trIconContainer.transform.Find("Item" + (j + 1));
                        if (trItem)
                        {
                            Transform trIcon  = trItem.transform.Find("Icon");
                            UITexture texture = trIcon.GetComponent <UITexture>();
                            texture.mainTexture = cat.contents[j].icon;

                            int iAmount = 0;
                            if (PlayerPrefs.HasKey("cc." + i + "." + j))
                            {
                                iAmount = PlayerPrefs.GetInt("cc." + i + "." + j);
                            }

                            //PlayerPrefs.SetInt("cc."+i+"."+j,1);
                            GameManager.SetNGUILabel(trItem.transform.Find("Label Amount"), iAmount.ToString());
                        }
                    }
                    ActivateColliders(obInst, false);
                }
            }
        }
    }
示例#17
0
    // Update is called once per frame
    public override void OnStart()
    {
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs)
        {
            int unlockedAmount = 0;
            for (int i = 0; i < gs.missions.Length; i++)
            {
                Mission    mission = gs.missions[i];
                GameObject obInst  = (GameObject)Instantiate(prefabContentAchievement);
                obInst.name                 = mission.name;
                obInst.transform.parent     = panelContainer.transform;
                obInst.transform.localScale = new Vector3(1, 1, 1);

                if (mission.missionType == Mission_Type.Tutorial)
                {
                    obInst.transform.localPosition = new Vector3(0, 260 - (iIndexMissionTutorial * 200), 0);
                    iIndexMissionTutorial++;
                }
                else
                {
                    obInst.transform.localPosition = new Vector3(0, 260 - (iIndexMissionProcedural * 200), 0);
                    iIndexMissionProcedural++;
                }
                UIDragScrollView scrollView = obInst.GetComponent <UIDragScrollView>();
                scrollView.scrollView = panelContainer.GetComponent <UIScrollView>();

                GameManager.SetNGUILabel(obInst.transform.Find("Label Name"), mission.MissionName);
                GameManager.SetNGUILabel(obInst.transform.Find("Label Desc"), mission.MissionDesc);
                GameManager.SetNGUILabel(obInst.transform.Find("Reward Coin Value"), mission.CoinReward.ToString());
                GameManager.SetNGUILabel(obInst.transform.Find("Reward Exp Value"), mission.ExpReward.ToString());

                Transform trButtonPlay = obInst.transform.Find("ButtonPlay");
                if (trButtonPlay)
                {
                    UIButton button = trButtonPlay.gameObject.GetComponent <UIButton>();
                    if (button)
                    {
                        button.onClick.Add(new EventDelegate(this, "OnClickButton"));
                    }
                }
            }
        }
    }
示例#18
0
    void OnClick()
    {
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs)
        {
            Transform trHiddenID = this.transform.parent.Find("Label Hidden ID");
            if (trHiddenID)
            {
                UILabel label = trHiddenID.gameObject.GetComponent <UILabel>();
                if (label)
                {
                    int index = int.Parse(label.text);

                    bool            bContinue = true;
                    ContentCategory cat       = (ContentCategory)gs.categories[index];
                    for (int j = 0; j < cat.contents.Length; j++)
                    {
                        int iPrizeAmount = 0;
                        if (PlayerPrefs.HasKey("cc." + index + "." + j))
                        {
                            iPrizeAmount = PlayerPrefs.GetInt("cc." + index + "." + j);
                        }

                        if (iPrizeAmount == 0)
                        {
                            bContinue = false;
                            break;
                        }
                    }

                    if (bContinue)
                    {
                        gs.OnClickBonusButton(index);
                    }
                    else
                    {
                        gs.ShowDialogBox("Info", "Not enough prize", false, "", this.gameObject);
                    }
                }
            }
        }
    }
示例#19
0
    public void OnClickBack()
    {
        if (powerUpAch)
        {
            powerUpAch = false;

            Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay> ();
            if (gs == null)
            {
                return;
            }

            //gs.achievementManager.OnAchievementEvent (AchievementType.PowerPlay, 1);
        }
        else
        {
            GUI_Dialog.ReleaseTopCanvas();
        }
    }
示例#20
0
    public void ProcessBuyPowerup()
    {
        powerUpAch = true;
        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        int gemucoins = GameManager.GEMUCOINS;

        gemucoins -= (int)currentShopContent.Price;
        PlayerPrefs.SetInt(PlayerPrefHandler.keyCoin, gemucoins);
        GameManager.GEMUCOINS = gemucoins;

        int    iAmount = 0;
        string sKey    = currentShopContent.name + "_Amount";

        if (PlayerPrefs.HasKey(sKey))
        {
            iAmount = PlayerPrefs.GetInt(sKey);
        }

        Debug.LogError("[GUI_Shop] sKey=" + sKey + " amount=" + iAmount);
        iAmount += currentShopContent.Amount;
        PlayerPrefs.SetInt(sKey, iAmount);
        Debug.LogError("[GUI_Shop] sKey=" + sKey + " amount=" + iAmount);
        guiIngame.RefreshPowerUpsInfo();
        guiIngame.RefreshGemuCoinInfo();
        RefreshInfo();
        //gs.achievementManager.OnAchievementEvent(AchievementType.PowerPlay,1);

        gs.ShowDialogBox("Info", "You just bought 1 " + currentShopContent.Name + " Power-Up", false, "confirmAch", null);
//		if ( PlayerPrefs.HasKey(sKey) )
//		{
//			iAmount = PlayerPrefs.GetInt(sKey);
//			Debug.LogError("[GUI_Shop] sKey="+sKey+" amount="+iAmount);
//		}

        GL1Connector.GetInstance().DecBalance(null, currentShopContent.Price.ToString(), "", "CMPOWERUP" + currentShopContent.Price.ToString());
    }
示例#21
0
    public void OnAchievementEvent(AchievementType type, int amount)
    {
        //Debug.LogError ("[AchievementManager] event=" + type.ToString () + " amount=" + amount);
        GameObject         gamestate = GameObject.FindGameObjectWithTag("Gamestate");
        Gamestate_Gameplay gameplay  = null;

        if (gamestate)
        {
            gameplay = gamestate.GetComponent <Gamestate_Gameplay> ();
        }

        for (int i = 0; i < achievements.Length; i++)
        {
            Achievement achievement = (Achievement)achievements[i];
            if (gameplay != null && type == achievement.type && achievement.amount == amount && !achievement.isUnlocked())
            {
//				Debug.LogError ("[AchievementManager] process event=" + type.ToString () + " amount=" + amount);
//
//				PlayerPrefs.SetInt("AC_"+achievement.id+"_"+achievement.amount,1);
//				gameplay.guiIngame.RefreshTicketInfo();
//
//				if(type == AchievementType.PowerPlay){
//					gameplay.guiAchievementUnlocked.ShowPowerPlay();
//				}
//				else
//					gameplay.guiAchievementUnlocked.Show(achievement.id,achievement.rewardAmount,achievement.rewardType);

//				if ( achievement.rewardType == AchievementReward.Ticket )
//				{
//					GameManager.TICKET += achievement.rewardAmount;
//					PlayerPrefs.SetInt("ticket",GameManager.TICKET);
//					GL1Connector.GetInstance().AddGameBalance(null,achievement.rewardAmount.ToString(),"","CMACHIEVE"+achievement.id);
//				}

//				switch(type){
//				case AchievementType.ShopTime:
//
//					break;
//
//				}
            }
            else
            {
                if (type == achievement.type)
                {
                    if (gameplay == null)
                    {
                        Debug.LogError("gameplay is null");
                    }
                    if (achievement.amount != amount)
                    {
                        Debug.LogError("amount is different");
                    }
                    if (achievement.isUnlocked() == false)
                    {
                        Debug.LogError("achievement has been unlocked");
                    }
                }
            }
        }
    }
    public void OnClickOK()
    {
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (sExec == "gotomainmenu")
        {
            if (gs)
            {
                gs.GoToMainMenu();
            }
        }
        else if (sExec == "logoutfb")
        {
            Debug.LogError("fb logout");
            //SPFacebook.instance.Logout();

            if (lastSender)
            {
                lastSender.SendMessage("OnFBLogout");
            }
        }
        else if (sExec == "redeemreward")
        {
            if (lastSender)
            {
                lastSender.SendMessage("OnConfirmRedeem");
            }
        }
        else if (sExec == "buyclaw")
        {
            if (gs)
            {
                gs.SendMissionEvent(Mission_Event.ShopBuyNewClaw);
            }
            if (lastSender)
            {
                lastSender.SendMessage("BuyClaw");
            }
        }
        else if (sExec == "buypowerup")
        {
            //ReleaseTopCanvas();
            lastSender.SendMessage("ProcessBuyPowerup");
        }
        else if (sExec == "buycoins")
        {
            lastSender.SendMessage("BuyCoins");
        }
        else if (sExec == "buyjoystick")
        {
            lastSender.SendMessage("BuyJoystick");
        }
        else if (sExec == "buyclaw")
        {
            lastSender.SendMessage("BuyClaw");
        }
        else if (sExec == "buyenergy")
        {
            lastSender.SendMessage("BuyEnergy");
        }
        else if (sExec == "confirmAch")
        {
            //ReleaseTopCanvas();
            if (gs == null)
            {
                return;
            }
            //gs.achievementManager.OnAchievementEvent(AchievementType.PowerPlay,1);
        }
        else if (sExec == "checkver0" || sExec == "checkver3")
        {
            Application.Quit();
        }
        else if (sExec == "checkver2")
        {
            Debug.Log("update");
            Application.OpenURL("https://play.google.com/store/apps/details?id=com.GameLevelOne.ClawMania");
            Application.Quit();
        }
        else if (sExec == "exitgame")
        {
            if (GameManager.separateAPKs)
            {
                Application.Quit();
            }
            else
            {
                if (gs)
                {
                    gs.BackToGemu();
                }
            }
        }
        else if (sExec == "levelup")
        {
            buttonShare.gameObject.SetActive(false);
            buttonInvite.gameObject.SetActive(false);
        }
        else if (sExec == "update")
        {
            Application.OpenURL("https://play.google.com/store/apps/details?id=com.GameLevelOne.ClawMania");
            Application.Quit();
        }
//		else if (sExec == "FreeEnergy") {
//			GUI_Shop.GetInstance().OnClickFreeEnergy();
//		}

        sExec      = "";
        lastSender = null;
        GUI_Dialog.ReleaseTopCanvas();
    }
示例#23
0
    /*
     * public void DeactivateSensors()
     * {
     *      for ( int i=0; i<hooks.Length; i++ )
     *      {
     *
     *              Hook hook = hooks[i];
     *              EnableCollider(hook.gameObject,false);
     *      }
     * }
     */

    public void SetListTrigger(ClawSensor sensor)
    {
        string sDebug = "[Pengait] SetListTrigger";

        if (sensor)
        {
            sDebug += "sensor=" + sensor.name + " collider=";
            if (sensor.currentCollider)
            {
                sDebug += " " + sensor.currentCollider.name;
            }
            else
            {
                sDebug += " NONE";
            }
        }
        //Debug.LogError (sDebug);
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs.grabState != GrabState.Grabbing)
        {
            return;
        }

        if (target != null)
        {
            return;
        }

        if (sensor == null)
        {
            return;
        }

        //Debug.LogError ("[Pengait] SetListTrigger:process");
        for (int i = 0; i < hooks.Length; i++)
        {
            if (hooks[i].gameObject == sensor.transform.parent.parent.parent.gameObject)
            {
                listTrigger[i] = sensor.currentCollider;
                break;
            }
        }

        bool       bAllTheSame = true;
        GameObject lastCheck   = null;

        for (int i = 0; i < listTrigger.Count; i++)
        {
            if (i == 0)
            {
                lastCheck = (GameObject)listTrigger[i];
            }
            else
            {
                if (listTrigger[i] == null)
                {
                    bAllTheSame = false;
                    break;
                }
                else if (listTrigger[i] != null && listTrigger[i] != lastCheck)
                {
                    bAllTheSame = false;
                    break;
                }
                lastCheck = (GameObject)listTrigger[i];
            }
        }

        if (bAllTheSame)
        {
            //Debug.LogError("all the same");
            DoneGrabbing = true;
            GameObject temp = ((GameObject)listTrigger[0]);
            SetTarget(temp);
            //Debug.LogError("done");
        }
    }
示例#24
0
    public override void OnShow()
    {
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs)
        {
            bool bAllTutorialDone = true;
            for (int i = 0; i < gs.missions.Length; i++)
            {
                Mission mission = gs.missions[i];
                if (mission.missionType == Mission_Type.Tutorial && PlayerPrefs.HasKey("mission." + mission.MissionName.Replace(" ", "")) == false)
                {
                    bAllTutorialDone = false;
                    break;
                }
            }

            Debug.LogError("bAllTutorialDone = " + bAllTutorialDone);
            for (int i = 0; i < gs.missions.Length; i++)
            {
                Mission mission = gs.missions[i];

                Transform trMissionContent = panelContainer.transform.Find(mission.name);
                if (trMissionContent)
                {
                    Transform trButtonPlay = trMissionContent.Find("ButtonPlay");
                    if (trButtonPlay)
                    {
                        trButtonPlay.gameObject.SetActive(true);
                        if (gs.currentMission && gs.currentMission.name.Equals(mission.name))
                        {
                            trButtonPlay.gameObject.SetActive(false);
                        }
                    }

                    if (mission.missionType == Mission_Type.Tutorial)
                    {
                        if (bAllTutorialDone == false)
                        {
                            trMissionContent.gameObject.SetActive(true);
                            if (PlayerPrefs.HasKey("mission." + mission.MissionName.Replace(" ", "")))
                            {
                                Transform trDone = trMissionContent.Find("InfoDone");
                                if (trDone)
                                {
                                    trDone.gameObject.SetActive(true);
                                }

                                if (trButtonPlay)
                                {
                                    trButtonPlay.gameObject.SetActive(false);
                                }
                            }
                        }
                        else
                        {
                            trMissionContent.gameObject.SetActive(false);
                        }
                    }
                    else if (mission.missionType == Mission_Type.Procedural)
                    {
                        //Debug.LogError("bMissionTutorialDone="+bMissionTutorialDone);
                        if (bAllTutorialDone == true)
                        {
                            trMissionContent.gameObject.SetActive(true);
                            if (trButtonPlay)
                            {
                                if (mission.missionEvent == Mission_Event.Prize)
                                {
                                    if (trButtonPlay.gameObject.activeInHierarchy)
                                    {
                                        int rnd = Random.Range(mission.Procedural_Min, mission.Procedural_Max);
                                        if (rnd == 0)
                                        {
                                            rnd = 1;
                                        }
                                        PlayerPrefs.SetInt(GameManager.PREF_PROCEDURAL_MISSION_PRIZE_AMOUNT, rnd);
                                        //PlayerPrefs.SetInt(GameManager.PREF_PROCEDURAL_MISSION_AMOUNT,1);

                                        GameManager.SetNGUILabel(trMissionContent.transform.Find("Label Desc"), "Collect " + rnd + " Prize");
                                    }
                                    else
                                    {
                                        GameManager.SetNGUILabel(trMissionContent.transform.Find("Label Desc"), "Collect " + PlayerPrefs.GetInt(GameManager.PREF_CURR_USER_PROCEDURAL_MISSION_PRIZE_AMOUNT) + "/" + PlayerPrefs.GetInt(GameManager.PREF_PROCEDURAL_MISSION_PRIZE_AMOUNT) + " Prize");
                                    }
                                }
                                else if (mission.missionEvent == Mission_Event.Coin)
                                {
                                    if (trButtonPlay.gameObject.activeInHierarchy)
                                    {
                                        int rnd = Random.Range(mission.Procedural_Min, mission.Procedural_Max);
                                        if (rnd == 0)
                                        {
                                            rnd = 1;
                                        }
                                        PlayerPrefs.SetInt(GameManager.PREF_PROCEDURAL_MISSION_COIN_AMOUNT, rnd);
                                        //PlayerPrefs.SetInt(GameManager.PREF_PROCEDURAL_MISSION_AMOUNT,1);
                                        GameManager.SetNGUILabel(trMissionContent.transform.Find("Label Desc"), "Collect " + rnd + " GemuGold");
                                    }
                                    else
                                    {
                                        GameManager.SetNGUILabel(trMissionContent.transform.Find("Label Desc"), "Collect " + PlayerPrefs.GetInt(GameManager.PREF_CURR_USER_PROCEDURAL_MISSION_COIN_AMOUNT) + "/" + PlayerPrefs.GetInt(GameManager.PREF_PROCEDURAL_MISSION_COIN_AMOUNT) + " GemuGold");
                                    }
                                }
                            }
                        }
                        else
                        {
                            trMissionContent.gameObject.SetActive(false);
                        }
                    }
                }
            }
            //labelInfo.text = unlockedAmount.ToString()+"/"+gs.achievementManager.achievements.Length;
        }
        panelContainer.ResetPosition();
    }
示例#25
0
    public void OnClickSpin()
    {
        currCoin  = GameManager.GEMUCOINS;
        currCoin -= 100;
        GameManager.GEMUCOINS = currCoin;
        PlayerPrefs.SetInt(PlayerPrefHandler.keyCoin, currCoin);

        GUI_InGame.instance.RefreshGemuCoinInfo();
        Debug.Log("spin gacha");

        int       itemWon = 0, contentChild = 0;
        Transform trChild;

        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        //play animation

        if (Random.value >= 0 && Random.value <= 0.1)
        {
            itemWon = Random.Range(0, 4);
        }
        else
        {
            itemWon = Random.Range(4, gachaList.Count);
        }

        gs.ShowDialogBox("Info", "You got " + gachaList [itemWon], false, "", this.gameObject);

        switch (itemWon)
        {
        case 0:
            contentChild = 1;
            trChild      = GUI_Shop.GetInstance().containerShopJoystick.transform.GetChild(contentChild);
            setShopItem(trChild, "joystick");
            break;

        case 1:
            contentChild = 2;
            trChild      = GUI_Shop.GetInstance().containerShopJoystick.transform.GetChild(contentChild);
            setShopItem(trChild, "joystick");
            break;

        case 2:
            contentChild = 1;
            trChild      = GUI_Shop.GetInstance().containerShopClaw.transform.GetChild(contentChild);
            setShopItem(trChild, "claw");
            break;

        case 3:
            contentChild = 2;
            trChild      = GUI_Shop.GetInstance().containerShopClaw.transform.GetChild(contentChild);
            setShopItem(trChild, "claw");
            break;

        case 4:
            contentChild = 0;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;

        case 5:
            contentChild = 1;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;

        case 6:
            contentChild = 2;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;

        case 7:
            contentChild = 3;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;

        case 8:
            contentChild = 4;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;
        }

        if (currCoin < 100)
        {
            buttonGachaActive.gameObject.SetActive(false);
            buttonGachaInactive.gameObject.SetActive(true);
        }
        else
        {
            buttonGachaActive.gameObject.SetActive(true);
            buttonGachaInactive.gameObject.SetActive(false);
        }
    }
示例#26
0
    // Update is called once per frame
    void Update()
    {
        if (!bTouch && Input.GetMouseButtonDown(0))
        {
            currType       = ControllerType.None;
            bTouch         = true;
            currTouchedObj = null;
            startPos       = Input.mousePosition;
            RaycastHit hit;

            Camera cam2D = Camera.allCameras [1];
            Ray    ray   = cam2D.ScreenPointToRay(startPos);

            if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerGUI))
            {
                //Debug.LogError("hit gui "+hit.collider.transform.parent.name+"."+hit.collider.name);
            }
            else
            {
                Camera cam3D = Camera.allCameras [0];
                ray = cam3D.ScreenPointToRay(startPos);
                if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerJoystickController))
                {
                    currType       = ControllerType.Joystick;
                    currTouchedObj = hit.collider.gameObject;
                }
                else if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerGrabButton))
                {
                    currType       = ControllerType.GrabButton;
                    currTouchedObj = hit.collider.gameObject;
                }
                else if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerCamController))
                {
                    currType       = ControllerType.Camera;
                    currTouchedObj = hit.collider.gameObject;
                }
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (currTouchedObj)
            {
                if (currType == ControllerType.Camera)
                {
                    Vector3 currPos = Input.mousePosition;

                    if (Mathf.Abs(startPos.x - currPos.x) > 40)
                    {
                        int iDir = 0;
                        if (startPos.x < currPos.x)
                        {
                            iDir = 1;                             //left
                        }
                        else if (startPos.x > currPos.x)
                        {
                            iDir = -1;                             //right
                        }
                        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay>();
                        if (gs)
                        {
                            gs.OnSwipe(iDir);
                        }
                    }
                }
                else if (currType == ControllerType.GrabButton)
                {
                    RaycastHit hit;

                    Camera cam3D = Camera.allCameras [0];
                    Ray    ray   = cam3D.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(ray, out hit, 1000.0f, 1 << GameManager.LayerGrabButton))
                    {
                        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay>();
                        if (gs)
                        {
                            gs.GrabObject();
                        }
                    }
                    else
                    {
                    }
                }
            }
            currType         = ControllerType.None;
            fPutJoyBackTimer = 0;
            vDir             = Vector3.zero;
            bTouch           = false;
            currTouchedObj   = null;
        }

        //Debug.LogError("touching "+Input.mousePosition);
        if (bTouch && currTouchedObj != null)
        {
            if (currType == ControllerType.Joystick)
            {
                Vector3 initPos = Input.mousePosition + new Vector3(-Screen.width * 0.5f, -Screen.height * 0.5f, 0);
                //debugSprite2.transform.localPosition = initPos ;
                Vector3 targetPos = Get2DPos(currTouchedObj.transform.position);
                Vector3 vDiff     = (targetPos - initPos);
                vDiff *= 0.01f;

                if (Mathf.Abs(vDiff.x) > 1)
                {
                    if (vDiff.x > 0)
                    {
                        vDiff.x = 1;
                    }
                    else if (vDiff.x < 0)
                    {
                        vDiff.x = -1;
                    }
                }

                if (Mathf.Abs(vDiff.y) > 1)
                {
                    if (vDiff.y > 0)
                    {
                        vDiff.y = 1;
                    }
                    else if (vDiff.y < 0)
                    {
                        vDiff.y = -1;
                    }
                }

                if (Mathf.Abs(vDiff.z) > 1)
                {
                    if (vDiff.z > 0)
                    {
                        vDiff.z = 1;
                    }
                    else if (vDiff.z < 0)
                    {
                        vDiff.z = -1;
                    }
                }

                Vector3 euler = obJoystick.transform.eulerAngles;
                euler.x = -vDiff.y * 30;
                euler.z = vDiff.x * 30;
                obJoystick.transform.eulerAngles = euler;
                //lastEuler = obJoystick.transform.eulerAngles;
                vDir = vDiff;
                //Debug.LogError("vDir="+vDir);
            }
        }
        if (obJoystick && bTouch == false)
        {
            obJoystick.transform.localEulerAngles = targetEuler;
            //Quaternion euler = obJoystick.transform.rotation;
            //obJoystick.transform.localEulerAngles = Vector3.Lerp(lastEuler,targetEuler,fPutJoyBackTimer);
            //fPutJoyBackTimer += Time.deltaTime;
        }
    }
示例#27
0
    public void OnClickFreeEnergy()
    {
        int watchCount = 0;

        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs == null)
        {
            return;
        }

        if (GameManager.FREECOINS >= 200)
        {
            //gs.ShowDialogBox("Info","Your energy is full",false,"energyFull",this.gameObject);
            Debug.Log("energy full");
        }
        else
        {
            if (TimerHandler.instance.FreeGiftAvailablilty())
            {
                Advertisement.Show(null, new ShowOptions {
                    resultCallback = result => {
                        Debug.Log(result.ToString());

                        switch (result)
                        {
                        case (ShowResult.Failed):
                            //gs.ShowDialogBox("Info","Ads Failed for some reason",false,"confirm",this.gameObject);
                            Debug.Log("ads failed");
                            break;

                        case (ShowResult.Skipped):
                            //gs.ShowDialogBox("Info","Ads Skipped. No energy added",false,"confirm",this.gameObject);
                            Debug.Log("ads skipped");
                            break;

                        case (ShowResult.Finished):


                            watchCount++;

                            if (watchCount >= 5)
                            {
                                watchCount = 0;
                                System.TimeSpan FreeGiftDuration    = TimeSpan.FromMinutes(20);
                                System.DateTime FreeGiftDurationEnd = System.DateTime.Now.Add(FreeGiftDuration);

                                PlayerPrefs.SetString(GamePreferences.Key_FreeGiftTimer, FreeGiftDurationEnd.ToBinary().ToString());

                                //gs.ShowDialogBox("Info","You got 20 energy",false,"confirm",this.gameObject);
                                Debug.Log("watched last ads");

                                PlayerPrefs.SetString(GamePreferences.Key_FreeGiftTimer, FreeGiftDurationEnd.ToBinary().ToString());
                                PlayerPrefs.Save();
                            }
                            else
                            {
                                //gs.ShowDialogBox("Info","You got 20 energy",false,"FreeEnergy",this.gameObject);
                                Debug.Log("got 20 energy");
                            }

                            GameManager.FREECOINS += 20;
//					guiIngame.RefreshFreeEnergyInfo();
//					guiIngame.RefreshGemuCoinInfo();
                            RefreshInfo();

                            //start the timer
//					System.TimeSpan FreeGiftDuration = TimerHandler.instance.FreeGiftExponentialTimer();

                            break;
                        }
                    }
                });
            }
            else
            {
                showTimerBox();
            }
        }
    }
示例#28
0
    public void OnClickShopContent()
    {
        UIButton button = UIButton.current;

        if (button == null)
        {
            return;
        }

        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        ShopContent content = button.transform.parent.gameObject.GetComponent <ShopContent> ();

        if (content.type == ShopContentType.IAP)
        {
            if (content.uniqueID == "freecoins")
            {
                GUI_Dialog.InsertStack(gemuFreeCoins.gameObject);
                //if ( GameDataManager.GetTimerToWatchAds() > GameDataManager.TIMER_TO_WATCH_ADS )
                //{
                //if (GameDataManager.PlayUnityVideoAd ()) {
                //	StartCoroutine(ShowingAds());
                //} else {
                //	gs.ShowDialogBox ("Info", "Please wait...", false, "", this.gameObject);
                //}
                //}
                //else
                //	gs.ShowDialogBox("Info","Please wait to watch the next ads.",false,"",this.gameObject);
            }
            else if (PlayerPrefs.HasKey("joystick." + content.uniqueID) == true)
            {
                PlayerPrefs.SetString("playerjoy", content.uniqueID);
                gs.SetJoystick(content.uniqueID);
                RefreshJoystickStatus();
            }
            else if (PlayerPrefs.HasKey("claw." + content.uniqueID) == true)
            {
                PlayerPrefs.SetString("playerclaw", content.uniqueID);
                gs.SetClaw(content.uniqueID);
                RefreshClawStatus();
            }
            else
            {
                currentShopContent = content;
                AndroidInAppPurchaseManager.instance.purchase(currentShopContent.uniqueID);
                //OnSuccessfulPurchase(currentShopContent.uniqueID);
            }
        }
        else if (content.type == ShopContentType.PowerUp)
        {
            int gemucoins = GameManager.GEMUCOINS;
            if (gemucoins - content.Price >= 0)
            {
                currentShopContent = content;
                gs.ShowDialogBox(content.Name, content.Desc + "\n\nDo you want to buy ?", true, "buypowerup", this.gameObject);
                //gs.achievementManager.OnAchievementEvent(AchievementType.PowerPlay,1);
            }
            else
            {
                gs.ShowDialogBox("Info", "Not enough coins", false, "confirm", this.gameObject);
            }
        }
        else if (content.type == ShopContentType.Claw)
        {
            if (PlayerPrefs.HasKey("claw." + content.uniqueID) == false)
            {
                int gemucoins = GameManager.GEMUCOINS;
                if (gemucoins - content.Price >= 0)
                {
                    //currentShopContent = content;
                    //gs.ShowDialogBox(content.Name,content.Desc+"Do you want to buy ?",true,"buyclaw",this.gameObject);
                    PlayerPrefs.SetString("playerclaw", content.uniqueID);
                    gs.SetClaw(content.uniqueID);
                    RefreshClawStatus();
                }
                else
                {
                    //gs.ShowDialogBox("Info","Not enough GemuGold",false,"confirm",this.gameObject);
                }
            }
            else
            {
                PlayerPrefs.SetString("playerclaw", content.uniqueID);
                gs.SetClaw(content.uniqueID);
                RefreshClawStatus();
            }
        }
        else if (content.type == ShopContentType.Joystick)
        {
            if (PlayerPrefs.HasKey("joystick." + content.uniqueID) == false)
            {
                int gemucoins = GameManager.GEMUCOINS;
                if (gemucoins - content.Price >= 0)
                {
                    //currentShopContent = content;
                    //gs.ShowDialogBox(content.Name,content.Desc+"Do you want to buy ?",true,"buyjoystick",this.gameObject);
                    PlayerPrefs.SetString("playerjoy", content.uniqueID);
                    gs.SetJoystick(content.uniqueID);
                    RefreshJoystickStatus();
                }
                else
                {
                    //gs.ShowDialogBox("Info","Not enough GemuGold",false,"confirm",this.gameObject);
                }
            }
            else
            {
                PlayerPrefs.SetString("playerjoy", content.uniqueID);
                gs.SetJoystick(content.uniqueID);
                RefreshJoystickStatus();
            }
        }
        else if (content.type == ShopContentType.FreeCoin)
        {
            int gemucoins = GameManager.GEMUCOINS;
            if (gemucoins - content.Price >= 0)
            {
                currentShopContent = content;
                gs.ShowDialogBox(content.Name, "Do you want to buy ?", true, "buyenergy", this.gameObject);
            }
            else
            {
                gs.ShowDialogBox("Info", "Not enough GemuGold", false, "confirm", this.gameObject);
            }
        }
        else
        {
            gs.ShowNotImplemented();
        }

        PlayerPrefs.Save();
    }