예제 #1
0
        public int SelectRow()
        {
            int             curRow = 0, curInd = 0, prevRow = 0;
            UnitDeployPlace udp = new UnitDeployPlace();
            ConsoleKey      k;

            DRAW.PushColor(ConsoleColor.DarkGreen);
            String what = "Select a row";

            DRAW.setBuffTo(39 - what.Length / 2, 32);
            DRAW.str(" " + what + " : ");
            DRAW.PopColor();
            int reverseStep = (!isBlue) ? -1 : 1;

            do
            {
                rows[curRow].RedrawAll(true);
                rows[prevRow].RedrawAll();

                k = Console.ReadKey().Key;

                prevRow = curRow;
                if (k == ConsoleKey.RightArrow)
                {
                    curRow -= reverseStep;
                }
                if (k == ConsoleKey.LeftArrow)
                {
                    curRow += reverseStep;
                }
                curRow = (curRow + rows.Count) % rows.Count;
            } while (k != ConsoleKey.Enter);

            return(curRow);
        }
예제 #2
0
        public void SelectAndDeployUnit(Unit unit, Game game)
        {
            int             curRow = 0, curInd = 0, prevRow = 0;
            UnitDeployPlace udp = new UnitDeployPlace();
            ConsoleKey      k;

            DRAW.PushColor(ConsoleColor.DarkGreen);
            String what = "Select a place for " + unit.name;

            DRAW.setBuffTo(39 - what.Length / 2, 32);
            DRAW.str(" " + what + " : ");
            DRAW.PopColor();
            int reverseStep = (!isBlue) ? -1 : 1;

            do
            {
                rows[curRow].getUnits.Insert(curInd, udp);
                rows[curRow].RedrawAll();
                rows[prevRow].RedrawAll();
                rows[curRow].getUnits.RemoveAt(curInd);

                k = Console.ReadKey().Key;
                if (k == ConsoleKey.DownArrow)
                {
                    curInd++;
                }
                if (k == ConsoleKey.UpArrow)
                {
                    curInd--;
                }

                prevRow = curRow;
                if (k == ConsoleKey.RightArrow)
                {
                    curRow -= reverseStep;
                }
                if (k == ConsoleKey.LeftArrow)
                {
                    curRow += reverseStep;
                }
                curRow = (curRow + rows.Count) % rows.Count;
                curInd = (curInd + rows[curRow].unitCount + 1) % (rows[curRow].unitCount + 1);
            } while (k != ConsoleKey.Enter);


            DRAW.setBuffTo(20, 32);
            DRAW.str("".PadLeft(40));

            Row add = rows[curRow];

            add.DeployUnitOnRow(unit, curInd);
            add.RedrawAll();
            unit.TriggerEvent(Event.deploy, game, unit);
        }
예제 #3
0
        public bool RedrawAll(bool selected)
        {
            DrawTop(TotalPower, 0);

            DRAW.PushColor(((selected)?ConsoleColor.DarkGreen : ConsoleColor.Black));
            DRAW.setBuffTo(bufHoriz, bufVert + 1);
            Console.Write("".PadLeft(6, (selected)?'V' : ' '));
            for (int i = 0; i < units.Count; i++)
            {
                units[i].TraceField(bufHoriz, 2 + bufVert + 3 * i);
            }
            if (units.Count < 9)
            {
                UnitDeployPlace.ClearField(bufHoriz, 2 + bufVert + 3 * units.Count);
            }
            DRAW.PopColor();
            return(true);
        }