1
- using System ;
2
1
using System . Collections . Generic ;
3
2
using System . Linq ;
4
- using System . Text ;
5
-
6
- using Android . App ;
7
- using Android . Content ;
8
- using Android . OS ;
9
- using Android . Runtime ;
10
- using Android . Views ;
11
- using Android . Widget ;
12
3
using Microsoft . Xna . Framework ;
4
+ using Microsoft . Xna . Framework . Audio ;
5
+ using Microsoft . Xna . Framework . Graphics ;
13
6
using MonoGame . Extended . Sprites ;
7
+ using SpriterDotNet ;
8
+ using SpriterDotNet . MonoGame ;
9
+ using SpriterDotNet . Providers ;
10
+ using Sprite = MonoGame . Extended . Sprites . Sprite ;
11
+ using SpriterSprite = SpriterDotNet . MonoGame . Sprite ;
12
+ using Xmas_Hell . Spriter ;
14
13
15
14
namespace Xmas_Hell . Entities
16
15
{
@@ -21,31 +20,70 @@ class Boss
21
20
private float _initialLife ;
22
21
private float _life ;
23
22
23
+ // Spriter
24
+
25
+ private static readonly Config config = new Config
26
+ {
27
+ MetadataEnabled = true ,
28
+ EventsEnabled = true ,
29
+ PoolingEnabled = true ,
30
+ TagsEnabled = true ,
31
+ VarsEnabled = true ,
32
+ SoundsEnabled = false
33
+ } ;
34
+
35
+ private IList < MonoGameAnimator > animators = new List < MonoGameAnimator > ( ) ;
36
+ private MonoGameAnimator currentAnimator ;
37
+
24
38
public Boss ( XmasHell game , Vector2 position , float initialLife )
25
39
{
26
40
_game = game ;
27
- _sprite = new Sprite ( Assets . GetTexture2D ( "Graphics/Sprites/boss" ) )
28
- {
29
- Position = position
30
- } ;
31
41
32
42
_initialLife = initialLife ;
33
43
_life = initialLife ;
44
+
45
+ //_sprite = new Sprite(Assets.GetTexture2D("Graphics/Sprites/boss"))
46
+ //{
47
+ // Position = position
48
+ //};
49
+
50
+ // Spriter
51
+ DefaultProviderFactory < SpriterSprite , SoundEffect > factory = new DefaultProviderFactory < SpriterSprite , SoundEffect > ( config , true ) ;
52
+
53
+ SpriterContentLoader loader = new SpriterContentLoader ( _game . Content , "Graphics/Sprites/Bosses/XmasBall/spriter" ) ;
54
+ loader . Fill ( factory ) ;
55
+
56
+ foreach ( SpriterEntity entity in loader . Spriter . Entities )
57
+ {
58
+ var animator = new MonoGameDebugAnimator ( entity , _game . GraphicsDevice , factory ) ;
59
+ animators . Add ( animator ) ;
60
+ animator . Position = position ;
61
+ }
62
+
63
+ currentAnimator = animators . First ( ) ;
64
+ currentAnimator . EventTriggered += CurrentAnimator_EventTriggered ;
65
+ }
66
+
67
+ private void CurrentAnimator_EventTriggered ( string obj )
68
+ {
69
+ System . Diagnostics . Debug . WriteLine ( obj ) ;
34
70
}
35
71
36
72
public void Update ( GameTime gameTime )
37
73
{
38
74
_life -= 0.01f ;
75
+
76
+ currentAnimator . Update ( gameTime . ElapsedGameTime . Milliseconds ) ;
39
77
}
40
78
41
79
public void Draw ( GameTime gameTime )
42
80
{
43
- _sprite . Draw ( _game . SpriteBatch ) ;
81
+ currentAnimator . Draw ( _game . SpriteBatch ) ;
44
82
45
83
var percent = _life / _initialLife ;
46
84
_game . SpriteBatch . Draw (
47
85
Assets . GetTexture2D ( "Graphics/Pictures/pixel" ) ,
48
- new Rectangle ( 0 , 0 , ( int ) ( percent * Config . VirtualResolution . X ) , 20 ) ,
86
+ new Rectangle ( 0 , 0 , ( int ) ( percent * GameConfig . VirtualResolution . X ) , 20 ) ,
49
87
Color . Black
50
88
) ;
51
89
}
0 commit comments