示例#1
0
        public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
        {
            var effect = PrefabHelper.Intantiate(_explosionEffectPrefab, Game.Instance.gameObject);

            effect.transform.position   = castContext.Caster.Position;
            effect.transform.localScale = Vector3.zero;

            var radius  = _radius.GetValue(abilityLevel);
            var targets = MapController.Instance.GetEnemiesInArea(castContext.Caster.Position,
                                                                  radius, castContext.Caster.PlayerId);

            for (int i = 0; i < targets.Count; i++)
            {
                DamageSystem.ApplyDamage(castContext.Caster, _damage.GetValue(abilityLevel), targets[i]);
            }

            return(new SyncScenario(
                       new List <ISyncScenarioItem> {
                new ActionScenarioItem(() =>
                {
                    FMODUnity.RuntimeManager.PlayOneShot("event:/Explosion");
                }),
                new AlphaTween(effect, 1),
                new ScaleTween(effect, 10 * radius * Vector3.one, 0.5f, EaseType.QuadIn),
                new AlphaTween(effect, 0, 0.3f, EaseType.QuadOut)
            },
                       (s, interrupted) => Object.Destroy(effect.gameObject)
                       ).PlayRegisterAndReturnSelf());
        }
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            // Contains options that affect the behavior of the framework.
            var options = new CastOptions(ReceiverApplicationId);

            // CastContext coordinates all of the framework's activities.
            CastContext.SetSharedInstance(options);

            // Google Cast Logger
            Logger.SharedInstance.Delegate = this;

            // Use UICastContainerViewController as the Initial Controller.
            // Wraps our View Controllers and add a UIMiniMediaControlsViewController
            // at the bottom; a persistent bar to control remote videos.
            var appStoryboard        = UIStoryboard.FromName("Main", null);
            var navigationController = appStoryboard.InstantiateInitialViewController() as UINavigationController;
            var castContainer        = CastContext.SharedInstance.CreateCastContainerController(navigationController);

            castContainer.MiniMediaControlsItemEnabled = true;

            // Used to highlight the Cast button when it is first shown to users.
            CastContext.SharedInstance.PresentCastInstructionsViewControllerOnce();

            // Use Default Expanded Media Controls
            CastContext.SharedInstance.UseDefaultExpandedMediaControls = true;

            Window = new UIWindow(UIScreen.MainScreen.Bounds);
            Window.RootViewController = castContainer;
            Window.MakeKeyAndVisible();

            return(true);
        }
示例#3
0
        public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
        {
            var linesCollider = PrefabHelper.Intantiate(_linesColliderPrefab, Game.Instance.gameObject);

            linesCollider.transform.position   = castContext.Caster.Position;
            linesCollider.transform.localScale = Vector3.one;
            linesCollider.OnTrigger           += (unit) =>
            {
                if (unit.PlayerId != castContext.Caster.PlayerId)
                {
                    DamageSystem.ApplyDamage(castContext.Caster, _damage.GetValue(abilityLevel), unit);
                }
            };
            var renderers = linesCollider.GetComponentsInChildren <Renderer>();

            return(new SyncScenario(
                       new List <ISyncScenarioItem> {
                new ActionScenarioItem(() =>
                {
                    FMODUnity.RuntimeManager.PlayOneShot("event:/Explosion");
                }),
                new AlphaTween(renderers, 0),
                new AlphaTween(renderers, 1, 0.1f, EaseType.QuadIn),
                new AlphaTween(renderers, 0, 0.3f, EaseType.QuadOut)
            },
                       (s, interrupted) => Object.Destroy(linesCollider.gameObject)
                       ).PlayRegisterAndReturnSelf());
        }
        public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.Playback, AVAudioSessionCategoryOptions.DuckOthers);

            var discoveryCriteria = new DiscoveryCriteria("17F1E2B1");
            var options           = new CastOptions(discoveryCriteria);

            CastContext.SetSharedInstance(options);
            Logger.SharedInstance.Delegate = new LoggerDelegate();

            var navigationController = new UINavigationController(new FairPlayCastViewController());

            var castContainer = CastContext.SharedInstance.CreateCastContainerController(navigationController);

            castContainer.MiniMediaControlsItemEnabled = true;

            CastContext.SharedInstance.UseDefaultExpandedMediaControls = true;

            Window = new UIWindow(UIScreen.MainScreen.Bounds);
            Window.RootViewController = castContainer;

            //Window.RootViewController = new BasicPlayerViewController();
            //Window.RootViewController = new FairPlayViewContoller();

            Window.MakeKeyAndVisible();
            return(true);
        }
示例#5
0
 public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
 {
     return(new ActionScenarioItem(() =>
     {
         castContext.Target.Health.AddValue(HealAmount.GetValue(abilityLevel));
     }).PlayRegisterAndReturnSelf());
 }
示例#6
0
        void InitializeCast()
        {
            DiscoveryCriteria discoveryCriteria = new DiscoveryCriteria(castReceiverId);
            CastOptions       castOptions       = new CastOptions(discoveryCriteria);

            CastContext.SetSharedInstance(castOptions);
        }
示例#7
0
 public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
 {
     return(new ActionScenarioItem(() =>
     {
         DamageSystem.ApplyDamage(null, DamagePerTurn.GetValue(abilityLevel), castContext.Target);
     }
                                   ).PlayRegisterAndReturnSelf());
 }
示例#8
0
        public void SetupChromecast()
        {
            var discoveryCriteria = new DiscoveryCriteria("0A6928D1");
            var castOptions       = new CastOptions(discoveryCriteria);

            CastContext.SetSharedInstance(castOptions);
            CastContext.SharedInstance.UseDefaultExpandedMediaControls = true;
        }
示例#9
0
 public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
 {
     return(new ActionScenarioItem(() =>
     {
         castContext.Target.Character.Stats[Stat].MultiplyBy(Multiplicator.GetValue(abilityLevel));
     }
                                   ).PlayRegisterAndReturnSelf());
 }
示例#10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;
            base.OnCreate(savedInstanceState);

            castSessionManagerListener = new CastSessionManagerListener(this);
            castContext = CastContext.GetSharedInstance(this);
            castSession = castContext.SessionManager.CurrentCastSession;
            castContext.SessionManager.AddSessionManagerListener(castSessionManagerListener);

            //setup layout and video data
            SetContentView(Resource.Layout.playerPageLayout);
            mediaInfo = chromecastService.Value.GetPlaybackAsset();

            //TITLE
            assetTitle          = FindViewById <TextView>(Resource.Id.assetTitle);
            assetTitle.Text     = mediaInfo.DisplayName;
            assetTitle.TextSize = 20;

            //BACKBUTTON
            backButton        = FindViewById <Button>(Resource.Id.backButton);
            backButton.Click += BackButton_Click;

            //Cast Button setup
            castButton = (MediaRouteButton)FindViewById(Resource.Id.media_route_button);
            CastButtonFactory.SetUpMediaRouteButton(ApplicationContext, castButton);

            //VideoPlayer Source
            videoView = FindViewById <VideoView>(Resource.Id.video_view);
            var videoURL = Android.Net.Uri.Parse(mediaInfo.SourceURL);

            mController = new Android.Widget.MediaController(this);
            mController.SetAnchorView(videoView);
            videoView.SetVideoURI(videoURL);
            videoView.SetMediaController(mController);

            if (mLocation == PlaybackLocation.LOCAL)
            {
                videoView.Start();
            }
            else
            {
                castSession = castContext.SessionManager.CurrentCastSession;
                if ((castSession != null) && (castSession.IsConnected == true))
                {
                    //setup media to send to cast receiver
                    mLocation = PlaybackLocation.REMOTE;
                    var test = castContext.SessionManager.CurrentCastSession;

                    //call/initialize customCastMediaManager if needed. this sample uses default things
                }
            }
        }
示例#11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            CastContext castContext = CastContext.GetSharedInstance(this);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
        }
示例#12
0
 public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
 {
     return(new ActionScenarioItem(() =>
     {
         var unitAura = Instantiate(PoisonousAuraPrefab);
         unitAura.Attach(castContext.Caster, (holder, target) =>
         {
             if (target.PlayerId != holder.PlayerId)
             {
                 target.AddEffect(new CharacterEffect(EffectOnTouch, abilityLevel));
             }
         });
         unitAura.SetSize(castContext.Caster.GetComponentInChildren <CircleCollider2D>().radius + 0.1f);
     }).PlayRegisterAndReturnSelf());
 }
        private List <ShowWithCast> ShowsWithCasts(PagingParameterModel pagingparametermodel)
        {
            List <ShowWithCast> results = new List <ShowWithCast>();

            try
            {
                _ShowCastcontext = new ShowCastContext();
                _Showcontext     = new ShowContext();
                _Castcontext     = new CastContext();
                var shows = from sh in _Showcontext.Show
                            select sh;
                int ii        = shows.Count();
                var showsList = shows.Skip((pagingparametermodel.pageNumber - 1) * pagingparametermodel.pageSize).Take(pagingparametermodel.pageSize).ToList();

                foreach (Show s in showsList)
                {
                    ShowWithCast sc = new ShowWithCast();
                    sc.ShowID = s.ShowID;
                    sc.Name   = s.ShowName;

                    var showPairs = from sp in _ShowCastcontext.ShowCast
                                    where sp.ShowID == s.ShowID
                                    select sp;

                    sc.Cast = new List <Cast>();

                    foreach (ShowCast item in showPairs)
                    {
                        var casts = from cst in _Castcontext.Cast
                                    where cst.CastID == item.CastID
                                    select cst;

                        foreach (Cast aCast in casts)
                        {
                            sc.Cast.Add(aCast);
                        }
                    }
                    sc.Cast = sc.Cast.OrderByDescending(x => x.BirthDay).ToList();
                    results.Add(sc);
                }
            }
            catch (Exception ex)
            {
                string er = ex.ToString();
            }
            return(results);
        }
        public async Task <JsonResult> ScrapeShowsAndPersistData()
        {
            _ShowCastcontext = new ShowCastContext();
            _Showcontext     = new ShowContext();
            _Castcontext     = new CastContext();
            //Clears existing data in the database first:
            _Showcontext.Database.ExecuteSqlCommand("TRUNCATE TABLE [Show]");

            string url = "http://api.tvmaze.com/shows";
            List <ShowWithCast> jSonResult = new List <ShowWithCast>();

            try
            {
                _Showcontext = new ShowContext();
                var showName = from sn in _Showcontext.Show
                               select sn;


                using (var client = new HttpClient())
                {
                    using (var r = await client.GetAsync(new Uri(url)))
                    {
                        string JsonStr = await r.Content.ReadAsStringAsync();

                        var result = JsonConvert.DeserializeObject <List <ShowFull> >(JsonStr);

                        foreach (ShowFull fliek in result)
                        {
                            Show aShow = new Show();
                            aShow.ShowID   = fliek.id;
                            aShow.ShowName = fliek.name;
                            _Showcontext.Add(aShow);
                            await _Showcontext.SaveChangesAsync();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string error = ex.ToString();
            }
            var shows = from sctx in _Showcontext.Show
                        select sctx;

            return(await Task.FromResult(Json(shows)));
        }
示例#15
0
        public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
        {
            var directions = _directions[_index].GetDirections();

            _index = _index + 1 >= _directions.Length ? 0 : _index + 1;
            var items = new List <ISyncScenarioItem>();

            foreach (var direction in directions)
            {
                var effect = PrefabHelper.Intantiate(_explosionEffectPrefab, Game.Instance.gameObject);
                effect.transform.position   = castContext.Caster.Position + direction * _distance;
                effect.transform.localScale = Vector3.zero;
                var radius = _radius.GetValue(abilityLevel);

                items.Add(new SyncScenario(
                              new List <ISyncScenarioItem>
                {
                    new AlphaTween(effect, 1),
                    new ScaleTween(effect, 10 * radius * Vector3.one, 0.5f, EaseType.QuadIn),

                    new ActionScenarioItem(() =>
                    {
                        FMODUnity.RuntimeManager.PlayOneShot("event:/Gas");
                    }),
                    new ActionScenarioItem(() =>
                    {
                        var targets = MapController.Instance.GetEnemiesInArea(effect.transform.position,
                                                                              radius, castContext.Caster.PlayerId);

                        for (int i = 0; i < targets.Count; i++)
                        {
                            if (!DamageSystem.ApplyDamage(castContext.Caster, _damage.GetValue(abilityLevel), targets[i]))
                            {
                                targets[i].AddEffect(new CharacterEffect(EffectOnTouch, abilityLevel));
                            }
                        }
                    }),
                    new AlphaTween(effect, 0, 0.3f, EaseType.QuadOut)
                },
                              (s, interrupted) => Object.Destroy(effect.gameObject)
                              ));
            }

            return(new CompositeItem(items).PlayRegisterAndReturnSelf());
        }
示例#16
0
        private void InitCast()
        {
            castContext = CastContext.GetSharedInstance(this.ApplicationContext);

            castContext.SessionManager.AddSessionManagerListener(this);

            //var prov = new MediaRouteActionProvider(Application.Context);

            callback = new MediaRouteSelectorCallback();

            mediaRouteSelector = new MediaRouteSelector.Builder()
                                 // These are the framework-supported intents
                                 .AddControlCategory(MediaControlIntent.CategoryRemotePlayback)
                                 .AddControlCategory(MediaControlIntent.CategoryLiveAudio)
                                 .AddControlCategory(CastMediaControlIntent.CategoryForCast(CastMediaControlIntent.DefaultMediaReceiverApplicationId))
                                 .Build();

            mediaRouter = MediaRouter.GetInstance(this.ApplicationContext);
        }
示例#17
0
        // Activity lifecycle methods.

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            //Getting the cast context later than onStart can cause device discovery not to take place.
            castContext = CastContext.GetSharedInstance(this);

            SetContentView(Resource.Layout.main_activity);

            localPlayerView = (PlayerView)FindViewById(Resource.Id.local_player_view);
            localPlayerView.RequestFocus();

            castControlView = (PlayerControlView)FindViewById(Resource.Id.cast_control_view);

            mediaQueueListAdapter = new MediaQueueListAdapter();
            mediaQueueList        = (RecyclerView)FindViewById(Resource.Id.sample_list);
            mediaQueueList.SetLayoutManager(new LinearLayoutManager(this));
            mediaQueueList.HasFixedSize = true;

            ItemTouchHelper helper = new ItemTouchHelper(new RecyclerViewCallback(playerManager, mediaQueueListAdapter));

            helper.AttachToRecyclerView(mediaQueueList);

            FindViewById(Resource.Id.add_sample_button).SetOnClickListener(this);
        }
        public async Task <JsonResult> PairShowsCastsAndPersistData()
        {
            _ShowCastcontext = new ShowCastContext();
            _Castcontext     = new CastContext();
            //Deletes all existing data in the local database first
            _ShowCastcontext.Database.ExecuteSqlCommand("TRUNCATE TABLE [ShowCast]");
            _Castcontext.Database.ExecuteSqlCommand("TRUNCATE TABLE [Cast]");
            string url = "";
            List <ShowWithCast> jSonResult = new List <ShowWithCast>();

            try
            {
                _Castcontext     = new CastContext();
                _ShowCastcontext = new ShowCastContext();

                var shows = from sh in _Showcontext.Show
                            select sh;

                int ShowCastCounter = 0;
                //loop through all the shows
                foreach (Show s in shows)
                {
                    //retrieves every show's cast
                    //Example - http://api.tvmaze.com/shows/1/cast
                    url = "http://api.tvmaze.com/shows/" + s.ShowID + "/cast";

                    using (var client = new HttpClient())
                    {
                        using (var r = await client.GetAsync(new Uri(url)))
                        {
                            string JsonStr2 = await r.Content.ReadAsStringAsync();

                            var result2 = JsonConvert.DeserializeObject <List <CastFull> >(JsonStr2);

                            foreach (CastFull cast in result2)
                            {
                                ShowCastCounter++;
                                Cast aCast = new Cast();
                                aCast.CastID   = cast.person.id;
                                aCast.Name     = cast.person.name;
                                aCast.BirthDay = cast.person.birthday;
                                _Castcontext   = new CastContext();

                                _Castcontext.Add(aCast);
                                await _Castcontext.SaveChangesAsync();

                                ShowCast cs = new ShowCast();
                                cs.ShowCastID    = ShowCastCounter;
                                cs.ShowID        = s.ShowID;
                                cs.CastID        = aCast.CastID;
                                _ShowCastcontext = new ShowCastContext();
                                _ShowCastcontext.Add(cs);
                                await _ShowCastcontext.SaveChangesAsync();
                            }
                        }
                    }
                }
                await _Castcontext.SaveChangesAsync();

                await _ShowCastcontext.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                string error = ex.ToString();
            }

            _Castcontext = new CastContext();
            var casts = from sh in _Castcontext.Cast
                        select sh;

            return(await Task.FromResult(Json(casts)));
        }
示例#19
0
 public override bool CouldApply(CastContext castContext, int abilityLevel)
 {
     return(true);
 }
示例#20
0
 public override ISyncScenarioItem Attach(CastContext castContext, int abilityLevel)
 {
     return(null);
 }
示例#21
0
        /**
         * @param queuePositionListener A {@link QueuePositionListener} for queue position changes.
         * @param localPlayerView The {@link PlayerView} for local playback.
         * @param castControlView The {@link PlayerControlView} to control remote playback.
         * @param context A {@link Context}.
         * @param castContext The {@link CastContext}.
         */
        public static PlayerManager CreatePlayerManager(IQueuePositionListener queuePositionListener, PlayerView localPlayerView, PlayerControlView castControlView, Context context, CastContext castContext)
        {
            PlayerManager playerManager = new PlayerManager(queuePositionListener, localPlayerView, castControlView, context, castContext);

            playerManager.Init();
            return(playerManager);
        }
示例#22
0
        private PlayerManager(IQueuePositionListener queuePositionListener, PlayerView localPlayerView, PlayerControlView castControlView, Context context, CastContext castContext)
        {
            this.queuePositionListener = queuePositionListener;
            this.localPlayerView       = localPlayerView;
            this.castControlView       = castControlView;
            mediaQueue               = new List <DemoUtil.Sample>();
            currentItemIndex         = C.IndexUnset;
            concatenatingMediaSource = new ConcatenatingMediaSource();

            DefaultTrackSelector trackSelector    = new DefaultTrackSelector(BANDWIDTH_METER);
            IRenderersFactory    renderersFactory = new DefaultRenderersFactory(context);

            exoPlayer = ExoPlayerFactory.NewSimpleInstance(renderersFactory, trackSelector);
            exoPlayer.AddListener(this);
            localPlayerView.Player = exoPlayer;

            castPlayer = new CastPlayer(castContext);
            castPlayer.AddListener(this);
            castPlayer.SetSessionAvailabilityListener(this);
            castControlView.Player = castPlayer;
        }
示例#23
0
 public abstract bool CouldApply(CastContext castContext, int abilityLevel);
示例#24
0
 public abstract ISyncScenarioItem Apply(CastContext castContext, int abilityLevel);