PlayerManager.cs
1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//Debug.Log Dir http://docs.unity3d.com/Manual/Debug.LogFiles.html
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using UnityEngine.UI;
public class PlayerManager : GenericPlayerManager {
//Importacao de metodos de instancia do core via DLLs
[DllImport ("CorePlugin")] public static extern int coreInitialize();
[DllImport ("CorePlugin")] private static extern IntPtr coreExecute();
[DllImport ("CorePlugin")] public static extern int coreFinalize();
public ScreenManager screenManager;
private string[] randomAnimationNames = new string[] {
"[RELAXAR]",
"[BOCEJAR]",
"[COCHILAR]",
"[ESPREGUI_ADA]"
};
public override void Start()
{
Screen.SetResolution(640, 480, false);
// Puxa as dlls do core
try { Debug.Log("Inicializando: " + coreInitialize()); } catch (Exception e) { Debug.Log (e.ToString()); }
base.setRandomAnimations(randomAnimationNames);
base.Start();
}
public string catchGlosa() {
return Marshal.PtrToStringAnsi(coreExecute());
}
public void start_local_play() {
start_local_play(catchGlosa());
}
public void start_local_play(string glosa)
{
base.gloss = glosa;
base.playNow(glosa);
}
private System.Object LOCKER_STATE = new System.Object();
protected override void onPlayingStateChange() {
lock (LOCKER_STATE) {
this.screenManager.updateButtons(base.isPlaying(), base.isPaused());
}
}
protected override WWW loadAssetBundle(string aniName)
{
string assetPath = Application.dataPath + "/Bundles/" + aniName;
if ( ! File.Exists(assetPath))
return null;
try {
WWW www = new WWW("file://" + assetPath);
return www;
} catch (Exception e) {
Debug.Log(e);
}
return null;
}
protected override void onConnectionError(string gloss, string word) { }
void OnApplicationQuit()
{
try {
Debug.Log("Finalizando: " + coreFinalize());
} catch (Exception e) {
Debug.Log(e.ToString());
}
}
}