Пример #1
0
    public void JoinGame()
    {
        RoomInfo[] rooms = PhotonNetwork.GetRoomList();

        if (rooms.Length == 0)
        {
            Debug.Log("Room dos not exist");
        }
        else
        {
            foreach (RoomInfo room in rooms)
            {
                if (JoinedRoomName.text.Equals(room.Name))
                {
                    if (room.PlayerCount < room.MaxPlayers)
                    {
                        Debug.Log(room.PlayerCount);
                        currentroom.gameObject.SetActive(true);
                        menufindagame.gameObject.SetActive(false);
                        backbtn.gameObject.SetActive(false);
                        PhotonNetwork.JoinRoom(room.Name);
                    }
                    else
                    {
                        AndroidNativeFunctions.ShowToast("Room in max players !");
                        Debug.Log("Room in max players: " + room.PlayerCount);
                    }
                }
                else
                {
                    Debug.Log("Room dos not exist");
                }
            }
        }
    }
 public void OnClick_NotificationItem(int i)
 {
     AndroidNativeFunctions.ShowProgressDialog("Loading . . .");
     StartCoroutine(SeeOfferAPI(i.ToString(), action => {
         print(action.downloadHandler.text);
         var con                                = JsonUtility.FromJson <confirmation>(action.downloadHandler.text);
         numberOfTransaction                    = int.Parse(con.me.number);
         confirmation_OfferBookName.text        = con.offer.book_name;
         confirmation_OfferBookDescription.text = con.offer.description;
         confirmation_OfferName.text            = con.offer.name;
         confirmation_MeBookDescription.text    = con.me.description;
         confirmation_MeBookName.text           = con.me.book_name;
         StartCoroutine(LoadBookPicture(con.offer.image, pic => {
             var texture = DownloadHandlerTexture.GetContent(pic);
             confirmation_offerPicture.sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);
             StartCoroutine(LoadBookPicture(con.offer.user_image, pic2 => {
                 var texture1 = DownloadHandlerTexture.GetContent(pic2);
                 confirmation_userPicture.sprite = Sprite.Create(texture1, new Rect(0.0f, 0.0f, texture1.width, texture1.height), new Vector2(0.5f, 0.5f), 100.0f);
                 StartCoroutine(LoadBookPicture(con.me.image, pic3 => {
                     var texture2 = DownloadHandlerTexture.GetContent(pic3);
                     confirmation_mePicture.sprite = Sprite.Create(texture2, new Rect(0.0f, 0.0f, texture2.width, texture2.height), new Vector2(0.5f, 0.5f), 100.0f);
                     UIManager.ShowConfirmation();
                     AndroidNativeFunctions.HideProgressDialog();
                 }));
             }));
         }));
     }));
 }
    public void MakeMoneyPurchase(IndexData indexSelected)
    {
        int index = indexSelected.IndexValue;

        if (index < 0 || index >= prices.Count)
        {
            return;
        }

        var amountBought = prices[index].CoinAmount;

        // update the amount of potions the player has
        potionInstance.CoinAmount += amountBought;

        // setup an alert and say purchase has been made
        var message = "Thank you for your purchase you now have " + potionInstance.CoinAmount + " coins.";

        Debug.Log(message);

        // This is not my code, warpped in a try catch incase something fails
        try {
            AndroidNativeFunctions.ShowAlert(message: message, title: "Purchase Completed", positiveButton: "Ok", negativeButton: "", neutralButton: "", action: ShowAlertAction);
        } catch (System.Exception) {}

        coinAmountText.text = potionInstance.CoinAmount.ToString();
    }
    public void OnClick_MyBookSelfItem(int bookId)
    {
        TextButtonSelectBook.text = "Delete this book";
        AndroidNativeFunctions.ShowProgressDialog("Loading . . .");
        currentBookID = bookId;
        StartCoroutine(LoadBookDetail(bookId, action1 => {
            var bookDetail = JsonUtility.FromJson <BookData>(action1.downloadHandler.text);
            StartCoroutine(LoadBookPicture(bookDetail.image, action3 => {
                var texture = DownloadHandlerTexture.GetContent(action3);
                BookDetail_BookPicture.sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);
            }));
            BookDetail_BookName.text        = bookDetail.book_name;
            BookDetail_BookDescription.text = bookDetail.description;
            StartCoroutine(LoadUserProfile(int.Parse(bookDetail.user_creator), action2 => {
                print(action2.downloadHandler.text);
                var userProfile = JsonUtility.FromJson <UserProfile>(action2.downloadHandler.text);
                StartCoroutine(LoadBookPicture(userProfile.image, action3 => {
                    var texture = DownloadHandlerTexture.GetContent(action3);
                    BookDetail_ProfilePicture.sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);

                    AndroidNativeFunctions.HideProgressDialog();
                    UIManager.ShowBookDetail();
                }));
                BookDetail_ProfileName.text = userProfile.name;
            }));
        }));
    }
Пример #5
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         if (buffer)
         {
             Application.Quit();
         }
         else
         {
             AndroidNativeFunctions.ShowToast("Press again to exit");
             buffer = true;
             StartCoroutine(bufferTime());
         }
     }
     if (Input.touches.Length > 1)
     {
         Globals.paused = false;
         pauseBtn.image.overrideSprite = null;
     }
     if (Globals.paused)
     {
         pauseBtn.image.overrideSprite = resumeSprite;
     }
     else
     {
         pauseBtn.image.overrideSprite = null;
     }
 }
Пример #6
0
    public void Login()
    {
        var loginData = new LoginData()
        {
            login    = IF_Username.text,
            password = IF_Password.text
        };

        StartCoroutine(LoginAPI(loginData, res => {
            if (res.downloadHandler.text != null && res.responseCode == 200)
            {
                var userData = JsonUtility.FromJson <UserData>(res.downloadHandler.text);

                PlayerPrefs.SetString("token", res.GetResponseHeaders()["x-auth"]);
                PlayerPrefs.SetString("user_id", userData.user_id);
                PlayerPrefs.SetString("telephone", userData.telephone);
                PlayerPrefs.SetString("name", userData.name);
                PlayerPrefs.SetString("email", userData.email);
                PlayerPrefs.SetString("username", userData.username);

                OneSignal.SetEmail(userData.email);

                SceneManager.LoadScene("MainPage");
            }
            else if (res.responseCode == 400)
            {
                AndroidNativeFunctions.ShowAlert("Check your email or password and try again . . .",
                                                 "Error !",
                                                 "Ok", "", "",
                                                 (action) => { });
            }
        }));
    }
Пример #7
0
    public void Signup()
    {
        var data = new SignupData()
        {
            username  = Username.text,
            name      = Fullname.text,
            email     = Email.text,
            password  = Password.text,
            telephone = Telephone.text
        };

        if (Password.text == RePassword.text)
        {
            StartCoroutine(SignupAPI(data, res => {
                if (res.responseCode == 200)
                {
                    AndroidNativeFunctions.ShowAlert("We will send email to you, please confirm",
                                                     "Please follow instructer to reset your password",
                                                     "Ok", "", "",
                                                     (action) => { });
                    GameObject.Find("UIManager").GetComponent <LoginUIManager>().AnimateSigninGroup();
                }
                else if (res.responseCode == 400)
                {
                    AndroidNativeFunctions.ShowAlert("We will send email to you, please confirm",
                                                     "Please follow instructer to reset your password",
                                                     "Ok", "", "",
                                                     (action) => { });
                }
            }));
        }
    }
Пример #8
0
    public void ShareText(string text)
    {
#if UNITY_ANDROID
        AndroidNativeFunctions.ShareText(text, "", "Robo Flight");
#elif UNITY_IOS
        NativeShare.Share(text);
#endif
    }
Пример #9
0
 // Use this for initialization
 void Start()
 {
     if (PlayerPrefs.GetInt("kill") == 1)
     {
         AndroidNativeFunctions.ShowToast("You Lost ! Please remove your headset");
         PlayerPrefs.SetInt("kill", 0);
     }
 }
Пример #10
0
    private static void CreateGO()
    {
        if (instance != null)
        {
            return;
        }
        GameObject go = new GameObject("AndroidNativeFunctions");

        instance = go.AddComponent <AndroidNativeFunctions>();
    }
Пример #11
0
    private void FailCapturePhoto(string msg)
    {
#if PLATFORM_ANDROID
        AndroidNativeFunctions.ShowToast(msg);
#endif
        uiToBeHidden.SetActive(true);
        uiToBeHidden2.SetActive(true);
        uiToBeHidden3.SetActive(true);
        uiToBeShown.SetActive(false);
    }
Пример #12
0
    private void SuccessCapturePhoto(string msg)
    {
#if PLATFORM_ANDROID
        AndroidNativeFunctions.ShowToast("Photo Saved to Gallery");
#endif
        uiToBeHidden.SetActive(true);
        uiToBeHidden2.SetActive(true);
        uiToBeHidden3.SetActive(true);
        uiToBeShown.SetActive(false);
    }
Пример #13
0
 public void ShowInterstitial()
 {
     if (this.interstitial.IsLoaded())
     {
         this.interstitial.Show();
     }
     else
     {
         AndroidNativeFunctions.ShowToast("Interstitial is not ready yet");
     }
 }
Пример #14
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape) && exit == true)
     {
         Application.Quit();
     }
     else if (Input.GetKeyDown(KeyCode.Escape) && exit == false)
     {
         exit = true;
         AndroidNativeFunctions.ShowToast("Press back button again to exit");
         StartCoroutine(cancelExit());
     }
 }
 public void FindInternetMatch()
 {
     if (matchNameJoinInput.text.Equals(""))
     {
         AndroidNativeFunctions.ShowToast("Please enter name of room");
         print("matchNameJoinInput + faragh");
     }
     else
     {
         lobbyManager.StartMatchMaker();
         lobbyManager.matchMaker.ListMatches(0, 10, matchNameJoinInput.text, true, 0, 0, lobbyManager.OnMatchList);
     }
 }
Пример #16
0
 void OnCollisionEnter2D()
 {
     if (!shield)
     {
         if (PlayerPrefs.GetInt("VBR") == 1)
         {
             AndroidNativeFunctions.Vibrate(500);
         }
         Debug.Log("we got hit");
         FindObjectOfType <AudioManager>().Play("collision");
         FindObjectOfType <GameManager>().EndGame();
         collisionTime = (int)Time.time;
     }
 }
Пример #17
0
    void MovePlayer(Vector2 pos)
    {
        if (focus)
        {
            UnFocus();
        }
        StopCoroutine(StopMovement());
        StopCoroutine(Slash());
        StopCoroutine(Dash());
        // StopAllCoroutines();

        if (Player.GetComponent <PlayerAttribute>().EnoughStamina())
        {
            Player.GetComponent <PlayerAttribute>().Slash();
            bool tempIsRight = false;
            tempIsRight = (pos.x > Player.transform.position.x)?true:false;
            if (tempIsRight != isRight)
            {
                FlipPlayer();
            }

            DrawSlash(Player.GetComponent <PlayerAttribute>().PointSword.position, endPoint);
            Player.transform.position = endPoint;
            Player.GetComponent <PlayerAttribute>().CheckGroundManual();

            if (!Player.GetComponent <PlayerAttribute>().isGround)
            {
                StartCoroutine(StopMovement());
            }
            else
            {
                Rigidbody2D Rigid = Player.GetComponent <Rigidbody2D>();
                Player.GetComponent <PlayerAttribute>().gravityable = true;
                Rigid.constraints = RigidbodyConstraints2D.FreezeRotation;
            }

            if (enemy)
            {
                StartCoroutine(Slash());
            }
            else
            {
                StartCoroutine(Dash());
            }
        }
        else
        {
            AndroidNativeFunctions.ShowToast("Not Enough Stamina");
        }
    }
        public void OnClickCreateMatchmakingGame()
        {
            Debug.Log("Size selected" + roomSizeDropDown.value);
            switch (roomSizeDropDown.value)
            {
            case 0:
                roomSize = 8;
                break;

            case 1:
                roomSize = 10;
                break;

            case 2:
                roomSize = 12;
                break;

            case 3:
                roomSize = 14;
                break;
            }

            if (matchNameInput.text.Equals(""))
            {
                AndroidNativeFunctions.ShowToast("Please select Room Name");
                print("matchNameInput + faragh");
            }
            else
            {
                MenuFindAGame.SetActive(false);
                Debug.Log("CLICKED" + matchNameInput.text);
                Debug.Log("CLICKED" + roomSize);
                lobbyManager.StartMatchMaker();
                lobbyManager.matchMaker.CreateMatch(
                    matchNameInput.text,
                    (uint)roomSize,
                    true,
                    "", "", "", 0, 0,
                    lobbyManager.OnMatchCreate);

                lobbyManager.backDelegate   = lobbyManager.StopHost;
                lobbyManager._isMatchmaking = true;
                lobbyManager.DisplayIsConnecting();

                lobbyManager.SetServerInfo("Matchmaker Host", lobbyManager.matchHost);
                //NetManager.roomName = matchNameInput.text;
            }
        }
Пример #19
0
    public void Upgrade()
    {
        int poin = PlayerPrefs.GetInt("poin");

        if (poin > 0)
        {
            int level = PlayerPrefs.GetInt(key);
            PlayerPrefs.SetInt(key, level + 1);
            levelPoin.DecreesePoin();
            ShowLevel();
        }
        else
        {
            AndroidNativeFunctions.ShowToast("Not enough level poin");
        }
    }
Пример #20
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         if (buffer)
         {
             Application.Quit();
         }
         else
         {
             AndroidNativeFunctions.ShowToast("Press again to exit");
             buffer = true;
             StartCoroutine(bufferTime());
         }
     }
 }
    public void OnClick_MyBookItem(int bookId)
    {
        var OfferData = new offerData()
        {
            book_deal  = currentBookID.ToString(),
            book_offer = bookId.ToString(),
            user_deal  = currentUserID.ToString()
        };

        AndroidNativeFunctions.ShowProgressDialog("Loading . . .");
        StartCoroutine(SentOfferAPI(OfferData, action => {
            var TemList = new List <Transform>();
            int x       = MarketPage.childCount;
            for (int i = 0; i < x; i++)
            {
                TemList.Add(MarketPage.GetChild(i));
            }
            for (int i = 0; i < x; i++)
            {
                Destroy(TemList[i].gameObject);
            }
            TemList.Clear();
            x = MyBookPage.childCount;
            for (int i = 0; i < x; i++)
            {
                TemList.Add(MyBookPage.GetChild(i));
            }
            for (int i = 0; i < x; i++)
            {
                Destroy(TemList[i].gameObject);
            }
            TemList.Clear();
            x = MyBookSelectPage.childCount;
            for (int i = 0; i < x; i++)
            {
                TemList.Add(MyBookSelectPage.GetChild(i));
            }
            for (int i = 0; i < x; i++)
            {
                Destroy(TemList[i].gameObject);
            }
            LoadBook();
            UIManager.ShowDialog();

            AndroidNativeFunctions.HideProgressDialog();
        }));
    }
 private void Update()
 {
     if (timeToCloseApp > (Time.time - 1.2f))
     {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             Application.Quit();
         }
     }
     else
     {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             timeToCloseApp = Time.time;
             AndroidNativeFunctions.ShowToast("double tab to exit app . . .", true);
         }
     }
 }
Пример #23
0
    private static IEnumerator LoginAPI(LoginData loginData, Action <UnityWebRequest> callBack)
    {
        var request = new UnityWebRequest($"{Config.URL()}/users/login", "POST");

        request.uploadHandler   = new UploadHandlerRaw(new UTF8Encoding().GetBytes(JsonUtility.ToJson(loginData)));
        request.downloadHandler = new DownloadHandlerBuffer();
        request.SetRequestHeader("Content-Type", "application/json");

        request.SendWebRequest();
        AndroidNativeFunctions.ShowProgressDialog($"Loading . . .");
        while (!request.isDone)
        {
            yield return(null);
        }
        AndroidNativeFunctions.HideProgressDialog();

        callBack(request);
    }
Пример #24
0
 public void ClickPlay()
 {
     if (Application.internetReachability == NetworkReachability.NotReachable)
     {
         Debug.Log("Error. Check internet connection!");
         AndroidNativeFunctions.ShowToast("Please check your Internet connection!", false);
         //EditorUtility.DisplayDialog("Error", "Check internet connection!", "Ok");
     }
     else
     {
         menuplay.SetActive(true);
         bond.SetActive(true);
         play.SetActive(false);
         panel.SetActive(true);
         leaderboard.SetActive(false);
         options.SetActive(false);
     }
 }
 public void OnClick_SelectBook()
 {
     if (TextButtonSelectBook.text.Equals("Delete this book"))
     {
         AndroidNativeFunctions.ShowAlert("This action will delete your book information and orther people can't acess it", "Remove book from SwapBook", "Sure", "Cancel", "", action => {
             if (action == DialogInterface.Positive)
             {
                 StartCoroutine(DeleteBookAPI(currentBookID.ToString(), callback => {
                     var TemList = new List <Transform>();
                     int x       = MarketPage.childCount;
                     for (int i = 0; i < x; i++)
                     {
                         TemList.Add(MyBookPage.GetChild(i));
                     }
                     for (int i = 0; i < x; i++)
                     {
                         Destroy(TemList[i].gameObject);
                     }
                     TemList.Clear();
                     x = MyBookSelectPage.childCount;
                     for (int i = 0; i < x; i++)
                     {
                         TemList.Add(MyBookSelectPage.GetChild(i));
                     }
                     for (int i = 0; i < x; i++)
                     {
                         Destroy(TemList[i].gameObject);
                     }
                     LoadBook();
                     UIManager.HideBookDetail();
                 }));
             }
         });
         return;
     }
     if (int.Parse(MyBookNumber.text) > 0)
     {
         UIManager.OnClick_Offer();
     }
     else
     {
         AndroidNativeFunctions.ShowToast("Your don't have any book to swap !");
     }
 }
Пример #26
0
 //PlayerName
 public void ChangeName()
 {
     if (PlayerName.text.Equals(""))
     {
         AndroidNativeFunctions.ShowToast("Name is required");
     }
     else if (PlayerName.text.Length < 4)
     {
         AndroidNativeFunctions.ShowToast("Name is too Short");
     }
     else
     {
         foreach (var item in l)
         {
             if (item.Equals(PlayerName.text))
             {
                 ok = false;
                 break;
             }
             else
             {
                 ok = true;
             }
         }
         if (!ok)
         {
             Debug.Log("Name already exist");
             AndroidNativeFunctions.ShowToast("Name already exist");
         }
         else
         {
             PhotonNetwork.playerName = PlayerName.text;
             nameplayer = PlayerName.text;
             GameObject lobbyCanvasObj = MainCanvasManager.Instance.CurrentRoomCanvas.gameObject;
             if (lobbyCanvasObj == null)
             {
                 return;
             }
             CurrentRoomCanvas lobbyCanvas = lobbyCanvasObj.GetComponent <CurrentRoomCanvas>();
             lobbyCanvas.OnReadyButton();
         }
     }
 }
Пример #27
0
 public void ForgotPassword()
 {
     if (IF_Email.text != null)
     {
         StartCoroutine(ForgetAPI(IF_Email.text, res => {
             if (res.responseCode == 200)
             {
                 AndroidNativeFunctions.ShowAlert("We will send email to you, please confirm",
                                                  "Please follow instructer to reset your password",
                                                  "Ok", "", "",
                                                  (action) => { });
             }
             else if (res.responseCode == 400 || res.downloadHandler.text == null)
             {
                 AndroidNativeFunctions.ShowAlert("Check your email and try again . . .",
                                                  "ERROR !",
                                                  "Ok", "", "",
                                                  (action) => { });
             }
         }));
     }
 }
Пример #28
0
 public void StartGame()
 {
     FindObjectOfType <AudioManager>().Play("button");
     //set the name
     UserName = UserInput.text;
     //only for debugging:
     Debug.Log("UserName: "******"UserInput.text: " + UserInput.text);
     if (UserInput.text == "")
     {
         AndroidNativeFunctions.ShowAlert("you forgot to type your name :(", "whats your name?", "ok", "", "", action);
         //only for debugging:
         //UserName = "******";
         //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
     }
     else
     {
         PlayerPrefs.SetString("UserName", UserName);
         //move to GamePlay scene
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
     }
 }
Пример #29
0
        public override void OnMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matches)
        {
            base.OnMatchList(success, extendedInfo, matches);
            if (success)
            {
                if (matches.Count != 0)
                {
                    //Debug.Log("A list of matches was returned");

                    //join the last server (just in case there are two...)
                    MenuFindAGame.SetActive(false);
                    LobbyManager.singleton.matchMaker.JoinMatch(matches[matches.Count - 1].networkId, "", "", "", 0, 0, OnMatchJoined);
                }
                else
                {
                    AndroidNativeFunctions.ShowToast("No matches in requested room!");
                    Debug.Log("No matches in requested room!");
                }
            }
            else
            {
                Debug.LogError("Couldn't connect to match maker");
            }
        }
Пример #30
0
    public void OnClick_CreateRoom()
    {
        Debug.Log("Size selected" + roomSizeDropDown.value);
        switch (roomSizeDropDown.value)
        {
        case 0:
            roomSize = 8;
            break;

        case 1:
            roomSize = 10;
            break;

        case 2:
            roomSize = 12;
            break;

        case 3:
            roomSize = 14;
            break;
        }
        //MaxPlayers = (byte)roomSize
        RoomOptions roomOptions = new RoomOptions()
        {
            IsVisible = true, IsOpen = true, MaxPlayers = 3
        };

        RoomInfo[] rooms = PhotonNetwork.GetRoomList();
        if (RoomName.text.Equals(""))
        {
            AndroidNativeFunctions.ShowToast("Please select Room Name");
            print("matchNameInput + faragh");
        }
        else
        {
            if (rooms.Length == 0)
            {
                Debug.Log("Room dos not exist");

                if (PhotonNetwork.CreateRoom(RoomName.text, roomOptions, TypedLobby.Default))
                {
                    print("create room successfully sent.");
                    currentroom.gameObject.SetActive(true);
                    menufindagame.gameObject.SetActive(false);
                    backbtn.gameObject.SetActive(false);
                }
                else
                {
                    print("create room failed to send");
                }
            }
            else
            {
                foreach (RoomInfo room in rooms)
                {
                    if (RoomName.text.Equals(room.Name))
                    {
                        AndroidNativeFunctions.ShowToast("This room exists !");
                        Debug.Log("This room exists !");
                        break;
                    }
                    else
                    {
                        if (PhotonNetwork.CreateRoom(RoomName.text, roomOptions, TypedLobby.Default))
                        {
                            print("create room successfully sent.");
                            currentroom.gameObject.SetActive(true);
                            menufindagame.gameObject.SetActive(false);
                            backbtn.gameObject.SetActive(false);
                        }
                        else
                        {
                            print("create room failed to send");
                        }
                    }
                }
            }
        }
    }