Exemplo n.º 1
0
        public BulletFood GetNearBullet(Vector2 pos)
        {
            BulletFood bf = null;

            foreach (BulletFood item in allBulletFoods)
            {
                if (bf == null)
                {
                    bf = item;
                    continue;
                }
                if (Vector2.Distance(item.Position, pos) < Vector2.Distance(bf.Position, pos))
                {
                    bf = item;
                }
            }
            return(bf);
        }
Exemplo n.º 2
0
        public override void OnKeyDown(ConsoleKey key)
        {
            base.OnKeyDown(key);

            if (!isOn)
            {
                return;
            }

            if (key == ConsoleKey.J && nowMode == 3)
            {
                if (!(fc.allBulletFoods.Count == 0))
                {
                    BulletFood bf = fc.GetNearBullet(Position);

                    Vector2 v = Vector2.Normalize(Vector2.Lerp(Position, bf.Position, 0.1f) - Position);

                    pbc.ShotOne(Position, v, 0.5f, fc);
                }
            }
        }
Exemplo n.º 3
0
        private void T_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (!Enabled)
            {
                t.Stop();
                return;
            }

            //随机一种食物
            int rNum = Dice.Next(1, 100);

            if (rNum < 20 && isInsSpeedFood)
            {
                SpeedFood sf = new SpeedFood();
                NowScene.Ins.AddObjectToNowScene(sf);
                sf.target = followHead;
                sf.Init();
                sf.RandomPos();
                allSpeedFoods.Add(sf);
            }
            else if (rNum < 67 && isInsBulletFood)
            {
                BulletFood bf = new BulletFood();
                NowScene.Ins.AddObjectToNowScene(bf);
                bf.Init();
                bf.RandomPos();
                bf.RandomForce();
                allBulletFoods.Add(bf);
            }
            else
            {
                NormalFood nf = new NormalFood();
                nf.fColor = Dice.NextColor();
                NowScene.Ins.AddObjectToNowScene(nf);
                nf.Init();
                nf.RandomPos();
                nf.RandomForce();
                allFoods.Add(nf);
            }
        }