Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
COMMIT_MESSAGE: "Release https://github.com/TaloDev/unity/releases/tag/${{ github.ref_name }}"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16

- name: Copy files
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Check version change
id: check
uses: EndBug/version-check@v1
uses: EndBug/version-check@v2
with:
file-name: Packages/com.trytalo.talo/package.json

Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/Events/FlushEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

public class FlushEvents : MonoBehaviour
{
public void OnButtonClick()
public async void OnButtonClick()
{
Flush();
await Flush();
}

private async void Flush()
private async Task Flush()
{
try
{
Expand Down
9 changes: 5 additions & 4 deletions Assets/Scripts/Events/TrackEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
using UnityEngine;
using TaloGameServices;
using System.Linq;
using System.Threading.Tasks;

public class TrackEvent : MonoBehaviour
{
public string eventName;
public Prop[] props;
public bool flushImmediately;

public void OnButtonClick()
public async void OnButtonClick()
{
Track();
await Track();
}

private async void Track()
private async Task Track()
{
try
{
Talo.Events.Track(eventName, props.Select((prop) => (prop.key, prop.value)).ToArray());
await Talo.Events.Track(eventName, props.Select((prop) => (prop.key, prop.value)).ToArray());

ResponseMessage.SetText($"{eventName} tracked");

Expand Down
9 changes: 5 additions & 4 deletions Assets/Scripts/Events/TrackLevelUpEvent.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
using UnityEngine;
using TaloGameServices;
using System;
using System.Threading.Tasks;

public class TrackLevelUpEvent : MonoBehaviour
{
public int level = 1;
private float timeTaken;

public void OnButtonClick()
public async void OnButtonClick()
{
Track();
await Track();
}

private void Track()
private async Task Track()
{
level++;

try
{
Talo.Events.Track(
await Talo.Events.Track(
"Level up",
("newLevel", $"{level}"),
("timeTaken", $"{timeTaken}")
Expand Down
7 changes: 4 additions & 3 deletions Assets/Scripts/Leaderboards/GetLeaderboardEntries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
using TaloGameServices;
using UnityEngine;
using System.Linq;
using System.Threading.Tasks;

public class GetLeaderboardEntries : MonoBehaviour
{
public string internalName;
public int page;

public void OnButtonClick()
public async void OnButtonClick()
{
FetchEntries();
await FetchEntries();
}

private async void FetchEntries()
private async Task FetchEntries()
{
try
{
Expand Down
7 changes: 4 additions & 3 deletions Assets/Scripts/Leaderboards/PostLeaderboardEntry.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
using System;
using System.Threading.Tasks;
using TaloGameServices;
using UnityEngine;

public class PostLeaderboardEntry : MonoBehaviour
{
public string internalName;

public void OnButtonClick()
public async void OnButtonClick()
{
PostEntry();
await PostEntry();
}

private async void PostEntry()
private async Task PostEntry()
{
try
{
Expand Down
7 changes: 4 additions & 3 deletions Assets/Scripts/Players/IdentifyPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEngine;
using UnityEngine.UI;
using TaloGameServices;
using System.Threading.Tasks;

public class IdentifyPlayer : MonoBehaviour
{
Expand Down Expand Up @@ -34,12 +35,12 @@ private void Start()
};
}

public void OnButtonClick()
public async void OnButtonClick()
{
Identify();
await Identify();
}

private async void Identify()
private async Task Identify()
{
try
{
Expand Down
9 changes: 5 additions & 4 deletions Assets/Scripts/Players/SetHealthProp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
using System.Collections.Generic;
using UnityEngine;
using TaloGameServices;
using System.Threading.Tasks;

public class SetHealthProp : MonoBehaviour
{
public string key = "currentHealth";

public void OnButtonClick()
public async void OnButtonClick()
{
UpdateProp();
await UpdateProp();
}

private void UpdateProp()
private async Task UpdateProp()
{
string value = Random.Range(0, 100).ToString();

Talo.CurrentPlayer.SetProp(key, value);
await Talo.CurrentPlayer.SetProp(key, value);
ResponseMessage.SetText($"{key} set to {value}");
}
}
7 changes: 7 additions & 0 deletions Assets/Scripts/Saves/LoadableCube.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

public class LoadableCube : Loadable
{
private void OnMouseDrag()
{
var nextPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
nextPos.z = 0;
transform.position = nextPos;
}

public override void RegisterFields()
{
RegisterField("x", transform.position.x);
Expand Down
7 changes: 4 additions & 3 deletions Assets/Scripts/Saves/OfflineSavesLoader.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using UnityEngine;
using TaloGameServices;
using System;
using System.Threading.Tasks;

public class OfflineSavesLoader : MonoBehaviour
{
public void OnButtonClick()
public async void OnButtonClick()
{
Save();
await Save();
}

private async void Save()
private async Task Save()
{
try
{
Expand Down
7 changes: 4 additions & 3 deletions Assets/Scripts/Saves/SaveManager.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
using UnityEngine;
using TaloGameServices;
using System;
using System.Threading.Tasks;

public class SaveManager : MonoBehaviour
{
public string saveName = "New Save";
public bool updateCurrentSave;
public SaveMode saveMode = SaveMode.BOTH;

public void OnButtonClick()
public async void OnButtonClick()
{
Save();
await Save();
}

private async void Save()
private async Task Save()
{
try
{
Expand Down
1 change: 0 additions & 1 deletion Packages/com.trytalo.talo/Runtime/Entities/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
public class Event
{
public string name;
public int aliasId;
public Prop[] props;
public long timestamp;
}
Expand Down
11 changes: 6 additions & 5 deletions Packages/com.trytalo.talo/Runtime/Entities/Player.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using UnityEngine;
using System.Linq;
using System;

using System.Threading.Tasks;

namespace TaloGameServices
{
[Serializable]
Expand All @@ -22,7 +23,7 @@ public string GetProp(string key, string fallback = null)
return prop?.key ?? fallback;
}

public void SetProp(string key, string value)
public async Task SetProp(string key, string value)
{
if (GetProp(key) != null)
{
Expand All @@ -39,17 +40,17 @@ public void SetProp(string key, string value)
props = propList.ToArray();
}

Talo.Players.Update();
await Talo.Players.Update();
}

public void DeleteProp(string key)
public async Task DeleteProp(string key)
{
Prop prop = props.First((prop) => prop.key == key);
if (prop == null) throw new Exception($"Prop with key {key} does not exist");

prop.value = null;

Talo.Players.Update();
await Talo.Players.Update();
}

public bool IsInGroup(string groupId)
Expand Down
16 changes: 6 additions & 10 deletions Packages/com.trytalo.talo/Runtime/EventsAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ public class EventsAPI : BaseAPI

public EventsAPI(TaloManager manager) : base(manager, "events") { }

public void Track(string name)
{
Track(name, null);
}

private string GetWindowMode()
{
if (Screen.fullScreenMode == FullScreenMode.ExclusiveFullScreen)
Expand Down Expand Up @@ -52,13 +47,14 @@ private Prop[] BuildMetaProps()
};
}

public void Track(string name, params (string, string)[] props)
public async Task Track(string name, params (string, string)[] props)
{
Talo.IdentityCheck();

var ev = new Event();
ev.aliasId = Talo.CurrentAlias.id;
ev.name = name;
var ev = new Event
{
name = name
};

if (props != null)
{
Expand All @@ -73,7 +69,7 @@ public void Track(string name, params (string, string)[] props)

if (queue.Count >= minQueueSize)
{
_ = Flush();
await Flush();
}
}

Expand Down
3 changes: 2 additions & 1 deletion Packages/com.trytalo.talo/Runtime/GameConfigAPI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using UnityEngine;

namespace TaloGameServices
Expand All @@ -9,7 +10,7 @@ public class GameConfigAPI : BaseAPI

public GameConfigAPI(TaloManager manager) : base(manager, "game-config") { }

public async void Get()
public async Task Get()
{
var uri = new Uri(baseUrl);
var json = await Call(uri, "GET");
Expand Down
2 changes: 1 addition & 1 deletion Packages/com.trytalo.talo/Runtime/PlayersAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task Identify(string service, string identifier)
OnIdentified?.Invoke(Talo.CurrentPlayer);
}

public async void Update()
public async Task Update()
{
var uri = new Uri(baseUrl + $"/{Talo.CurrentPlayer.id}");
var content = JsonUtility.ToJson(Talo.CurrentPlayer);
Expand Down
2 changes: 1 addition & 1 deletion Packages/com.trytalo.talo/Runtime/SavesAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private void DeleteOfflineSave(int saveId)
WriteOfflineSavesContent(offlineContent);
}

public async void DeleteSave(int saveId)
public async Task DeleteSave(int saveId)
{
GameSave save = _allSaves.First((save) => save.id == saveId);
if (save == null) throw new Exception("Save not found");
Expand Down
3 changes: 2 additions & 1 deletion Packages/com.trytalo.talo/Runtime/StatsAPI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using UnityEngine;

namespace TaloGameServices
Expand All @@ -7,7 +8,7 @@ public class StatsAPI : BaseAPI
{
public StatsAPI(TaloManager manager) : base(manager, "game-stats") { }

public async void Track(string internalName, float change = 1f)
public async Task Track(string internalName, float change = 1f)
{
Talo.IdentityCheck();

Expand Down
Loading