added analytics!
This commit is contained in:
parent
7e399acf9b
commit
864760ab0e
10 changed files with 5907 additions and 26 deletions
|
@ -29,7 +29,7 @@ namespace Android {
|
||||||
this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
|
this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
|
||||||
|
|
||||||
TextInputWrapper.Current = new TextInputWrapper.Mobile();
|
TextInputWrapper.Current = new TextInputWrapper.Mobile();
|
||||||
this.game = new GameImpl();
|
this.game = new GameImpl(new AndroidAnalytics(this));
|
||||||
this.game.GraphicsDeviceManager.ResetWidthAndHeight(this.game.Window);
|
this.game.GraphicsDeviceManager.ResetWidthAndHeight(this.game.Window);
|
||||||
this.game.OnLoadContent += game => game.InputHandler.HandleMouse = false;
|
this.game.OnLoadContent += game => game.InputHandler.HandleMouse = false;
|
||||||
this.game.GraphicsDeviceManager.IsFullScreen = true;
|
this.game.GraphicsDeviceManager.IsFullScreen = true;
|
||||||
|
|
|
@ -47,31 +47,33 @@
|
||||||
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
|
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System"/>
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core"/>
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml"/>
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="Mono.Android"/>
|
<Reference Include="Mono.Android" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Activity1.cs"/>
|
<Compile Include="Activity1.cs" />
|
||||||
<Compile Include="Resources\Resource.Designer.cs"/>
|
<Compile Include="AndroidAnalytics.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs"/>
|
<Compile Include="Resources\Resource.Designer.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AndroidResource Include="Resources\Drawable\Icon.png"/>
|
<AndroidResource Include="Resources\Drawable\Icon.png" />
|
||||||
<AndroidResource Include="Resources\Values\Strings.xml"/>
|
<AndroidResource Include="Resources\Values\Strings.xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Properties\AndroidManifest.xml"/>
|
<None Include="Properties\AndroidManifest.xml" />
|
||||||
<MonoGameContentReference Include="..\TouchyTickets\Content\Content.mgcb">
|
<MonoGameContentReference Include="..\TouchyTickets\Content\Content.mgcb">
|
||||||
<Link>Content\Content.mgcb</Link>
|
<Link>Content\Content.mgcb</Link>
|
||||||
</MonoGameContentReference>
|
</MonoGameContentReference>
|
||||||
<None Include="..\TouchyTickets\Content\*\**"/>
|
<None Include="..\TouchyTickets\Content\*\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Contentless" Version="2.0.6"/>
|
<PackageReference Include="Contentless" Version="2.0.6" />
|
||||||
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9"/>
|
<PackageReference Include="GameAnalytics.Xamarin.SDK" Version="4.1.0" />
|
||||||
<PackageReference Include="MonoGame.Framework.Android" Version="3.7.1.189"/>
|
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
|
||||||
|
<PackageReference Include="MonoGame.Framework.Android" Version="3.7.1.189" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\TouchyTickets\TouchyTickets.csproj">
|
<ProjectReference Include="..\TouchyTickets\TouchyTickets.csproj">
|
||||||
|
@ -79,5 +81,5 @@
|
||||||
<Name>TouchyTickets</Name>
|
<Name>TouchyTickets</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets"/>
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
26
Android/AndroidAnalytics.cs
Normal file
26
Android/AndroidAnalytics.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Android.App;
|
||||||
|
using GameAnalyticsSDK;
|
||||||
|
using GameAnalyticsSDK.Utilities;
|
||||||
|
using TouchyTickets;
|
||||||
|
|
||||||
|
namespace Android {
|
||||||
|
public class AndroidAnalytics : Analytics {
|
||||||
|
|
||||||
|
private readonly Activity activity;
|
||||||
|
|
||||||
|
public AndroidAnalytics(Activity activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Setup(Dictionary<string, object> json) {
|
||||||
|
GameAnalytics.Initialize(this.activity, GA_MiniJSON.JsonEncode(new Hashtable(json)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void AddResourceEvent(bool sink, string currency, float amount, string itemType, string itemId) {
|
||||||
|
GameAnalytics.NewResourceEvent(sink ? GAResourceFlowType.Sink : GAResourceFlowType.Source, currency, amount, itemType, itemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
5806
Android/Resources/Resource.Designer.cs
generated
5806
Android/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load diff
11
TouchyTickets/Analytics.cs
Normal file
11
TouchyTickets/Analytics.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace TouchyTickets {
|
||||||
|
public abstract class Analytics {
|
||||||
|
|
||||||
|
public abstract void Setup(Dictionary<string, object> json);
|
||||||
|
|
||||||
|
public abstract void AddResourceEvent(bool sink, string currency, float amount, string itemType, string itemId);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,10 +5,7 @@ using Coroutine;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using MLEM.Cameras;
|
using MLEM.Cameras;
|
||||||
using MLEM.Extensions;
|
|
||||||
using MLEM.Font;
|
|
||||||
using MLEM.Startup;
|
using MLEM.Startup;
|
||||||
using TouchyTickets.Attractions;
|
|
||||||
|
|
||||||
namespace TouchyTickets {
|
namespace TouchyTickets {
|
||||||
public class GameImpl : MlemGame {
|
public class GameImpl : MlemGame {
|
||||||
|
@ -16,6 +13,7 @@ namespace TouchyTickets {
|
||||||
public static GameImpl Instance { get; private set; }
|
public static GameImpl Instance { get; private set; }
|
||||||
public readonly ISet<Upgrade> AppliedUpgrades = new HashSet<Upgrade>();
|
public readonly ISet<Upgrade> AppliedUpgrades = new HashSet<Upgrade>();
|
||||||
public readonly Tutorial Tutorial = new Tutorial();
|
public readonly Tutorial Tutorial = new Tutorial();
|
||||||
|
public readonly Analytics Analytics;
|
||||||
public BigInteger Tickets;
|
public BigInteger Tickets;
|
||||||
public int TimesRestarted;
|
public int TimesRestarted;
|
||||||
public int Stars;
|
public int Stars;
|
||||||
|
@ -26,13 +24,26 @@ namespace TouchyTickets {
|
||||||
public DateTime LastUpdate;
|
public DateTime LastUpdate;
|
||||||
private double saveCounter;
|
private double saveCounter;
|
||||||
|
|
||||||
public GameImpl() {
|
public GameImpl(Analytics analytics) {
|
||||||
|
this.Analytics = analytics;
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadContent() {
|
protected override void LoadContent() {
|
||||||
base.LoadContent();
|
base.LoadContent();
|
||||||
|
|
||||||
|
// set up analytics
|
||||||
|
var settings = new Dictionary<string, object>();
|
||||||
|
settings["InfoLog"] = true;
|
||||||
|
settings["VerboseLog"] = true;
|
||||||
|
settings["SubmitErrors"] = true;
|
||||||
|
settings["ResourceCurrencies"] = new[] {"Tickets", "Stars"};
|
||||||
|
settings["ResourceItemTypes"] = new[] {"Attraction", "Restart", "Upgrade"};
|
||||||
|
// ios comes first, then android. For now they're the same
|
||||||
|
settings["GameKey"] = new[] {"cc18de06eebbc5d5e987c384fcd28000", "cc18de06eebbc5d5e987c384fcd28000"};
|
||||||
|
settings["SecretKey"] = new[] {"82ca1a930ee38e2383ffb02db7631e16033b511d", "82ca1a930ee38e2383ffb02db7631e16033b511d"};
|
||||||
|
this.Analytics.Setup(settings);
|
||||||
|
|
||||||
if (!SaveHandler.Load(this))
|
if (!SaveHandler.Load(this))
|
||||||
this.Map = new ParkMap(12, 12);
|
this.Map = new ParkMap(12, 12);
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,8 @@ namespace TouchyTickets {
|
||||||
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Place")) {
|
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Place")) {
|
||||||
OnPressed = e2 => {
|
OnPressed = e2 => {
|
||||||
GameImpl.Instance.Tickets -= price;
|
GameImpl.Instance.Tickets -= price;
|
||||||
|
GameImpl.Instance.Analytics.AddResourceEvent(true, "Tickets", (long) price, "Attraction", attraction.Key);
|
||||||
|
|
||||||
map.Place(map.PlacingPosition, map.PlacingAttraction);
|
map.Place(map.PlacingPosition, map.PlacingAttraction);
|
||||||
this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name));
|
this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name));
|
||||||
},
|
},
|
||||||
|
@ -197,7 +199,11 @@ namespace TouchyTickets {
|
||||||
panel.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Yes")) {
|
panel.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Yes")) {
|
||||||
OnPressed = e2 => {
|
OnPressed = e2 => {
|
||||||
this.uiSystem.Remove(e2.Root.Name);
|
this.uiSystem.Remove(e2.Root.Name);
|
||||||
|
|
||||||
var game = GameImpl.Instance;
|
var game = GameImpl.Instance;
|
||||||
|
game.Analytics.AddResourceEvent(true, "Tickets", (long) game.Tickets, "Restart", "Restart" + game.TimesRestarted);
|
||||||
|
game.Analytics.AddResourceEvent(false, "Stars", (long) game.Tickets, "Restart", "Restart" + game.TimesRestarted);
|
||||||
|
|
||||||
game.Stars += (int) (game.Tickets / game.GetStarPrice());
|
game.Stars += (int) (game.Tickets / game.GetStarPrice());
|
||||||
game.TimesRestarted++;
|
game.TimesRestarted++;
|
||||||
game.Tickets = 0;
|
game.Tickets = 0;
|
||||||
|
@ -337,6 +343,8 @@ namespace TouchyTickets {
|
||||||
ChildPadding = new Vector2(4),
|
ChildPadding = new Vector2(4),
|
||||||
OnPressed = e => {
|
OnPressed = e => {
|
||||||
GameImpl.Instance.Stars -= upgrade.Price;
|
GameImpl.Instance.Stars -= upgrade.Price;
|
||||||
|
GameImpl.Instance.Analytics.AddResourceEvent(true, "Stars", upgrade.Price, "Upgrade", upgrade.Name);
|
||||||
|
|
||||||
GameImpl.Instance.AppliedUpgrades.Add(upgrade);
|
GameImpl.Instance.AppliedUpgrades.Add(upgrade);
|
||||||
upgrade.OnApplied();
|
upgrade.OnApplied();
|
||||||
PopulateUpgradeList(upgradeList);
|
PopulateUpgradeList(upgradeList);
|
||||||
|
|
19
iOS/IosAnalytics.cs
Normal file
19
iOS/IosAnalytics.cs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using GameAnalyticsSDK;
|
||||||
|
using GameAnalyticsSDK.Utilities;
|
||||||
|
using TouchyTickets;
|
||||||
|
|
||||||
|
namespace iOS {
|
||||||
|
public class IosAnalytics : Analytics {
|
||||||
|
|
||||||
|
public override void Setup(Dictionary<string, object> json) {
|
||||||
|
GameAnalytics.Initialize(GA_MiniJSON.JsonEncode(new Hashtable(json)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void AddResourceEvent(bool sink, string currency, float amount, string itemType, string itemId) {
|
||||||
|
GameAnalytics.NewResourceEvent(sink ? GAResourceFlowType.Sink : GAResourceFlowType.Source, currency, amount, itemType, itemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
using Foundation;
|
using Foundation;
|
||||||
|
using GameAnalyticsSDK;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using TouchyTickets;
|
using TouchyTickets;
|
||||||
using UIKit;
|
using UIKit;
|
||||||
|
|
||||||
|
@ -10,7 +14,7 @@ namespace iOS {
|
||||||
private static GameImpl game;
|
private static GameImpl game;
|
||||||
|
|
||||||
private static void RunGame() {
|
private static void RunGame() {
|
||||||
game = new GameImpl();
|
game = new GameImpl(new IosAnalytics());
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,7 @@
|
||||||
<Reference Include="Xamarin.iOS" />
|
<Reference Include="Xamarin.iOS" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="IosAnalytics.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -116,7 +117,7 @@
|
||||||
<MonoGameContentReference Include="..\TouchyTickets\Content\Content.mgcb">
|
<MonoGameContentReference Include="..\TouchyTickets\Content\Content.mgcb">
|
||||||
<Link>Content\Content.mgcb</Link>
|
<Link>Content\Content.mgcb</Link>
|
||||||
</MonoGameContentReference>
|
</MonoGameContentReference>
|
||||||
<None Include="..\TouchyTickets\Content\*\**"/>
|
<None Include="..\TouchyTickets\Content\*\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BundleResource Include="Default.png" />
|
<BundleResource Include="Default.png" />
|
||||||
|
@ -126,6 +127,7 @@
|
||||||
<InterfaceDefinition Include="LaunchScreen.storyboard" />
|
<InterfaceDefinition Include="LaunchScreen.storyboard" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="GameAnalytics.Xamarin.SDK" Version="4.1.0" />
|
||||||
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
|
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
|
||||||
<PackageReference Include="MonoGame.Framework.iOS" Version="3.7.1.189" />
|
<PackageReference Include="MonoGame.Framework.iOS" Version="3.7.1.189" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
Loading…
Reference in a new issue