public Core()
        {
            DrawStuff drawStuff = new DrawStuff(windowSize, title);

            _logics = new Logics(drawStuff, ChangeState, drawStuff.SetActive, ChkState);

            eventCatcher     = new EventCatcher(drawStuff);
            drawingComponent = drawStuff;
        }
Beispiel #2
0
        public void Render()
        {
            float w  = 0.3f;
            float x3 = x1 + (x2 - x1 - w) * t;
            float x4 = x3 + w;

            DrawStuff.DrawQuad(new Vector3(x1, y1, 0), new Vector3(x2, y1, 0), new Vector3(x2, y2, 0), new Vector3(x1, y2, 0), new Color(0, 0, 0, 0.4f * alpha));
            DrawStuff.DrawQuad(new Vector3(x3, y1, 0), new Vector3(x4, y1, 0), new Vector3(x4, y2, 0), new Vector3(x3, y2, 0), Color.red);
            DrawStuff.DrawFrame(new Vector3(x1, y1, 0), new Vector3(x2, y1, 0), new Vector3(x2, y2, 0), new Vector3(x1, y2, 0), Color.white);
        }
Beispiel #3
0
    void Update()
    {
        double currTime = AudioSettings.dspTime;

        if (currSegment != null)
        {
            if (currTime + prefetchTime >= nextSegmentStartTime)
            {
                currSegment = nextSegment;
                nextSegment = currSegment.transitions[random.Next(0, currSegment.transitions.Length)];
                if (currSegment.mixerSnapshot != null)
                {
                    currSegment.mixerSnapshot.TransitionTo(currSegment.snapshotTransitionTime);
                }

                float  beatLength = 60.0f / currSegment.bpm;
                double len        = currSegment.lengthInBeats * beatLength;
                for (int n = 0; n < layers.Length; n++)
                {
                    layers[n].NextClip(this);
                    if (n == 0 && layers[n].currDebugRect != null)
                    {
                        DrawStuff.AddTextMesh(gameObject, layers[n].currDebugRect.x1, -3.0f, currSegment.name);
                    }
                }

                currSegmentStartTime  = nextSegmentStartTime;
                nextSegmentStartTime += len + nextSegment.startTime * beatLength;
            }

            for (int n = 0; n < layers.Length; n++)
            {
                layers[n].Update(this, currTime);
            }
        }

        foreach (var s in scheduledStingers)
        {
            if (s.time < currTime)
            {
                stingerSource.PlayOneShot(s.clip, s.level);
                s.disposed = true;
            }
        }

        scheduledStingers.RemoveAll(item => item.disposed);

        if (camera != null)
        {
            camPosition += (camTarget - camPosition) * 0.02f;
            camera.transform.position = new Vector3(camPosition, camera.transform.position.y, camera.transform.position.z);
        }
    }
    GameObject CreateInstance(GameObject prefab, string name)
    {
        GameObject instance = GameObject.Instantiate(prefab);

        instance.name = name;
        Vector3 sides = new Vector3(0.28f, 0.28f, 0.28f);

        instance.transform.localScale = sides;
        instance.transform.position   = DrawStuff.LH_YUP(new Vector3(0f, 3.4f, 7.15f));          //7.15f, 3.85f
        instance.transform.rotation   = Quaternion.identity;
        instance.transform.parent     = transform;
        return(instance);
    }
Beispiel #5
0
        public Logics(DrawStuff drawStuff, Action <Core.gameState> changeStateMethodRef,
                      Action <bool> setWindowThreadActiveAction, Func <Core.gameState> ChkCurrentStateFunc)
        {
            requestDrawObj       = drawStuff.DrawObject;
            changeState          = changeStateMethodRef;
            requestDrawSingleObj = drawStuff.DrawSingleObject;
            clearWindow          = drawStuff.ClearView;
            display = drawStuff.Display;

            this.setWindowThreadActive = setWindowThreadActiveAction;
            ChkCurrentState            = ChkCurrentStateFunc;
            backgroundContainer.IniBg(new Vector2f(WindowData.windowSize.X, WindowData.windowSize.Y));
        }
Beispiel #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (bmp == null || (bmp.Width != this.ClientSize.Width || bmp.Height != this.ClientSize.Height))
            {
                bmp         = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
                this.Region = DrawStuff.DoRegion(this.ClientSize.Width, this.ClientSize.Height);
            }

            Graphics g  = Graphics.FromImage(bmp);
            Color    bg = Color.FromArgb(255, 7, 47, 0);

            this.BackColor = bg;
            g.FillRectangle(new SolidBrush(bg), 0, 0, this.ClientSize.Width, this.ClientSize.Height);

            Pen lg, ng, dg;

            lg = new Pen(Color.FromArgb(255, 7, 70, 0));
            ng = new Pen(Color.FromArgb(255, 7, 50, 0));
            dg = new Pen(Color.FromArgb(255, 7, 30, 0));
            {
                Pen tmp;
                tmp = lg;
                lg  = dg;
                dg  = tmp;
            }
            DrawStuff.DrawHatchedBackground(g, this.ClientSize.Width, this.ClientSize.Height, 10, lg, ng, dg);

            Pen p = new Pen(Color.FromArgb(255, 14, 65, 0), 6);

            DrawStuff.DrawArcBorder(g, this.ClientSize.Width, this.ClientSize.Height, 3, p);

            p = new Pen(Color.Goldenrod, 2);

            DrawStuff.DrawArcBorder(g, this.ClientSize.Width, this.ClientSize.Height, 0, p);

            Font fnt = new System.Drawing.Font("MS Sans Serif", 8.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

            DrawStuff.DrawTextShadow(g, "GMT", fnt, Brushes.Goldenrod, txtOffset.Left + txtOffset.Width + 10, txtOffset.Top + 3);
            DrawStuff.DrawTextShadowLeft(g, "Name", fnt, Brushes.Goldenrod, txtName.Top, txtName.Left - 5, txtName.Height);
            DrawStuff.DrawTextShadowLeft(g, "Offset", fnt, Brushes.Goldenrod, txtOffset.Top, txtOffset.Left - 5, txtOffset.Height);
            DrawStuff.DrawTextShadowLeft(g, "DST", fnt, Brushes.Goldenrod, chkDST.Top, chkDST.Left - 5, chkDST.Height);

            e.Graphics.DrawImage(bmp, 0, 0);
        }
Beispiel #7
0
    GameObject CreateInstance(GameObject prefab, string name)
    {
#if TEST_DETERMINISM
        for (int i = 0; i < transform.childCount; i++)
        {
            GameObject.Destroy(transform.GetChild(i).gameObject);
        }
        numBodies      = 0;
        numPhysxBodies = 0;
        UnityEngine.Random.InitState(0);
#endif
        GameObject instance = GameObject.Instantiate(prefab);
        instance.name = name;
        Vector3 sides = new Vector3(0.28f, 0.28f, 0.28f);
        instance.transform.localScale = sides;
        instance.transform.position   = DrawStuff.LH_YUP(new Vector3(0f, 3.4f, 7.15f));          //7.15f, 3.85f
        instance.transform.rotation   = Quaternion.identity;
        instance.transform.parent     = transform;

        return(instance);
    }
Beispiel #8
0
        public void NextClip(MusicScheduler musicScheduler)
        {
            if (index < musicScheduler.currSegment.layers.Length)
            {
                MusicSegment.Layer layer = musicScheduler.currSegment.layers[index];
                if (layer.clips.Length > 0)
                {
                    currSource = 1 - currSource;
                    var s = sources[currSource];

                    var nextClip = layer.clips[random.Next(0, layer.clips.Length)];
                    while (nextClip == currClip)
                    {
                        nextClip = layer.clips[random.Next(0, layer.clips.Length)];
                    }

                    s.Stop();

                    float  beatLength = 60.0f / musicScheduler.currSegment.bpm;
                    double t0         = musicScheduler.GetNextEventStartTime() + layer.startTime * beatLength;
                    s.outputAudioMixerGroup = layer.mixerGroup;
                    s.clip          = nextClip;
                    s.volume        = (musicScheduler.currSegment.fadeInTime > 0.0f) ? 0.0f : layer.volume;
                    s.panStereo     = layer.pan;
                    s.reverbZoneMix = layer.reverbZoneMix;
                    s.PlayScheduled(t0);
                    sourceStartTime[currSource] = t0;
                    sourceEndTime[currSource]   = t0 + nextClip.length;

                    prevDebugRect = currDebugRect;
                    float x = (float)(t0 - musicScheduler.GetStartTime()), y = index * 5.0f + currSource * 2.0f;
                    currDebugRect = new DebugRect(x, y, x + nextClip.length, y + 2.0f);
                    debugRects.Add(currDebugRect);

                    DrawStuff.AddTextMesh(go, x, y, nextClip.name);

                    musicScheduler.camTarget = Mathf.Max(musicScheduler.camTarget, (float)(musicScheduler.GetNextEventStartTime() - musicScheduler.GetStartTime() + nextClip.length * 0.5));
                }
            }
        }
Beispiel #9
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.ClientSize.Height != (30 + lst.Count * 20 + 100 + 20))
            {
                int offset = this.Height - this.ClientSize.Height;

                this.Height = (30 + lst.Count * 20 + 100 + 20) + offset;

                cmdExit.Top = this.Height - 10 - cmdExit.Height;

                cmdAdd.Top = cmdExit.Top - 10 - cmdAdd.Height;

                cmdExit.Left = this.Width - cmdExit.Width - 10;
                cmdAdd.Left  = cmdExit.Left;
            }

            if (bmp == null || (bmp.Width != this.ClientSize.Width || bmp.Height != this.ClientSize.Height))
            {
                bmp         = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
                this.Region = DrawStuff.DoRegion(this.ClientSize.Width, this.ClientSize.Height);
            }

            Graphics g  = Graphics.FromImage(bmp);
            Color    bg = Color.FromArgb(255, 7, 47, 0);

            this.BackColor = bg;
            g.FillRectangle(new SolidBrush(bg), 0, 0, this.ClientSize.Width, this.ClientSize.Height);

            Pen lg, ng, dg;

            lg = new Pen(Color.FromArgb(255, 7, 70, 0));
            ng = new Pen(Color.FromArgb(255, 7, 50, 0));
            dg = new Pen(Color.FromArgb(255, 7, 30, 0));
            {
                Pen tmp;
                tmp = lg;
                lg  = dg;
                dg  = tmp;
            }
            DrawStuff.DrawHatchedBackground(g, this.ClientSize.Width, this.ClientSize.Height, 10, lg, ng, dg);

            Pen p = new Pen(Color.FromArgb(255, 14, 65, 0), 6);

            DrawStuff.DrawArcBorder(g, this.ClientSize.Width, this.ClientSize.Height, 3, p);

            p = new Pen(Color.Goldenrod, 2);

            DrawStuff.DrawArcBorder(g, this.ClientSize.Width, this.ClientSize.Height, 0, p);

            Font fnt = new System.Drawing.Font("MS Sans Serif", 8.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

            DateTime now = DateTime.Now;
            int      i   = 0;

            foreach (TimeItem itm in lst)
            {
                DateTime newtime = now.ToUniversalTime().AddHours(itm.Offset);
                if (itm.DST)
                {
                    bool bDST = DSTTime.Get.Offset(now);
                    if (bDST)
                    {
                        newtime = newtime.AddHours(1);
                    }
                }
                DrawStuff.DrawTextShadowLeft(g, itm.Name, fnt, Brushes.Goldenrod, 20 + i * 20, 100, 0);
                DrawStuff.DrawTextShadow(g, newtime.ToString("HH:mm:ss fffffff"),
                                         fnt, Brushes.Goldenrod, 110, 20 + i * 20);

                if ((i + 1) == Button_num)
                {
                    DrawStuff.DrawTextShadow(g, "Remove", fnt, Brushes.Gold, 110 + 120, 20 + i * 20);
                }
                else
                {
                    DrawStuff.DrawTextShadow(g, "Remove", fnt, Brushes.LightGreen, 110 + 120, 20 + i * 20);
                }

                i++;
            }

            DrawSpinnyClock(g, now, 20, 30 + lst.Count * 20);

            e.Graphics.DrawImage(bmp, 0, 0);
        }
Beispiel #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (bmp == null || (bmp.Width != this.ClientSize.Width || bmp.Height != this.ClientSize.Height))
            {
                bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
                DoRegion();
            }

            Graphics g  = Graphics.FromImage(bmp);
            Color    bg = Color.FromArgb(255, 7, 47, 0);

            this.BackColor = bg;
            g.FillRectangle(new SolidBrush(bg), 0, 0, this.ClientSize.Width, this.ClientSize.Height);

            Pen lg, ng, dg;

            lg = new Pen(Color.FromArgb(255, 7, 70, 0));
            ng = new Pen(Color.FromArgb(255, 7, 50, 0));
            dg = new Pen(Color.FromArgb(255, 7, 30, 0));
            {
                Pen tmp;
                tmp = lg;
                lg  = dg;
                dg  = tmp;
            }
            DrawStuff.DrawHatchedBackground(g, this.ClientSize.Width, this.ClientSize.Height, 10, lg, ng, dg);

            Pen p = new Pen(Color.FromArgb(255, 14, 65, 0), 6);

            DrawStuff.DrawArcBorder(g, this.ClientSize.Width, this.ClientSize.Height, 3, p);

            p = new Pen(Color.Goldenrod, 2);

            DrawStuff.DrawArcBorder(g, this.ClientSize.Width, this.ClientSize.Height, 0, p);

            Font fnt = new System.Drawing.Font("MS Sans Serif", 8.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

            int i = 0;

            DateTime now = DateTime.Now;

            foreach (TimeItem itm in lst)
            {
                DateTime newtime = now.ToUniversalTime().AddHours(itm.Offset);
                if (itm.DST)
                {
                    bool bDST = DSTTime.Get.Offset(now);
                    if (bDST)
                    {
                        newtime = newtime.AddHours(1);
                    }
                }
                DrawStuff.DrawTextShadowLeft(g, itm.Name, fnt, Brushes.Goldenrod, 0, 20 + i * 20, 100, 0);
                DrawStuff.DrawTextShadow(g, newtime.ToString("HH:mm:ss fffffff"),
                                         fnt, Brushes.Goldenrod, 110, 20 + i * 20);

                i++;
            }

            float  x, y;
            double theta;

            for (int c = 0; c < 360; c += (360 / 12))
            {
                theta = ((c + (360 - 90)) % 360) * (Math.PI / 180);

                x = (float)Math.Cos(theta) * (100 / 2);
                y = (float)Math.Sin(theta) * (100 / 2);
                g.DrawLine(Pens.Black, 20 + (100 / 2) - x, 180 + (100 / 2) - y, 20 + (100 / 2) + x, 180 + (100 / 2) + y);
            }

            theta = ((((now.Hour % 12) / 12.0f) * 360) + (((now.Minute % 60) / 60.0f) * (360 / 12)) + (360 - 90)) * (Math.PI / 180);
            x     = (float)Math.Cos(theta) * (100 / 4);
            y     = (float)Math.Sin(theta) * (100 / 4);
            g.DrawLine(Pens.Goldenrod, 20 + (100 / 2), 180 + (100 / 2), 20 + (100 / 2) + x, 180 + (100 / 2) + y);

            theta = ((((now.Minute % 60) / 60.0f) * 360) + (((now.Second % 60) / 60.0f) * (360 / 60)) + (360 - 90)) * (Math.PI / 180);
            x     = (float)Math.Cos(theta) * (100 / 3);
            y     = (float)Math.Sin(theta) * (100 / 3);
            g.DrawLine(Pens.Goldenrod, 20 + (100 / 2), 180 + (100 / 2), 20 + (100 / 2) + x, 180 + (100 / 2) + y);

            theta = (((((now.Second % 60) / 60.0f)) * 360) + ((now.Millisecond / 1000.0) * (360 / 60)) + (360 - 90)) * (Math.PI / 180);
            x     = (float)Math.Cos(theta) * (100 / 2);
            y     = (float)Math.Sin(theta) * (100 / 2);
            g.DrawLine(Pens.Red, 20 + (100 / 2), 180 + (100 / 2), 20 + (100 / 2) + x, 180 + (100 / 2) + y);

            theta = (((((now.Millisecond % 1000) / 1000.0f)) * 360) + (360 - 90)) * (Math.PI / 180);
            x     = (float)Math.Cos(theta) * (100 / 2);
            y     = (float)Math.Sin(theta) * (100 / 2);
            g.DrawLine(Pens.Red, 20 + (100 / 2), 180 + (100 / 2), 20 + (100 / 2) + x, 180 + (100 / 2) + y);

/*
 *                      now = now.AddHours(-9);
 *
 *                      theta = ((((now.Hour % 12) / 12.0f) * 360) + (((now.Minute % 60) / 60.0f) * (360 / 12)) + (360 - 90)) * (Math.PI / 180);
 *                      x = (float)Math.Cos(theta) * (100 / 4);
 *                      y = (float)Math.Sin(theta) * (100 / 4);
 *                      g.DrawLine(Pens.Brown, 20 + (100 / 2), 180 + (100 / 2), 20 + (100 / 2) + x, 180 + (100 / 2) + y);
 */
            g.DrawEllipse(Pens.LightGreen, 20, 180, 100, 100);

            g.DrawEllipse(Pens.LightGreen, 20 + (100 / 2) - (6 / 2), 180 + (100 / 2) - (6 / 2), 6, 6);

            e.Graphics.DrawImage(bmp, 0, 0);
        }