Skip to content
This repository was archived by the owner on Mar 25, 2023. It is now read-only.

Commit e4d911a

Browse files
Actions fixes
1 parent 78be78a commit e4d911a

12 files changed

+154
-42
lines changed

Assets/Art/Fonts/dogica SDF.asset

+69-25
Large diffs are not rendered by default.

Assets/Scenes/SampleScene.unity

+3-3
Original file line numberDiff line numberDiff line change
@@ -35047,7 +35047,7 @@ MonoBehaviour:
3504735047
m_text: "{ \"base_class_name\" : \"Object\", \"class_name\" : \"Bear\", \"properties\"
3504835048
: {\"id\": -1, \"position\": \"(2,1)\"} }\n{ \"base_class_name\" : \"Action\",
3504935049
\"class_name\" : \"Move\", \"properties\" : {\"object_id\": -1, \"direction\":
35050-
\"DOWN\"} } \u200B"
35050+
\"SOUTH\"} } \u200B"
3505135051
m_isRightToLeft: 0
3505235052
m_fontAsset: {fileID: 11400000, guid: c399690e56859744287b7d0dab7e59da, type: 2}
3505335053
m_sharedMaterial: {fileID: -2209677979897307283, guid: c399690e56859744287b7d0dab7e59da, type: 2}
@@ -46448,7 +46448,7 @@ MonoBehaviour:
4644846448
{"id": -1, "position": "(2,1)"} }
4644946449

4645046450
{ "base_class_name" : "Action", "class_name"
46451-
: "Move", "properties" : {"object_id": -1, "direction": "DOWN"} } '
46451+
: "Move", "properties" : {"object_id": -1, "direction": "SOUTH"} } '
4645246452
m_CaretBlinkRate: 0.85
4645346453
m_CaretWidth: 1
4645446454
m_ReadOnly: 0
@@ -62254,7 +62254,7 @@ MonoBehaviour:
6225462254
m_Name:
6225562255
m_EditorClassIdentifier:
6225662256
username: testuser2
62257-
sendCodeUrl: https://server.blazej-smorawski.com
62257+
sendCodeUrl: http://localhost:9000
6225862258
prefabs:
6225962259
- {fileID: 4821601493024767675, guid: 34f88d0fe2837ec45a120a43da02a9b3, type: 3}
6226062260
- {fileID: 5771171370426418569, guid: d47ac087dc8fe97418c9a331bec75e04, type: 3}

Assets/Scripts/DealDmg.cs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
using UnityEngine;
5+
6+
public class DealDmg : Action
7+
{
8+
public DealDmg(string properties) { }
9+
10+
public override Task Execute(World world)
11+
{
12+
return Task.CompletedTask;
13+
}
14+
}

Assets/Scripts/DealDmg.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Deserializer.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,21 @@ static public Action GetAction(string json)
1616

1717
ActionProperties properties = JsonUtility.FromJson<ActionProperties>(json);
1818

19-
Type type = Type.GetType(properties.class_name.ToString());
20-
Action action = (Action)Activator.CreateInstance(type, propertiesJson);
19+
Action action = null;
20+
21+
try
22+
{
23+
Type type = Type.GetType(properties.class_name.ToString());
24+
Debug.Log(properties.class_name.ToString());
25+
action = (Action)Activator.CreateInstance(type, propertiesJson);
26+
}
27+
catch (Exception e)
28+
{
29+
Debug.LogException(e);
30+
}
31+
2132
return action;
33+
2234
}
2335

2436
static public Object GetObject(string json, List<GameObject> prefabs)

Assets/Scripts/Move.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ public override async Task Execute(World world)
2727

2828
switch(properties.direction)
2929
{
30-
case "UP":
30+
case "NORTH":
3131
dx = 0;
3232
dz = 1;
3333
break;
34-
case "RIGHT":
34+
case "EAST":
3535
dx = 1;
3636
dz = 0;
3737
break;
38-
case "DOWN":
38+
case "SOUTH":
3939
dx = 0;
4040
dz= -1;
4141
break;
42-
case "LEFT":
42+
case "WEST":
4343
dx = -1;
4444
dz = 0;
4545
break;
@@ -49,6 +49,8 @@ public override async Task Execute(World world)
4949
break;
5050
}
5151

52+
// Object.transform.position already
53+
// accounts for Objects size
5254
Vector3 destination = new Vector3(
5355
agent.transform.position.x + dx,
5456
agent.transform.position.y,

Assets/Scripts/Prepare.cs Assets/Scripts/PrepareToSlam.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
using System.Threading.Tasks;
44
using UnityEngine;
55

6-
public class PrepareProperties
6+
public class PrepareToSlamProperties
77
{
88
public int object_id;
99
}
1010

11-
public class Prepare : Action
11+
public class PrepareToSlam : Action
1212
{
13-
private PrepareProperties properties;
13+
private PrepareToSlamProperties properties;
1414

15-
public Prepare(string propertiesJson) : base()
15+
public PrepareToSlam(string propertiesJson) : base()
1616
{
17-
properties = JsonUtility.FromJson<PrepareProperties>(propertiesJson);
17+
properties = JsonUtility.FromJson<PrepareToSlamProperties>(propertiesJson);
1818
}
1919

2020
public override async Task Execute(World world)
File renamed without changes.

Assets/Scripts/WaitForCode.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
using UnityEngine;
5+
6+
public class WaitForCode : Action
7+
{
8+
public WaitForCode(string properties)
9+
{
10+
11+
}
12+
13+
public override Task Execute(World world)
14+
{
15+
return Task.CompletedTask;
16+
}
17+
}

Assets/Scripts/WaitForCode.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/World.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public async Task RunRequest(string request, string route)
107107
if (log.Contains("Action"))
108108
{
109109
Action action = Deserializer.GetAction(log);
110-
await action.Execute(this);
110+
if (action != null)
111+
await action.Execute(this);
111112
}
112113
else if (log.Contains("Object"))
113114
{

ProjectSettings/ProjectSettings.asset

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ PlayerSettings:
4545
defaultScreenWidth: 1024
4646
defaultScreenHeight: 768
4747
defaultScreenWidthWeb: 960
48-
defaultScreenHeightWeb: 600
48+
defaultScreenHeightWeb: 640
4949
m_StereoRenderingPath: 0
5050
m_ActiveColorSpace: 0
5151
m_MTRendering: 1
@@ -591,7 +591,7 @@ PlayerSettings:
591591
webGLDebugSymbols: 0
592592
webGLEmscriptenArgs:
593593
webGLModulesDirectory:
594-
webGLTemplate: APPLICATION:Minimal
594+
webGLTemplate: APPLICATION:Default
595595
webGLAnalyzeBuildSize: 0
596596
webGLUseEmbeddedResources: 0
597597
webGLCompressionFormat: 1

0 commit comments

Comments
 (0)