Пример #1
0
        void Start()
        {
            ConstructorInfo circleCtor   = typeof(HitCircle).GetConstructor(new Type[0]);
            ConstructorInfo approachCtor = typeof(ApproachCircle).GetConstructor(new Type[0]);

            circleActivator   = GameObject.GetActivator <HitCircle>(circleCtor);
            approachActivator = GameObject.GetActivator <ApproachCircle>(approachCtor);

            hitWindow300 = DifficultyCalc.GetHitWindow300(mapInfo.overallDifficulty);
            hitWindow100 = DifficultyCalc.GetHitWindow100(mapInfo.overallDifficulty);
            hitWindow50  = DifficultyCalc.GetHitWindow50(mapInfo.overallDifficulty);
            // more Leniency
            //hitWindow300 += 0.05f;
            //hitWindow100 += 0.075f;
            //hitWindow50 += 0.1f;


            lifeTime = DifficultyCalc.GetObjectLifeTime(mapInfo.approachRate);

            ApproachCircleResizer.lifeTime               = lifeTime;
            ApproachCircleResizer.approachSizes          = approachCircleSizes;
            ApproachCircleResizer.safeApproachSizesCount = approachCircleSizes.Count - 1;

            HitDetector.radius        = hitRadius;
            HitDetector.radiusSquared = hitRadius * hitRadius;
            HitDetector.spriteMap     = hitCircle;

            HitResultDestroyer.lifeTime = 1f;
        }
Пример #2
0
        public GameMaster()
        {
            mapInfo = new MapParser(GetMapPath())
            {
                overallDifficulty = 4
            };

            int consoleWidth  = Console.BufferWidth;
            int consoleHeight = Console.BufferHeight;

            float xScale = consoleWidth / 512f;
            float yScale = consoleHeight / 384f;

            foreach (KeyValuePair <float, CircleInfo> circle in mapInfo.hitObjects)
            {
                circle.Value.position.X *= (int)Math.Round(xScale, 0);

                circle.Value.position.Y *= (int)Math.Round(yScale, 0);
            }

            Bitmap circleImage = (Bitmap)Image.FromFile($"{GetSkinPath()}\\hitcircleoverlay.png");

            float circleRadius = DifficultyCalc.GetCircleArea(mapInfo.circleSize);

            float circleScale = circleRadius / circleImage.Width;

            SetUpHitImages(circleScale);

            // The circle doesn't begin perfectly at the file edge
            // Scale calculation?
            //circleRadius -= 20;

            float approachCircleScale = circleScale * 3;

            List <string[, ]> approachCircleSizes = new List <string[, ]>();

            Bitmap approachImage = (Bitmap)Image.FromFile($"{GetSkinPath()}\\approachcircle.png");

            float circleLifeTime = DifficultyCalc.GetObjectLifeTime(mapInfo.approachRate);
            int   imageAmount    = Convert.ToInt32(circleLifeTime * approachImagesPerSecond);

            for (float i = imageAmount - 1; i >= 0; i--)
            {
                float newScale = Lerp(circleScale, approachCircleScale, (i / imageAmount));

                approachCircleSizes.Add(BitMapToStringArray(Sprite.ResizeImage(
                                                                image: approachImage,
                                                                width: (int)(approachImage.Width * newScale),
                                                                height: (int)(approachImage.Height * newScale))));
            }


            CircleSpawner circleSpawner = AddComponent <CircleSpawner>();

            circleSpawner.approachCircleSizes = approachCircleSizes;
            circleSpawner.hitCircle           = new Sprite(circleImage, circleScale).colorValues;
            circleSpawner.mapInfo             = mapInfo;
            circleSpawner.hitRadius           = circleRadius;


            //new Thread(() =>
            //{
            //	WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer();

            //	player.enableContextMenu = false;

            //	player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(Player_PlayStateChange);
            //	player.MediaError += new WMPLib._WMPOCXEvents_MediaErrorEventHandler(Player_MediaError);
            //	player.URL = Directory.GetParent(GetMapPath()) + "\\" + mapInfo.audioFilename;

            //	player.controls.play();

            //	//System.Media.SoundPlayer s = new System.Media.SoundPlayer();
            //}).Start();
        }