Skip to content

Commit

Permalink
Server fully implemented and sends data properly through Unity.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Dunne committed Mar 7, 2022
1 parent c6dd288 commit 870eea6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions RWM-P2-TEAM-C/Assets/Scenes/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,6 @@ MonoBehaviour:
_invincibleTimer: 2
_damagedFlashRate: 0.25
megaManHealthText: {fileID: 1277291920}
ending: {fileID: 1427678666}
--- !u!50 &706003890
Rigidbody2D:
serializedVersion: 4
Expand Down Expand Up @@ -1526,7 +1525,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 6.5, y: -0.69999695}
m_AnchoredPosition: {x: 6.5, y: -0.7000122}
m_SizeDelta: {x: 49.4386, y: 23.909576}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1001556107
Expand Down Expand Up @@ -2180,7 +2179,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1427678666}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 98.13, y: -0.4, z: -14.377633}
m_LocalPosition: {x: 99, y: -0.4, z: -14.377633}
m_LocalScale: {x: 160.25209, y: 104.93665, z: 1}
m_Children: []
m_Father: {fileID: 0}
Expand Down Expand Up @@ -2260,6 +2259,7 @@ MonoBehaviour:
deathCount: 0
defeatedEnemies: 0
level: 0
version: week_1
--- !u!4 &1482684144
Transform:
m_ObjectHideFlags: 0
Expand Down
10 changes: 6 additions & 4 deletions RWM-P2-TEAM-C/Assets/Scripts/Server/AnalyticsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
[System.Serializable]
public class GameState
{
public int bulletsFired;
public int deathCount;
public int defeatedEnemies;
public int level;
public int bulletsFired = 0;
public int deathCount = 0;
public int defeatedEnemies = 0;
public int level = 0;
public string version = "week_1";
}

public class AnalyticsManager : MonoBehaviour
Expand Down Expand Up @@ -42,6 +43,7 @@ void resetdata()

public IEnumerator PostMethod()
{
Debug.Log("Posting data...");
string jsonData = JsonUtility.ToJson(data); // uses pre-made data object

string url = "http://34.242.150.74/upload_data";
Expand Down
5 changes: 5 additions & 0 deletions RWM-P2-TEAM-C/Assets/Scripts/levelover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void Update()
timer += Time.deltaTime;
displayText();
}

//if(Input.GetMouseButtonDown(0))

}
void displayText()
Expand All @@ -39,7 +41,10 @@ private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.name == "Player")
{
Debug.Log("player detected ending");
ended = true;
Debug.Log(AnalyticsManager.instance);
StartCoroutine(AnalyticsManager.instance.PostMethod());
over.SetActive(true);
}
}
Expand Down
Binary file modified server/__pycache__/game_analytics.cpython-39.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion server/game_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def connect_to_database():
return db

def connect_to_database_outside_docker():
client = MongoClient('34.242.150.74', 80, username="test", password="test")
client = MongoClient('localhost', 27017, username="test", password="test")

global db
db = client.test_database
Expand Down
2 changes: 1 addition & 1 deletion server/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_post_data():
def test_get_data():
#game_analytics.connect_to_database_outside_docker()
print("Connecting to database in test_get_data")
game_analytics.connect_to_database()
game_analytics.connect_to_database_outside_docker()

df = game_analytics.get_dataframe()
print(df)
Expand Down

0 comments on commit 870eea6

Please sign in to comment.