re-added analytics
This commit is contained in:
parent
5d81b5374d
commit
6c83312ad3
13 changed files with 5917 additions and 11 deletions
|
@ -1,5 +1,7 @@
|
||||||
using Android.App;
|
using Android.App;
|
||||||
|
using Android.Content;
|
||||||
using Android.Content.PM;
|
using Android.Content.PM;
|
||||||
|
using Android.Net;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
using Android.Views;
|
using Android.Views;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
@ -29,9 +31,12 @@ 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;
|
||||||
|
game.UiSystem.LinkBehavior = l => this.StartActivity(new Intent(Intent.ActionView, Uri.Parse(l.Match.Groups[1].Value)));
|
||||||
|
};
|
||||||
this.game.GraphicsDeviceManager.IsFullScreen = true;
|
this.game.GraphicsDeviceManager.IsFullScreen = true;
|
||||||
this.view = this.game.Services.GetService(typeof(View)) as View;
|
this.view = this.game.Services.GetService(typeof(View)) as View;
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Activity1.cs" />
|
<Compile Include="Activity1.cs" />
|
||||||
|
<Compile Include="AndroidAnalytics.cs" />
|
||||||
<Compile Include="Resources\Resource.Designer.cs" />
|
<Compile Include="Resources\Resource.Designer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -70,6 +71,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Contentless" Version="2.0.6" />
|
<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.Content.Builder" Version="3.7.0.9" />
|
||||||
<PackageReference Include="MonoGame.Framework.Android" Version="3.7.1.189" />
|
<PackageReference Include="MonoGame.Framework.Android" Version="3.7.1.189" />
|
||||||
</ItemGroup>
|
</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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@
|
||||||
"Tutorial11": "Now that you have a couple of attractions, you can start thinking about purchasing modifiers for them! Swipe to access the modifier menu on the far right and purchase a modifier.",
|
"Tutorial11": "Now that you have a couple of attractions, you can start thinking about purchasing modifiers for them! Swipe to access the modifier menu on the far right and purchase a modifier.",
|
||||||
"Tutorial12": "Different kinds of modifiers can be applied to different attractions. Click on one of your attractions and add the modifier to it.",
|
"Tutorial12": "Different kinds of modifiers can be applied to different attractions. Click on one of your attractions and add the modifier to it.",
|
||||||
"Tutorial13": "Modifiers add a ticket sale multiplier to a single attraction. Each attraction can have an infinite amount of any given modifier, so they're a great way to rack up tickets faster.",
|
"Tutorial13": "Modifiers add a ticket sale multiplier to a single attraction. Each attraction can have an infinite amount of any given modifier, so they're a great way to rack up tickets faster.",
|
||||||
|
"GDPRInfo": "This game uses user data for advertising and analytics. For more information, see <c CornflowerBlue><l https://gameanalytics.com/privacy>GameAnalytics'</l></c> and <c CornflowerBlue><l http://www.google.com/policies/privacy/partners/>Google's</l></c> policies on data collection.",
|
||||||
"Carousel": "Carousel",
|
"Carousel": "Carousel",
|
||||||
"FoodCourt": "Food Court",
|
"FoodCourt": "Food Court",
|
||||||
"FerrisWheel": "Ferris Wheel",
|
"FerrisWheel": "Ferris Wheel",
|
||||||
|
|
|
@ -13,6 +13,8 @@ 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 bool ReadAnalyticsInfo;
|
||||||
|
public readonly Analytics Analytics;
|
||||||
public BigInteger Tickets;
|
public BigInteger Tickets;
|
||||||
public int TimesRestarted;
|
public int TimesRestarted;
|
||||||
public int Stars;
|
public int Stars;
|
||||||
|
@ -23,8 +25,21 @@ 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;
|
||||||
|
|
||||||
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadContent() {
|
protected override void LoadContent() {
|
||||||
|
|
|
@ -25,7 +25,8 @@ namespace TouchyTickets {
|
||||||
Stars = game.Stars,
|
Stars = game.Stars,
|
||||||
TimesRestarted = game.TimesRestarted,
|
TimesRestarted = game.TimesRestarted,
|
||||||
Upgrades = game.AppliedUpgrades.Select(u => u.Name).ToList(),
|
Upgrades = game.AppliedUpgrades.Select(u => u.Name).ToList(),
|
||||||
TutorialStep = game.Tutorial.CurrentStep
|
TutorialStep = game.Tutorial.CurrentStep,
|
||||||
|
ReadAnalyticsInfo = game.ReadAnalyticsInfo
|
||||||
};
|
};
|
||||||
Serializer.Serialize(stream, data);
|
Serializer.Serialize(stream, data);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +49,7 @@ namespace TouchyTickets {
|
||||||
foreach (var name in data.Upgrades)
|
foreach (var name in data.Upgrades)
|
||||||
game.AppliedUpgrades.Add(Upgrade.Upgrades[name]);
|
game.AppliedUpgrades.Add(Upgrade.Upgrades[name]);
|
||||||
game.Tutorial.CurrentStep = data.TutorialStep;
|
game.Tutorial.CurrentStep = data.TutorialStep;
|
||||||
|
game.ReadAnalyticsInfo = data.ReadAnalyticsInfo;
|
||||||
|
|
||||||
// version 1 had smaller maps
|
// version 1 had smaller maps
|
||||||
if (data.SaveVersion <= 1) {
|
if (data.SaveVersion <= 1) {
|
||||||
|
@ -88,6 +90,7 @@ namespace TouchyTickets {
|
||||||
public int TimesRestarted;
|
public int TimesRestarted;
|
||||||
public List<string> Upgrades;
|
public List<string> Upgrades;
|
||||||
public int TutorialStep;
|
public int TutorialStep;
|
||||||
|
public bool ReadAnalyticsInfo;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Coroutine" Version="1.0.4" />
|
<PackageReference Include="Coroutine" Version="1.0.4" />
|
||||||
<PackageReference Include="MLEM.Startup" Version="3.3.3-201" />
|
<PackageReference Include="MLEM.Startup" Version="3.3.3-204" />
|
||||||
<PackageReference Include="MonoGame.Framework.Portable" Version="3.7.1.189">
|
<PackageReference Include="MonoGame.Framework.Portable" Version="3.7.1.189">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -172,6 +172,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));
|
||||||
},
|
},
|
||||||
|
@ -234,7 +236,11 @@ namespace TouchyTickets {
|
||||||
if (map.SelectedPosition == null)
|
if (map.SelectedPosition == null)
|
||||||
return;
|
return;
|
||||||
var attraction = map.GetAttractionAt(map.SelectedPosition.Value);
|
var attraction = map.GetAttractionAt(map.SelectedPosition.Value);
|
||||||
GameImpl.Instance.Tickets -= attraction.GetModifierPrice(map.PlacingModifier);
|
|
||||||
|
var price = attraction.GetModifierPrice(map.PlacingModifier);
|
||||||
|
GameImpl.Instance.Tickets -= price;
|
||||||
|
GameImpl.Instance.Analytics.AddResourceEvent(true, "Tickets", price, "Modifier", modifier.Name);
|
||||||
|
|
||||||
attraction.ApplyModifier(map.PlacingModifier);
|
attraction.ApplyModifier(map.PlacingModifier);
|
||||||
},
|
},
|
||||||
OnUpdated = (e2, time) => {
|
OnUpdated = (e2, time) => {
|
||||||
|
@ -297,6 +303,9 @@ namespace TouchyTickets {
|
||||||
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 += game.GetBuyableStars();
|
game.Stars += game.GetBuyableStars();
|
||||||
game.TimesRestarted++;
|
game.TimesRestarted++;
|
||||||
game.Tickets = 0;
|
game.Tickets = 0;
|
||||||
|
@ -378,6 +387,19 @@ namespace TouchyTickets {
|
||||||
center.DrawAlpha -= 0.015F;
|
center.DrawAlpha -= 0.015F;
|
||||||
yield return new WaitEvent(CoroutineEvents.Update);
|
yield return new WaitEvent(CoroutineEvents.Update);
|
||||||
}
|
}
|
||||||
|
if (!GameImpl.Instance.ReadAnalyticsInfo) {
|
||||||
|
var evt = new Event();
|
||||||
|
var panel = splash.AddChild(new Panel(Anchor.Center, new Vector2(0.8F), Vector2.Zero, true));
|
||||||
|
panel.AddChild(new Paragraph(Anchor.AutoLeft, 1, Localization.Get("GDPRInfo")));
|
||||||
|
panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 30), Localization.Get("Okay")) {
|
||||||
|
OnPressed = e2 => {
|
||||||
|
GameImpl.Instance.ReadAnalyticsInfo = true;
|
||||||
|
splash.RemoveChild(panel);
|
||||||
|
CoroutineHandler.RaiseEvent(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
yield return new WaitEvent(evt);
|
||||||
|
}
|
||||||
while (splash.DrawAlpha > 0) {
|
while (splash.DrawAlpha > 0) {
|
||||||
splash.DrawAlpha -= 0.015F;
|
splash.DrawAlpha -= 0.015F;
|
||||||
yield return new WaitEvent(CoroutineEvents.Update);
|
yield return new WaitEvent(CoroutineEvents.Update);
|
||||||
|
@ -457,6 +479,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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ namespace iOS {
|
||||||
|
|
||||||
private static void RunGame() {
|
private static void RunGame() {
|
||||||
TextInputWrapper.Current = new TextInputWrapper.Mobile();
|
TextInputWrapper.Current = new TextInputWrapper.Mobile();
|
||||||
game = new GameImpl();
|
game = new GameImpl(new IosAnalytics());
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,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>
|
||||||
|
@ -131,6 +132,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Contentless" Version="2.0.6" />
|
<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.Content.Builder" Version="3.7.0.9" />
|
||||||
<PackageReference Include="MonoGame.Framework.iOS" Version="3.8.0.1375-develop" />
|
<PackageReference Include="MonoGame.Framework.iOS" Version="3.8.0.1375-develop" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
Loading…
Reference in a new issue