forked from mp1011/KidChameleonRemake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIceBlock.cs
77 lines (60 loc) · 2.27 KB
/
IceBlock.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
using Engine;
using Engine.Collision;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace KidC
{
class IceBlock : KCCollidingTile, IBreakableTile
{
private SimpleGraphic mGraphic;
private Direction mDirection;
public IceBlock(KCTileInstance tile, TileCollisionView collisionView)
: base(tile, collisionView)
{
mGraphic = KidCGraphic.IceBlockBreak.CreateSimpleGraphic(this.Context);
}
protected override SoundResource HitSound
{
get { return Sounds.RockBlockDestroyed; }
}
protected override bool ShouldInteract(CollisionEvent collision, CollisionResponse response)
{
return this.ShouldBreak;
}
protected override void Draw(Engine.Graphics.Painter p, RGRectangleI canvas)
{
mGraphic.Position = this.Location;
mGraphic.Draw(p, canvas);
}
protected override void Update()
{
if (this.Age > 2)
{
this.Kill(Engine.ExitCode.Removed);
var loc = this.Location;
var breakDirection = Direction.Up;
List<Sprite> spikes = new List<Sprite>();
spikes.Add(KidCObject.IceFragment.Create(this.TileLayer));
spikes.Add(KidCObject.IceFragment.Create(this.TileLayer));
spikes.Add(KidCObject.IceFragment.Create(this.TileLayer));
foreach (var spike in spikes)
{
spike.MotionManager.MainMotion.Direction = mDirection;
spike.Direction = mDirection;
}
var center = this.TileInstance.TileArea.Center;
spikes[0].Location = center.Offset(mDirection, 4);
spikes[1].Location = center.Offset(mDirection.RotateD(RotationType.Clockwise, 90), 4);
spikes[2].Location = center.Offset(mDirection.RotateD(RotationType.Counterclockwise, 90), 4);
}
}
public bool ShouldBreak { get; private set; }
public void Break(CollisionEvent evt)
{
this.ShouldBreak = true;
mDirection = evt.CollisionSide.ToDirection();
}
}
}