Пример #1
0
    public RRShip(PhysicsGame me, double width, double height, int startHP, double scoreValue, Vector spawnPosition, Action<RRShip, PhysicsObject> onCollision, Action<RRShip> updateHPMeter)
        : base(width, height)
    {
        this.Shape = Shape.Diamond;
        this.Tag = "P"; //It is a player..
        this.Health = startHP;
        this.ScoreValue = scoreValue;
        this.Position = spawnPosition;

        this.CanRotate = false;
        this.Color = Color.Red;
        this.CollisionIgnoreGroup = 2;
        this.IgnoresGravity = true;
        this.IgnoresExplosions = true;

        // We know what to do
        this.Add(new GameObject(PhysicsGame.LoadImage("PlayerSprite")));
        this.collisionFunc = onCollision;
        this.updateMeters = updateHPMeter;

        me.AddCollisionHandler<RRShip, PhysicsObject>(this, collisionHandler);

        // Call the meter handler just to reinit
        updateMeters(this);
    }