• R/O
  • SSH
  • HTTPS

nlgp1: Commit


Commit MetaInfo

Revision843 (tree)
Zeit2011-03-04 11:18:07
Autorbiikame

Log Message

Nlgp1.Parameters.Polygonを追加

Ändern Zusammenfassung

Diff

--- trunk/Nlgp1/Nlgp1/Characters/SpriteFactory.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Characters/SpriteFactory.cs (revision 843)
@@ -125,7 +125,7 @@
125125 #region 10秒アイテム
126126 sprite.Shape.Stepped += ( sender ,e ) => {
127127 foreach( ISpriteContact contact in e.Shape.Contacts ) {
128- if( contact.Target == PlayerStatus.Player.Sprite.Shape ) {
128+ if( ( ( IPolygonSpriteShape )( contact.Other ) ).Shape == PlayerStatus.Player.Sprite.Shape ) {
129129 PlayerStatus.TimerInitialize();
130130 }
131131 }
--- trunk/Nlgp1/Nlgp1/Sprites/Sprite.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Sprites/Sprite.cs (revision 843)
@@ -86,15 +86,15 @@
8686 startTick = StageMap.TickCount;
8787 steppedEventArgs = new SpriteSteppedEventArgs( this.Owner );
8888
89- this.Body = StageMap.World.CreateSpriteBody( this , position );
90- if( layerType != LayerType.Character ) {
91- this.Body.CreatePolygonSpriteShape( new SpriteShapeFilter( 1 , 2 ), Rectangle.FromCenterRadius( new Vector() , new Vector( chipSize.X / 2.0f , chipSize.Y / 2.0f ) ).ToVertices() );
92- }
93- else {
94- this.Body.CreatePolygonSpriteShape( new SpriteShapeFilter( 1 , 2 ), new Octagon( Rectangle.FromCenterRadius( new Vector() , new Vector( chipSize.X / 2.0f - 2.0f , chipSize.Y / 2.0f - 2.0f ) ) , 0.5f ).ToVertices() );
95- this.Shape = this.Body.CreatePolygonSpriteShape( new SpriteShapeFilter( 2 , 1 ) , new Octagon( Rectangle.FromCenterRadius( new Vector() , new Vector( chipSize.X / 2.0f - 2.0f , chipSize.Y / 2.0f - 2.0f ) ) , 0.5f ).ToVertices() );
96- }
97- this.Body.Load();
89+ //this.Body = StageMap.World.CreateSpriteBody( true , position );
90+ //if( layerType != LayerType.Character ) {
91+ // this.Body.CreatePolygonSpriteShape( new SpriteShapeFilter( 1 , 2 ), new Polygon( Rectangle.FromCenterRadius( new Vector() , new Vector( chipSize.X / 2.0f , chipSize.Y / 2.0f ) ) ) );
92+ //}
93+ //else {
94+ // this.Body.CreatePolygonSpriteShape( new SpriteShapeFilter( 1 , 2 ), new Polygon( Rectangle.FromCenterRadius( new Vector() , new Vector( chipSize.X / 2.0f - 2.0f , chipSize.Y / 2.0f - 2.0f ) ) , 0.5f ) );
95+ // this.Shape = this.Body.CreatePolygonSpriteShape( new SpriteShapeFilter( 2 , 1 ) , new Polygon( Rectangle.FromCenterRadius( new Vector() , new Vector( chipSize.X / 2.0f - 2.0f , chipSize.Y / 2.0f - 2.0f ) ) , 0.5f ) );
96+ //}
97+ //this.Body.Load();
9898 }
9999 }
100100
--- trunk/Nlgp1/Nlgp1/Parameters/StageWorld.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Parameters/StageWorld.cs (revision 843)
@@ -17,7 +17,7 @@
1717 this.world.SetDebugDraw(this.debugDraw);
1818 }
1919
20- public ISpriteBody CreateSpriteBody(Sprite sprite, Vector position)
20+ public ISpriteBody CreateSpriteBody(bool isMovable, Vector position)
2121 {
2222 throw new NotImplementedException();
2323 }
--- trunk/Nlgp1/Nlgp1/Parameters/ICircleSpriteContact.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Parameters/ICircleSpriteContact.cs (revision 843)
@@ -9,6 +9,11 @@
99 public interface ICircleSpriteContact : ISpriteContact
1010 {
1111 /// <summary>
12+ /// 衝突元のICircleSpriteShape
13+ /// </summary>
14+ ICircleSpriteShape Shape { get; }
15+
16+ /// <summary>
1217 /// 衝突位置
1318 /// </summary>
1419 Vector Position { get; }
--- trunk/Nlgp1/Nlgp1/Parameters/ICircleSpriteShape.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Parameters/ICircleSpriteShape.cs (revision 843)
@@ -10,6 +10,11 @@
1010 public interface ICircleSpriteShape : ISpriteShape
1111 {
1212 /// <summary>
13+ /// 衝突範囲
14+ /// </summary>
15+ Circle Area { get; }
16+
17+ /// <summary>
1318 /// IStageWorld.Step後に実行されるイベント
1419 /// </summary>
1520 event EventHandler<CircleSpriteShapeSteppedEventArgs> Stepped;
@@ -18,10 +23,5 @@
1823 /// 衝突結果
1924 /// </summary>
2025 IEnumerable<ICircleSpriteContact> Contacts { get; }
21-
22- /// <summary>
23- /// 範囲
24- /// </summary>
25- Circle Area { get; }
2626 }
2727 }
--- trunk/Nlgp1/Nlgp1/Parameters/IStageWorld.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Parameters/IStageWorld.cs (revision 843)
@@ -12,10 +12,10 @@
1212 /// <summary>
1313 /// ISpriteBodyを作成する
1414 /// </summary>
15- /// <param name="sprite">作成元のSprite</param>
15+ /// <param name="sprite">移動できるかどうか</param>
1616 /// <param name="position">初期位置</param>
1717 /// <returns>作成されたオブジェクト</returns>
18- ISpriteBody CreateSpriteBody(Sprite sprite, Vector position);
18+ ISpriteBody CreateSpriteBody(bool isMovable, Vector position);
1919
2020 /// <summary>
2121 /// 状態を進める
--- trunk/Nlgp1/Nlgp1/Parameters/SpriteBody.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Parameters/SpriteBody.cs (revision 843)
@@ -14,7 +14,6 @@
1414 RigidBody chara;
1515 Vector normalgravity = new Vector(0,193);
1616 //IEnumerable<SpriteShape> bodyshapes;
17- Sprite sprite;
1817 //Unloadで削除する
1918
2019 float liniervelocity = 0.5f, angulervelocity = 0, friction = 0f, restitution = 0, density = 0.1f;
@@ -65,7 +64,7 @@
6564
6665 //}
6766
68- public IPolygonSpriteShape CreatePolygonSpriteShape(SpriteShapeFilter filter, IEnumerable<Vector> area)
67+ public IPolygonSpriteShape CreatePolygonSpriteShape(SpriteShapeFilter filter, Polygon area)
6968 {
7069 throw new NotImplementedException();
7170 }
@@ -86,7 +85,6 @@
8685 ////画面外に出ると削除
8786 //GameMap.World.DestroyBody(this.chara.SelfBody);
8887 //this.bodyshapes = null;
89- this.sprite = null;
9088
9189 }
9290
@@ -114,14 +112,6 @@
114112
115113 }
116114
117- public Sprite Sprite
118- {
119- get
120- {
121- throw new NotImplementedException();
122- }
123- }
124-
125115 public Vector Position
126116 {
127117 get
--- trunk/Nlgp1/Nlgp1/Parameters/Polygon.cs (nonexistent)
+++ trunk/Nlgp1/Nlgp1/Parameters/Polygon.cs (revision 843)
@@ -0,0 +1,27 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using Box2DX.Common;
5+
6+namespace Nlgp1.Parameters
7+{
8+ public struct Polygon
9+ {
10+ public Polygon(int verticesCount)
11+ {
12+ this.Vertices = new Vector[verticesCount];
13+ }
14+
15+ public Polygon(Vector[] vertices)
16+ {
17+ this.Vertices = vertices;
18+ }
19+
20+ internal Vec2[] ToVerticesAsVec2()
21+ {
22+ return this.Vertices.Cast<Vec2>().ToArray();
23+ }
24+
25+ public Vector[] Vertices;
26+ }
27+}
--- trunk/Nlgp1/Nlgp1/Parameters/ISpriteContact.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Parameters/ISpriteContact.cs (revision 843)
@@ -10,13 +10,8 @@
1010 public interface ISpriteContact
1111 {
1212 /// <summary>
13- /// 衝突元のISpriteShape
13+ /// 衝突先のISpriteContact
1414 /// </summary>
15- ISpriteShape Source { get; }
16-
17- /// <summary>
18- /// 衝突先のISpriteShape
19- /// </summary>
20- ISpriteShape Target { get; }
15+ ISpriteContact Other { get; }
2116 }
2217 }
--- trunk/Nlgp1/Nlgp1/Parameters/SpriteShapeFilter.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Parameters/SpriteShapeFilter.cs (revision 843)
@@ -13,8 +13,8 @@
1313 this.MaskBits = maskBits;
1414 }
1515
16- public readonly ushort CategoryBits;
16+ public ushort CategoryBits;
1717
18- public readonly ushort MaskBits;
18+ public ushort MaskBits;
1919 }
2020 }
--- trunk/Nlgp1/Nlgp1/Parameters/ISpriteBody.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Parameters/ISpriteBody.cs (revision 843)
@@ -16,7 +16,7 @@
1616 /// <param name="filter">衝突フィルター</param>
1717 /// <param name="area">衝突範囲</param>
1818 /// <returns>作成されたオブジェクト</returns>
19- IPolygonSpriteShape CreatePolygonSpriteShape(SpriteShapeFilter filter, IEnumerable<Vector> area);
19+ IPolygonSpriteShape CreatePolygonSpriteShape(SpriteShapeFilter filter, Polygon area);
2020
2121 /// <summary>
2222 /// 自身が保有するICircleSpriteShapeを作成する
@@ -48,11 +48,6 @@
4848 void ApplyForce(Vector force);
4949
5050 /// <summary>
51- /// 自身を保持するSprite
52- /// </summary>
53- Sprite Sprite { get; }
54-
55- /// <summary>
5651 /// 位置
5752 /// </summary>
5853 Vector Position { get; }
--- trunk/Nlgp1/Nlgp1/Parameters/IPolygonSpriteShape.cs (revision 842)
+++ trunk/Nlgp1/Nlgp1/Parameters/IPolygonSpriteShape.cs (revision 843)
@@ -10,6 +10,16 @@
1010 public interface IPolygonSpriteShape : ISpriteShape
1111 {
1212 /// <summary>
13+ /// 衝突元のIPolygonSpriteShape
14+ /// </summary>
15+ IPolygonSpriteShape Shape { get; }
16+
17+ /// <summary>
18+ /// 衝突範囲
19+ /// </summary>
20+ IEnumerable<Polygon> Area { get; }
21+
22+ /// <summary>
1323 /// IStageWorld.Step後に実行されるイベント
1424 /// </summary>
1525 event EventHandler<PolygonSpriteShapeSteppedEventArgs> Stepped;
@@ -18,10 +28,5 @@
1828 /// 衝突結果
1929 /// </summary>
2030 IEnumerable<IPolygonSpriteContact> Contacts { get; }
21-
22- /// <summary>
23- /// 衝突範囲
24- /// </summary>
25- IEnumerable<Vector> Area { get; }
2631 }
2732 }
Show on old repository browser