示例#1
0
    public void ShowLastPlayedPuzzle()
    {
        int lastPuzzleID = ZPlayerPrefs.GetInt("LastPlayedPuzzle");

        if (lastPuzzleID == 0)
        {
            FollowMachine.SetOutput("No Last Puzzle");
            return;
        }

        Puzzle puzzle = LocalDBController.Table <Puzzle>().
                        SqlWhere(p => p.ID == lastPuzzleID).
                        FirstOrDefault();

        int?categoryID = puzzle?.CategoryID;

        if (categoryID != null)
        {
            int      id       = categoryID.Value;
            Category category =
                LocalDBController.
                Table <Category>().
                SqlWhere(c => c.ID == id).
                FirstOrDefault();

            Debug.Log(category.ID);
            PuzzleList.CategoryWindow.Select(category);
            FollowMachine.SetOutput("Play");
            return;
        }
        FollowMachine.SetOutput("No Last Puzzle");
    }
示例#2
0
    public void CheckWord()
    {
        if (_puzzleIndex > 1)
        {
            FollowMachine.SetOutput("Continue");
            return;
        }

        Word currentWord = Singleton
                           .Instance
                           .WordManager
                           .Words[CurrentWord];

        Debug.Log(currentWord.Name);

        bool correctWord = currentWord
                           .IsComplete;

        if (_break || !correctWord)
        {
            FollowMachine.SetOutput("Break");
            _break = true;
            return;
        }
        CurrentWord++;
        FollowMachine.SetOutput("NextWord");
    }
    private void CheckData()
    {
        var parts = Data.Split('&');

        if (parts.Length == 0)
        {
            FollowMachine.SetOutput("Unkown Command");
            return;
        }

        switch (parts[0])
        {
        case "sup":
            if (parts.Length != 3)
            {
                FollowMachine.SetOutput("Unkown Command");
                return;
            }

            PuzzleID = parts[1];
            UserID   = parts[2];

            FollowMachine.SetOutput("Show User Puzzle");
            break;

        default:
            FollowMachine.SetOutput("Unkown Command");
            break;
        }
    }
    public void GetDeepLinkInfo()
    {
        if (Application.platform == RuntimePlatform.Android)
        {
            AndroidJavaClass  UnityPlayer     = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = UnityPlayer.GetStatic <AndroidJavaObject>("currentActivity");

            AndroidJavaObject intent = currentActivity.Call <AndroidJavaObject>("getIntent");

            var action = intent.Call <string>("getAction");

            if (action.Contains("VIEW"))
            {
                Data = intent.Call <string>("getDataString");
                Data = Data.Split('?').Last();
                //"ShowPuzzle,u8217,hosein"

                CheckData();
            }
            else
            {
                FollowMachine.SetOutput("Normal");
            }
        }
        else
        {
            FollowMachine.SetOutput("Normal");
            //CheckData();
        }
    }
        private void CreateFollowMachine(Graph graph)
        {
            var bRect = _selectedNodes.BoundigRect();

            _fmNode =
                (FollowMachineNode)graph.Editor().Repository.CreateNode(
                    typeof(FollowMachineNode),
                    bRect.center);

            if (_fmNode != null)
            {
                _fMachine = graph.Editor().Repository.CreateFollowMachine("Follow Machine");

                _fmNode.FollowMachine = _fMachine;

                _inputNode = (InputNode)_fMachine.Editor().Repository.CreateNode(typeof(InputNode), bRect.center);


                _outputNode = (OutputNode)_fMachine.Editor().Repository.CreateNode(typeof(OutputNode), bRect.center);

                _inputNode.Editor().Move(Vector2.left * (bRect.width / 2 + 300));

                _outputNode.Editor().Move(Vector2.right * (bRect.width / 2 + 200));


                _fMachine.Position = graph.Position;
                _fMachine.Zoom     = graph.Zoom;

                _fmNode.Editor().OnShow();
            }
        }
 public void HasUserPuzzle()
 {
     FollowMachine.SetOutput(
         !LocalDBController.Table <UserPuzzle>().Any() &&
         LocalDBController.Table <PlayPuzzles>().Count() > 10 &&
         Random.Range(0, 100) > 70 ? "Yes" : "No");
 }
    public IEnumerator FeedBack(float star)
    {
        string s  = ((int)star).ToString();
        int?   id = Singleton.Instance.PlayerController.GetPlayerID;

        if (!id.HasValue)
        {
            FollowMachine.SetOutput("Fail");
            yield break;
        }

        string trim = ServerRespond["Creator"].ToString().Trim();

        if (LocalDBController.Table <PlayerInfo>().FirstOrDefault().Name.Trim() == trim)
        {
            FollowMachine.SetOutput("Fail");
            yield break;
        }

        yield return(ServerController
                     .Post <string>($@"PuzzleRates/RegisterFeedback?puzzleID={_pID}&playerID={id}&star={s}",
                                    null,
                                    r => { FollowMachine.SetOutput("Success"); },
                                    request => { FollowMachine.SetOutput(request.isNetworkError ? "Network Error" : "Fail"); }
                                    ));
    }
    public IEnumerator GetUserPuzzle(string puzzleID, string senderID)
    {
        ServerRespond = null;

        yield return(ServerController
                     .Post <string>($@"UserPuzzles/GetInviteData?puzzleID={puzzleID}&senderID={senderID}",
                                    null,
                                    r =>
        {
            ServerRespond = JObject.Parse(r);
            FollowMachine.SetOutput("Success");
        },
                                    request =>
        {
            if (request.isNetworkError)
            {
                FollowMachine.SetOutput("Network Error");
            }
            else
            {
                FollowMachine.SetOutput("Fail");
            }
        }
                                    ));
    }
    public void CheckPlayerInfo()
    {
        _playerInfo =
            LocalDBController
            .Table <PlayerInfo>()
            .FirstOrDefault();

        if (_playerInfo == null)
        {
            FollowMachine.SetOutput("No Player Info");
        }
        else if (_playerInfo.PlayerID == null || _playerInfo.PlayerID == -1)
        {
            if (_playerInfo.PlayerID == -1)
            {
                _playerInfo.PlayerID = null;
                LocalDBController.DeleteAll <PlayerInfo>();
                LocalDBController.InsertOrReplace(_playerInfo);
            }
            FollowMachine.SetOutput("No Player ID");
        }
        else
        {
            FollowMachine.SetOutput("Has Player ID");
        }
    }
示例#10
0
 public void Add(FollowMachine followmachine)
 {
     if (followmachine != null)
     {
         GraphList.Add(followmachine.GetInstanceID());
     }
     followmachine.Editor().OnShow();
 }
 private int GetAdjustedInsertIndex(Transform parent, FollowMachine machine, int insertIndex)
 {
     if (machine.transform.parent == parent && machine.transform.GetSiblingIndex() < insertIndex)
     {
         return(--insertIndex);
     }
     return(insertIndex);
 }
示例#12
0
        protected override IEnumerator Run()
        {
            FollowMachine.SetOutput("");

            Assinments.ForEach(a => a.Assign());

            return(null);
        }
示例#13
0
    public IEnumerator ShowAd()
    {
        _endShow = false;
        Tapsell.showAd(_adid, _showOptions);

        yield return(new WaitUntil(() => _endShow));

        FollowMachine.SetOutput(_completWatch ? "Rewarded": "Cancel");
    }
示例#14
0
 public void SharePuzzle(int?puzzleID)
 {
     if (!puzzleID.HasValue || Application.isEditor)
     {
         FollowMachine.SetOutput("NotOnline");
         return;
     }
     StartCoroutine(ShareUserPuzzle(puzzleID.Value));
 }
示例#15
0
 public void SelectMarket()
 {
     if (BazzarMarket)
     {
         FollowMachine.SetOutput("Bazaar");
         return;
     }
     FollowMachine.SetOutput("ZarrinPal");
 }
        protected override void SingleClickedItem(int id)
        {
            base.SingleClickedItem(id);
            FollowMachine machine = (FollowMachine)EditorUtility.InstanceIDToObject(id);

            if (machine)
            {
                Selection.activeGameObject = machine.gameObject;
            }
        }
 public void ListToShow()
 {
     if (LocalDBController.Table <Category>().SqlWhere(c => c.ParentID == SelectedCategory.ID).ToList().Count == 0)
     {
         FollowMachine.SetOutput("Puzzle List");
     }
     else
     {
         FollowMachine.SetOutput("Child Category List");
     }
 }
示例#18
0
        public override Node GetNextNode()
        {
            foreach (var socket in OutputSocketList)
            {
                if (FollowMachine.CheckOutputLable(socket.Info))
                {
                    return(socket.GetNextNode());
                }
            }

            return(null);
        }
示例#19
0
    public IEnumerator SetForSpawn(string ID)
    {
        if (ID.Length < 2)
        {
            FollowMachine.SetOutput("Fail");
            yield break;
        }

        int id = int.Parse(ID);

        yield return(SetForSpawn(id));
    }
    private void CheckData()
    {
        var parts = Data.Split('&');

        if (parts.Length == 0)
        {
            FollowMachine.SetOutput("Unkown Command");
            return;
        }

        switch (parts[0])
        {
        case "sup":
            if (parts.Length != 3)
            {
                FollowMachine.SetOutput("Unkown Command");
                break;
            }

            PuzzleID = parts[1];
            UserID   = parts[2];

            FollowMachine.SetOutput("Show User Puzzle");
            break;

        case "generatepuzzle":
            FollowMachine.SetOutput("Generate Puzzle");
            break;

        case "RegisterPhone":
            FollowMachine.SetOutput("Register Phone");
            break;

        case "getinvitereward":
            if (parts.Length != 3)
            {
                FollowMachine.SetOutput("Unkown Command");
                break;
            }

            InvitedUser  = parts[1];
            RewartAmount = int.Parse(parts[2]);
            FollowMachine.SetOutput("Unkown Command");
            break;
            FollowMachine.SetOutput("Get Invite Reward");
            StartCoroutine(ShowInviteRewardMessage(MessageWindow));
            break;

        default:
            FollowMachine.SetOutput("Unkown Command");
            break;
        }
    }
示例#21
0
    public IEnumerator ConnectToAccount()
    {
        AccountInfo accountInfo = null;

        // Ask command center to connect to account
        yield return(ServerController.Post <AccountInfo>(
                         $@"Account/ConnectToAccount?phoneNumber={_phoneNumber}",
                         null,
                         // On Successfully connect to the account
                         info => { accountInfo = info; },
                         // On Error
                         request =>
        {
            // Network Error !!!!!
            if (request.isNetworkError)
            {
                FollowMachine.SetOutput("Network Error");
            }

            // Account recovery Error !!!!
            else if (request.isHttpError)
            {
                FollowMachine.SetOutput("Account Error");
            }
        }));

        if (accountInfo != null)
        {
            // Restore player info
            Singleton.Instance.PlayerController
            .SetPlayerInfoAndSaveTolocalDB(accountInfo.PlayerInfo);

            // Restore play history
            PlayPuzzleController.Instance.RestorePlayHistory(accountInfo.PlayPuzzleses);

            // Restore purchases
            PurchaseController.Instance.RestorePurchase(accountInfo.Purchaseses);

            // Restore user puzzles
            UserPuzzleSynchronizer.Instance.RestoreUserPuzzles(accountInfo.UserPuzzles);

            // Set connection result to success


            ZPlayerPrefs.DeleteAll();

            StoreInventory.GiveItem("charsoo_coin", accountInfo.PlayerInfo.CoinCount);

            FollowMachine.SetOutput("Success");

            _phoneNumber = " ";
        }
    }
示例#22
0
    public void ShouldLike()
    {
        if (PlayerPrefs.GetInt("Liked", 0) == 0 &&
            LocalDBController.Table <PlayPuzzles>().Count() > 20 &&
            Random.Range(0.1f, 1f) > 0.5f &&
            GetComponent <CheckMarket>().BazzarMarket)
        {
            FollowMachine.SetOutput("Yes");
            return;
        }

        FollowMachine.SetOutput("No");
    }
示例#23
0
    public void PayCoins(int amount)
    {
        if (amount > _playerInfo.CoinCount)
        {
            FollowMachine.SetOutput("NotEnough");
            return;
        }
        StoreInventory.TakeItem("charsoo_coin", amount);

        SoundManager.PlayAudioClip(PayCoinAudioClip);

        FollowMachine.SetOutput("Payed");
    }
示例#24
0
    public void HasAccount()
    {
        PlayerInfo playerInfo = Singleton.Instance.PlayerController.PlayerInfo;

        if (playerInfo != null && playerInfo.HasAccount())
        {
            FollowMachine.SetOutput("Yes");
        }
        else
        {
            FollowMachine.SetOutput("No");
        }
    }
示例#25
0
    public IEnumerator ShareUserPuzzle(int puzzleID)
    {
        Vector2   screen  = new Vector2(Screen.width, Screen.height);
        PixleSize picSize = new PixleSize()
        {
            Input = Vector2.Scale(ScalerRect.size / 100, screen)
        };
        Rect rectToScreenShot =
            new Rect(
                Vector2.Scale(ScalerRect.position / 100, screen),
                picSize.Input
                );

        Texture2D screenShot = new Texture2D(picSize.X, picSize.Y, TextureFormat.RGB24, true);

        screenShot.ReadPixels(rectToScreenShot, 0, 0);
        screenShot.Apply();
        int random = Random.Range(1, 55465463);

        byte[] dataToSave  = screenShot.EncodeToJPG();
        string fileName    = "sharedpuzzle " + WordSpawner.Clue + random + ".jpg";
        string destination = Path.Combine(Application.persistentDataPath, fileName);


        if (File.Exists(destination))
        {
            File.Delete(destination);
        }

        while (File.Exists(destination))
        {
            yield return(new WaitForSeconds(0.1f));
        }

        File.WriteAllBytes(destination, dataToSave);

        while (!File.Exists(destination))
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Debug.Log(destination + "\n" + Application.persistentDataPath);

        string body = "حدس میزنم از حل کردن این جدول لذت ببری.\n خودم این جدول رو ساختم. امتحانش کن." +
                      "\n" +
                      "http://charsoog.ir/inapp.html?sup&" + puzzleID + "&" + PlayerController.PlayerID;

        NativeShare.Share(body, destination);
        FollowMachine.SetOutput("Success");
    }
示例#26
0
    public void CheckHintWord()
    {
        if (!_selectedWord)
        {
            FollowMachine.SetOutput("No");
            return;
        }

        if (_selectedWord.IsComplete)
        {
            FollowMachine.SetOutput("Yes");
            HideHintLetters();
        }
    }
示例#27
0
    public void CheckFinishGame()
    {
        foreach (Word word in Words)
        {
            if (!word.IsComplete)
            {
                FollowMachine.SetOutput("No");
                return;
            }
        }

        FollowMachine.SetOutput("Yes");

        OnEnd.Invoke();
    }
示例#28
0
    public void PuzzleSolved()
    {
        var puzzles = LocalDBController.Table <Puzzle>().
                      SqlWhere(p => p.CategoryID == _puzzle.CategoryID);

        Puzzle nextPuzzle = puzzles.FirstOrDefault(p => p.Row == _puzzleIndex);

        if (nextPuzzle == null || nextPuzzle.Solved)
        {
            FollowMachine.SetOutput("No Next Puzzle");
            return;
        }

        FollowMachine.SetOutput("Play Next");
    }
示例#29
0
    public void Search(List <Letter> letters, List <Letter> dropLetters, List <Word> words)
    {
        // Initialize
        FoundWords.Clear();
        FoundErrorWords.Clear();

        // create location dictionary
        _location = new Dictionary <Vector3, Letter>();
        letters.ForEach(l => _location.Add(l.transform.position, l));

        // discover complete words
        foreach (WordDirection direction in Enum.GetValues(typeof(WordDirection)))
        {
            for (var i = 0; i < letters.Count; i++)
            {
                var letter = letters[i];

                if (!IsStart(letter, direction))
                {
                    continue;
                }

                List <List <Letter> > foundLettersList = FindLettersList(letter, direction);

                foreach (var foundLetters in foundLettersList)
                {
                    if (dropLetters.Count > 0 && !foundLetters.Any(dropLetters.Contains))
                    {
                        continue;
                    }

                    if (!CheckCorrectWords(foundLetters, direction, words))
                    {
                        CheckErrorWords(foundLetters, direction, words);
                    }
                }
            }
        }

        if (FoundErrorWords.Count > 0 || FoundWords.Count > 0)
        {
            FollowMachine.SetOutput("Found");
        }
        else
        {
            FollowMachine.SetOutput("Not found");
        }
    }
    public void SpawnInvitedPuzzle()
    {
        var json = StringCompressor.DecompressString(ServerRespond["Content"].ToString());

        WordSet wordSet = new WordSet();

        JsonUtility.FromJsonOverwrite(json, wordSet);

        Singleton.Instance.WordSpawner.WordSet   = wordSet;
        Singleton.Instance.WordSpawner.Clue      = ServerRespond["Clue"].ToString();
        Singleton.Instance.WordSpawner.PuzzleID  = -1;
        Singleton.Instance.WordSpawner.PuzzleRow = ServerRespond["Creator"].ToString();

        Singleton.Instance.WordSpawner.EditorInstatiate = null;
        FollowMachine.SetOutput("Success");
    }