-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainEx.cs
152 lines (123 loc) · 5.15 KB
/
MainEx.cs
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AFCoreEx
{
class MainEx
{
static void HeartBeatEventHandler(AFIDENTID self, string strHeartBeat, float fTime, AFIDataList valueList)
{
Console.Write(self);
Console.Write(" ");
Console.Write(strHeartBeat);
Console.Write(" ");
Console.Write(fTime.ToString());
Console.WriteLine(" ");
}
static void OnRecordEventHandler(AFIDENTID self, string strRecordName, AFIRecord.eRecordOptype eType, int nRow, int nCol, AFIDataList oldVar, AFIDataList newVar)
{
Console.Write(self);
Console.Write(" ");
Console.Write(strRecordName);
Console.Write(" ");
Console.Write(eType.ToString());
Console.Write(" ");
Console.Write(nRow);
Console.Write(" ");
Console.Write(nCol);
Console.Write(" ");
Console.Write(oldVar.Int64Val(0));
Console.Write(" ");
Console.Write(newVar.Int64Val(0));
Console.WriteLine(" ");
}
static void OnPropertydHandler(AFIDENTID self, string strProperty, AFIDataList oldVar, AFIDataList newVar)
{
Console.Write(self);
Console.Write(" ");
Console.Write(strProperty);
Console.Write(" ");
Console.Write(oldVar.Int64Val(0));
Console.Write(" ");
Console.Write(newVar.Int64Val(0));
Console.WriteLine(" ");
}
static void OnClassHandler(AFIDENTID self, int nContainerID, int nGroupID, AFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex)
{
Console.Write(self);
Console.Write(" ");
Console.Write(eType.ToString());
Console.Write(" ");
Console.Write(strClassName);
Console.Write(" ");
Console.Write(strConfigIndex);
Console.WriteLine(" ");
}
public static void Main()
{
AFIKernel kernel = new AFCKernel();
Console.WriteLine("****************AFIDataList******************");
AFIDataList var = new AFCDataList();
for (int i = 0; i < 9; i +=3)
{
var.AddInt64(i);
var.AddFloat((float)i+1);
var.AddString((i+2).ToString());
}
for (int i = 0; i < 9; i += 3)
{
Int64 n = var.Int64Val(i);
float f = var.FloatVal(i+1);
string str = var.StringVal(i+2);
Console.WriteLine(n);
Console.WriteLine(f);
Console.WriteLine(str);
}
Console.WriteLine("***************AFProperty*******************");
AFIDENTID ident = new AFIDENTID(0, 1);
AFIObject gameObject = kernel.CreateObject(ident, 0, 0, "", "", new AFCDataList());
AFIDataList valueProperty = new AFCDataList();
valueProperty.AddInt64(112221);
gameObject.GetPropertyManager().AddProperty("111", valueProperty);
Console.WriteLine(gameObject.QueryPropertyInt("111"));
Console.WriteLine("***************AFRecord*******************");
AFIDataList valueRecord = new AFCDataList();
valueRecord.AddInt64(0);
valueRecord.AddFloat(0);
valueRecord.AddString("");
valueRecord.AddObject(ident);
gameObject.GetRecordManager().AddRecord("testRecord", 10, valueRecord);
kernel.SetRecordInt(ident, "testRecord", 0, 0, 112221);
kernel.SetRecordFloat(ident, "testRecord", 0, 1, 1122210.0f);
kernel.SetRecordString(ident, "testRecord", 0, 2, ";;;;;;112221");
kernel.SetRecordObject(ident, "testRecord", 0, 3, ident);
Console.WriteLine(gameObject.QueryRecordInt("testRecord", 0,0));
Console.WriteLine(gameObject.QueryRecordFloat("testRecord", 0, 1));
Console.WriteLine(gameObject.QueryRecordString("testRecord", 0, 2));
Console.WriteLine(gameObject.QueryRecordObject("testRecord", 0, 3));
Console.WriteLine(" ");
Console.WriteLine("***************PropertyAFEvent*******************");
//挂属性回调,挂表回调
kernel.RegisterPropertyCallback(ident, "111", OnPropertydHandler);
kernel.SetPropertyInt(ident, "111", 2456);
Console.WriteLine(" ");
Console.WriteLine("***************RecordAFEvent*******************");
kernel.RegisterRecordCallback(ident, "testRecord", OnRecordEventHandler);
kernel.SetRecordInt(ident, "testRecord", 0, 0, 1111111);
Console.WriteLine(" ");
Console.WriteLine("***************ClassAFEvent*******************");
kernel.RegisterClassCallBack("CLASSAAAAA", OnClassHandler);
kernel.CreateObject(new AFIDENTID(0, 2), 0, 0, "CLASSAAAAA", "COAFIGINDEX", new AFCDataList());
kernel.DestroyObject(new AFIDENTID(0, 2));
Console.WriteLine(" ");
Console.WriteLine("***************AFHeartBeat*******************");
kernel.AddHeartBeat(new AFIDENTID(0, 1), "TestHeartBeat", HeartBeatEventHandler, 5.0f, new AFCDataList());
while (true)
{
System.Threading.Thread.Sleep(1000);
kernel.UpDate(1.0f);
}
}
}
}