コード例 #1
0
ファイル: Player.cs プロジェクト: JohnHumble/BitMiner
        public void Update(PickupManager pickups, PlanetColecction planets)
        {
            ship.Update(pickups);

            pDock = null;
            foreach (var planet in planets.Planets)
            {
                if (Tool.distance2(ship.Locaion, planet.Position) < planet.Size)
                {
                    pDock = planet;
                }
            }
        }
コード例 #2
0
ファイル: Astroroid.cs プロジェクト: JohnHumble/BitMiner
        protected void buildAstroroid(Planet planet = null)
        {
            cells = new List <Cell>();
            for (int i = 0; i < Size; i++)
            {
                for (int j = 0; j < Size; j++)
                {
                    const int BEVEL = 1;
                    if ((j <= BEVEL || j >= Size - BEVEL) && (i <= BEVEL || i >= Size - BEVEL))
                    {
                        int chance = rand.Next(0, 10);
                        if (chance % 20 == 0)
                        {
                            makeCell(i, j);
                        }
                    }
                    else
                    {
                        makeCell(i, j);
                    }
                }
            }

            float velx = 0;
            float vely = 0;

            if (planet == null)
            {
                velx = (float)(rand.NextDouble() - .5) * 1f;
                vely = (float)(rand.NextDouble() - .5) * 1f;
            }
            else
            {
                float angle = Tool.angleTo(location, planet.Position);
                angle -= 1.57079f; // P/2
                float dis   = Tool.distance2(location, planet.Position);
                float speed = (float)(rand.NextDouble() - .5) * 100000f / dis;
                velx = (float)Math.Cos(angle) * speed;
                vely = (float)Math.Sin(angle) * speed;
            }

            velocity = new Vector2(velx, vely);
            rotSpeed = (float)(rand.NextDouble() - .5) * 0.1357f;
        }