1
Fork 0
mirror of https://github.com/Steffo99/better-tee.git synced 2024-11-24 00:04:19 +00:00

Complete drawing

This commit is contained in:
Steffo 2019-09-11 16:12:59 +02:00
parent 4a3b3fb339
commit b4955cd27a
10 changed files with 68 additions and 15 deletions

View file

@ -15,8 +15,7 @@ public class DrawableFrame : MonoBehaviour
[Header("References")]
protected Texture2D texture = null;
protected Sprite sprite = null;
private SpriteRenderer spriteRenderer;
protected SpriteRenderer spriteRenderer;
public Rect Bounds {
get {
@ -60,6 +59,10 @@ public class DrawableFrame : MonoBehaviour
}
}
public byte[] ToPNG() {
return texture.EncodeToPNG();
}
protected void Update() {
if(hasChanged) {
texture.Apply();

View file

@ -36,6 +36,9 @@ public class DrawingManager : MonoBehaviour
protected Text actDescription;
protected Timer timer;
[Header("Results")]
public byte[] png = null;
void Start() {
if(jsonString != "") {
JsonUtility.FromJsonOverwrite(jsonString, settings);
@ -81,8 +84,18 @@ public class DrawingManager : MonoBehaviour
timer = Instantiate(timerPrefab, canvas.transform).GetComponent<Timer>();
timer.TimerSet(settings.timeLimit);
timer.OnTimeOut += ActEnd;
//TODO: replace with a countdown or something
ActStart();
}
void ActStart() {
timer.TimerStart();
drawableFrame.locked = false;
}
void ActEnd(object sender, EventArgs e) {
drawableFrame.locked = true;
png = drawableFrame.ToPNG();
}
}

View file

@ -20,7 +20,7 @@ public class Timer : MonoBehaviour
}
else {
if(isTriggered) {
_OnTimeOut(EventArgs.Empty);
_OnTimeOut(this, EventArgs.Empty);
time = 0f;
isTriggered = false;
isRunning = false;
@ -50,7 +50,7 @@ public class Timer : MonoBehaviour
}
public event EventHandler OnTimeOut;
protected virtual void _OnTimeOut(EventArgs e)
protected virtual void _OnTimeOut(object sender, EventArgs e)
{
EventHandler handler = OnTimeOut;
handler?.Invoke(this, e);

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: aaf9bd224abbcaf4ea735306b30dab0f
guid: dcae4071051a0e74ea8904241ee3d0e1
folderAsset: yes
DefaultImporter:
externalObjects: {}

View file

@ -302,6 +302,12 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!4 &781296762 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3241962964773812267, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
m_PrefabInstance: {fileID: 3241962965509540481}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1207901189
GameObject:
m_ObjectHideFlags: 0
@ -368,17 +374,48 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1832035424
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1832035425}
m_Layer: 0
m_Name: Game Controller
m_TagString: GameController
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1832035425
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1832035424}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 781296762}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &3241962965509540481
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_TransformParent: {fileID: 1832035425}
m_Modifications:
- target: {fileID: 3241962964773812264, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
propertyPath: m_Name
value: Drawing Manager
value: Drawing Controller
objectReference: {fileID: 0}
- target: {fileID: 3241962964773812267, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
@ -398,17 +435,17 @@ PrefabInstance:
- target: {fileID: 3241962964773812267, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3241962964773812267, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3241962964773812267, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3241962964773812267, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
@ -418,7 +455,7 @@ PrefabInstance:
- target: {fileID: 3241962964773812267, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
propertyPath: m_RootOrder
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3241962964773812267, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
@ -438,7 +475,7 @@ PrefabInstance:
- target: {fileID: 3241962964773812269, guid: 4fd713402edcc1c43b82d4d86a713998,
type: 3}
propertyPath: jsonString
value: '{"startingColor":{"r":1.0,"g":1.0,"b":1.0,"a":1.0},"palette":[{"r":1.0,"g":0.0,"b":0.0,"a":1.0},{"r":1.0,"g":1.0,"b":0.0,"a":1.0},{"r":0.0,"g":1.0,"b":0.0,"a":1.0},{"r":0.0,"g":1.0,"b":1.0,"a":1.0},{"r":0.0,"g":0.0,"b":1.0,"a":1.0},{"r":1.0,"g":0.0,"b":1.0,"a":1.0},{"r":1.0,"g":1.0,"b":1.0,"a":1.0}],"timeLimit":99.0,"actName":"RAINBOWS","actDescription":"Disegna
value: '{"startingColor":{"r":1.0,"g":1.0,"b":1.0,"a":1.0},"palette":[{"r":1.0,"g":0.0,"b":0.0,"a":1.0},{"r":1.0,"g":1.0,"b":0.0,"a":1.0},{"r":0.0,"g":1.0,"b":0.0,"a":1.0},{"r":0.0,"g":1.0,"b":1.0,"a":1.0},{"r":0.0,"g":0.0,"b":1.0,"a":1.0},{"r":1.0,"g":0.0,"b":1.0,"a":1.0},{"r":1.0,"g":1.0,"b":1.0,"a":1.0}],"timeLimit":5.0,"actName":"RAINBOWS","actDescription":"Disegna
qualcosa con questi colori superluminosi!"}'
objectReference: {fileID: 0}
m_RemovedComponents: []

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4d49d9643c1c6c64fbdf252e73798063
guid: 034dca9b3427d3c43be44c9c652b2816
folderAsset: yes
DefaultImporter:
externalObjects: {}

View file

@ -6,6 +6,6 @@ EditorBuildSettings:
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/Scenes/SampleScene.unity
path: Assets/SampleScene.unity
guid: 2cda990e2423bbf4892e6590ba056729
m_configObjects: {}