Exemplo n.º 1
0
 protected override bool OnHitAlive(HitInfo hit)
 {
     Direction = DirectionUtils.GetOpposite(Direction);
     velocity *= -1;
     UpdateSprite();
     return(true);
 }
Exemplo n.º 2
0
        public Player(PlayerData data, DungeonTile tile, Direction direction)
        {
            Data = data;

            X     = tile.ScreenX + Global.TileSize / 2;
            Y     = tile.ScreenY + Global.TileSize / 2;
            Angle = DirectionUtils.GetAngle(direction);

            Type     = Global.TypePlayer;
            Layer    = Global.LayerMain;
            Collider = data.PixelMask;
            OriginX  = Width / 2;
            OriginY  = Height / 2;

            sortNode = new Renderable();
            Add(sortNode);

            sprite = new Animator(data.Anim);
            sprite.CenterOrigin();
            sprite.Play("idle");
            sortNode.Add(sprite);

            bloodFrontSprite = new Animator(data.Anim);
            bloodFrontSprite.CenterOrigin();
            sortNode.Add(bloodFrontSprite);

            bloodBackSprite = new Animator(data.Anim);
            bloodBackSprite.CenterOrigin();
            sortNode.Add(bloodBackSprite);

            hurtSprite = new Animator(data.Anim);
            hurtSprite.CenterOrigin();
            sortNode.Add(hurtSprite);

            blinker         = new Blinker(PlayerData.InvincibleBlinkInterval, sortNode);
            blinker.Enabled = false;
            Add(blinker);

            if (engineSound == null)
            {
                engineSound = Asset.LoadSoundEffect("sfx/car_engine").CreateInstance();
            }
            engineSound.Volume   = 0.0f;
            engineSound.IsLooped = true;
            engineSound.Play();

            if (driftSounds == null)
            {
                driftSounds = new SoundEffectInstance[2];
                for (var i = 0; i < driftSounds.Length; i++)
                {
                    driftSounds[i]        = Asset.LoadSoundEffect("sfx/car_drift_" + (i + 1)).CreateInstance();
                    driftSounds[i].Volume = 0.7f;
                }
            }

            if (breakSound == null)
            {
                breakSound = Asset.LoadSoundEffect("sfx/car_break").CreateInstance();
            }
            breakSound.Volume = 0.7f;

            Engine.Track(this, "Position");
            Engine.Track(this, "Speed");
            Engine.Track(this, "Angle");
            Engine.Track(this, "engineState");
            Engine.Track(this, "enginePct");
            Engine.Track(this, "driftPct");
            Engine.Track(this, "tireBloodPct");
            Engine.Track(this, "velocity");
            Engine.Track(this, "bounceVelocity");
            Engine.Track(this, "driftAngle");
            Engine.Track(this, "forward");
        }
Exemplo n.º 3
0
 public Goblin(EntityArguments args) : base(args)
 {
     velocity = DirectionUtils.GetNormal(Direction) * 20.0f;
     UpdateSprite();
 }