Exemplo n.º 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;
            }));
        }));
    }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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) => { });
            }
        }));
    }
Exemplo n.º 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) => { });
                }
            }));
        }
    }
Exemplo n.º 8
0
    public void ShareText(string text)
    {
#if UNITY_ANDROID
        AndroidNativeFunctions.ShareText(text, "", "Robo Flight");
#elif UNITY_IOS
        NativeShare.Share(text);
#endif
    }
Exemplo n.º 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);
     }
 }
Exemplo n.º 10
0
    private static void CreateGO()
    {
        if (instance != null)
        {
            return;
        }
        GameObject go = new GameObject("AndroidNativeFunctions");

        instance = go.AddComponent <AndroidNativeFunctions>();
    }
Exemplo n.º 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);
    }
Exemplo n.º 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);
    }
Exemplo n.º 13
0
 public void ShowInterstitial()
 {
     if (this.interstitial.IsLoaded())
     {
         this.interstitial.Show();
     }
     else
     {
         AndroidNativeFunctions.ShowToast("Interstitial is not ready yet");
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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");
        }
    }
Exemplo n.º 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());
         }
     }
 }
Exemplo n.º 21
0
    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();
        }));
    }
Exemplo n.º 22
0
 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);
         }
     }
 }
Exemplo n.º 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);
    }
Exemplo n.º 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);
     }
 }
Exemplo n.º 25
0
 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 !");
     }
 }
Exemplo n.º 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();
         }
     }
 }
Exemplo n.º 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) => { });
             }
         }));
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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");
            }
        }
Exemplo n.º 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");
                        }
                    }
                }
            }
        }
    }