Пример #1
0
        public static IEnumerator<bool> Default(PlayerUser player)
        {
            int count = 0;

            while (true)
            {
                if (player.IsTriggerShottableTiming && player.Operatable)
                {
                    var dr = (count / player.ShotInterval) % 8;
                    var pad = player.CurrentInput;

                    if (pad.ExtraDirection == PlayerInputDirection.Right) dr = 0;
                    if (pad.ExtraDirection == (PlayerInputDirection.Right | PlayerInputDirection.Down)) dr = 1;
                    if (pad.ExtraDirection == PlayerInputDirection.Down) dr = 2;
                    if (pad.ExtraDirection == (PlayerInputDirection.Down | PlayerInputDirection.Left)) dr = 3;
                    if (pad.ExtraDirection == PlayerInputDirection.Left) dr = 4;
                    if (pad.ExtraDirection == (PlayerInputDirection.Left | PlayerInputDirection.Up)) dr = 5;
                    if (pad.ExtraDirection == PlayerInputDirection.Up) dr = 6;
                    if (pad.ExtraDirection == (PlayerInputDirection.Up | PlayerInputDirection.Right)) dr = 7;

                    player.ParentManager.Add(
                        new PlayerImageBullet(player, Linear(Math.PI / 4.0 * dr, 8, 90),
                        CommonObjects.ImageShot, player.ShotStrength)
                    {
                        X = player.X,
                        Y = player.Y,
                        HomeX = 8,
                        HomeY = 8,
                    }, PlayerBulletLayer);
                }
                count++;
                yield return true;
            }
        }
Пример #2
0
        private static IEnumerator<bool> LazyHomingToEnemy(PlayerUser par, PlayerBullet b, double startAngle, double startSpeed, int delay, double homingSpeed)
        {
            for (int i = 0; i < delay; i++)
            {
                b.X += Math.Cos(startAngle) * startSpeed;
                b.Y += Math.Sin(startAngle) * startSpeed;
                yield return true;
            }

            var t = par.ParentManager
                .Where(p => p.MyKind != b.MyKind && ((p.DamageKind & b.MyKind) != 0))
                .OrderBy(p => (p.X - b.X) * (p.X - b.X) + (p.Y - b.Y) * (p.Y - b.Y))
                .FirstOrDefault();
            var ang = 0.0;
            if (t == null)
            {
                ang = rnd.NextDouble() * Math.PI * 2;
            }
            else
            {
                ang = Math.Atan2(t.Y - b.Y, t.X - b.X);
            }

            while (true)
            {
                b.X += Math.Cos(ang) * homingSpeed;
                b.Y += Math.Sin(ang) * homingSpeed;
                yield return true;
            }
        }
Пример #3
0
 public PlayerOption(PlayerUser p, OptionInformation user,SceneGame game)
     : this()
 {
     Parent = p;
     Game = game;
     Information = user;
     SourceUser = Information.SourceUser;
     Image = UserImageManager.GetUserImage(SourceUser);
     ExecuteCoroutine = user.TargetOperation(this, user.InitializationInformation);
 }
Пример #4
0
 public static IEnumerator<bool> MouseOperaiton(PlayerUser player)
 {
     while (true)
     {
         if (player.Operatable)
         {
             player.X = player.CurrentInput.MouseX;
             player.Y = player.CurrentInput.MouseY;
         }
         yield return true;
     }
 }
Пример #5
0
 public static CoroutineFunction<UserSprite, PlayerBullet> LazyHomingToEnemy(PlayerUser u, double startAngle, double startSpeed, int delay, double homingSpeed)
 {
     return (par, b) => LazyHomingToEnemy(u, b, startAngle, startSpeed, delay, homingSpeed);
 }