Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
MusketWidget.cs
浏览该文件的文档.
1
using
System.Xml.Linq;
2
using
Engine
;
3
4
namespace
Game
{
5
public
class
MusketWidget
:
CanvasWidget
{
6
public
IInventory
m_inventory
;
7
8
public
int
m_slotIndex
;
9
10
public
GridPanelWidget
m_inventoryGrid
;
11
12
public
InventorySlotWidget
m_inventorySlotWidget
;
13
14
public
LabelWidget
m_instructionsLabel
;
15
public
static
string
fName
=
"MusketWidget"
;
16
17
public
MusketWidget
(
IInventory
inventory,
int
slotIndex) {
18
m_inventory
= inventory;
19
m_slotIndex
= slotIndex;
20
XElement node =
ContentManager
.
Get
<XElement>(
"Widgets/MusketWidget"
);
21
LoadContents
(
this
, node);
22
m_inventoryGrid
=
Children
.Find<
GridPanelWidget
>(
"InventoryGrid"
);
23
m_inventorySlotWidget
=
Children
.Find<
InventorySlotWidget
>(
"InventorySlot"
);
24
m_instructionsLabel
=
Children
.Find<
LabelWidget
>(
"InstructionsLabel"
);
25
for
(
int
i = 0; i <
m_inventoryGrid
.RowsCount; i++) {
26
for
(
int
j = 0; j <
m_inventoryGrid
.ColumnsCount; j++) {
27
InventorySlotWidget
widget =
new
();
28
m_inventoryGrid
.Children.Add(widget);
29
m_inventoryGrid
.SetWidgetCell(widget,
new
Point2
(j, i));
30
}
31
}
32
int
num = 10;
33
foreach
(
Widget
child
in
m_inventoryGrid
.Children) {
34
(child as
InventorySlotWidget
)?.AssignInventorySlot(inventory, num++);
35
}
36
m_inventorySlotWidget
.AssignInventorySlot(inventory, slotIndex);
37
m_inventorySlotWidget.CustomViewMatrix =
Matrix
.
CreateLookAt
(
new
Vector3
(1f, 0f, 0f),
new
Vector3
(0f, 0f, 0f), -
Vector3
.
UnitZ
);
38
}
39
40
public
override
void
Update
() {
41
int
slotValue =
m_inventory
.GetSlotValue(
m_slotIndex
);
42
int
slotCount =
m_inventory
.GetSlotCount(
m_slotIndex
);
43
if
(
Terrain
.
ExtractContents
(slotValue) == 212
44
&& slotCount > 0) {
45
switch
(
MusketBlock
.
GetLoadState
(
Terrain
.
ExtractData
(slotValue))) {
46
case
MusketBlock
.
LoadState
.Empty: m_instructionsLabel.Text =
LanguageControl
.
Get
(
fName
, 0);
break
;
47
case
MusketBlock
.
LoadState
.Gunpowder: m_instructionsLabel.Text =
LanguageControl
.
Get
(
fName
, 1);
break
;
48
case
MusketBlock
.
LoadState
.Wad: m_instructionsLabel.Text =
LanguageControl
.
Get
(
fName
, 2);
break
;
49
case
MusketBlock
.
LoadState
.Loaded: m_instructionsLabel.Text =
LanguageControl
.
Get
(
fName
, 3);
break
;
50
default
: m_instructionsLabel.Text =
string
.Empty;
break
;
51
}
52
}
53
else
{
54
ParentWidget
.Children.Remove(
this
);
55
}
56
}
57
}
58
}
Vector3
Engine.Vector3 Vector3
定义
SubsystemAudio.cs:5
Game.CanvasWidget
定义
CanvasWidget.cs:4
Game.ContainerWidget.Children
readonly WidgetsList Children
定义
ContainerWidget.cs:5
Game.ContentManager
定义
ContentManager.cs:50
Game.ContentManager.Get
static object Get(Type type, string name)
定义
ContentManager.cs:70
Game.GridPanelWidget
定义
GridPanelWidget.cs:4
Game.InventorySlotWidget
定义
InventorySlotWidget.cs:7
Game.LabelWidget
定义
LabelWidget.cs:4
Game.LanguageControl
定义
LanguageControl.cs:8
Game.LanguageControl.Get
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
定义
LanguageControl.cs:247
Game.MusketBlock
定义
MusketBlock.cs:5
Game.MusketBlock.GetLoadState
static LoadState GetLoadState(int data)
定义
MusketBlock.cs:98
Game.MusketBlock.LoadState
LoadState
定义
MusketBlock.cs:7
Game.MusketWidget.m_instructionsLabel
LabelWidget m_instructionsLabel
定义
MusketWidget.cs:14
Game.MusketWidget.Update
override void Update()
定义
MusketWidget.cs:40
Game.MusketWidget.fName
static string fName
定义
MusketWidget.cs:15
Game.MusketWidget.MusketWidget
MusketWidget(IInventory inventory, int slotIndex)
定义
MusketWidget.cs:17
Game.MusketWidget.m_inventoryGrid
GridPanelWidget m_inventoryGrid
定义
MusketWidget.cs:10
Game.MusketWidget.m_inventory
IInventory m_inventory
定义
MusketWidget.cs:6
Game.MusketWidget.m_slotIndex
int m_slotIndex
定义
MusketWidget.cs:8
Game.MusketWidget.m_inventorySlotWidget
InventorySlotWidget m_inventorySlotWidget
定义
MusketWidget.cs:12
Game.Terrain
定义
Terrain.cs:5
Game.Terrain.ExtractContents
static int ExtractContents(int value)
定义
Terrain.cs:303
Game.Terrain.ExtractData
static int ExtractData(int value)
定义
Terrain.cs:307
Game.Widget
定义
Widget.cs:10
Game.Widget.ParentWidget
ContainerWidget ParentWidget
定义
Widget.cs:468
Game.Widget.LoadContents
virtual void LoadContents(object eventsTarget, XElement node)
定义
Widget.cs:507
Game.IInventory
定义
IInventory.cs:5
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Engine.Matrix
定义
Matrix.cs:17
Engine.Matrix.CreateLookAt
static Matrix CreateLookAt(Vector3 position, Vector3 target, Vector3 up)
定义
Matrix.cs:282
Engine.Point2
定义
Point2.cs:2
Engine.Vector3
定义
Vector3.cs:2
Engine.Vector3.UnitZ
static readonly Vector3 UnitZ
定义
Vector3.cs:17
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Widget
MusketWidget.cs
制作者
1.16.1