• R/O
  • SSH
  • HTTPS

nlgp1: Commit


Commit MetaInfo

Revision842 (tree)
Zeit2011-03-03 08:33:43
Autorbiikame

Log Message

Nlgp1.Charactersの修正を復元

Ändern Zusammenfassung

Diff

--- trunk/Nlgp1/Nlgp1/Characters/Character.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Characters/Character.cs (revision 842)
@@ -1,5 +1,4 @@
11 using System;
2-using System.Collections.Generic;
32 using Box2DX.Collision;
43 using Nlgp1.Attacks;
54 using Nlgp1.Attacks.Guns;
@@ -15,53 +14,48 @@
1514 /// </summary>
1615 public class Character : ISpriteOwner {
1716 public Character( int typeID , SpriteType spriteType , VectorI characterSize , Vector position ) {
18- UpGravity = 0.75f;
19- DownGravity = 2;
20- JumpPower = 5;
21- FlyGravity = 0.05f;
22- HitPoint = 1;
23- jumpBoost = 5;
2417 this.Sprite = new Sprite( LayerType.Character , typeID , spriteType , this , "CharacterImages" , characterSize , () => {
18+ Sprite sprite = this.Sprite;
2519 MotionType result = MotionType.RestRight;
26- if( this.IsNowJumping == false &&
27- ( this.MovingDirections == Directions.Left || this.MovingDirections == Directions.Right ) && this.Sprite.Body.Velocity != Vector.Zero ) {
20+ if( sprite.IsNowJumping == false &&
21+ ( sprite.MovingDirections == Directions.Left || sprite.MovingDirections == Directions.Right ) && sprite.Body.Velocity != Vector.Zero ) {
2822 // 静止状態
29- if( this.Directions == ( this.Directions | Directions.Right ) )
23+ if( sprite.Directions == ( sprite.Directions | Directions.Right ) )
3024 result = MotionType.RestRight;
3125 else
3226 result = MotionType.RestLeft;
33- } else if( this.Directions == Directions.Right ) {
34- if( this.IsBoosting )
27+ } else if( sprite.Directions == Directions.Right ) {
28+ if( sprite.IsBoosting )
3529 result = MotionType.BoostRight;
3630 else
3731 result = MotionType.WalkRight;
38- } else if( this.Directions == Directions.Left ) {
39- if( this.IsBoosting )
32+ } else if( sprite.Directions == Directions.Left ) {
33+ if( sprite.IsBoosting )
4034 result = MotionType.BoostLeft;
4135 else
4236 result = MotionType.WalkLeft;
43- } else if( this.Directions == ( this.Directions | Directions.Right ) ) {
37+ } else if( sprite.Directions == ( sprite.Directions | Directions.Right ) ) {
4438 // 右方向
45- if( this.Directions == ( this.Directions | Directions.Top ) ) {
46- if( this.IsBoosting )
39+ if( sprite.Directions == ( sprite.Directions | Directions.Top ) ) {
40+ if( sprite.IsBoosting )
4741 result = MotionType.BoostUpRight;
4842 else
4943 result = MotionType.UpRight;
5044 } else {
51- if( this.IsBoosting )
45+ if( sprite.IsBoosting )
5246 result = MotionType.BoostDownRight;
5347 else
5448 result = MotionType.UpRight;
5549 }
56- } else if( this.Directions == ( this.Directions | Directions.Left ) ) {
50+ } else if( sprite.Directions == ( sprite.Directions | Directions.Left ) ) {
5751 // 左方向
58- if( this.Directions == ( this.Directions | Directions.Top ) ) {
59- if( this.IsBoosting )
52+ if( sprite.Directions == ( sprite.Directions | Directions.Top ) ) {
53+ if( sprite.IsBoosting )
6054 result = MotionType.BoostUpLeft;
6155 else
6256 result = MotionType.UpLeft;
6357 } else {
64- if( this.IsBoosting )
58+ if( sprite.IsBoosting )
6559 result = MotionType.BoostLeft;
6660 else
6761 result = MotionType.DownLeft;
@@ -100,184 +94,5 @@
10094 }
10195 }
10296 #endregion
103-
104- /// <summary>
105- /// 攻撃スロットに関連付けられているIAttackOwnerオブジェクトを取得します。
106- /// </summary>
107- /// <param name="attackType">攻撃方法</param>
108- /// <returns>IAttackOwnerオブジェクト</returns>
109- public IAttackOwner GetAttackOwner( AttackType attackType ) {
110- return attackOwnerSlot[attackType];
111- }
112-
113- /// <summary>
114- /// 攻撃のためのIAttackOwnerインスタンスを指定したスロットに登録する。
115- /// </summary>
116- /// <param name="attackType">攻撃方法</param>
117- /// <param name="attackOwner">攻撃方法を実装したインスタンス</param>
118- public void SetAttackOwner( AttackType attackType , IAttackOwner attackOwner ) {
119- if( attackOwnerSlot.ContainsKey( attackType ) ) {
120- if( attackOwnerSlot[attackType] != null )
121- attackOwnerSlot[attackType].Unload();
122- attackOwnerSlot.Remove( attackType );
123- }
124- attackOwnerSlot.Add( attackType , attackOwner );
125- }
126-
127- private Dictionary<AttackType,IAttackOwner> attackOwnerSlot = new Dictionary<AttackType , IAttackOwner>();
128-
129- #region 方向
130- /// <summary>
131- /// スプライトの静止状態での向きを取得します。
132- /// </summary>
133- public Directions Directions {
134- get;
135- private set;
136- }
137- /// <summary>
138- /// スプライトが移動している方向を取得します。
139- /// </summary>
140- public Directions MovingDirections {
141- get;
142- private set;
143- }
144- /// <summary>
145- /// スプライトが衝突したBlock属性のセルの方向を取得します。
146- /// </summary>
147- public Directions HitBlockDirections {
148- get;
149- private set;
150- }
151- /// <summary>
152- /// スプライトが上または、下方向に衝突したセル座標を取得します。
153- /// </summary>
154- public Vector VerticalPos {
155- get;
156- private set;
157- }
158- /// <summary>
159- /// スプライトが左または、右方向に衝突したセル座標を取得します。
160- /// </summary>
161- public Vector HorizontalPos {
162- get;
163- private set;
164- }
165- #endregion
166-
167- #region 動きを制御するパラメータ
168- /// <summary>
169- /// 上昇重力を設定または、取得します。
170- /// </summary>
171- public float UpGravity {
172- get;
173- set;
174- }
175- /// <summary>
176- /// 降下重力を設定または、取得します。
177- /// </summary>
178- public float DownGravity {
179- get;
180- set;
181- }
182- /// <summary>
183- /// 滞空時に掛かる重力を設定または、取得します。
184- /// </summary>
185- public float FlyGravity {
186- get;
187- set;
188- }
189- /// <summary>
190- /// スプライトのジャンプ力を取得または、設定します。
191- /// </summary>
192- public float JumpPower {
193- get;
194- set;
195- }
196- /// <summary>
197- /// 飛行中かどうか取得します。
198- /// </summary>
199- public bool IsFlying {
200- get;
201- private set;
202- }
203- /// <summary>
204- /// スプライトを高速移動するかどうか設定または、取得します。
205- /// </summary>
206- public bool IsBoosting {
207- get;
208- set;
209- }
210- #endregion
211-
212- #region 状態を管理するパラメータ
213- /// <summary>
214- /// スプライトが静止状態かどうか取得します。
215- /// </summary>
216- public bool IsRest {
217- get {
218- return IsNowJumping == false && Sprite.Body.Velocity != Vector.Zero;
219- }
220- }
221- /// <summary>
222- /// スプライトが飛行中かどうか取得します。
223- /// </summary>
224- public bool IsNowJumping {
225- get;
226- private set;
227- }
228- /// <summary>
229- /// スプライトがダメージを受けないようにするかどうか設定または、取得します。
230- /// </summary>
231- public bool IsNotDamage {
232- get;
233- set;
234- }
235- /// <summary>
236- /// 残りヒットポイント
237- /// </summary>
238- public int HitPoint {
239- get;
240- set;
241- }
242- #endregion
243-
244- #region ロジック
245- /// <summary>
246- /// ジャンプを入力を開始します。
247- /// </summary>
248- public void StartJump() {
249- if( IsNowJumping == false ) {
250- Sprite.Body.ApplyForce( new Vector( 0 , -JumpPower ) );
251- jumpBoost = JumpPower;
252- }
253- }
254- /// <summary>
255- /// 強制的にジャンプする
256- /// </summary>
257- public void StartConstraintJump() {
258- Sprite.Body.ApplyForce( new Vector( 0 , -JumpPower ) );
259- jumpBoost = JumpPower;
260- }
261- /// <summary>
262- /// ジャンプ入力を停止します。
263- /// </summary>
264- public void StopJump() {
265- Sprite.Body.ApplyForce( new Vector( 0 , 0 ) );
266- }
267- /// <summary>
268- /// 飛行を開始します。
269- /// </summary>
270- public void StartFly() {
271- if( IsBoosting && IsNowJumping && MovingDirections == ( MovingDirections | Directions.Bottom ) )
272- IsFlying = true;
273- }
274- /// <summary>
275- /// 飛行を停止します。
276- /// </summary>
277- public void StopFly() {
278- IsFlying = false;
279- }
280- private float jumpBoost = 0;
281- #endregion
28297 }
28398 }
--- trunk/Nlgp1/Nlgp1/Characters/SpriteFactory.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Characters/SpriteFactory.cs (revision 842)
@@ -11,9 +11,9 @@
1111
1212 namespace Nlgp1.Characters {
1313 public static class SpriteFactory {
14- private static Character create( int typeID , Vector position , VectorI characterSize ){
15- var character = new Character( typeID , SpriteType.Monster , characterSize , position );
16- return character;
14+ private static Sprite create( int typeID , Vector position , VectorI characterSize ){
15+ var sprite = new Character( typeID , SpriteType.Monster , characterSize , position ).Sprite;
16+ return sprite;
1717 }
1818 /// <summary>
1919 /// キャラクタを生成してマップ上に配置します。
@@ -23,13 +23,13 @@
2323 /// <param name="characterSize">スプライトのサイズ</param>
2424 /// <returns>生成されたキャラクタオブジェクト</returns>
2525 public static Sprite CreateSprite( int typeID , Vector position , VectorI characterSize ) {
26- var character = create( typeID , position , characterSize );
26+ var sprite = create( typeID , position , characterSize );
2727 switch( typeID ) {
2828 case 2:
2929 break;
3030 case 4:
3131 #region ゆっくりと左に歩いてくる
32- character.Sprite.Stepping += new EventHandler<SpriteSteppingEventArgs>( ( sender , e ) => {
32+ sprite.Stepped += new EventHandler<SpriteSteppedEventArgs>( ( sender , e ) => {
3333 e.SpriteOwner.Sprite.Body.ApplyForce( new Vector( -0.01f , 0 ) );
3434 } );
3535 #endregion
@@ -36,7 +36,7 @@
3636 break;
3737 case 5:
3838 #region ゆっくりと右に歩いてくる
39- character.Sprite.Stepping += new EventHandler<SpriteSteppingEventArgs>( ( sender , e ) => {
39+ sprite.Stepped += new EventHandler<SpriteSteppedEventArgs>( ( sender , e ) => {
4040 e.SpriteOwner.Sprite.Body.ApplyForce( new Vector( +0.01f , 0 ) );
4141 } );
4242 #endregion
@@ -44,20 +44,20 @@
4444 case 6:
4545 #region ジャンプしながら左に向かってくる
4646
47- character.JumpPower = 4;
48- character.UpGravity = 0.05f;
49- character.Sprite.Stepping += new EventHandler<SpriteSteppingEventArgs>( ( sender , e ) => {
47+ sprite.JumpPower = 4;
48+ sprite.UpGravity = 0.05f;
49+ sprite.Stepped += new EventHandler<SpriteSteppedEventArgs>( ( sender , e ) => {
5050 e.SpriteOwner.Sprite.Body.ApplyForce( new Vector( -0.01f , 0 ) );
51- ( ( Character )( e.SpriteOwner ) ).StartJump();
51+ e.SpriteOwner.Sprite.StartJump();
5252 } );
5353 #endregion
5454 break;
5555 case 7:
5656 #region ジャンプしながら右に向かってくる
57- character.JumpPower = 4;
58- character.UpGravity = 0.05f;
59- character.Sprite.Stepping += new EventHandler<SpriteSteppingEventArgs>( ( sender , e ) => {
60- ( ( Character)( e.SpriteOwner ) ).StartJump();
57+ sprite.JumpPower = 4;
58+ sprite.UpGravity = 0.05f;
59+ sprite.Stepped += new EventHandler<SpriteSteppedEventArgs>( ( sender , e ) => {
60+ e.SpriteOwner.Sprite.StartJump();
6161 } );
6262 #endregion
6363 break;
@@ -69,14 +69,14 @@
6969 // newSprite.GetRectangle.PrevReset();
7070 // newSprite.LogicParameter.InitX = cellX * MapData.CellSize;
7171 // newSprite.LogicParameter.InitY = cellY * MapData.CellSize;
72- character.Sprite.Body.ApplyForce( new Vector( 1 , 0 ) );
73- character.Sprite.Shape.Stepped += ( sender , e ) => {
72+ sprite.Body.ApplyForce( new Vector( 1 , 0 ) );
73+ sprite.Shape.Stepped += ( sender , e ) => {
7474 };
7575 #endregion
7676 break;
7777 case 9:
7878 #region 床から落下しないように左右に移動する。
79- character.Sprite.Shape.Stepped += ( sender , e ) => {
79+ sprite.Shape.Stepped += ( sender , e ) => {
8080 };
8181 #endregion
8282 break;
@@ -83,29 +83,29 @@
8383 case 10:
8484 #region 上下に浮遊する
8585 // newSprite.CanDefaultAction = false;
86- character.Sprite.LogicParameter.Radius = 50;   // 半径
87- character.Sprite.LogicParameter.Angle = 90; // 角度
88- character.Sprite.LogicParameter.Speed = 1; // 速度
89- character.Sprite.LogicParameter.LimitDistance = 100;// 移動距離
90- character.Sprite.Stepping += new EventHandler<SpriteSteppingEventArgs>( ( sender , e ) => {
86+ sprite.LogicParameter.Radius = 50;   // 半径
87+ sprite.LogicParameter.Angle = 90; // 角度
88+ sprite.LogicParameter.Speed = 1; // 速度
89+ sprite.LogicParameter.LimitDistance = 100;// 移動距離
90+ sprite.Stepped += new EventHandler<SpriteSteppedEventArgs>( ( sender , e ) => {
9191 } );
9292 #endregion
9393 break;
9494 case 11:
9595 #region 時計回り
96- character.Sprite.CanActDefault = false; // 既定の重力計算などを無効にする。
97- character.Sprite.LogicParameter.Radius = 100; // 半径
98- character.Sprite.LogicParameter.Speed = 8; // 回転速度
99- character.Sprite.Stepping += new EventHandler<SpriteSteppingEventArgs>( ( sender , e ) => {
96+ sprite.CanActDefault = false; // 既定の重力計算などを無効にする。
97+ sprite.LogicParameter.Radius = 100; // 半径
98+ sprite.LogicParameter.Speed = 8; // 回転速度
99+ sprite.Stepped += new EventHandler<SpriteSteppedEventArgs>( ( sender , e ) => {
100100 } );
101101 #endregion
102102 break;
103103 case 12:
104104 #region 反時計回り
105- character.Sprite.IsBlock = false;
106- character.Sprite.LogicParameter.Speed = 2;
107- character.Sprite.LogicParameter.Radius = 100;
108- character.Sprite.Stepping += new EventHandler<SpriteSteppingEventArgs>( ( sender , e ) => {
105+ sprite.IsBlock = false;
106+ sprite.LogicParameter.Speed = 2;
107+ sprite.LogicParameter.Radius = 100;
108+ sprite.Stepped += new EventHandler<SpriteSteppedEventArgs>( ( sender , e ) => {
109109 // Sprite.HitStop( PlayerStatus.Player , e.Target );
110110 } );
111111 #endregion
@@ -112,18 +112,18 @@
112112 break;
113113 case 13:
114114 #region 空中を回転しながら浮遊する
115- character.Sprite.LogicParameter.LimitDistance = 150; // 移動距離
116- character.Sprite.LogicParameter.Speed = 2; // 上下に移動するときの速度
117- character.Sprite.LogicParameter.Angle = 90; // 移動する方向。90度 = 上下方向。45度 = 斜めなど。
118- character.Sprite.CanActDefault = false;
119- character.Sprite.Stepping += new EventHandler<SpriteSteppingEventArgs>( ( sender , e ) => {
120- character.Sprite.LogicParameter.Angle++;
115+ sprite.LogicParameter.LimitDistance = 150; // 移動距離
116+ sprite.LogicParameter.Speed = 2; // 上下に移動するときの速度
117+ sprite.LogicParameter.Angle = 90; // 移動する方向。90度 = 上下方向。45度 = 斜めなど。
118+ sprite.CanActDefault = false;
119+ sprite.Stepped += new EventHandler<SpriteSteppedEventArgs>( ( sender , e ) => {
120+ sprite.LogicParameter.Angle++;
121121 } );
122122 #endregion
123123 break;
124124 case 14:
125125 #region 10秒アイテム
126- character.Sprite.Shape.Stepped += ( sender ,e ) => {
126+ sprite.Shape.Stepped += ( sender ,e ) => {
127127 foreach( ISpriteContact contact in e.Shape.Contacts ) {
128128 if( contact.Target == PlayerStatus.Player.Sprite.Shape ) {
129129 PlayerStatus.TimerInitialize();
@@ -145,7 +145,7 @@
145145 default:
146146 break;
147147 }
148- return character.Sprite;
148+ return sprite;
149149 }
150150 }
151151 }
--- trunk/Nlgp1/Nlgp1/Players/PlayerController.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Players/PlayerController.cs (revision 842)
@@ -109,17 +109,17 @@
109109
110110
111111 if( PlayerController.Jump ) {
112- PlayerStatus.Player.StartJump();
112+ PlayerStatus.Player.Sprite.StartJump();
113113 } else if( PlayerController.Jumping == false ) {
114- PlayerStatus.Player.StopJump();
114+ PlayerStatus.Player.Sprite.StopJump();
115115 }
116116
117- PlayerStatus.Player.IsBoosting = PlayerController.Boost;
117+ PlayerStatus.Player.Sprite.IsBoosting = PlayerController.Boost;
118118
119119 if( PlayerController.Fly )
120- PlayerStatus.Player.StartFly();
120+ PlayerStatus.Player.Sprite.StartFly();
121121 else
122- PlayerStatus.Player.StopFly();
122+ PlayerStatus.Player.Sprite.StopFly();
123123
124124 PlayerStatus.Player.AttackType = PlayerController.Attack ? AttackType.DivineBuster : AttackType.None;
125125 #endregion
--- trunk/Nlgp1/Nlgp1/Players/PlayerStatus.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Players/PlayerStatus.cs (revision 842)
@@ -21,7 +21,7 @@
2121 private static int playerTimer = 0;
2222
2323 /// <summary>
24- /// 残り時間の最大値をフレーム単位で取得します。
24+ /// 残り時間の最大値をミリ秒単位で取得します。
2525 /// </summary>
2626 public static int LimitMax {
2727 get {
@@ -29,11 +29,11 @@
2929 }
3030 }
3131 /// <summary>
32- /// 残り時間(フレーム単位)で取得します。
32+ /// 残り時間(ミリ秒単位)で取得します。
3333 /// </summary>
3434 public static int TimeLimit {
3535 get {
36- return LimitMax - ( StageMap.TickCount - playerTimer );
36+ return LimitMax - ( Environment.TickCount - playerTimer );
3737 }
3838 }
3939 /// <summary>
@@ -40,7 +40,7 @@
4040 /// 残り時間を初期化します。
4141 /// </summary>
4242 public static void TimerInitialize() {
43- playerTimer = StageMap.TickCount;
43+ playerTimer = Environment.TickCount;
4444 }
4545
4646 /// <summary>
@@ -63,7 +63,7 @@
6363
6464 // 自分自身のパラメータは、ここで設定する
6565 Player = new Character( 1 , SpriteType.Player , MapData.DefaultChipSize , position );
66- Player.HitPoint = 100;
66+ Player.Sprite.HitPoint = 100;
6767 // Player.GetRectangle.BlankLeft = -2;
6868 // Player.GetRectangle.BlankRight = -2;
6969 // Player.GetRectangle.BlankBottom = 32;
--- trunk/Nlgp1/Nlgp1/Stages/StageMap.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Stages/StageMap.cs (revision 842)
@@ -112,9 +112,14 @@
112112 else {
113113 this.sprite = SpriteFactory.CreateSprite( this.Cell.TypeID , this.Position , MapData.DefaultChipSize ); // キャラクタ
114114 }
115+ this.sprite.Stepped += ( sender , e ) => {
116+ this.sprite.Body.ApplyForce( new Vector( 0 , this.sprite.DownGravity ) );
117+ };
115118 }
116119 else {
117120 this.sprite = new Sprite( this.LayerType , this.Cell.TypeID , SpriteType.Monster , null , Path.Combine( @"Stages\Defines\Maps\Normal" , this.LayerType.ToString() ) , MapData.DefaultChipSize , null , null , this.Position );
121+ this.sprite.UpGravity = 0;
122+ this.sprite.DownGravity = 0;
118123 }
119124 this.sprite.IsBlock = ( this.Cell.Types & CellTypes.Wall ) != 0;
120125 this.sprite.IsDestroyable = ( this.Cell.Types & CellTypes.Destroy ) != 0;
--- trunk/Nlgp1/Nlgp1/Sprites/SpriteSteppingEventArgs.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Sprites/SpriteSteppingEventArgs.cs (nonexistent)
@@ -1,49 +0,0 @@
1-using System;
2-using System.Collections.Generic;
3-using System.Linq;
4-using System.Text;
5-using Nlgp1.Parameters;
6-using Nlgp1.Stages;
7-using Nlgp1.Common;
8-
9-namespace Nlgp1.Sprites {
10- /// <summary>
11- /// スプライトの行動が発生したときのイベント引数
12- /// </summary>
13- public class SpriteSteppingEventArgs : EventArgs {
14- /// <summary>
15- /// SpriteSteppingEventArgsクラスの新しいインスタンスを初期化します。
16- /// </summary>
17- /// <param name="target">対象のスプライト</param>
18- public SpriteSteppingEventArgs( ISpriteOwner spriteOwner ) {
19- this.SpriteOwner = spriteOwner;
20- }
21- /// <summary>
22- /// 対象のスプライトを取得します。
23- /// </summary>
24- public ISpriteOwner SpriteOwner {
25- get;
26- private set;
27- }
28- }
29-
30- /// <summary>
31- /// スプライトの行動が発生したときのイベント引数
32- /// </summary>
33- public class SpriteSteppingEventArgs<T> : EventArgs where T : ISpriteOwner {
34- /// <summary>
35- /// SpriteSteppingEventArgsクラスの新しいインスタンスを初期化します。
36- /// </summary>
37- /// <param name="target">対象のスプライト</param>
38- public SpriteSteppingEventArgs( T spriteOwner ) {
39- this.SpriteOwner = spriteOwner;
40- }
41- /// <summary>
42- /// 対象のスプライトを取得します。
43- /// </summary>
44- public T SpriteOwner {
45- get;
46- private set;
47- }
48- }
49-}
--- trunk/Nlgp1/Nlgp1/Sprites/Types.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Sprites/Types.cs (revision 842)
@@ -3,12 +3,14 @@
33 using System.Linq;
44 using System.Text;
55
6-namespace Nlgp1.Sprites {
6+namespace Nlgp1.Sprites
7+{
78 /// <summary>
89 /// 上下左右での方向を表します。
910 /// </summary>
1011 [Flags]
11- public enum Directions {
12+ public enum Directions
13+ {
1214 /// <summary>
1315 /// 方向なし
1416 /// </summary>
@@ -24,7 +26,7 @@
2426 /// <summary>
2527 /// 上
2628 /// </summary>
27- Top = 4 ,
29+ Top = 3 ,
2830 /// <summary>
2931 /// 下
3032 /// </summary>
@@ -33,7 +35,8 @@
3335 /// <summary>
3436 /// 上・下・左・右の何れかを表す
3537 /// </summary>
36- public enum Direction {
38+ public enum Direction
39+ {
3740 /// <summary>
3841 /// 左
3942 /// </summary>
@@ -52,36 +55,10 @@
5255 Bottom = 3 ,
5356 }
5457 /// <summary>
55- /// 水平方向を表す。
56- /// </summary>
57- public enum HorizontalDirection {
58- /// <summary>
59- /// 左
60- /// </summary>
61- Left,
62- /// <summary>
63- /// 右
64- /// </summary>
65- Right,
66- }
67- /// <summary>
68- /// 鉛直方向を表す。
69- /// </summary>
70- public enum VerticalDirection {
71- /// <summary>
72- /// 上
73- /// </summary>
74- Top,
75- /// <summary>
76- /// 下
77- /// </summary>
78- Bottom,
79- }
80-
81- /// <summary>
8258 /// 縦・横方向を表す。
8359 /// </summary>
84- public enum Aspect {
60+ public enum Aspect
61+ {
8562 /// <summary>
8663 /// 横方向。水平
8764 /// </summary>
--- trunk/Nlgp1/Nlgp1/Sprites/Sprite.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Sprites/Sprite.cs (revision 842)
@@ -19,6 +19,7 @@
1919 /// <summary>
2020 /// 生存するスプライトをコレクションで取得します。
2121 /// </summary>
22+ /// <returns></returns>
2223 public static IEnumerable<Sprite> GetCollection() {
2324 lock( objectList ) {
2425 int count = objectList.Count;
@@ -41,6 +42,10 @@
4142 }
4243
4344 private int startTick = 0;
45+ private float jumpBoost = 0;
46+ private Vector verticalPos = new Vector();
47+ private Vector horizontalPos = new Vector();
48+ private Dictionary<AttackType,IAttackOwner> attackOwnerSlot = new Dictionary<AttackType , IAttackOwner>();
4449
4550 /// <summary>
4651 /// Spriteのコンストラクタ
@@ -69,11 +74,17 @@
6974 this.TypeID = typeID;
7075 this.DebugID = debugID;
7176 if( layerType != LayerType.Back ) {
77+ this.HitPoint = 1;
78+ jumpBoost = 5;
79+ UpGravity = 0.75f;
80+ DownGravity = 2;
81+ JumpPower = 5;
82+ FlyGravity = 0.05f;
7283 IsBlock = true;
7384 ActiveCellCount = 2;
7485 CanActDefault = true;
7586 startTick = StageMap.TickCount;
76- steppedEventArgs = new SpriteSteppingEventArgs( this.Owner );
87+ steppedEventArgs = new SpriteSteppedEventArgs( this.Owner );
7788
7889 this.Body = StageMap.World.CreateSpriteBody( this , position );
7990 if( layerType != LayerType.Character ) {
@@ -104,6 +115,29 @@
104115 }
105116
106117 /// <summary>
118+ /// 攻撃スロットに関連付けられているIAttackOwnerオブジェクトを取得します。
119+ /// </summary>
120+ /// <param name="attackType">攻撃方法</param>
121+ /// <returns>IAttackOwnerオブジェクト</returns>
122+ public IAttackOwner GetAttackOwner( AttackType attackType ) {
123+ return attackOwnerSlot[attackType];
124+ }
125+
126+ /// <summary>
127+ /// 攻撃のためのIAttackOwnerインスタンスを指定したスロットに登録する。
128+ /// </summary>
129+ /// <param name="attackType">攻撃方法</param>
130+ /// <param name="attackOwner">攻撃方法を実装したインスタンス</param>
131+ public void SetAttackOwner( AttackType attackType , IAttackOwner attackOwner ) {
132+ if( attackOwnerSlot.ContainsKey( attackType ) ) {
133+ if( attackOwnerSlot[attackType] != null )
134+ attackOwnerSlot[attackType].Unload();
135+ attackOwnerSlot.Remove( attackType );
136+ }
137+ attackOwnerSlot.Add( attackType , attackOwner );
138+ }
139+
140+ /// <summary>
107141 /// レイヤーの種類を取得します。
108142 /// </summary>
109143 public LayerType LayerType {
@@ -143,8 +177,90 @@
143177 private set;
144178 }
145179
180+ #region 方向
181+ /// <summary>
182+ /// スプライトの静止状態での向きを取得します。
183+ /// </summary>
184+ public Directions Directions {
185+ get;
186+ private set;
187+ }
188+ /// <summary>
189+ /// スプライトが移動している方向を取得します。
190+ /// </summary>
191+ public Directions MovingDirections {
192+ get;
193+ private set;
194+ }
195+ /// <summary>
196+ /// スプライトが衝突したBlock属性のセルの方向を取得します。
197+ /// </summary>
198+ public Directions HitBlockDirections {
199+ get;
200+ private set;
201+ }
202+ /// <summary>
203+ /// スプライトが上または、下方向に衝突したセル座標を取得します。
204+ /// </summary>
205+ public Vector VerticalPos {
206+ get {
207+ return verticalPos;
208+ }
209+ }
210+ /// <summary>
211+ /// スプライトが左または、右方向に衝突したセル座標を取得します。
212+ /// </summary>
213+ public Vector HorizontalPos {
214+ get {
215+ return horizontalPos;
216+ }
217+ }
218+ #endregion
219+
146220 #region 動きを制御するパラメータ
147221 /// <summary>
222+ /// 上昇重力を設定または、取得します。
223+ /// </summary>
224+ public float UpGravity {
225+ get;
226+ set;
227+ }
228+ /// <summary>
229+ /// 降下重力を設定または、取得します。
230+ /// </summary>
231+ public float DownGravity {
232+ get;
233+ set;
234+ }
235+ /// <summary>
236+ /// 滞空時に掛かる重力を設定または、取得します。
237+ /// </summary>
238+ public float FlyGravity {
239+ get;
240+ set;
241+ }
242+ /// <summary>
243+ /// スプライトのジャンプ力を取得または、設定します。
244+ /// </summary>
245+ public float JumpPower {
246+ get;
247+ set;
248+ }
249+ /// <summary>
250+ /// 飛行中かどうか取得します。
251+ /// </summary>
252+ public bool IsFlying {
253+ get;
254+ private set;
255+ }
256+ /// <summary>
257+ /// スプライトを高速移動するかどうか設定または、取得します。
258+ /// </summary>
259+ public bool IsBoosting {
260+ get;
261+ set;
262+ }
263+ /// <summary>
148264 /// スプライトの既定のアクションを実行してスプライトを適切に移動します。
149265 /// 規定値は、trueです。falseの場合も衝突判定を行いますがスプライトの移動は、行いません。
150266 /// </summary>
@@ -179,6 +295,14 @@
179295 set;
180296 }
181297 /// <summary>
298+ /// スプライトが静止状態かどうか取得します。
299+ /// </summary>
300+ public bool IsRest {
301+ get {
302+ return IsNowJumping == false && Body.Velocity != Vector.Zero;
303+ }
304+ }
305+ /// <summary>
182306 /// スプライトを通過可能かどうか設定または、取得します。
183307 /// </summary>
184308 public bool IsBlock {
@@ -186,6 +310,27 @@
186310 set;
187311 }
188312 /// <summary>
313+ /// スプライトが飛行中かどうか取得します。
314+ /// </summary>
315+ public bool IsNowJumping {
316+ get;
317+ private set;
318+ }
319+ /// <summary>
320+ /// スプライトがダメージを受けないようにするかどうか設定または、取得します。
321+ /// </summary>
322+ public bool IsNotDamage {
323+ get;
324+ set;
325+ }
326+ /// <summary>
327+ /// 残りヒットポイント
328+ /// </summary>
329+ public int HitPoint {
330+ get;
331+ set;
332+ }
333+ /// <summary>
189334 /// 破壊可能か
190335 /// </summary>
191336 public bool IsDestroyable {
@@ -203,7 +348,7 @@
203348
204349 #region ロジック
205350
206- private SpriteSteppingEventArgs steppedEventArgs = null;
351+ private SpriteSteppedEventArgs steppedEventArgs = null;
207352
208353 /// <summary>
209354 /// キャラクタの既定の行動を行う
@@ -218,14 +363,45 @@
218363 }
219364 // 参考→http://d.hatena.ne.jp/Gemma/20080517/1211010942
220365
221- if( this.Stepping != null ) {
222- this.Stepping( this , this.steppedEventArgs );
223- }
366+ this.Body.Step();
224367
225- if( this.Body != null ) {
226- this.Body.Step();
368+ this.OnStepped( this , this.steppedEventArgs );
369+ }
370+ /// <summary>
371+ /// ジャンプを入力を開始します。
372+ /// </summary>
373+ public void StartJump() {
374+ if( IsNowJumping == false ) {
375+ Body.ApplyForce( new Vector( 0 , -JumpPower ) );
376+ jumpBoost = JumpPower;
227377 }
228378 }
379+ /// <summary>
380+ /// 強制的にジャンプする
381+ /// </summary>
382+ public void StartConstraintJump() {
383+ Body.ApplyForce( new Vector( 0 , -JumpPower ) );
384+ jumpBoost = JumpPower;
385+ }
386+ /// <summary>
387+ /// ジャンプ入力を停止します。
388+ /// </summary>
389+ public void StopJump() {
390+ Body.ApplyForce( new Vector( 0 , 0 ) );
391+ }
392+ /// <summary>
393+ /// 飛行を開始します。
394+ /// </summary>
395+ public void StartFly() {
396+ if( IsBoosting && IsNowJumping && MovingDirections == ( MovingDirections | Directions.Bottom ) )
397+ IsFlying = true;
398+ }
399+ /// <summary>
400+ /// 飛行を停止します。
401+ /// </summary>
402+ public void StopFly() {
403+ IsFlying = false;
404+ }
229405 #endregion
230406
231407 #region ロジック拡張
@@ -239,7 +415,13 @@
239415 /// <summary>
240416 /// 行動が発生して既定の行動が実行されたあとに発生します。
241417 /// </summary>
242- public event EventHandler<SpriteSteppingEventArgs> Stepping;
418+ public event EventHandler<SpriteSteppedEventArgs> Stepped;
419+
420+ private void OnStepped( object sender , SpriteSteppedEventArgs e ) {
421+ if( this.Stepped != null ) {
422+ this.Stepped( sender , e );
423+ }
424+ }
243425 #endregion
244426
245427 #region IUnloadableComponent メンバー
--- trunk/Nlgp1/Nlgp1/Sprites/SpriteSteppedEventArgs.cs (nonexistent)
+++ trunk/Nlgp1/Nlgp1/Sprites/SpriteSteppedEventArgs.cs (revision 842)
@@ -0,0 +1,49 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using Nlgp1.Parameters;
6+using Nlgp1.Stages;
7+using Nlgp1.Common;
8+
9+namespace Nlgp1.Sprites {
10+ /// <summary>
11+ /// スプライトの行動が発生したときのイベント引数
12+ /// </summary>
13+ public class SpriteSteppedEventArgs : EventArgs {
14+ /// <summary>
15+ /// SpriteSteppedEventArgsクラスの新しいインスタンスを初期化します。
16+ /// </summary>
17+ /// <param name="target">対象のスプライト</param>
18+ public SpriteSteppedEventArgs( ISpriteOwner spriteOwner ) {
19+ this.SpriteOwner = spriteOwner;
20+ }
21+ /// <summary>
22+ /// 対象のスプライトを取得します。
23+ /// </summary>
24+ public ISpriteOwner SpriteOwner {
25+ get;
26+ private set;
27+ }
28+ }
29+
30+ /// <summary>
31+ /// スプライトの行動が発生したときのイベント引数
32+ /// </summary>
33+ public class SpriteSteppedEventArgs<T> : EventArgs where T : ISpriteOwner {
34+ /// <summary>
35+ /// SpriteSteppedEventArgsクラスの新しいインスタンスを初期化します。
36+ /// </summary>
37+ /// <param name="target">対象のスプライト</param>
38+ public SpriteSteppedEventArgs( T spriteOwner ) {
39+ this.SpriteOwner = spriteOwner;
40+ }
41+ /// <summary>
42+ /// 対象のスプライトを取得します。
43+ /// </summary>
44+ public T SpriteOwner {
45+ get;
46+ private set;
47+ }
48+ }
49+}
--- trunk/Nlgp1/Nlgp1/Attacks/IAttackOwner.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Attacks/IAttackOwner.cs (revision 842)
@@ -1,5 +1,4 @@
11 using System;
2-using Nlgp1.Characters;
32 using Nlgp1.Sprites;
43
54 namespace Nlgp1.Attacks {
@@ -15,7 +14,7 @@
1514 /// <summary>
1615 /// オブジェクトを所有するスプライトを取得します。
1716 /// </summary>
18- Character Character {
17+ ISpriteOwner SpriteOwner {
1918 get;
2019 }
2120
--- trunk/Nlgp1/Nlgp1/Attacks/Shot.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Attacks/Shot.cs (revision 842)
@@ -1,7 +1,6 @@
11 using System;
22 using System.Collections.Generic;
33 using Nlgp1.Attacks.Guns;
4-using Nlgp1.Characters;
54 using Nlgp1.Common;
65 using Nlgp1.Common.Parameters;
76 using Nlgp1.Sprites;
@@ -14,7 +13,7 @@
1413 /// <typeparam name="T">弾丸クラスの型</typeparam>
1514 public class Shot<T> : IAttackOwner where T : IGun , new() {
1615 private List<T> gunList = new List<T>();
17- private Character character;
16+ private ISpriteOwner ownerObject;
1817
1918 /// <summary>
2019 /// Shotクラスのコンストラクタ
@@ -22,9 +21,9 @@
2221 /// <param name="typeID">Shotクラスのオブジェクトに適応するイメージID</param>
2322 /// <param name="gunTypeID">弾丸(IGun)に適応するイメージID</param>
2423 /// <param name="gunSize">生成する弾のサイズ</param>
25- public Shot( int typeID , int gunTypeID , Character character , VectorI gunSize ) {
26- this.Attack = new Attack( character , typeID , character.Sprite.SpriteType , gunSize );
27- this.character = character;
24+ public Shot( int typeID , int gunTypeID , ISpriteOwner spriteOwner , VectorI gunSize ) {
25+ this.Attack = new Attack( spriteOwner , typeID , spriteOwner.Sprite.SpriteType , gunSize );
26+ this.ownerObject = spriteOwner;
2827 this.GunTypeID = gunTypeID;
2928 this.GunSize = gunSize;
3029 this.Attack.CanMovingAttack = false;
@@ -34,7 +33,7 @@
3433 gun.Initialize( this.GunTypeID , this , gunSize );
3534
3635 if( Initialized != null )
37- Initialized( this , new SpriteSteppingEventArgs<T>( gun ) );
36+ Initialized( this , new SpriteSteppedEventArgs<T>( gun ) );
3837
3938 lock( gunList )
4039 gunList.Add( gun );
@@ -82,9 +81,9 @@
8281 void IAttackOwner.Start() {
8382 this.Attack.Start();
8483 }
85- Character IAttackOwner.Character {
84+ ISpriteOwner IAttackOwner.SpriteOwner {
8685 get {
87- return character;
86+ return ownerObject;
8887 }
8988 }
9089 #endregion
@@ -94,6 +93,6 @@
9493 }
9594 #endregion
9695
97- public event EventHandler<SpriteSteppingEventArgs<T>> Initialized;
96+ public event EventHandler<SpriteSteppedEventArgs<T>> Initialized;
9897 }
9998 }
--- trunk/Nlgp1/Nlgp1/Attacks/Attack.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Attacks/Attack.cs (revision 842)
@@ -1,5 +1,4 @@
11 using System;
2-using Nlgp1.Characters;
32 using Nlgp1.Common;
43 using Nlgp1.Common.Parameters;
54 using Nlgp1.Parameters;
@@ -18,14 +17,14 @@
1817 /// Attackクラスのインスタンスを作成します。
1918 /// </summary>
2019 /// <param name="sprite">攻撃アクションを実行するスプライト(キャラクタなど)</param>
21- public Attack( Character character , int typeID , SpriteType spriteType , VectorI attackSize ) {
20+ public Attack( ISpriteOwner spriteOwner , int typeID , SpriteType spriteType , VectorI attackSize ) {
2221 CanMovingAttack = true;
23- this.Character = character;
22+ this.SpriteOwner = spriteOwner;
2423 // キャラクタスプライトが破棄されたとき、自分も破棄する。
25- this.Character.Sprite.Unloaded += new EventHandler( ( sender , e ) => Unload() );
24+ this.SpriteOwner.Sprite.Unloaded += new EventHandler( ( sender , e ) => Unload() );
2625
2726 #region 攻撃状態の変化
28- this.Character.Sprite.Stepping += new EventHandler<SpriteSteppingEventArgs>( ( sender , e ) => {
27+ this.SpriteOwner.Sprite.Stepped += new EventHandler<SpriteSteppedEventArgs>( ( sender , e ) => {
2928 if( ActionType == ActionType.None )
3029 return;
3130 else if( ActionType == ActionType.Starting && StageMap.TickCount - attackTick >= StartingWait && canAttack ) {
@@ -52,7 +51,7 @@
5251 /// <summary>
5352 /// Attackオブジェクトを所有するスプライトを取得します。
5453 /// </summary>
55- public Character Character {
54+ public ISpriteOwner SpriteOwner {
5655 get;
5756 private set;
5857 }
@@ -116,7 +115,7 @@
116115
117116 private bool canAttack {
118117 get {
119- return CanMovingAttack || Character.IsRest;
118+ return CanMovingAttack || SpriteOwner.Sprite.IsRest;
120119 }
121120 }
122121
--- trunk/Nlgp1/Nlgp1/Attacks/Guns/Gun.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Attacks/Guns/Gun.cs (revision 842)
@@ -22,7 +22,7 @@
2222 }
2323
2424 /// <summary>
25- /// 弾を生成したIAttackOwnerオブジェクトを取得します。
25+ /// 弾を生成したIShotオブジェクトを取得します。
2626 /// </summary>
2727 public IAttackOwner Owner {
2828 get;
@@ -32,7 +32,7 @@
3232 #region IGun メンバー
3333 void IGun.Initialize( int typeID , IAttackOwner source , VectorI gunSize ) {
3434 this.Owner = source;
35- this.Sprite = new Sprite( LayerType.Character , typeID , source.Character.Sprite.SpriteType , this , "GunImages" , gunSize , null , null , new Vector() );
35+ this.Sprite = new Sprite( LayerType.Character , typeID , source.SpriteOwner.Sprite.SpriteType , this , "GunImages" , gunSize , null , null , new Vector() );
3636
3737
3838 }
--- trunk/Nlgp1/Nlgp1/Program.cs (revision 841)
+++ trunk/Nlgp1/Nlgp1/Program.cs (revision 842)
@@ -62,7 +62,7 @@
6262 meiryoFont , new Common.Parameters.ColorI( 0x00 , 0xFF , 0xFF ) );
6363
6464 // if( message == null )
65- DebugCharacter( PlayerStatus.Player );
65+ DebugSprite( PlayerStatus.Player.Sprite );
6666
6767 Form.DrawString( new VectorI( 5 , 32 ), message , meiryoFont , new Common.Parameters.ColorI( 0x00 , 0xFF , 0x00 ) );
6868
@@ -83,7 +83,7 @@
8383
8484 private static string message = null;
8585
86- public static void DebugCharacter( Character c ) {
86+ public static void DebugSprite( Sprite s ) {
8787 message = string.Format(
8888 @"Pos > X ={0} Y ={1}
8989 Speed > X ={2} Y ={3}
@@ -91,14 +91,14 @@
9191 MovingDir = {5}
9292 Jump={6} Hit={7} FPS = {8}
9393 " ,
94- c.Sprite.Body.Position.X ,
95- c.Sprite.Body.Position.Y ,
96- c.Sprite.Body.Velocity.X ,
97- c.Sprite.Body.Velocity.Y ,
98- c.Directions ,
99- c.MovingDirections ,
100- c.IsNowJumping ,
101- c.HitPoint ,
94+ s.Body.Position.X ,
95+ s.Body.Position.Y ,
96+ s.Body.Velocity.X ,
97+ s.Body.Velocity.Y ,
98+ s.Directions ,
99+ s.MovingDirections ,
100+ s.IsNowJumping ,
101+ s.HitPoint ,
102102 rate.FlameRate
103103 );
104104 }
Show on old repository browser