Пример #1
0
        private void SelectToSelect()
        {
            int selectIndex = 0;

            Console.CursorTop  = ActivitySelects[selectIndex].PrintLine;
            Console.CursorLeft = 0;
            PrintHelper.PrintWriteColor("=>", ConsoleColor.Red);    //Console.Write();
            Console.SetCursorPosition(0, 0);
            while (true)
            {
                Controller.KeyName kk = Controller.ReadKeyDown();
                switch (kk)
                {
                case Controller.KeyName.UpKey:
                    Console.CursorTop  = ActivitySelects[selectIndex].PrintLine;
                    Console.CursorLeft = 0;
                    Console.Write("  ");
                    selectIndex -= 1;
                    break;

                case Controller.KeyName.DownKey:
                    Console.CursorTop  = ActivitySelects[selectIndex].PrintLine;
                    Console.CursorLeft = 0;
                    Console.Write("  ");
                    selectIndex += 1;
                    break;

                case Controller.KeyName.LeftKey:
                case Controller.KeyName.RightKey:
                case Controller.KeyName.BackKey:
                case Controller.KeyName.MenuKey:
                    foreach (var item in ActivitySelects)
                    {
                        if (item.Key == kk)
                        {
                            TriggerSelectByType(item);
                            return;
                        }
                    }
                    break;

                case Controller.KeyName.EnterKey:
                    TriggerSelectByType(ActivitySelects[selectIndex]);
                    return;
                }

                if (selectIndex <= 0)
                {
                    selectIndex = 0;
                }
                if (selectIndex >= ActivitySelects.Count - 1)
                {
                    selectIndex = ActivitySelects.Count - 1;
                }
                Console.CursorTop  = ActivitySelects[selectIndex].PrintLine;
                Console.CursorLeft = 0;
                PrintHelper.PrintWriteColor("=>", ConsoleColor.Red);
            }
        }
Пример #2
0
 /// <summary>
 /// 创建指向游戏单位介绍房间的选项实例
 /// </summary>
 /// <param name="k">按键代号</param>
 /// <param name="t">选项介绍</param>
 /// <param name="u">游戏单位实例</param>
 public KeySelect(Controller.KeyName k, StringBuilder t, GameUnit u)
 {
     Key           = k;
     SelectText    = t;
     ToScript      = typeof(UnitInfoRoom).Name;
     SelectTextAll = new StringBuilder();
     Unit          = u;
     TheType       = KeySelectType.ToUnit;
 }
Пример #3
0
 /// <summary>
 /// 创建指向地图类房间的选项实例方法(只进入地图房间)
 /// </summary>
 /// <param name="k">按键代号</param>
 /// <param name="t">选项介绍文字</param>
 /// <param name="m">指向的地图脚本</param>
 public KeySelect(Controller.KeyName k, StringBuilder t, Type m)
 {
     Key           = k;
     SelectText    = t;
     ToScript      = typeof(MapRoomScript).Name;
     SelectTextAll = new StringBuilder();
     ToMapScript   = m;
     TheType       = KeySelectType.ToMap;
 }
Пример #4
0
        }                                 //开始打印行数

        //创建指向故事类房间的选项实例方法
        /// <summary>
        /// 创建指向故事类房间的选项实例方法(可进入不同故事房间)
        /// </summary>
        /// <param name="k">按键代号</param>
        /// <param name="s">指向的房间脚本名字</param>
        /// <param name="t">选项介绍文字</param>
        public KeySelect(Controller.KeyName k, string s, StringBuilder t)
        {
            Key           = k;
            SelectText    = t;
            ToScript      = s;
            SelectTextAll = new StringBuilder();
            ToMapScript   = null;
            TheType       = KeySelectType.ToStory;
        }
Пример #5
0
 private void OnlyKeyToSelect()
 {
     while (ActivitySelects.Count > 0)//如果有选项则执行下面按键循环
     {
         Controller.KeyName kk = Controller.ReadKeyDown();
         foreach (var item in Script.KeySelects)
         {
             if (item != null && item.Key == kk)
             {
                 TriggerSelectByType(item);
                 return;
             }
         }
     }
 }
Пример #6
0
        public override void Runing()
        {
            DeBugRun();
            Console.WriteLine();


            int line = Console.CursorTop;

            if (RetureRoom == false)
            {
                SelectIndex = 0;
                ComeRoom    = LastRoom;
            }
            else
            {
                if (SelectIndex + 1 > GameMainRecycle.PlayerInfo.PlayerUnit.Inventorys.Count)
                {
                    SelectIndex -= 1;
                }
            }

            bool goOut = false;

            Console.WriteLine("物品:");
            foreach (var item in GameMainRecycle.PlayerInfo.PlayerUnit.Inventorys)
            {
                Console.WriteLine("  {0}", item.Name);
            }


            while (GameMainRecycle.PlayerInfo.PlayerUnit.Inventorys.Count > 0 && goOut == false)
            {
                Console.SetCursorPosition(0, 0);
                Console.SetCursorPosition(0, SelectIndex + 1 + line);
                Console.Write("=>");
                Controller.KeyName key = Controller.ReadKeyDown();
                Console.SetCursorPosition(0, SelectIndex + 1 + line);
                Console.Write("  ");
                switch (key)
                {
                case Controller.KeyName.UpKey:
                    SelectIndex -= 1;
                    break;

                case Controller.KeyName.DownKey:
                    SelectIndex += 1;
                    break;

                case Controller.KeyName.LeftKey:
                    break;

                case Controller.KeyName.RightKey:
                    break;

                case Controller.KeyName.EnterKey:
                    OutRoom = GameMainRecycle.RoomScripts.Group[typeof(InverntoryInfoRoom).Name];
                    InverntoryInfoRoom room = (InverntoryInfoRoom)OutRoom;
                    room.SeeInventory = GameMainRecycle.PlayerInfo.PlayerUnit.Inventorys[SelectIndex];
                    room.LastRoom     = this;
                    goOut             = true;
                    break;

                case Controller.KeyName.BackKey:
                    OutRoom            = ComeRoom;
                    OutRoom.RetureRoom = true;
                    goOut = true;
                    break;

                case Controller.KeyName.MenuKey:
                    break;
                }
                if (SelectIndex >= GameMainRecycle.PlayerInfo.PlayerUnit.Inventorys.Count - 1)
                {
                    SelectIndex = GameMainRecycle.PlayerInfo.PlayerUnit.Inventorys.Count - 1;
                }
                else if (SelectIndex <= 0)
                {
                    SelectIndex = 0;
                }
            }
            Console.WriteLine("物品栏为空按<{0}>返回", Controller.ControllerKeys[Controller.KeyName.BackKey]);
            while (GameMainRecycle.PlayerInfo.PlayerUnit.Inventorys.Count == 0)
            {
                Controller.KeyName key = Controller.ReadKeyDown();
                if (key == Controller.KeyName.BackKey)
                {
                    OutRoom            = ComeRoom;
                    OutRoom.RetureRoom = true;
                    break;
                }
            }
        }
Пример #7
0
        /// <summary>
        /// 地图按键相关操作方法
        /// </summary>
        /// <param name="start">地图初始绘制行号</param>
        private void KeyToControl(int start)
        {
            bool goOut = false;

            while (!goOut)
            {
                //方向移动主角方法,不能移动的地块尝试出发其事件
                Controller.KeyName kkk = Controller.ReadKeyDown();
                switch (kkk)
                {
                case Controller.KeyName.UpKey:
                    if (Y - 1 >= 0)
                    {
                        if (Script.NowMapChar[Y - 1, X] == '、')
                        {
                            UpdateTile(start, 0, -1);
                        }
                        else
                        {
                            SeeX = X;
                            SeeY = Y - 1;
                            Script.TileToMap[SeeY, SeeX].TileEvent();
                            goOut = true;
                        }
                    }
                    break;

                case Controller.KeyName.DownKey:
                    if (Y + 1 <= Script.NowMapChar.GetLength(0) - 1)
                    {
                        if (Script.NowMapChar[Y + 1, X] == '、')
                        {
                            UpdateTile(start, 0, 1);
                        }
                        else
                        {
                            SeeX = X;
                            SeeY = Y + 1;
                            Script.TileToMap[SeeY, SeeX].TileEvent();
                            goOut = true;
                        }
                    }
                    break;

                case Controller.KeyName.LeftKey:
                    if (X - 1 >= 0)
                    {
                        if (Script.NowMapChar[Y, X - 1] == '、')
                        {
                            UpdateTile(start, -1, 0);
                        }
                        else
                        {
                            SeeX = X - 1;
                            SeeY = Y;
                            Script.TileToMap[SeeY, SeeX].TileEvent();
                            goOut = true;
                        }
                    }
                    break;

                case Controller.KeyName.RightKey:
                    if (X + 1 <= Script.NowMapChar.GetLength(1) - 1)
                    {
                        if (Script.NowMapChar[Y, X + 1] == '、')
                        {
                            UpdateTile(start, 1, 0);
                        }
                        else
                        {
                            SeeX = X + 1;
                            SeeY = Y;
                            Script.TileToMap[SeeY, SeeX].TileEvent();
                            goOut = true;
                        }
                    }
                    break;

                case Controller.KeyName.EnterKey:
                    break;

                case Controller.KeyName.BackKey:
                    break;

                case Controller.KeyName.MenuKey:
                    OutRoom = GameMainRecycle.RoomScripts.Group[typeof(GameSelectRoom).Name];
                    goOut   = true;
                    break;
                }
                Console.CursorTop  = 0;
                Console.CursorLeft = 0;
            }
        }
Пример #8
0
        public static int PrintSelectText(List <string> array, int s)
        {
            if (s == 999)
            {
                s = 0;
            }
            int SelectIndex = s;

            if (SelectIndex >= array.Count - 1)
            {
                SelectIndex = array.Count - 1;
            }
            else if (SelectIndex <= 0)
            {
                SelectIndex = 0;
            }

            int  line  = Console.CursorTop;
            bool goOut = false;

            foreach (var item in array)
            {
                Console.WriteLine("  {0}", item);
            }
            while (array.Count > 0 && goOut == false)
            {
                Console.SetCursorPosition(0, SelectIndex + line);
                PrintHelper.PrintWriteColor("=>", ConsoleColor.Red);
                Controller.KeyName key = Controller.ReadKeyDown();
                Console.SetCursorPosition(0, SelectIndex + line);
                Console.Write("  ");
                switch (key)
                {
                case Controller.KeyName.UpKey:
                    SelectIndex -= 1;
                    break;

                case Controller.KeyName.DownKey:
                    SelectIndex += 1;
                    break;

                case Controller.KeyName.LeftKey:
                    break;

                case Controller.KeyName.RightKey:
                    //goOut = true;
                    break;

                case Controller.KeyName.EnterKey:
                    goOut = true;
                    break;

                case Controller.KeyName.BackKey:
                    return(999);

                case Controller.KeyName.MenuKey:
                    break;
                }
                if (SelectIndex >= array.Count - 1)
                {
                    SelectIndex = array.Count - 1;
                }
                else if (SelectIndex <= 0)
                {
                    SelectIndex = 0;
                }
            }
            return(SelectIndex);
        }