Beispiel #1
0
        private async void RemoveExecute()
        {
            Int64 startTicks = Log.VIEWMODEL("(ToyDetailViewModel) Enter", Common.LOG_CATEGORY);

            var isReferenced =
                await _ToyDataService.IsReferencedByCatAsync(SelectedToy.Id);

            if (isReferenced)
            {
                var message = $"The Cat ({SelectedToy.Name})" +
                              " can't be removed;  It is referenced by at least one Cat";

                DialogService.Show("NotificationDialog", new DialogParameters($"message={message}"), r =>
                {
                });

                return;
            }

            SelectedToy.PropertyChanged -= Wrapper_PropertyChanged;
            _ToyDataService.Remove(SelectedToy.Model);
            Toys.Remove(SelectedToy);
            SelectedToy = null;
            HasChanges  = _ToyDataService.HasChanges();

            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();

            Log.VIEWMODEL("(ToyDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #2
0
 void OnScan(ToyWrapper toy, bool TLL)
 {
     if (allowNewPlayer)
     {
         LoadingWheel.gameObject.SetActive(false);
         playerStorage   = new Player(toy);
         newActivePlayer = true;
     }
 }
Beispiel #3
0
    public static ToyWrapper FromToy(BitToys.Toy toy)
    {
        ToyWrapper tw = new ToyWrapper();

        tw.bitToysId  = toy.bitToysId;
        tw.styleId    = toy.styleId;
        tw.ownerId    = toy.ownerId;
        tw.skuId      = toy.skuId;
        tw.customData = new LiteralCustomData(toy.customData);

        return(tw);
    }
Beispiel #4
0
    public static ToyWrapper EmulateToy(string bitToysId, string styleId, string ownerId, string skuId)
    {
        ToyWrapper tw = new ToyWrapper();

        tw.bitToysId  = bitToysId;
        tw.styleId    = styleId;
        tw.ownerId    = ownerId;
        tw.skuId      = skuId;
        tw.customData = new EmulatedCustomData(bitToysId);

        return(tw);
    }
Beispiel #5
0
    public static Player RegisterPlayer(ToyWrapper toy, string username, int team, ShardColor aff)
    {
        Player player = new Player(toy);

        toy.customData.SetString("username", username);
        toy.customData.SetBool("registered", true);

        toy.customData.SetInt("affinity", (int)aff);

        toy.customData.SendAsync();

        return(player);
    }
Beispiel #6
0
    void OnClaim(ToyWrapper toy, bool TLL)
    {
        if (toy.customData.GetBool_Global("installed", false) == false)
        {
            toy.customData.SetInt_Global("Blue_score", 15);
            toy.customData.SetInt_Global("Red_score", 5);
            toy.customData.SetInt_Global("Yellow_score", 30);

            toy.customData.SetBool_Global("installed", true);
        }

        if (toy.customData.GetBool("registered", false) == false)
        {
            if (toy.styleId == "dtc_trex00")
            {
                toy.customData.SetString("username", "Jacob");
                toy.customData.SetInt("score", 15);
                toy.customData.SetString("team", "Yellow");
            }
            else if (toy.styleId == "dtc_lexov00")
            {
                toy.customData.SetString("username", "Geoffrey");
                toy.customData.SetInt("score", 15);
                toy.customData.SetString("team", "Yellow");
            }
            else if (toy.styleId == "dtc_ttops00")
            {
                toy.customData.SetString("username", "Jeffrey");
                toy.customData.SetInt("score", 15);
                toy.customData.SetString("team", "Blue");
            }
            else if (toy.styleId == "dtc_paras00")
            {
                toy.customData.SetString("username", "Doug");
                toy.customData.SetInt("score", 5);
                toy.customData.SetString("team", "Red");
            }

            toy.customData.SetBool("registered", true);
        }

        string username   = toy.customData.GetString("username", "DEFAULT_USER_ERROR");
        int    score      = toy.customData.GetInt("score", -1);
        string team       = toy.customData.GetString("team", "DEFAULT_TEAM_ERROR");
        int    team_score = toy.customData.GetInt_Global(team + "_score", -1);

        text.text  = "Welcome, " + username + ". You're score is: " + score + "\n";
        text.text += "You're team, " + team + ", has " + team_score + " points.";
    }
Beispiel #7
0
        void AddExecute()
        {
            Int64 startTicks = Log.VIEWMODEL("(ToyDetailViewModel) Enter", Common.LOG_CATEGORY);

            var wrapper = new ToyWrapper(new Domain.Toy());

            wrapper.PropertyChanged += Wrapper_PropertyChanged;

            _ToyDataService.Add(wrapper.Model);
            Toys.Add(wrapper);

            wrapper.Name = "";  // Trigger the validation

            Log.VIEWMODEL("(ToyDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #8
0
    void OnClaimToy(ToyWrapper toy, bool TLL)
    {
        if (clearChip)
        {
            clearChip = false;
            toy.customData.SetBool("registered", false);
            toy.customData.SendAsync();

            UnlockUI();
        }
        else if (fullClearChip)
        {
            // fullClearChip = false;
            toy.customData.FullClear();
            toy.customData.SendAsync();
        }
        else if (fullClearServer)
        {
            fullClearServer = false;
            toy.customData.ServerFullClear();

            UnlockUI();
        }
        else
        {
            if (toy.customData.GetBool("registered", false) == true)
            {
                string username = toy.customData.GetString("username", "");

                userFeedback.text = "Token is already registered to " + username + ".";
            }
            else if (ready == false)
            {
                userFeedback.text = "Please click okay button first.";
            }
            else
            {
                Debug.Log((ShardColor)affinitySelection.value + 1);
                Player.RegisterPlayer(toy, userField.text, 1, (ShardColor)affinitySelection.value + 1);

                UnlockUI();
            }
        }
    }
Beispiel #9
0
        private async void RemoveExecute()
        {
            Int64 startTicks = Log.VIEWMODEL("(ToyDetailViewModel) Enter", Common.LOG_CATEGORY);

            var isReferenced =
                await _ToyDataService.IsReferencedByCatAsync(SelectedToy.Id);

            if (isReferenced)
            {
                var message = $"The Toy ({SelectedToy.Name})" +
                              " can't be removed;  It is referenced by at least one Cat";

                //MessageDialogService.ShowInfoDialog(
                //    $"The Cat ({SelectedToy.Name})" +
                //    " can't be removed;  It is referenced by at least one Cat");

                DialogService.Show("NotificationDialog", new DialogParameters($"message={message}"), r =>
                {
                    //if (r.Result == ButtonResult.None)
                    //    Message = "Result is None";
                    //else if (r.Result == ButtonResult.OK)
                    //    Message = "Result is OK";
                    //else if (r.Result == ButtonResult.Cancel)
                    //    Message = "Result is Cancel";
                    //else
                    //    Message = "I Don't know what you did!?";
                });

                return;
            }

            SelectedToy.PropertyChanged -= Wrapper_PropertyChanged;
            _ToyDataService.Remove(SelectedToy.Model);
            Toys.Remove(SelectedToy);
            SelectedToy = null;
            HasChanges  = _ToyDataService.HasChanges();

            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();

            Log.VIEWMODEL("(ToyDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #10
0
        // private async void OpenDetailView(OpenDetailViewEventArgs args)
        // {
        // Int64 startTicks = Log.EVENT("(ToyDetailViewModel) Enter", Common.LOG_CATEGORY);

        // await LoadAsync(args.Id);

        // Log.EVENT("(ToyDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        // }

        #endregion

        #region Public Methods

        public override async Task LoadAsync(int id)
        {
            Int64 startTicks = Log.VIEWMODEL("(ToyDetailViewModel) Enter Id:({id})", Common.LOG_CATEGORY);

            Id = id;

            foreach (var wrapper in Toys)
            {
                wrapper.PropertyChanged -= Wrapper_PropertyChanged;
            }

            Toys.Clear();

            var items = await _ToyDataService.AllAsync();

            foreach (var model in items)
            {
                var wrapper = new ToyWrapper(model);
                wrapper.PropertyChanged += Wrapper_PropertyChanged;
                Toys.Add(wrapper);
            }

            Log.VIEWMODEL("(ToyDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #11
0
 public void emulateToyClaim(ToyWrapper toy, bool TLL_val)
 {
     OnClaimToy_OK(toy, TLL_val);
 }
Beispiel #12
0
    private void OnClaimToy_OKWrapper(BitToys.Toy toy, bool TLL_val)
    {
        ToyWrapper tw = ToyWrapper.FromToy(toy);

        OnClaimToy_OK(tw, TLL_val);
    }
Beispiel #13
0
 public Player(ToyWrapper bittoy)
 {
     toy = bittoy;
 }