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;
|
||||
|
||||
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.OnLoadContent += game => game.InputHandler.HandleMouse = false;
|
||||
this.game.GraphicsDeviceManager.IsFullScreen = true;
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Activity1.cs" />
|
||||
<Compile Include="AndroidAnalytics.cs" />
|
||||
<Compile Include="Resources\Resource.Designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -70,6 +71,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Contentless" Version="2.0.6" />
|
||||
<PackageReference Include="GameAnalytics.Xamarin.SDK" Version="4.1.0" />
|
||||
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
|
||||
<PackageReference Include="MonoGame.Framework.Android" Version="3.7.1.189" />
|
||||
</ItemGroup>
|
||||
|
|
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.Graphics;
|
||||
using MLEM.Cameras;
|
||||
using MLEM.Extensions;
|
||||
using MLEM.Font;
|
||||
using MLEM.Startup;
|
||||
using TouchyTickets.Attractions;
|
||||
|
||||
namespace TouchyTickets {
|
||||
public class GameImpl : MlemGame {
|
||||
|
@ -16,6 +13,7 @@ namespace TouchyTickets {
|
|||
public static GameImpl Instance { get; private set; }
|
||||
public readonly ISet<Upgrade> AppliedUpgrades = new HashSet<Upgrade>();
|
||||
public readonly Tutorial Tutorial = new Tutorial();
|
||||
public readonly Analytics Analytics;
|
||||
public BigInteger Tickets;
|
||||
public int TimesRestarted;
|
||||
public int Stars;
|
||||
|
@ -26,13 +24,26 @@ namespace TouchyTickets {
|
|||
public DateTime LastUpdate;
|
||||
private double saveCounter;
|
||||
|
||||
public GameImpl() {
|
||||
public GameImpl(Analytics analytics) {
|
||||
this.Analytics = analytics;
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
protected override void 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))
|
||||
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")) {
|
||||
OnPressed = e2 => {
|
||||
GameImpl.Instance.Tickets -= price;
|
||||
GameImpl.Instance.Analytics.AddResourceEvent(true, "Tickets", (long) price, "Attraction", attraction.Key);
|
||||
|
||||
map.Place(map.PlacingPosition, map.PlacingAttraction);
|
||||
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")) {
|
||||
OnPressed = e2 => {
|
||||
this.uiSystem.Remove(e2.Root.Name);
|
||||
|
||||
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.TimesRestarted++;
|
||||
game.Tickets = 0;
|
||||
|
@ -337,6 +343,8 @@ namespace TouchyTickets {
|
|||
ChildPadding = new Vector2(4),
|
||||
OnPressed = e => {
|
||||
GameImpl.Instance.Stars -= upgrade.Price;
|
||||
GameImpl.Instance.Analytics.AddResourceEvent(true, "Stars", upgrade.Price, "Upgrade", upgrade.Name);
|
||||
|
||||
GameImpl.Instance.AppliedUpgrades.Add(upgrade);
|
||||
upgrade.OnApplied();
|
||||
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.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Foundation;
|
||||
using GameAnalyticsSDK;
|
||||
using Newtonsoft.Json;
|
||||
using TouchyTickets;
|
||||
using UIKit;
|
||||
|
||||
|
@ -10,7 +14,7 @@ namespace iOS {
|
|||
private static GameImpl game;
|
||||
|
||||
private static void RunGame() {
|
||||
game = new GameImpl();
|
||||
game = new GameImpl(new IosAnalytics());
|
||||
game.Run();
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@
|
|||
<Reference Include="Xamarin.iOS" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="IosAnalytics.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -126,6 +127,7 @@
|
|||
<InterfaceDefinition Include="LaunchScreen.storyboard" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GameAnalytics.Xamarin.SDK" Version="4.1.0" />
|
||||
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
|
||||
<PackageReference Include="MonoGame.Framework.iOS" Version="3.7.1.189" />
|
||||
</ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue