Esempio n. 1
0
 //The function used to intiialize an arrow when it's created.  Sets speed, spawn time, direction, and starting position
 public void Initialize(float speed, float spawnTime, arrowType dir, Vector3 startPos)
 {
     this.speed = speed;
     this.spawnTime = spawnTime;
     this.dir = dir;
     transform.position = startPos;
 }
Esempio n. 2
0
        /// <summary>
        /// save as bmp file
        /// </summary>
        /// <param name="n"></param>
        /// <returns>Bitmap of current Node and children</returns>
        public Bitmap drawTree(Node n)
        {
            Bitmap   b;
            Graphics g;

            Options.OptionsData d = Options.OptionsData.Instance;
            // set drawing options
            justification       = d.Justification;
            join                = d.Join;
            treeOrientation     = d.TreeOrientation;
            useRnotation        = d.Notation;
            dropShadow          = d.DropShadow;
            boxShading          = d.BoxShading;
            showLegend          = d.ShowLegend;
            arrows              = d.Arrow;
            marker              = d.Marker;
            helpersAsCoPremises = d.HelpersAsCoPremises;
            // Width and height calculation should only be a cross check
            maxWidth  = 0;
            maxHeight = 0;

            recalc(n);

            b = new Bitmap((int)maxWidth + 20, (int)maxHeight + 20); // 20 pixel border
            g = Graphics.FromImage(b);                               // gets the graphics drawing object
            g.Clear(Color.White);                                    // clears the background
            drawTree(g, n);

            return(b);
        }
Esempio n. 3
0
        /// <summary>
        /// Draws the tree from the specified node
        /// </summary>
        /// <param name="g">The Drawing GDI object</param>
        /// <param name="n">Root Node</param>
        public void drawTree(Graphics g, Node n)
        {
            graphics = g;

            Options.OptionsData d = Options.OptionsData.Instance;
            // set drawing options
            justification       = d.Justification;
            join                = d.Join;
            treeOrientation     = d.TreeOrientation;
            useRnotation        = d.Notation;
            dropShadow          = d.DropShadow;
            boxShading          = d.BoxShading;
            showLegend          = d.ShowLegend;
            arrows              = d.Arrow;
            marker              = d.Marker;
            helpersAsCoPremises = d.HelpersAsCoPremises;
            // Width and height calculation should only be a cross check
            maxWidth    = 0;
            maxHeight   = 0;
            g.PageScale = zoom;

            // if(needsRecalc)
            recalc(n);

            // calcStartXY(n,ref x,ref y);

            // for debug
            // g.DrawRectangle(new Pen(Color.Bisque),0,0,maxWidth,maxHeight);
            // g.DrawString("maxHeight & maxWidth:"+maxWidth+" : "+maxHeight,new Font("Courier",8F),new SolidBrush(Color.Black),offsetX,offsetY+maxHeight+margin);

            drawNode(n.x, n.y, n, 0);

            legendY = maxHeight - legendHeight;
            drawLegend(n, true);
        }
Esempio n. 4
0
        /// <summary>
        /// New drawing object for the argument map
        /// </summary>
        /// <param name="offsetX">Offset from the left</param>
        /// <param name="offsetY">Offset from the top</param>
        /// <param name="zoom">Magnification</param>
        public DrawTree(float offsetX, float offsetY, float zoom)
        {
            // Create font and brush.
            drawFont      = new Font("Arial", 16);
            drawFontSmall = new Font("Arial", 8);
            drawBrush     = new SolidBrush(Color.Black);

            justification       = justificationType.jCentre;
            join                = joinType.dogleg;
            arrows              = arrowType.none;
            marker              = markerType.none;
            helpersAsCoPremises = false;

            this.offsetX = offsetX; this.offsetY = offsetY;
            this.zoom    = zoom;
            System.Diagnostics.Debug.Assert(zoom > 0F, "Zoom cannot be zero or less");
        }
Esempio n. 5
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     arow = arrowType.none;
     //this.BackColor = Color.FromArgb(0, Color.Red);
 }
Esempio n. 6
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (arow != arrowType.none)
            {
                reSize(e);
                return;
            }

            if (e.Y <= recArrow[4].Bottom && e.Y >= recArrow[4].Top && e.X >= recArrow[4].Left && e.X <= recArrow[4].Right)//左上
                Cursor = Cursors.SizeNWSE;
            else if (e.Y <= recArrow[5].Bottom && e.Y >= recArrow[5].Top && e.X >= recArrow[5].Left && e.X <= recArrow[5].Right)//左下
                Cursor = Cursors.SizeNESW;
            else if (e.Y <= recArrow[6].Bottom && e.Y >= recArrow[6].Top && e.X >= recArrow[6].Left && e.X <= recArrow[6].Right)//右上
                Cursor = Cursors.SizeNESW;
            else if (e.Y <= recArrow[7].Bottom && e.Y >= recArrow[7].Top && e.X >= recArrow[7].Left && e.X <= recArrow[7].Right)//右下
                Cursor = Cursors.SizeNWSE;
            else if (e.Y <= recArrow[0].Bottom && e.Y >= recArrow[0].Top)//上
                Cursor = Cursors.SizeNS;
            else if (e.Y <= recArrow[1].Bottom && e.Y >= recArrow[1].Top)//下
                Cursor = Cursors.SizeNS;
            else if (e.X >= recArrow[2].Left && e.X <= recArrow[2].Right)//左
                Cursor = Cursors.SizeWE;
            else if (e.X >= recArrow[3].Left && e.X <= recArrow[3].Right)//右
                Cursor = Cursors.SizeWE;
            else
                Cursor = Cursors.SizeAll;

            if (e.Button == MouseButtons.Left)
            {
                Point t = this.PointToScreen(e.Location);
                Point l = this.m_LastPoint;

                if (e.Y <= recArrow[4].Bottom && e.Y >= recArrow[4].Top && e.X >= recArrow[4].Left && e.X <= recArrow[4].Right)//左上
                    arow = arrowType.leftUp;
                else if (e.Y <= recArrow[5].Bottom && e.Y >= recArrow[5].Top && e.X >= recArrow[5].Left && e.X <= recArrow[5].Right)//左下
                    arow = arrowType.leftDown;
                else if (e.Y <= recArrow[6].Bottom && e.Y >= recArrow[6].Top && e.X >= recArrow[6].Left && e.X <= recArrow[6].Right)//右上
                    arow = arrowType.rightUp;
                else if (e.Y <= recArrow[7].Bottom && e.Y >= recArrow[7].Top && e.X >= recArrow[7].Left && e.X <= recArrow[7].Right)//右下
                    arow = arrowType.rightDown;
                else if (e.Y <= recArrow[0].Bottom && e.Y >= recArrow[0].Top)//上
                    arow = arrowType.up;
                else if (e.Y <= recArrow[1].Bottom && e.Y >= recArrow[1].Top)//下
                    arow = arrowType.down;
                else if (e.X >= recArrow[2].Left && e.X <= recArrow[2].Right)//左
                    arow = arrowType.left;
                else if (e.X >= recArrow[3].Left && e.X <= recArrow[3].Right)//右
                    arow = arrowType.right;
                else
                    arow = arrowType.none;

                l.Offset(t.X - this.m_MousePoint.X, t.Y - this.m_MousePoint.Y);
                if (arow != arrowType.none)
                    reSize(e);
                else
                {
                    this.Location = l;
                    Refresh();//这句很重要立即重绘 不然拖动到时候会出现卡卡 的现象 ,找了半天原因
                }
            }
        }
Esempio n. 7
0
    void Update()
    {
        if (replayMode)
        {
            float brightness = (Mathf.Sin(timeToBeat(Time.time) * Mathf.PI / 2f) + 1) * 255f / 2;
            byte  alpha      = (byte)Mathf.RoundToInt(brightness);

            replayText.color = new Color32(255, 255, 255, alpha);

            return;
        }
        if (playing)
        {
            float currentBeat = timeToBeat(Time.time);

            RenderArrows(currentBeat);

            AnimateGuideArrows(currentBeat);

            bool pressedLeft  = false;
            bool pressedUp    = false;
            bool pressedDown  = false;
            bool pressedRight = false;

            if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A))
            {
                pressedLeft = true;
            }
            if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))
            {
                pressedUp = true;
            }
            if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S))
            {
                pressedDown = true;
            }
            if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D))
            {
                pressedRight = true;
            }

            bool leftHeld  = pressedLeft;
            bool downHeld  = pressedDown;
            bool upHeld    = pressedUp;
            bool rightHeld = pressedRight;

            if ((Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) && (currentBeat - leftLastPressed) <= goodThreshold)
            {
                leftHeld = true;
            }
            if ((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) && (currentBeat - downLastPressed) <= goodThreshold)
            {
                downHeld = true;
            }
            if ((Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) && (currentBeat - upLastPressed) <= goodThreshold)
            {
                upHeld = true;
            }
            if ((Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) && (currentBeat - rightLastPressed) <= goodThreshold)
            {
                rightHeld = true;
            }

            int  x = lastResolved + 1;
            bool checkMoreArrows = true;

//            arrowState command = arrowState.normal;

            do
            {
                if (x >= songArrows.Length)
                {
                    checkMoreArrows = false;
                }
                else if (currentBeat > songArrows[x].beat + missThreshold)   //clear if past missThreshold
                {
                    foreach (Transform eachChild in transform)
                    {
                        if (eachChild.tag == "Arrow")
                        {
                            if (eachChild.gameObject.GetComponent <RhythmArrow>().reference == x)
                            {
                                eachChild.gameObject.GetComponent <RhythmArrow>().DoStuff(arrowState.ClearMiss, arrowType.none);
                            }
                        }
                    }

                    switch (songArrows[x].type)
                    {
                    case (arrowType.spy):
                        spySlider.value = Mathf.Max(spySlider.value - 3, 0);
                        break;

                    case (arrowType.romance):
                        loveSlider.value = Mathf.Max(loveSlider.value - 3, 0);
                        break;
                    }

                    lastResolved = x;
                    x++;
                }
                else if (currentBeat < songArrows[x].beat - missThreshold) //
                {
                    checkMoreArrows = false;
                }
                else
                {
                    float      beat           = songArrows[x].beat;
                    List <int> arrowsThisBeat = new List <int>();

                    while (songArrows[x].beat == beat)
                    {
                        arrowsThisBeat.Add(x);
                        x++;

                        if (x >= songArrows.Length)
                        {
                            break;
                        }
                    }

                    bool fail         = false;
                    bool success      = false;
                    int  successCount = 0;

                    arrowType clearType = arrowType.none;

                    if (arrowsThisBeat.Count == 1)
                    {
                        int y = arrowsThisBeat[0];

                        if (songArrows[y].direction == arrowDirection.left && pressedLeft ||
                            songArrows[y].direction == arrowDirection.up && pressedUp ||
                            songArrows[y].direction == arrowDirection.right && pressedRight ||
                            songArrows[y].direction == arrowDirection.down && pressedDown)
                        {
                            successCount = 1;
                            success      = true;
                            fail         = false;
                            clearType    = songArrows[y].type;
                        }
                    }

                    if (arrowsThisBeat.Count > 1)
                    {
                        foreach (int y in arrowsThisBeat)
                        {
                            if (songArrows[y].direction == arrowDirection.left && pressedLeft ||
                                songArrows[y].direction == arrowDirection.up && pressedUp ||
                                songArrows[y].direction == arrowDirection.right && pressedRight ||
                                songArrows[y].direction == arrowDirection.down && pressedDown)
                            {
                                successCount++;
                            }
                        }

                        if (successCount > 0)
                        {
                            int spiesFound = 0;
                            int spiesHit   = 0;
                            int loveFound  = 0;
                            int loveHit    = 0;

                            foreach (int y in arrowsThisBeat)
                            {
                                bool hit;
                                if ((songArrows[y].direction == arrowDirection.left && leftHeld) ||
                                    (songArrows[y].direction == arrowDirection.up && upHeld) ||
                                    (songArrows[y].direction == arrowDirection.down && downHeld) ||
                                    (songArrows[y].direction == arrowDirection.right && rightHeld))
                                {
                                    hit = true;
                                }
                                else
                                {
                                    hit = false;
                                }

                                if (songArrows[y].type == arrowType.spy)
                                {
                                    spiesFound++;
                                    if (hit)
                                    {
                                        spiesHit++;
                                    }
                                }
                                if (songArrows[y].type == arrowType.romance)
                                {
                                    loveFound++;
                                    if (hit)
                                    {
                                        loveHit++;
                                    }
                                }
                            }

                            if (spiesHit > 0 && loveHit > 0)
                            {
                                fail    = true;                 // if you hit both spies and hearts, you fail
                                success = false;
                            }
                            else if (spiesHit == spiesFound && spiesHit > 0)
                            {
                                success      = true;
                                fail         = false;
                                successCount = spiesHit;
                                clearType    = arrowType.spy;
                            }
                            else if (loveHit == loveFound && loveHit > 0)
                            {
                                success      = true;
                                fail         = false;
                                successCount = loveHit;
                                clearType    = arrowType.romance;
                            }
                        }
                    }

                    arrowState precision = arrowState.normal;

                    if (success == true || fail == true)
                    {
                        if (fail == true)
                        {
                            clearType = arrowType.none;
                            precision = arrowState.ClearMiss;

                            spySlider.value  = Mathf.Max(spySlider.value - 3, 0);
                            loveSlider.value = Mathf.Max(loveSlider.value - 3, 0);

                            gameManager.cluck = true;
                            audio.volume      = 1f;
                            if (Random.value < .5)
                            {
                                audio.PlayOneShot(squawk1);
                            }
                            else
                            {
                                audio.PlayOneShot(squawk2);
                            }
                        }
                        else if (success == true)
                        {
                            int points = 0;
                            if (Mathf.Abs(beat - currentBeat) <= goodThreshold)
                            {
                                precision = arrowState.ClearGood;
                                points    = 3;
                            }
                            else if (Mathf.Abs(beat - currentBeat) <= OKThreshold)
                            {
                                precision = arrowState.ClearOK;
                                points    = 1;
                            }
                            else if (Mathf.Abs(beat - currentBeat) <= poorThreshold)
                            {
                                precision = arrowState.ClearPoor;
                                points    = 0;
                            }
                            else
                            {
                                precision = arrowState.ClearMiss;
                                points    = -3;
                            }

                            switch (clearType)
                            {
                            case (arrowType.spy):
                                spySlider.value  = Mathf.Min(spySlider.value + points * successCount, 100);
                                loveSlider.value = Mathf.Max(loveSlider.value - 3 * successCount, 0);
                                reportSpyHits   += successCount;
                                break;

                            case (arrowType.romance):
                                loveSlider.value = Mathf.Min(loveSlider.value + points * successCount, 100);
                                spySlider.value  = Mathf.Max(spySlider.value - 3 * successCount, 0);
                                reportLoveHits  += successCount;
                                break;
                            }
                        }

                        foreach (Transform eachChild in transform)
                        {
                            if (eachChild.tag == "Arrow")
                            {
                                foreach (int y in arrowsThisBeat)
                                {
                                    if (eachChild.gameObject.GetComponent <RhythmArrow>().reference == y)
                                    {
                                        switch (clearType)
                                        {
                                        case (arrowType.spy):
                                            eachChild.gameObject.GetComponent <RhythmArrow>().DoStuff(precision, clearType, spy); break;

                                        case (arrowType.romance):
                                            eachChild.gameObject.GetComponent <RhythmArrow>().DoStuff(precision, clearType, heart); break;

                                        default:
                                            eachChild.gameObject.GetComponent <RhythmArrow>().DoStuff(precision, clearType); break;
                                        }
                                    }
                                }
                            }
                        }

                        lastResolved = x - 1;
                    }
                }
            } while (checkMoreArrows);

            if (pressedLeft)
            {
                leftLastPressed = currentBeat;
            }
            if (pressedDown)
            {
                downLastPressed = currentBeat;
            }
            if (pressedUp)
            {
                upLastPressed = currentBeat;
            }
            if (pressedRight)
            {
                rightLastPressed = currentBeat;
            }

            if (nextReport < reportTimes.Length && currentBeat > reportTimes[nextReport] + missThreshold)
            {
                makeReport();
            }
        }
    }