Exemple #1
0
        public void AddCard(int index, CardValues cs, IPlayerView iPlayerView = null)
        {
            GameObject prefab = GetPrefab();
            ICardView  cv     = Instantiate(prefab, transform).GetComponent <ICardView>();

            cv.SetIndex(index);
            cv.SetCard(cs);
            cv.IPlayerView = iPlayerView;
            list.Add(cv);
        }
Exemple #2
0
 void CardMouseOver(ICardView card)
 {
     if (card == null)
     {
         return;
     }
     if (Time.time - _lastClipPlayed > _minTimeBetweenClips)
     {
         _AudioSource.PlayOneShot(MouseOverClip);
         _lastClipPlayed = Time.time;
     }
     Verbose(20, $"MouseOver {card.Agent.Model}");
 }
Exemple #3
0
 protected override void Awake()
 {
     handHidden    = handHiddenGO.GetComponent <IHandView>();
     weaponCard    = weaponGO.GetComponent <ICardView>();
     handCards     = handCardsGO.GetComponent <ICardListView>();
     propertyCards = propertyCardsGO.GetComponent <ICardListView>();
     skill         = skillGO.GetComponent <ISkillView>();
     TurnView      = turnCountdownGO.GetComponent <ICountdownView>();
     ResponseView  = responseCountdownGO.GetComponent <ICountdownView>();
     turnCountdownGO.SetActive(false);
     responseCountdownGO.SetActive(false);
     base.Awake();
     SetTurn(false);
 }
Exemple #4
0
 /// <summary>
 /// Gets the appropriate image for a card
 /// </summary>
 /// <param name="card"></param>
 /// <returns></returns>
 private Image GetImage(ICardView card)
 {
     if (card == null)
     {
         return(null);
     }
     try
     {
         return(Image.FromFile(UIConfig.IMG_FOLDER + card.FileName));
     }
     catch (FileNotFoundException)
     {
         return(Image.FromFile(UIConfig.IMG_FOLDER + "c_not_found.png"));
     }
 }
Exemple #5
0
        private void pbCard_Click(object sender, EventArgs e)
        {
            ICardView clickedCard = (ICardView)((PictureBox)sender).Tag;

            if (IsSelected(clickedCard))
            {
                // deselect
                Selected.Remove(clickedCard);
                ((PictureBox)sender).BorderStyle = BorderStyle.None;
                update();
            }
            else
            {
                // select
                Selected.Add(clickedCard);
                ((PictureBox)sender).BorderStyle = BorderStyle.FixedSingle;
                update();
            }
        }
Exemple #6
0
 public void RegisterView(ICardView view)
 {
     _view = view;
 }
Exemple #7
0
 public CardController(ICardModel model, ICardView view)
 {
     this.model = model;
     this.view  = view;
     Initialize();
 }
Exemple #8
0
 void Awake()
 {
     discardTopCard = discardTopCardGO.GetComponent <ICardView>();
 }
Exemple #9
0
 private bool IsSelected(ICardView card)
 {
     return(Selected.Contains(card));
 }
Exemple #10
0
 void SelectImageFromGallery(ICardView target, string localUrl, string remoteUrl, string fileName,string cacheKey)
 {
            if (target == null) return;

            var vc = new GalleryImagePicker();
            vc.Canceled += (sender, e) => { vc.DismissViewController(true, null); };
            vc.FinishedPickingMedia += (object sender, UIImagePickerMediaPickedEventArgs e) =>
            {
                switch (e.Info[UIImagePickerController.MediaType].ToString())
                {
                    case "public.image":
                        Console.WriteLine("Image selected");

                        target.ToggleLoadingIndicators(true);
                        UIImage editedImage = e.Info[UIImagePickerController.EditedImage] as UIImage;
                        editedImage = ImageUtils.ScaledToSize(editedImage, new CGSize(200, 200));
                        var bytes = ImageUtils.ByteArrayFromImage(editedImage, 100);
                        S3Utils.UploadPhoto(bytes,localUrl, remoteUrl, fileName, () =>
                        {
                            SDWebImageManager.SharedManager.ImageCache.ClearDisk();
                            SDWebImageManager.SharedManager.ImageCache.ClearMemory();
                            Update(true);
                        }, null);


                        break;
                    case "public.video":
                        Console.WriteLine("Video selected");
                        break;
                }
                vc.DismissViewController(true, null);
            };
            PresentViewController(vc, true, null);
        }
Exemple #11
0
			if (cardBack != null) 
                cardBack.BindDataToView(SelectedCard, Editable);

            PerformFlipAnimationIfNecessary();
        }
        public void PerformFlipAnimationIfNecessary()
        {
            var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).First();
            var cardBack = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardBack)).First();

            //animation not needed
            if (cardFront.Hidden == SelectedCard.IsFlipped) return;

            UIView.Transition(View, 0.5, UIViewAnimationOptions.TransitionFlipFromRight, () =>
            {
                cardFront.Hidden = SelectedCard.IsFlipped;
                cardBack.Hidden = !SelectedCard.IsFlipped;
            }, null);
        }

        public void Flip()
        {
            if (SelectedCard == null) return;

            SelectedCard.Flip();

            var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).First();
            var cardBack = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardBack)).First();

            UIView.Transition(View, 0.5, UIViewAnimationOptions.TransitionFlipFromRight, () =>
            {
                cardFront.Hidden = SelectedCard.IsFlipped;
                cardBack.Hidden = !SelectedCard.IsFlipped;
            }, null);
        }

        void DownloadFacebookImage(ICardView target, string localUrl, string remoteUrl, string fileName, string cacheKey)
        {
            if (target == null) return;

            var me = RealmUserServices.GetMe(false);
            if (me == null) return;

            var url = me.GetFacebookProfilePictureUrl();
            if (url == null) return;
                           
            target.ToggleLoadingIndicators(true);
            SDWebImageManager.SharedManager.ImageDownloader.DownloadImage(NSUrl.FromString(url), SDWebImageDownloaderOptions.HighPriority, null, (image, data, error, finished) => 
            {
                if (image == null || error != null)
                {
                    target.ToggleLoadingIndicators(false);
                    return;
                }

                var bytes = ImageUtils.ByteArrayFromImage(image, 100);
                S3Utils.UploadPhoto(bytes, localUrl,remoteUrl, fileName, () =>
                {
                    SDWebImageManager.SharedManager.ImageCache.RemoveImage(cacheKey, true, null);
                    Update(true);
                }, null);
            });
        }