Esempio n. 1
0
        private async void DoShootBullets(object sender, DoWorkEventArgs e)
        {
            int bulletsshot = 0;

            while (bulletsshot < 5)
            {
                // Release bullets
                for (int ang = 0; ang < 360; ang += 60)
                {
                    Debug.WriteLine("Shooting bullet towards angle {0}", ang);
                    double spawnX, spawnY;
                    spawnX = CurrentCharacter.Position.X += 5 * Math.Cos(ang);
                    spawnY = CurrentCharacter.Position.Y -= 5 * Math.Sin(ang);
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                    {
                        ShotsFired.Add(new BulletNPC(CurrentCharacter.Position, ang, (int)spawnX, (int)spawnY));
                    });
                }

                LastBulletRelease = DateTime.Now;
                bulletsshot++;
                await Task.Delay((int)BulletReleaseTimeSpan.TotalMilliseconds);
            }
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
            {
                ShotsFired.Clear();
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Play attack animation
        /// </summary>
        public void Attack()
        {
            if (_shootWaitTime < MaxShootIntervals)
            {
                return;
            }
            var playerWindow = _playerWindow;
            var x            = CurrentDirection == Direction.Right ? 30f : -30f;
            var pos          = new Vector2f(Position.X + x, Position.Y);

            ShotsFired.Add(new Shot(ref playerWindow, Name + "Shot", pos)
            {
                Direction = CurrentDirection
            });
            _shotSound?.Play();
            _shootWaitTime = 0;
        }
Esempio n. 3
0
        /// <summary>
        /// Attack the player
        /// </summary>
        public void Attack()
        {
            if (_timeSinceLastShot >= ShotSpeed)
            {
                var window   = (RenderWindow)_renderTarget;
                var x        = CurrentDirection == Direction.Right ? 30f : -30f;
                var pos      = new Vector2f(Position.X + x, Position.Y);
                var shotName = "";
                switch (Type)
                {
                case EnemyType.Nurse:
                    shotName = "Needle";
                    break;

                case EnemyType.Teenager:
                    shotName = "Skateboard";
                    break;

                case EnemyType.GrimReeper:
                    shotName = "Sycth";
                    break;

                case EnemyType.FuneralHomeDirector:
                    shotName = "Tombstone";
                    break;
                }
                ShotsFired.Add(new Shot(ref window, shotName, pos)
                {
                    Direction = CurrentDirection
                });
                //_shotSound.Play();
                _timeSinceLastShot = 0;
            }
            else
            {
                _timeSinceLastShot += GameMaster.Delta.AsSeconds();
            }
        }