// cannot define the interface inline can we.. public void Visualize(Func<IVisualizer> new_Visualizer) { // how many sounds we have? Soundboard sb = new Soundboard(); new[] { sb.loopmachinegun, sb.loophelicopter1, sb.loopdiesel2, sb.loopsand_run, sb.loopjeepengine, sb.loopcrickets, sb.loopstrange1, sb.loop_GallinagoDelicata, }.WithEachIndex( (s, index) => { var v = new_Visualizer(); v.SetMasterVolume = value => s.MasterVolume = double.Parse(value); // we did it for imp. v.SetLeftVolume = value => s.LeftVolume = double.Parse(value); v.SetRightVolume = value => s.RightVolume = double.Parse(value); s.MasterVolume = 0; s.Sound.play(); v.Initialize(new { index }.ToString()); } ); }
public ApplicationSprite() { var lobby = new FlashHeatZeeker.Lobby.ApplicationSprite(); lobby.AttachTo(this); var sb = new Soundboard(); this.InvokeWhenPromotionIsReady( delegate { lobby.StartClicked += delegate { if (lobby == null) return; sb.snd_click.play(); try { lobby.ytp.Loader.unloadAndStop(true); //lobby.ytp.pauseVideo(); } catch { } lobby.Orphanize(); lobby = null; new ApplicationSpriteContent().AttachTo(this); }; } ); }
public StarlingGameSpriteWithPedControl() { // http://armorgames.com/play/13701/ var textures_ped = new StarlingGameSpriteWithPedTextures( this.new_tex_crop, this.new_texsprite_crop ); //this.disablephysicsdiagnostics = true; this.onbeforefirstframe += (stage, s) => { var patrol1 = new PhysicalPed(textures_ped, this) { speed = 10 }; var physical0 = new PhysicalPed(textures_ped, this) { AttractZombies = true //speed = 8 }; //physical0.visual.WalkLikeZombie = true; physical0.visual.StandWithVisibleGun = true; current = physical0; // 32x32 = 15FPS? // 24x24 35? stage.mouseWheel += e => { if (e.delta < 0) { this.internalscale -= 0.05; } if (e.delta > 0) { this.internalscale += 0.05; } }; #region others for (int ix = 0; ix < 4; ix++) for (int iy = 0; iy < 4; iy++) { var p = new PhysicalPed(textures_ped, this); p.SetPositionAndAngle( 32 * ix, 32 * iy, random.NextDouble() ); if (ix == 0) p.BehaveLikeZombie(); } #endregion #region __keyDown stage.keyDown += e => { // http://circlecube.com/2008/08/actionscript-key-listener-tutorial/ if (e.altKey) __keyDown[Keys.Alt] = true; __keyDown[(Keys)e.keyCode] = true; this.Text = new { e.keyCode, Keys.A }.ToString(); }; stage.keyUp += e => { if (!e.altKey) __keyDown[Keys.Alt] = false; __keyDown[(Keys)e.keyCode] = false; }; #endregion bool mode_changepending = false; var mode_gun = false; var sb = new Soundboard(); onsyncframe += delegate { #region patrol1 if (syncframeid % 300 == 100) { patrol1.body.SetAngle( 45.DegreesToRadians() ); var partol_commands = new KeySample(); partol_commands[Keys.Up] = true; patrol1.SetVelocityFromInput(partol_commands); } if (syncframeid % 300 == 150) { var partol_commands = new KeySample(); //partol_commands[Keys.Left] = true; patrol1.SetVelocityFromInput(partol_commands); } if (syncframeid % 300 == 200) { patrol1.body.SetAngle( (180 + 45).DegreesToRadians() ); var partol_commands = new KeySample(); partol_commands[Keys.Up] = true; patrol1.SetVelocityFromInput(partol_commands); } if (syncframeid % 300 == 250) { var partol_commands = new KeySample(); //partol_commands[Keys.Left] = true; patrol1.SetVelocityFromInput(partol_commands); } #endregion current.SetVelocityFromInput(__keyDown); #region simulate a weapone! if (__keyDown[Keys.ControlKey]) { mode_gun = true; } else { if (mode_gun) { mode_gun = false; (current as PhysicalPed).With( ped => { ped.visual.StandWithVisibleGunFire.Restart(); } ); sb.snd_shotgun3.play(); #region CreateBullet Action<double> CreateBullet = a => { var bodyDef = new b2BodyDef(); bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody; // stop moving if legs stop walking! bodyDef.linearDamping = 0; bodyDef.angularDamping = 0; //bodyDef.angle = 1.57079633; bodyDef.fixedRotation = true; var dx = Math.Cos(current.body.GetAngle() + current.CameraRotation + a); var dy = Math.Sin(current.body.GetAngle() + current.CameraRotation + a); var body = damage_b2world.CreateBody(bodyDef); body.SetPosition( new b2Vec2( current.body.GetPosition().x + dx * 0.3, current.body.GetPosition().y + dy * 0.3 ) ); body.SetLinearVelocity( new b2Vec2( dx * 100, dy * 100 ) ); var fixDef = new Box2D.Dynamics.b2FixtureDef(); fixDef.density = 20; fixDef.friction = 0.0; fixDef.restitution = 0; fixDef.shape = new Box2D.Collision.Shapes.b2CircleShape(0.3); var fix = body.CreateFixture(fixDef); }; #endregion CreateBullet(-6.DegreesToRadians()); CreateBullet(-2.DegreesToRadians()); CreateBullet(2.DegreesToRadians()); CreateBullet(6.DegreesToRadians()); //body.SetPosition( // new b2Vec2(0, -100 * 16) //); } } #endregion #region mode if (!__keyDown[Keys.Space]) { // space is not down. mode_changepending = true; } else { if (mode_changepending) { if (physical0.visual.LayOnTheGround) physical0.visual.LayOnTheGround = false; else physical0.visual.LayOnTheGround = true; mode_changepending = false; } } #endregion }; }; }
public ApplicationSpriteContent() { this.InvokeWhenStageIsReady( delegate { this.stage.frameRate = 30; this.stage.frameRate = 60; // http://gamua.com/starling/first-steps/ // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue Starling.handleLostContext = true; var s = new Starling( typeof(StarlingGameSpriteWithTestDriversWithAudio).ToClassToken(), this.stage, // http://forum.starling-framework.org/topic/air-34 profile: "baseline" ); //Starling.current.showStats s.showStats = true; #region atresize Action atresize = delegate { // http://forum.starling-framework.org/topic/starling-stage-resizing s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle( 0, 0, this.stage.stageWidth, this.stage.stageHeight ); s.stage.stageWidth = this.stage.stageWidth; s.stage.stageHeight = this.stage.stageHeight; //b2stage_centerize(); }; atresize(); #endregion StarlingGameSpriteBase.onresize = yield => { this.stage.resize += delegate { atresize(); yield(this.stage.stageWidth, this.stage.stageHeight); }; yield(this.stage.stageWidth, this.stage.stageHeight); }; this.stage.enterFrame += delegate { StarlingGameSpriteBase.onframe(this.stage, s); }; s.start(); #region FULL_SCREEN_INTERACTIVE this.stage.keyUp += e => { if (e.keyCode == (uint)System.Windows.Forms.Keys.F11) { this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE; } if (e.keyCode == (uint)System.Windows.Forms.Keys.F) { this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE; } }; #endregion #region F8 var CanConnectAndroid = true; this.stage.keyUp += e => { if (e.keyCode == (uint)System.Windows.Forms.Keys.F8) { if (!CanConnectAndroid) return; CanConnectAndroid = false; var sb = new Soundboard(); sb.snd_lookingforlongrangecomms.play( loops: 2, sndTransform: new ScriptCoreLib.ActionScript.flash.media.SoundTransform(0.4) ); var text = new ScriptCoreLib.ActionScript.flash.text.TextField().AttachTo(this); text.width = 800; text.y = 72; text.textColor = 0xffffff; text.multiline = true; FlashHeatZeeker.TestGamePad.Library.MulticastService.InitializeConnection( StarlingGameSpriteWithTestDriversWithAudio.__keyDown, WriteMode: false, ReadMode: true, text: text, yield_PostMessage: PostMessage => { StarlingGameSpriteWithTestDriversWithAudio.current_changed += g => { Action<string> __switchto = type => { PostMessage( new XElement( "switchto", new XAttribute("type", type), new XAttribute("syncframeid", "" + g.syncframeid) ).ToString()); }; if (g.current is PhysicalPed) __switchto("ped"); if (g.current is PhysicalTank) __switchto("tank"); if (g.current is PhysicalJeep) __switchto("jeep"); if (g.current is PhysicalHind) __switchto("hind"); if (g.current is PhysicalBunker) __switchto("bunker"); if (g.current is PhysicalCannon) __switchto("cannon"); if (g.current is PhysicalSilo) __switchto("silo"); if (g.current is PhysicalWatertower) __switchto("watertower"); }; } ); } }; #endregion } ); }
public ShopExperience(Sprite that) { var currentped = default(IPhysicalUnit); var shopcontent = new ApplicationCanvas(); var sb = new Soundboard(); #region GiveMeWhatIWant Action GiveMeWhatIWant = delegate { shopcontent.bg_ammo.Fill = Brushes.Green; shopcontent.bg_shotgun.Fill = Brushes.Green; sb.snd_SelectWeapon.play(); shopcontent.t2o.Opacity = 0.1; (currentped as PhysicalPed).With( ped => { ped.visual.StandWithVisibleGun = true; } ); }; #endregion #region BuyAmmo shopcontent.BuyAmmo += delegate { Console.WriteLine("BuyAmmo"); // BuyAmmo //facebookOAuthConnectPopup: { facebookOAuthConnectPopup_window = _blank } //after facebookOAuthConnectPopup //still in window: { Right = 739, Left = 675 } //{ zombie_forceA = 4.867357484065154 } //facebookOAuthConnectPopup callback { connectUserId = fb1527339800, access_token = AAADLSABgZCZC0BAOroZC3jsNhsgRVFhBK4VcAT19uePwd2iZBKX8ZCVwtdu8ZBhtmU9bH6nMJHO0qJ6I5dzvhw9Ty1kt542zpH2BZCMKKPI0wZDZD, facebookuserid = 1527339800 } //at callback //BuyAmmo { facebookuserid = 1527339800, Length = 1 } //{ item = [playerio.VaultItem][itemKey="Shotgun3", id="403939388", purchaseDate=Mon Mar 11 21:32:08 GMT+0200 2013] = { //FreelyGivable:true //PriceUSD:99 //} } //set facebookOAuthConnectPopupItems_cache sb.snd_click.play( sndTransform: new ScriptCoreLib.ActionScript.flash.media.SoundTransform(0.5) ); #if FFACEBOOK that.facebookOAuthConnectPopupItems( (Client xclient, string access_token, string facebookuserid, object[] items) => { Console.WriteLine("BuyAmmo " + new { facebookuserid, xclient.payVault.items.Length }); #region itemKey_exists var itemKey = "Shotgun3"; var itemKey_exists = false; foreach (var item in items) { var dyn = new DynamicContainer { Subject = item }; var dyn_itemKey = (string)dyn["itemKey"]; Console.WriteLine(new { item }); if (dyn_itemKey == itemKey) itemKey_exists = true; } if (itemKey_exists) { GiveMeWhatIWant(); return; } #endregion // facebookOAuthConnectPopup callback { connectUserId = fb1527339800, access_token = AAADLSABgZCZC0BAOroZC3jsNhsgRVFhBK4VcAT19uePwd2iZBKX8ZCVwtdu8ZBhtmU9bH6nMJHO0qJ6I5dzvhw9Ty1kt542zpH2BZCMKKPI0wZDZD, facebookuserid = 1527339800 } //BuyAmmo { facebookuserid = 1527339800, Length = 1 } //{ item = [playerio.VaultItem][itemKey="Shotgun3", id="403939388", purchaseDate=Mon Mar 11 21:32:08 GMT+0200 2013] = { //FreelyGivable:true //PriceUSD:99 //} } } ); #endif }; #endregion #region BuyShotgun shopcontent.BuyShotgun += delegate { Console.WriteLine("BuyShotgun"); sb.snd_click.play( sndTransform: new ScriptCoreLib.ActionScript.flash.media.SoundTransform(0.5) ); // that.facebookOAuthConnectPopupItems( // (Client xclient, string access_token, string facebookuserid, object[] items) => // { // Console.WriteLine("BuyShotgun " + new { facebookuserid, xclient.payVault.items.Length }); // var itemKey = "Shotgun3"; // var BuyAnyway = false; // if (BuyAnyway) // { // } // else // { // #region itemKey_exists // var itemKey_exists = false; // foreach (var item in items) // { // var dyn = new DynamicContainer { Subject = item }; // var dyn_itemKey = (string)dyn["itemKey"]; // Console.WriteLine(new { item }); // if (dyn_itemKey == itemKey) // itemKey_exists = true; // } // if (itemKey_exists) // { // GiveMeWhatIWant(); // return; // } // #endregion // } // Console.WriteLine("before getBuyDirectInfo"); // //// Gets information about how to make a direct item purchase with the specified PayVault provider. // //that.getBuyDirectInfo( // // xclient, // // facebookuserid, // // item_name: "Operation Heat Zeeker - Shotgun", // // itemKey: itemKey, // // yield_paypalurl: uri => // // { // // Console.WriteLine("at getBuyDirectInfo"); // // shopcontent.bg_shotgun.Fill = Brushes.Red; // // uri.NavigateTo(); // // } // //); // } //); }; #endregion ShopEnter = ped => { currentped = ped; shopcontent.AttachToContainer(that); shopcontent.AutoSizeTo(that.stage); }; shopcontent.Close += delegate { if (currentped == null) return; currentped = null; ScriptCoreLib.ActionScript.Extensions.CommonExtensions.Orphanize( ScriptCoreLib.ActionScript.Extensions.AvalonExtensions.ToSprite(shopcontent) ); }; ShopExit = delegate { if (currentped == null) return; currentped = null; ScriptCoreLib.ActionScript.Extensions.CommonExtensions.Orphanize( ScriptCoreLib.ActionScript.Extensions.AvalonExtensions.ToSprite(shopcontent) ); }; }
public ApplicationSprite() { var disable_F9 = false; var sb = new Soundboard(); this.InvokeWhenStageIsReady( delegate { Security.allowDomain("*"); Security.allowInsecureDomain("*"); // we are getting wrong bindings? // because of older playerglobal? // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/MouseEvent.html#RIGHT_CLICK // X:\jsc.svn\examples\actionscript\svg\FlashSVGCursorExperiment\FlashSVGCursorExperiment\ApplicationSprite.cs CommonExtensions.CombineDelegate( this.stage, new System.Action<MouseEvent>( e => { e.preventDefault(); } ) , "rightClick" ); //Error 8 The type 'FlashHeatZeeker.PlayerIOIntegrationBeta2.HTML.Images.FromAssets.Preview' exists in both 'x:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\packages\Chrome.Web.Server.1.0.0.0\lib\Chrome Web Server.dll' and 'x:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.PlayerIOIntegrationBeta2\bin\staging.AssetsLibrary\FlashHeatZeeker.PlayerIOIntegrationBeta2.AssetsLibrary.dll' X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.PlayerIOIntegrationBeta2\Application.cs 130 122 FlashHeatZeeker.PlayerIOIntegrationBeta2 //Error 15 The call is ambiguous between the following methods or properties: 'FlashHeatZeeker.PlayerIOIntegrationBeta2.XToMouseCursor.ToMouseCursor(ScriptCoreLib.ActionScript.flash.display.Sprite)' and 'FlashHeatZeeker.PlayerIOIntegrationBeta2.XToMouseCursor.ToMouseCursor(ScriptCoreLib.ActionScript.flash.display.Sprite)' X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.PlayerIOIntegrationBeta2\ApplicationSprite.cs 83 21 FlashHeatZeeker.PlayerIOIntegrationBeta2 //Error 16 The type 'FlashHeatZeeker.PlayerIOIntegrationBeta2.ActionScript.Images.MyCursor' exists in both 'x:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\packages\Chrome.Web.Server.1.0.0.0\lib\Chrome Web Server.dll' and 'x:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.PlayerIOIntegrationBeta2\bin\staging.AssetsLibrary\FlashHeatZeeker.PlayerIOIntegrationBeta2.AssetsLibrary.dll' X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.PlayerIOIntegrationBeta2\ApplicationSprite.cs 83 45 FlashHeatZeeker.PlayerIOIntegrationBeta2 // Error 87 The call is ambiguous between the following methods or properties: // 'FlashHeatZeeker.PlayerIOIntegrationBeta2.XToMouseCursor.ToMouseCursor(ScriptCoreLib.ActionScript.flash.display.Sprite)' and // 'FlashHeatZeeker.PlayerIOIntegrationBeta2.XToMouseCursor.ToMouseCursor(ScriptCoreLib.ActionScript.flash.display.Sprite)' // X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.PlayerIOIntegrationBeta2\ApplicationSprite.cs 90 21 FlashHeatZeeker.PlayerIOIntegrationBeta2 //Error 88 The type 'FlashHeatZeeker.PlayerIOIntegrationBeta2.ActionScript.Images.MyCursor' exists in both 'x:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\packages\Chrome.Web.Server.1.0.0.0\lib\Chrome Web Server.dll' and 'x:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.PlayerIOIntegrationBeta2\bin\staging.AssetsLibrary\FlashHeatZeeker.PlayerIOIntegrationBeta2.AssetsLibrary.dll' X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.PlayerIOIntegrationBeta2\ApplicationSprite.cs 90 45 FlashHeatZeeker.PlayerIOIntegrationBeta2 //new ActionScript.Images.MyCursor().ToMouseCursor(); var lasterror = 0; this.root.loaderInfo.uncaughtErrorEvents.uncaughtError += e => { if (lasterror == e.errorID) return; Console.WriteLine("error: " + new { e.errorID, e.error, e } + "\n run in flash debugger for more details!"); lasterror = e.errorID; }; #region keys this.stage.keyUp += e => { if (e.keyCode == (uint)System.Windows.Forms.Keys.F9) { if (disable_F9) return; disable_F9 = true; sb.snd_click.play(); Abstractatech.ActionScript.ConsoleFormPackage.ConsoleFormPackageExperience.Initialize(); } if (e.keyCode == (uint)System.Windows.Forms.Keys.F11) { sb.snd_click.play(); this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE; } if (e.keyCode == (uint)System.Windows.Forms.Keys.F) { sb.snd_click.play(); this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE; } }; #endregion } ); var lobby = new FlashHeatZeeker.Lobby.ApplicationSprite(); lobby.AttachTo(this); this.InvokeWhenPromotionIsReady( delegate { lobby.StartClicked += delegate { if (lobby == null) return; sb.snd_click.play(); try { // wtf? lobby.ytp.Loader.unloadAndStop(true); //lobby.ytp.pauseVideo(); } catch { } lobby.Orphanize(); lobby = null; //new ApplicationSpriteContent().AttachTo(this); Initialize(); #region F8 var CanConnectAndroid = true; this.stage.keyUp += e => { if (e.keyCode == (uint)System.Windows.Forms.Keys.F8) { if (!CanConnectAndroid) return; CanConnectAndroid = false; sb.snd_lookingforlongrangecomms.play( loops: 2, sndTransform: new ScriptCoreLib.ActionScript.flash.media.SoundTransform(0.4) ); var text = new ScriptCoreLib.ActionScript.flash.text.TextField().AttachTo(this); text.width = 800; text.y = 72; text.textColor = 0xffffff; text.multiline = true; FlashHeatZeeker.TestGamePad.Library.MulticastService.InitializeConnection( StarlingGameSpriteWithTestDriversWithAudio.__keyDown, WriteMode: false, ReadMode: true, text: text, yield_PostMessage: PostMessage => { StarlingGameSpriteWithTestDriversWithAudio.current_changed += g => { Action<string> __switchto = type => { PostMessage( new XElement( "switchto", new XAttribute("type", type), new XAttribute("syncframeid", "" + g.syncframeid) ).ToString()); }; if (g.current is PhysicalPed) __switchto("ped"); if (g.current is PhysicalTank) __switchto("tank"); if (g.current is PhysicalJeep) __switchto("jeep"); if (g.current is PhysicalHind) __switchto("hind"); if (g.current is PhysicalBunker) __switchto("bunker"); if (g.current is PhysicalCannon) __switchto("cannon"); if (g.current is PhysicalSilo) __switchto("silo"); if (g.current is PhysicalWatertower) __switchto("watertower"); }; } ); } }; #endregion var shop = new ShopExperience(this); StarlingGameSpriteBeta2.ShopEnter += ped => { #if FPLAYERIO // no go if (ApplicationSpriteWithConnection.CurrentClient == null) return; shop.ShopEnter(ped); #endif }; StarlingGameSpriteBeta2.ShopExit += shop.ShopExit; // http://www.flare3d.com/support/index.php?topic=1101.0 this.addChild(new net.hires.debug.Stats { alpha = 0.7 }); }; } ); }