• R/O
  • SSH
  • HTTPS

nlgp1: Commit


Commit MetaInfo

Revision855 (tree)
Zeit2011-05-11 14:11:09
Autorbiikame

Log Message

Nlgp1.Sprites.Owners.SpriteOwner.SpriteOwnerを修正

Ändern Zusammenfassung

Diff

--- trunk/Nlgp1/Nlgp1/Sprites/Owners/Characters/Character.cs (revision 854)
+++ trunk/Nlgp1/Nlgp1/Sprites/Owners/Characters/Character.cs (revision 855)
@@ -14,55 +14,9 @@
1414 /// キャラクタクラス
1515 /// </summary>
1616 public class Character : SpriteOwner {
17- public Character( int typeID , SpriteType spriteType , VectorI characterSize , Vector position ) {
18- this.Sprite = new Sprite( LayerType.Character , typeID , spriteType , this , "CharacterImages" , characterSize , () => {
19- MotionType result = MotionType.RestRight;
20- if( this.IsNowJumping == false &&
21- ( this.MovingDirections == Directions.Left || this.MovingDirections == Directions.Right ) && this.IsRest ) {
22- // 静止状態
23- if( this.Directions == ( this.Directions | Directions.Right ) )
24- result = MotionType.RestRight;
25- else
26- result = MotionType.RestLeft;
27- } else if( this.Directions == Directions.Right ) {
28- if( this.IsBoosting )
29- result = MotionType.BoostRight;
30- else
31- result = MotionType.WalkRight;
32- } else if( this.Directions == Directions.Left ) {
33- if( this.IsBoosting )
34- result = MotionType.BoostLeft;
35- else
36- result = MotionType.WalkLeft;
37- } else if( this.Directions == ( this.Directions | Directions.Right ) ) {
38- // 右方向
39- if( this.Directions == ( this.Directions | Directions.Top ) ) {
40- if( this.IsBoosting )
41- result = MotionType.BoostUpRight;
42- else
43- result = MotionType.UpRight;
44- } else {
45- if( this.IsBoosting )
46- result = MotionType.BoostDownRight;
47- else
48- result = MotionType.UpRight;
49- }
50- } else if( this.Directions == ( this.Directions | Directions.Left ) ) {
51- // 左方向
52- if( this.Directions == ( this.Directions | Directions.Top ) ) {
53- if( this.IsBoosting )
54- result = MotionType.BoostUpLeft;
55- else
56- result = MotionType.UpLeft;
57- } else {
58- if( this.IsBoosting )
59- result = MotionType.BoostLeft;
60- else
61- result = MotionType.DownLeft;
62- }
63- }
64- return result;
65- } , string.Format( "Character-{0}" , typeID ) , position );
17+ public Character( int typeID , SpriteType spriteType , VectorI characterSize , Vector position )
18+ : base( LayerType.Character , typeID , spriteType , "CharacterImages" , characterSize , string.Format( "Character-{0}" , typeID ) , position )
19+ {
6620 this.HitPoint = 1;
6721 jumpBoost = 5;
6822 UpGravity = 0.75f;
@@ -74,6 +28,55 @@
7428 };
7529 }
7630
31+ protected override MotionType GetMotionType() {
32+ MotionType result = MotionType.RestRight;
33+ if( this.IsNowJumping == false &&
34+ ( this.MovingDirections == Directions.Left || this.MovingDirections == Directions.Right ) && this.IsRest ) {
35+ // 静止状態
36+ if( this.Directions == ( this.Directions | Directions.Right ) )
37+ result = MotionType.RestRight;
38+ else
39+ result = MotionType.RestLeft;
40+ } else if( this.Directions == Directions.Right ) {
41+ if( this.IsBoosting )
42+ result = MotionType.BoostRight;
43+ else
44+ result = MotionType.WalkRight;
45+ } else if( this.Directions == Directions.Left ) {
46+ if( this.IsBoosting )
47+ result = MotionType.BoostLeft;
48+ else
49+ result = MotionType.WalkLeft;
50+ } else if( this.Directions == ( this.Directions | Directions.Right ) ) {
51+ // 右方向
52+ if( this.Directions == ( this.Directions | Directions.Top ) ) {
53+ if( this.IsBoosting )
54+ result = MotionType.BoostUpRight;
55+ else
56+ result = MotionType.UpRight;
57+ } else {
58+ if( this.IsBoosting )
59+ result = MotionType.BoostDownRight;
60+ else
61+ result = MotionType.UpRight;
62+ }
63+ } else if( this.Directions == ( this.Directions | Directions.Left ) ) {
64+ // 左方向
65+ if( this.Directions == ( this.Directions | Directions.Top ) ) {
66+ if( this.IsBoosting )
67+ result = MotionType.BoostUpLeft;
68+ else
69+ result = MotionType.UpLeft;
70+ } else {
71+ if( this.IsBoosting )
72+ result = MotionType.BoostLeft;
73+ else
74+ result = MotionType.DownLeft;
75+ }
76+ }
77+ return result;
78+ }
79+
7780 /// <summary>
7881 /// 現在の攻撃モードを取得または、設定します。
7982 /// </summary>
--- trunk/Nlgp1/Nlgp1/Sprites/Owners/SpriteOwner.cs (revision 854)
+++ trunk/Nlgp1/Nlgp1/Sprites/Owners/SpriteOwner.cs (revision 855)
@@ -1,14 +1,26 @@
11 using System;
2+using Nlgp1.Common;
3+using Nlgp1.Common.Parameters;
4+using Nlgp1.Sprites.Parameters;
25
36 namespace Nlgp1.Sprites.Owners {
47
58 public abstract class SpriteOwner : ISpriteOwner {
9+
10+ public SpriteOwner( LayerType layerType , int typeID , SpriteType spriteType , string imageTypeName , VectorI chipSize , string debugID , Vector position ) {
11+ this.Sprite = new Sprite( layerType , typeID , spriteType , this , imageTypeName , chipSize , this.GetMotionType , debugID , position );
12+ }
13+
14+ protected virtual MotionType GetMotionType() {
15+ return default( MotionType );
16+ }
17+
618 /// <summary>
719 /// Characterオブジェクトが所有するスプライトを取得します。
820 /// </summary>
921 public Sprite Sprite {
1022 get;
11- protected set;
23+ private set;
1224 }
1325
1426 #region ロジック拡張
--- trunk/Nlgp1/Nlgp1/Sprites/Owners/Attacks/Guns/Gun.cs (revision 854)
+++ trunk/Nlgp1/Nlgp1/Sprites/Owners/Attacks/Guns/Gun.cs (revision 855)
@@ -10,10 +10,18 @@
1010 /// <summary>
1111 /// 弾を表す
1212 /// </summary>
13- public class Gun : SpriteOwner , IGun {
13+ public class Gun : IGun {
1414 private bool isCharRight = false;
1515
1616 /// <summary>
17+ /// 弾のスプライトを取得します。
18+ /// </summary>
19+ public Sprite Sprite {
20+ get;
21+ private set;
22+ }
23+
24+ /// <summary>
1725 /// 弾を生成したIShotオブジェクトを取得します。
1826 /// </summary>
1927 public IAttackOwner Owner {
@@ -29,5 +37,37 @@
2937
3038 }
3139 #endregion
40+
41+ #region IUnloadableComponent メンバー
42+ public void Unload() {
43+ this.Sprite.Unload();
44+ this.OnUnloaded( this , EventArgs.Empty );
45+ }
46+
47+ public event EventHandler Unloaded;
48+
49+ private void OnUnloaded( object sender , EventArgs e ) {
50+ if( this.Unloaded != null ) {
51+ this.Unloaded( sender , e );
52+ }
53+ }
54+ #endregion
55+
56+ #region ロジック拡張
57+ /// <summary>
58+ /// 行動が発生して既定の行動が実行されたあとに発生します。
59+ /// </summary>
60+ public event EventHandler<SpriteSteppedEventArgs> Stepped;
61+ /// <summary>
62+ /// Steppedを発生させます。
63+ /// </summary>
64+ /// <param name="sender">センダー</param>
65+ /// <param name="e">イベント引数</param>
66+ public void OnStepped( object sender, SpriteSteppedEventArgs e ) {
67+ if( this.Stepped != null ) {
68+ this.Stepped( sender , e );
69+ }
70+ }
71+ #endregion
3272 }
3373 }
--- trunk/Nlgp1/Nlgp1/Sprites/Owners/ISpriteOwner.cs (revision 854)
+++ trunk/Nlgp1/Nlgp1/Sprites/Owners/ISpriteOwner.cs (revision 855)
@@ -3,6 +3,7 @@
33 using System.Linq;
44 using System.Text;
55 using Nlgp1.Sprites.Parameters;
6+using Nlgp1.Common;
67
78 namespace Nlgp1.Sprites.Owners {
89 /// <summary>
Show on old repository browser