示例#1
0
 public ZombieBehavior(GamePlayEntity entity)
     : base(entity)
 {
 }
示例#2
0
        async void Hug(GamePlayEntity entity)
        {
            var oldPos = entity.Position;
            entity.Position = Position;

            entity.IsHugging = true;
            IsHugging = true;
            entity.BeginTransformation();

            entity.Sprite.Effect = Sprite.Effect == SpriteEffects.FlipHorizontally ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
            var hugs = TaskEx.WhenAll(
                Sprite.PlayAnimation("hug"),
                entity.Sprite.PlayAnimation("hug"));

            await TaskEx.Delay(TimeSpan.FromSeconds(0.3));
            entity.TurnIntoFriend();
            Screen.Score++;
            Screen.IncreaseTimer(TimeSpan.FromSeconds(1));
            await hugs;

            entity.IsHugging = false;
            IsHugging = false;

            entity.Position = new Vector2(Position.X + (Sprite.Effect == SpriteEffects.FlipHorizontally ? -10 : 10), entity.Position.Y);
        }