示例#1
0
        private void RefreshButton_Click(object sender, EventArgs e)
        {
            float min, max;

            if (float.TryParse(MinSpikeTextBox.Text, out min) && float.TryParse(MaxSpikeTextBox.Text, out max))
            {
                m_listView.Items.Clear();

                Dictionary <string, SpikeData> dct = new Dictionary <string, SpikeData>();

                foreach (LogView logView in m_logControl.m_logViews)
                {
                    foreach (FrameRecord fr in logView.m_logData.FrameRecords)
                    {
                        foreach (RDIElementValue <ProfilerRDI> prdiEv in m_logControl.m_prdiTree.GetValueEnumerator(fr))
                        {
                            float  value = prdiEv.m_value;
                            string path  = prdiEv.m_rdi.Path;

                            if (value > min && value < max)
                            {
                                if (!dct.ContainsKey(path))
                                {
                                    dct[path] = new SpikeData(path, value);
                                }
                                else
                                {
                                    dct[path].numHits   += 1;
                                    dct[path].totalTime += value;
                                    dct[path].maxTime    = Math.Max(dct[path].maxTime, value);
                                }
                            }
                        }
                    }
                }

                m_listView.BeginUpdate();

                foreach (KeyValuePair <string, SpikeData> pair in dct)
                {
                    ListViewItem lvi = new ListViewItem(pair.Key);
                    lvi.Name    = pair.Key;
                    lvi.Tag     = pair.Value;
                    lvi.Checked = m_logControl.m_prdiTreeView.TreeNodeHierarchy.IsChecked(pair.Key);
                    lvi.SubItems.Add(string.Format("{0:n2} ms", pair.Value.maxTime));
                    lvi.SubItems.Add(string.Format("{0:n2} ms", pair.Value.totalTime));
                    lvi.SubItems.Add(string.Format("{0:d}", pair.Value.numHits));

                    m_listView.Items.Add(lvi);
                }

                m_listView.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                m_listView.Columns[1].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                m_listView.Columns[2].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                m_listView.Columns[3].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);

                m_listView.EndUpdate();
            }
        }
示例#2
0
    private void CreateSpikeInCell(Vector3 place, SpikeData spike)
    {
        var emptyCellObj = Instantiate(_spikePrefab, _emptyCellsParent);

        emptyCellObj.name = "Spike_" + spike.CellCoords.x.ToString() + "_" + spike.CellCoords.y.ToString();
        emptyCellObj.transform.position = place;
        emptyCellObj.GetComponent <SpikeObjectLogic>().Initialize(spike.Position);
    }
示例#3
0
            public int Compare(object a, object b)
            {
                SpikeData ia = ((ListViewItem)a).Tag as SpikeData;
                SpikeData ib = ((ListViewItem)b).Tag as SpikeData;

                switch (field)
                {
                case 3:
                    return((ia.numHits > ib.numHits) ? -1 : 1);

                case 2:
                    return((ia.totalTime > ib.totalTime) ? -1 : 1);

                case 1:
                    return((ia.maxTime > ib.maxTime) ? -1 : 1);

                case 0:
                    return(string.Compare(ia.Path, ib.Path));
                }
                return(1);
            }
示例#4
0
            public bool Show(AnimData AD)
            {
                SpikeData sd = ((SpikeData)AD.effect.Buffer);

                switch (AD.animType)
                {
                case AnimOperation.AnimInit:
                {
                    int xLeft   = AD.rcWnd.Left;
                    int xRight  = AD.rcWnd.Right;
                    int yTop    = AD.rcWnd.Bottom;
                    int yBottom = AD.rcWnd.Top;

                    for (int idx = 0; idx < 16; idx++)
                    {
                        Point[] pTriangle = sd.ptTriangleEnd[idx];

                        pTriangle[0] = AD.ptCenter;

                        if (idx < 4)
                        {
                            pTriangle[1].X = pTriangle[2].Y = yTop;
                            pTriangle[1].X = (xLeft * (4 - idx) + xRight * idx) / 4;
                            pTriangle[2].X = (xLeft * (3 - idx) + xRight * (idx + 1)) / 4;
                        }
                        else if (idx < 8)
                        {
                            pTriangle[1].X = pTriangle[2].X = xRight;
                            pTriangle[1].Y = (yTop * (8 - idx) + yBottom * (idx - 4)) / 4;
                            pTriangle[2].Y = (yTop * (7 - idx) + yBottom * (idx - 3)) / 4;
                        }
                        else if (idx < 12)
                        {
                            pTriangle[1].Y = pTriangle[2].Y = yBottom;
                            pTriangle[1].X = (xRight * (12 - idx) + xLeft * (idx - 8)) / 4;
                            pTriangle[2].X = (xRight * (11 - idx) + xLeft * (idx - 7)) / 4;
                        }
                        else
                        {
                            pTriangle[1].X = pTriangle[2].X = xLeft;
                            pTriangle[1].Y = (yBottom * (16 - idx) + yTop * (idx - 12)) / 4;
                            pTriangle[2].Y = (yBottom * (15 - idx) + yTop * (idx - 11)) / 4;
                        }

                        sd.ptEndCenter[idx].X = (pTriangle[0].X + pTriangle[1].X + pTriangle[2].X) / 3;
                        sd.ptEndCenter[idx].Y = (pTriangle[0].Y + pTriangle[1].Y + pTriangle[2].Y) / 3;
                    }

                    Point ptTrgCenter = new Point();

                    ptTrgCenter.X = AD.ptCenter.X;

                    ptTrgCenter.Y = AD.ptCenter.Y + (AD.ptRelRightTop.X + AD.ptRelRightTop.Y) * 4 / 5;

                    for (int idx = 0; idx < 16; idx++)
                    {
                        MATRIXF matrix;

                        matrix = MATRIXF.rotateMatrix((33 * MATRIXF.fixed1) + (-22 * MATRIXF.fixed1) * idx, AD.ptCenter);
                        sd.ptTriangleCenter[idx] = ptTrgCenter * matrix;
                        Point ptTemp = MATRIXF.subtract(sd.ptTriangleCenter[idx], sd.ptEndCenter[idx]);
                        sd.matrixCircle[idx] = MATRIXF.offsetMatrix(ptTemp.X, ptTemp.Y);
                    }

                    break;
                }                                //end case

                case AnimOperation.AnimDraw:
                case AnimOperation.AnimErase:
                {
                    Point[] ptTriangle = new Point[3];

                    double  fixedFactor;
                    MATRIXF matrix;
                    double  fxScale;

                    fxScale = MATRIXF.fixedDiv(AD.iStep, AD.iTotalSteps);

                    if (AD.iStep < AD.iTotalSteps / 2)
                    {
                        fixedFactor = (MATRIXF.fixed1 - MATRIXF.fixedDiv(AD.iStep * 2, AD.iTotalSteps)) * AD.iParameter;
                        for (int idx = 0; idx < 16; idx++)
                        {
                            matrix = MATRIXF.scaleMatrix(fxScale, fxScale, sd.ptEndCenter[idx]) *
                                     MATRIXF.rotateMatrix(fixedFactor, sd.ptEndCenter[idx]);

                            matrix = matrix * sd.matrixCircle[idx];

                            for (int iAngle = 0; iAngle < 3; iAngle++)
                            {
                                ptTriangle[iAngle] = sd.ptTriangleEnd[idx][iAngle] * matrix;
                            }

                            drawPoly(ptTriangle, AD.color);
                        }
                    }
                    else
                    {
                        fixedFactor = MATRIXF.fixedDiv(AD.iStep * 2 - AD.iTotalSteps, AD.iTotalSteps);
                        for (int idx = 0; idx < 16; idx++)
                        {
                            matrix  = MATRIXF.scaleMatrix(fxScale, fxScale, sd.ptEndCenter[idx]);
                            matrix *= MATRIXF.mix(MATRIXF.matrix1, sd.matrixCircle[idx], fixedFactor);

                            for (int iAngle = 0; iAngle < 3; iAngle++)
                            {
                                ptTriangle[iAngle] = sd.ptTriangleEnd[idx][iAngle] * matrix;
                            }

                            drawPoly(ptTriangle, AD.color);
                        }
                    }
                    break;
                }                //end case
                }                //end switch

                return(true);
            }    //end show
示例#5
0
        private void OnSpikeClicked(int row, int column, int cube1, int cube2)
        {
            if (FirstClick)                     //לחיצה ראשונית
            {
                if (eatenB <= 0 && eatenW <= 0) //בודק אם היעד חוקי
                {
                    if (Spikes[row, column].IsEmpty() || Spikes[row, column].Black != BlackTurn)
                    {
                        return;
                    }
                    else if (Spikes[row, column].Black != BlackTurn)
                    {
                        return;
                    }
                }

                if (numTurns == -1)//בודק אם נגמרו התורות
                {
                    Cube1 = cube1;
                    Cube2 = cube2;
                    SetNumTurns(row, column);
                }

                if (Spikes[row, column].OutMode)
                {
                    Spikes[row, column].SoldiersCount--;
                    ClearAll();
                    if (row == 1)
                    {
                        blacksOut++;
                    }
                    if (row == 0)
                    {
                        whitesOut++;
                    }
                    numTurns--;
                    if (cube1 != cube2)
                    {
                        if (!BlackTurn)
                        {
                            int fartherSpike = IdFartherWhitesSpike();
                            if (cube1 > cube2 && cube1 > fartherSpike)
                            {
                                cube1 = fartherSpike;
                            }
                            if (cube2 > cube1 && cube2 > fartherSpike)
                            {
                                cube2 = fartherSpike;
                            }
                            if (Spikes[row, column].SpikeId == cube1 - 1 && row == 0)
                            {
                                Cube1 = 0;
                            }
                            if (Spikes[row, column].SpikeId == cube2 - 1 && row == 0)
                            {
                                Cube2 = 0;
                            }
                        }
                        else
                        {
                            int fartherSpike = IdFartherBlacksSpike();
                            if (cube1 > cube2 && cube1 > fartherSpike)
                            {
                                cube1 = fartherSpike;
                            }
                            if (cube2 > cube1 && cube2 > fartherSpike)
                            {
                                cube2 = fartherSpike;
                            }
                            if (Spikes[row, column].SpikeId == 24 - cube1 && row == 1)
                            {
                                Cube1 = 0;
                            }
                            if (Spikes[row, column].SpikeId == 24 - cube2 && row == 1)
                            {
                                Cube2 = 0;
                            }
                        }
                    }

                    if (WhitesInHouse())
                    {
                        ShowWhitesOut(Cube1, Cube2);
                    }
                    if (BlacksInHouse())
                    {
                        ShowBlacksOut(Cube1, Cube2);
                    }

                    HandleEndTurn();
                    FirstClick = true;
                    return;
                }
                if (eatenB > 0 && BlackTurn) //בודק אם יש אכולים שחורים ומטפל בהם
                {
                    if (Spikes[row, column].PreviewMode)
                    {
                        if (Spikes[row, column].SoldiersCount == 1 && Spikes[row, column].Black == !BlackTurn)
                        {
                            Spikes[row, column].SoldiersCount--;
                            eatenW++;
                        }
                        if (Spikes[row, column].IsEmpty())
                        {
                            Spikes[row, column].Black = true;
                        }
                        Spikes[row, column].SoldiersCount++;
                        ClearAll();
                        eatenB--;
                        numTurns--;
                        if (Spikes[row, column].SpikeId == cube1 - 1)
                        {
                            Cube1 = 0;
                        }
                        if (Spikes[row, column].SpikeId == cube2 - 1)
                        {
                            Cube2 = 0;
                        }
                        HandleEat(Cube1, Cube2);
                        HandleEndTurn();
                        FirstClick = true;
                        return;
                    }
                }

                if (eatenW > 0 && !BlackTurn) //בודק אם יש אכולים לבנים ומטפל בהם
                {
                    if (Spikes[row, column].PreviewMode)
                    {
                        if (Spikes[row, column].SoldiersCount == 1 && Spikes[row, column].Black == !BlackTurn)
                        {
                            Spikes[row, column].SoldiersCount--;
                            eatenB++;
                        }
                        if (Spikes[row, column].IsEmpty())
                        {
                            Spikes[row, column].Black = false;
                        }
                        Spikes[row, column].SoldiersCount++;
                        ClearAll();
                        eatenW--;
                        numTurns--;
                        if (Spikes[row, column].SpikeId == 24 - cube1)
                        {
                            Cube1 = 0;
                        }
                        if (Spikes[row, column].SpikeId == 24 - cube2)
                        {
                            Cube2 = 0;
                        }
                        HandleEat(Cube1, Cube2);
                        HandleEndTurn();
                        FirstClick = true;
                        return;
                    }
                }

                if (cube1 == cube2)//מטפל במקרים של דאבל
                {
                    int[] locs = GetDoublePreviewLocations(row, column, cube1);

                    srcSpike = new SpikeData
                    {
                        Column = column,
                        Row    = row,
                        Spike  = Spikes[row, column]
                    };

                    for (var i = 0; i < locs.Length; i++)
                    {
                        (int r, int c) = GetSpikeById(locs[i]);
                        if (r == -1 || c == -1)
                        {
                            continue;
                        }
                        bool x = CheckSpike(r, c) && CheckMoveDirection(r, c);
                        if (!x)
                        {
                            break;
                        }
                        Spikes[r, c].PreviewMode = true;
                    }

                    Spikes[row, column].Marked = true;
                    FirstClick = false;
                    return;
                }

                (int l1, int l2, int l3) = GetPreviewLocation(row, column, Cube1, Cube2);

                srcSpike = new SpikeData
                {
                    Column = column,
                    Row    = row,
                    Spike  = Spikes[row, column],
                    l1     = l1, l2 = l2, l3 = l3
                };
                //מסמן את המקום על פי הקוביות
                if (l1 >= 0 && l1 < 24)
                {
                    (int rowl1, int columnl1)           = GetSpikeById(l1);
                    Spikes[rowl1, columnl1].PreviewMode = CheckSpike(rowl1, columnl1) && CheckMoveDirection(rowl1, columnl1);
                }

                if (l2 >= 0 && l2 < 24)
                {
                    (int rowl2, int columnl2)           = GetSpikeById(l2);
                    Spikes[rowl2, columnl2].PreviewMode = CheckSpike(rowl2, columnl2) && CheckMoveDirection(rowl2, columnl2);
                }

                if (l3 >= 0 && l3 < 24)
                {
                    (int rowl3, int columnl3)           = GetSpikeById(l3);
                    Spikes[rowl3, columnl3].PreviewMode = CheckSpike(rowl3, columnl3) && CheckMoveDirection(rowl3, columnl3);
                }

                Spikes[row, column].Marked = true;
                FirstClick = false;
                return;
            }

            if (!Spikes[row, column].PreviewMode && !Spikes[row, column].Marked)
            {
                return;
            }

            Spikes[srcSpike.Row, srcSpike.Column].Marked = false;

            if (Spikes[row, column].IsEmpty())
            {
                Spikes[row, column].Black = srcSpike.Spike.Black;
            }

            if (Spikes[row, column].PreviewMode)
            {
                if (Spikes[row, column].SoldiersCount == 1 && srcSpike.Spike.Black != Spikes[row, column].Black)
                {
                    Spikes[row, column].SoldiersCount--;

                    if (Spikes[row, column].Black)
                    {
                        eatenB++;
                    }
                    if (!Spikes[row, column].Black)
                    {
                        eatenW++;
                    }

                    Spikes[row, column].Black = srcSpike.Spike.Black;
                }
                Spikes[srcSpike.Row, srcSpike.Column].SoldiersCount--;
                Spikes[row, column].SoldiersCount++;
            }

            if (cube1 != cube2)
            {
                if (Spikes[row, column].SpikeId == srcSpike.l1)
                {
                    Cube1 = 0;
                    numTurns--;
                }

                if (Spikes[row, column].SpikeId == srcSpike.l2)
                {
                    Cube2 = 0;
                    numTurns--;
                }

                if (Spikes[row, column].SpikeId == srcSpike.l3)
                {
                    Cube1     = 0;
                    Cube2     = 0;
                    numTurns -= 2;
                }
            }
            else
            {
                int turns = Math.Abs(srcSpike.Spike.SpikeId - Spikes[row, column].SpikeId) / cube1;
                numTurns -= turns;
            }
            ClearAll();
            if (WhitesInHouse())
            {
                ShowWhitesOut(Cube1, Cube2);
            }
            if (BlacksInHouse())
            {
                ShowBlacksOut(Cube1, Cube2);
            }
            HandleEndTurn();
            FirstClick = true;
        }