コード例 #1
0
 public CollectableBullet(Vector2 position, float rotation, World world, Texture texture)
 {
     this.body              = FarseerPhysics.Factories.BodyFactory.CreateCircle(world, ConvertUnits.ToSimUnits(10), 10);
     this.body.BodyType     = BodyType.Static;
     this.body.IsSensor     = true;
     this.body.Position     = position;
     this.body.CollidesWith = Category.Cat2;
     Sprite                 = new Sprite(texture);
     Sprite.Origin         += new SFML.System.Vector2f(texture.Size.X / 2, texture.Size.Y / 2);
     Sprite.Position        = Vector2fExtensions.ToSf(position);
     Sprite.Rotation        = rotation;
     this.body.OnCollision += Body_OnCollision;
 }
コード例 #2
0
ファイル: Command.cs プロジェクト: Sinnaj94/csharp-games
        public void _Execute(Player p)
        {
            Vector2f dif = Vector2fExtensions.ToSf(p.body.Position);

            ca.Strength -= dif;
            Vector2 caSim = Vector2fExtensions.ToSimVector(ca.Strength);

            caSim -= p.body.Position;
            float angle = (float)(Math.Atan2(caSim.X - p.body.WorldCenter.X, caSim.Y - p.body.WorldCenter.Y) * -1);

            p.Rotate(angle);
            p.CursorPosition = ca.Strength + dif;
        }
コード例 #3
0
ファイル: Enemy.cs プロジェクト: Sinnaj94/csharp-games
        public void calculatePathToSimTargetUsingAStart(Vector2 position, Manhatten <Tile, Object> aStar)
        {
            playerPosition = position;
            List <Point>      backupPath  = Path;
            Vector2f          startVector = Vector2fExtensions.ToSf(this.body.Position);
            Vector2f          endVector   = Vector2fExtensions.ToSf(position);
            Point             start       = new Point((int)startVector.X / 32, (int)startVector.Y / 32);
            Point             end         = new Point((int)endVector.X / 32, (int)endVector.Y / 32);
            LinkedList <Tile> path        = aStar.Search(start, end, null);

            Path = new List <Point>();
            if (path != null)
            {
                foreach (Tile t in path)
                {
                    Path.Add(new Point(t.X, t.Y));
                }
            }
            else
            {
                Path = backupPath;
            }
        }