forked from mp1011/KidChameleonRemake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKidCTile.cs
145 lines (117 loc) · 3.69 KB
/
KidCTile.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Engine.Collision;
using Engine;
using System.ComponentModel;
namespace KidC
{
public enum SpecialTile
{
Normal=0,
Rock=10,
Prize=20,
Metal=30,
Rubber=40,
Platform=50,
Elevator=60,
Ice=70,
Vanishing=80,
Mushroom=90,
Teleporter=100,
Shifter = 110,
Ghost
}
public class KCTileDef : TileDef
{
public SpecialTile SpecialType { get; set; }
public KCTileDef() { }
public KCTileDef(TileDef baseDef)
{
this.SpecialType = SpecialTile.Normal;
this.SetValues(baseDef.TileID, baseDef.Flags, baseDef.Sides, baseDef.SourcePosition);
}
protected override object GetSaveModelExtra()
{
return (int)SpecialType;
}
protected override void LoadExtra(object data)
{
if (data == null)
SpecialType = SpecialTile.Normal;
else
SpecialType = (SpecialTile)((long)data);
}
}
public class KCTileInstance : TileInstance
{
private KCTileDef mTiledef = new KCTileDef();
[Browsable(false)]
public override TileDef TileDef
{
get
{
return mTiledef;
}
set
{
var d = value as KCTileDef;
if (d == null)
mTiledef = new KCTileDef(value);
else
mTiledef = d;
}
}
[Browsable(false)]
public KCTileDef KCTileDef { get { return mTiledef; } }
public PrizeType Prize { get; set; }
[Browsable(false)]
public DirectionFlags EffectSides { get; set; }
[DisplayName("EffectSides")]
public EditorDirectionFlags _SidesForEditor
{
get
{
if (EffectSides == null)
return EditorDirectionFlags.None;
return EffectSides.ToEditorFlags();
}
set
{
this.EffectSides = new DirectionFlags(value);
}
}
public override CollidingTile CreateCollidingTile(TileCollisionView collisionView)
{
var flags = this.TileDef.Flags;
switch (this.KCTileDef.SpecialType)
{
case SpecialTile.Prize: return new PrizeBlock(this, collisionView);
case SpecialTile.Rock: return new RockBlock(this, collisionView);
case SpecialTile.Metal: return new MetalBlock(this, collisionView);
case SpecialTile.Rubber: return new RubberBlock(this, collisionView);
case SpecialTile.Ice: return new IceBlock(this, collisionView);
case SpecialTile.Vanishing: return new VanishingBlock(this, collisionView);
case SpecialTile.Mushroom: return new MushroomBlock(this, collisionView);
default: return new PlainTile(this, collisionView);
}
}
[Browsable(false)]
public override bool IsSpecial
{
get { return this.KCTileDef.SpecialType != SpecialTile.Normal; }
}
}
class PlainTile : CollidingTile
{
public PlainTile(TileInstance tile, TileCollisionView collisionView) : base(tile, collisionView) { }
public override void HandleCollision(CollisionEvent collision, CollisionResponse response)
{
}
protected override void Update()
{
this.Kill(Engine.ExitCode.Finished);
}
}
}