Exemple #1
0
        public void MIMIC(RBYPokemon Attacker, RBYPokemon Defender)
        {
            int replace_index;
            var move = MoveEnyclopedia[Defender.Moveset[RandomNumberGenerator(1, 4)].Index];

            if (Attacker.Owner == 0)
            {
                replace_index = Trainer1.IndexPicked;
            }
            else
            {
                replace_index = Trainer2.IndexPicked;
            }

            var query = Attacker.Moveset.Where(p => p.Name == move.Name);

            if (query.Count() == 0)
            {
                Displayer.RelayMessage("The move failed");
                return;
            }

            Attacker.UsedMimic              = true;
            Attacker.MimicIndex             = replace_index;
            Attacker.OldMimic               = Attacker.Moveset[replace_index];
            Attacker.Moveset[replace_index] = move;
            Defender.NonDmgHit();
        }
Exemple #2
0
        private static Type ShowFunctionsAndGetFunction()
        {
            List <string> options = new List <string>(appFunctions);

            options.AddRange(rayConfigFunctions);

            Type funcInterface = typeof(IProgramFunction);
            var  funcs         = AppDomain.CurrentDomain.GetAssemblies()
                                 .SelectMany(a => a.GetTypes()
                                             .Where(t => t.GetInterfaces()
                                                    .Contains(typeof(IProgramFunction))));

            Console.WriteLine();
            Displayer.ShowConfigItem(
                "本机ip或域名", RayConfigExtensionRepository.Create().GetHostAddress(),
                addReture: true, color: ConsoleColor.Yellow);

            Displayer.ShowOptions(Displayer.HighLightColor, ConsoleColor.White, false, appFunctions, rayConfigFunctions);

            try
            {
                int    ch       = InputHelper.GetNumberInput();
                string funcName = options[ch - 1];
                Type   func     = funcs.FirstOrDefault(
                    t => (t.GetProperty(nameof(IProgramFunction.FunctionName))
                          .GetValue(null, null) as string) == funcName);
                return(func);
            }
            catch
            {
                throw new IndexOutOfRangeException(
                          $"输入错误, 输入的必须是 1-{options.Count} 之间的整数.");
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            string fileName = args[0];
            IStringListProvider    stringListProvider = new StringListProvider(fileName);
            IPersonParser          parser             = new PersonParser();
            IPersonProviderFactory factory            = new PersonProviderFactory(stringListProvider, parser);


            IPersonProvider personProvider = factory.Create();

            var list = personProvider.GetPeople().ToList();

            list.Sort();
            IOutputPort output = new Displayer();

            output.Send(list);

            stringListProvider = new StringListProvider("sorted-names - list.txt");
            factory            = new PersonProviderFactory(stringListProvider, parser);
            personProvider     = factory.Create();
            output             = new Saver(personProvider);
            output.Send(list);
            Console.WriteLine("End");
            Console.ReadLine();
        }
Exemple #4
0
        public void Execute()
        {
            RayConfigRepository repo = new RayConfigRepository();

            IList <RayPort> ports = repo.GetRayPorts();

            ConsoleConfigDisplayer.DisplayRayPorts(ports);
            try
            {
                int ch = InputHelper.GetNumberInput("输入端口索引选择端口", tipsColor: ConsoleColor.DarkGreen);
                ch -= 1;
                if (ch >= ports.Count)
                {
                    Displayer.ShowLine("输入错误, 超出索引.", ConsoleColor.Red);
                    return;
                }

                ConsoleInputRayPortConfigBuilder rayPortBuilder =
                    new ConsoleInputRayPortConfigBuilder(ports[ch]);
                RayPortUser user = rayPortBuilder.BuildPortUser();
                repo.AddUserToPort(ports[ch], user);

                Displayer.ShowLine("操作成功!", ConsoleColor.DarkGreen, true);
                ConsoleConfigDisplayer.DisplayUser(user);
            }
            catch (Exception ex)
            {
                Displayer.ShowLine($"操作失败!\r\n错误:{ex.Message}", ConsoleColor.Red, true);
            }
        }
Exemple #5
0
        /// <summary>
        /// Preparations before running the game mode: "Player Vs. Computer"
        /// </summary>
        private void PlayerVsComputer()
        {
            int  level       = 0;    // Holds the level of the computer
            bool isCompFirst = true; // Holds who is the first player to play

            // ====== Computer Levels Window ======
            Displayer.DisplayComputerLevels(true);
            level = UserInput.SetComputerLevel(this);

            // ======  First to Play Window  ======
            Displayer.DisplayWhoIsFirst(true);
            isCompFirst = UserInput.IsComputerFirstToPlay(this);

            if (isCompFirst)
            {
                Computer computer = new Computer("Computer", Shape.X, level);
                Human    human    = new Human(string.Empty, Shape.O, UserInput);
                RunGameMode(computer, human); // Run the mode
            }
            else
            {
                Human    human    = new Human(string.Empty, Shape.X, UserInput);
                Computer computer = new Computer("Computer", Shape.O, level);
                RunGameMode(human, computer); // Run the mode
            }
        }
        private bool PickSwitch(bool dead = false)
        {
            //Write a function to list switchable pokes
            //var alive = Trainer1.Party.Where(p => p.IsAlive == true).ToList();

            //if (alive.Count > 1)
            //    Displayer.DisplayPokesToSwitch(alive.ConvertAll(x => (Pokemon)x));

            Displayer.DisplayPokesToSwitch(Trainer1.Party.ConvertAll(x => (Pokemon)x));

            int selection = Input_Handler();

            if (selection > Trainer1.Party.Count || Trainer1.Party[selection] == Trainer1CurrentPoke || !Trainer1.Party[selection].IsAlive)
            {
                return(false);
            }
            else
            {
                Trainer1CurrentPoke = Trainer1.Party[selection];
                Trainer1.Switch(selection, Trainer1CurrentPoke);

                if (!dead)
                {
                    Displayer.TrainerSwitchedPokemon(Trainer1.Name, Trainer1CurrentPoke.Name);
                }
                else
                {
                    Displayer.RelayMessage($"Trainer threw out {Trainer1CurrentPoke.Name}");
                }
                return(true);
            }
        }
Exemple #7
0
    static public Displayer SetRotationFeed(GameObject newObject, RawImage image, int size = 64, float scale = 1f, float rotation = 0f, float speed = 0f, float camDistance = 3f, float camFOV = 30f)
    {
        Displayer d = GetDisplayer();

        d.Stage(newObject, image, scale, rotation, speed, camDistance, camFOV, size);
        return(d);
    }
Exemple #8
0
        static void Main(string[] args)
        {
            List <bool> gamesResults = new List <bool>();

            for (var i = 0; i < 100; i++)
            {
                Game game = new Game();
                game.SelectDoor();
                Displayer.GameState(game);
                game.OpenEmptyNotSelectedDoor();
                Displayer.GameState(game);
                game.ReselectDoor();
                Displayer.GameState(game);
                game.OpenPrizeDoor();
                Displayer.GameState(game);
                Displayer.GameResult(game);

                gamesResults.Add(game.IsCorrectGuess());

                Console.WriteLine();
            }

            int won  = gamesResults.Count(x => x);
            int lost = gamesResults.Count(x => !x);

            Console.WriteLine();
            Console.WriteLine($"You have won {won} times and lost {lost} times.");
        }
Exemple #9
0
        public void Run(IMenu <T> menu)
        {
            // display options
            Writer.WriteLine("welcome to our menu:");
            while (true)
            {
                Displayer.DisplayNenu(menu);
                // read option and validate
                int input = DataReader.Read(menu);
                if (input != -1)
                {
                    // run option action
                    var  option   = menu.Options.First(item => item.Key.Equals(input)).Value;
                    bool?exitMenu = option.Run()?.ExitMenu;

                    if (exitMenu != null && exitMenu == true)
                    {
                        break;
                    }


                    Writer.WriteLine("---------------------------------");
                }
                else
                {
                    Writer.WriteLine("the input is not valid");
                }
            }
        }
Exemple #10
0
        public override void Modify()
        {
            if (ConfigToModify == null)
            {
                return;
            }

            Console.Clear();

            ShowModifyOptions();

            int?ch = InputHelper.TryGetNumberInput("请输入序号来选择要修改的用户信息项");

            Displayer.ShowConfigItem("你输入了", ch?.ToString() ?? string.Empty, valueColor: Displayer.HighLightColor, addReture: true);

            if (ch == null || !optionsMap.Keys.Contains(ch.Value))
            {
                Displayer.PressAnyKeyToContinue("输入格式错误!", Displayer.ErrorColor);
                Modify();
            }
            else
            {
                optionsMap[ch.Value].Item2.Invoke();

                if (exitFunction == true)
                {
                    return;
                }

                UpdateOptionsMap();
                Modify();
            }
        }
    public void ShowImage(int id, string state, string path, bool protagonist)
    {
        Displayer displayer = m_Displayers[id];

        //if (state!=null)
        //    FindAndSet(id,state);
        if (displayer.video.GetComponent <MonitorGrid>() != null)
        {
            MonitorGrid mgrid = displayer.video.GetComponent <MonitorGrid>();
            mgrid.State       = state;
            mgrid.Protagonist = protagonist;
            if (mgrid.isAugmented)
            {
                FindAndSet(id, state);
            }
        }
        else//真实世界
        {
            FindAndSet(id, state);
        }
        RenderTexture.active = displayer.video.targetTexture;
        GL.Clear(true, true, Color.black);
        RenderTexture.active = null;
        //displayer.video.targetTexture.DiscardContents();
        //Graphics.Blit(firstFrameTexture, displayer.video.targetTexture);
        displayer.videoBG.gameObject.SetActive(false);
        displayer.image.gameObject.SetActive(true);
        displayer.image.sprite = Resources.Load <Sprite>(path);
    }
        private void KeyBoardInputWindow_OnKeyDown(object sender, KeyEventArgs e)
        {
            ObservableCollection.Add(e);

            //尝试滚动到最下面
            Displayer.ScrollIntoView(ObservableCollection.Last());
        }
Exemple #13
0
        private void ShowModifyOptions()
        {
            var options = optionsMap.Select(m => m.Value.Item1);

            Displayer.ShowOptions(indexColor: Displayer.HighLightColor,
                                  options: options.ToArray());
        }
        private void MultiHitMove(string name, int atk, int def, int lvl, int basepw, double stab, double multiplier, RBYPokemon Defender, bool physpec, bool crit_chance)
        {
            int hits = RandomNumberGenerator(2, 5);
            int dmg;

            if (name == "DOUBLE KICK")
            {
                hits = 2;
            }

            for (int i = 0; i < hits; i++)
            {
                dmg = DamageCalculation(atk, def, lvl, basepw, stab, multiplier, crit_chance);
                Defender.TakeDamage(dmg, physpec);

                if (i != hits - 1)
                {
                    Displayer.AttackContiunes();
                }

                if (!Defender.IsAlive)
                {
                    break;
                }
            }
        }
    public void Start()
    {
        switch (simulationMode)
        {
        case SimulationMode.Verlet:
            verletSimulator = new VerletSimulator(ref verletConstants)
            {
                simulationManager = this,
                targetManager     = TargetManager,
                particleDisplayer = Displayer
            };
            verletSimulator.Start();
            break;

        case SimulationMode.Euler:
            eulerSimulator = new EulerSimulator(ref eulerConstants)
            {
                simulationManager = this,
                targetManager     = TargetManager,
                particleDisplayer = Displayer
            };
            eulerSimulator.Start();
            break;
        }

        // Call this from here to make sure all the required variables are set
        Displayer.SpawnParticles();
    }
Exemple #16
0
        //private NextLifecycle _gridUpdate; //BoardGame in iteration #2

        public GOLEngine()
        {
            _display   = new Displayer();
            _gameBoard = new BoardGame();
            //_gridUpdate = new NextLifecycle();
            _menu = new ConsoleMenu();
        }
    // Use this for initialization
    void Start()
    {
        audioManager     = FindObjectOfType <AudioManager>();
        checkPointSystem = GameObject.FindGameObjectWithTag("CheckPointSystem").GetComponent <CheckPointSystem>();
        animator         = GetComponent <Animator>();
        akuAku           = GameObject.FindGameObjectWithTag("AkuAku").GetComponent <AkuAku>();
        lifeDisplayer    = lifeCanvas.GetComponent <Displayer>();
        wumpaDisplayer   = wumpaCanvas.GetComponent <Displayer>();
        spawnPoint       = transform.position;


        //get the position spawn
        if (checkPointSystem.checkpointsUnlocked.Count > 0)
        {
            lifeDisplayer.DisplayInfo(checkPointSystem.lifeAmount);
            Vector3 position = checkPointSystem.checkpointsUnlocked.Last();
            position.y        += 0.35F;
            transform.position = position;
        }
        else
        {
            transform.position = spawnPoint;
            TeleportStart();
        }
    }
Exemple #18
0
        public static void DisplayUser(
            RayPortUser rayPortUser, int?index = null,
            bool showShareUrl = true, bool addReturn = true,
            int intend        = 2)
        {
            if (rayPortUser == null)
            {
                return;
            }
            StringBuilder s  = new StringBuilder("");
            StringWriter  sw = new StringWriter(s);

            s.Append(' ', intend);
            Displayer.ShowConfigItem(s + "索引", index, Program.HighLightColor);
            Displayer.ShowConfigItem(s + "用户", rayPortUser.GetRayPortUserRemark(), Program.WarningColor);
            Displayer.ShowConfigItem(s + "用户Id", rayPortUser.Uuid);
            Displayer.ShowConfigItem(s + "用户额外Id", rayPortUser.AlterId);
            Displayer.ShowConfigItem(s + "等级(Level)", rayPortUser.Level);
            Displayer.ShowConfigItem(s + "邮箱", rayPortUser.Email);
            if (showShareUrl)
            {
                try
                {
                    Displayer.ShowConfigItem(
                        "分享链接",
                        rayPortUser.GenerateShareUrl(RayConfigRepository.GetRayPort(rayPortUser)), Program.ErrorColor);
                }
                catch (Exception) { }
            }

            if (addReturn)
            {
                Console.WriteLine();
            }
        }
Exemple #19
0
        static void Main(string[] args)
        {
            var displayer = new Displayer(new Model());

            displayer.DisplayWelcome(true);

            while (true)
            {
                var input = Console.ReadLine();
                if (input == "1" || input == "2")
                {
                    displayer.DisplayOrganism(input);
                }
                else if (input == "3")
                {
                    displayer.DisplayDonationForm("1", "1");
                }
                else if (input == "q")
                {
                    break;
                }

                displayer.DisplayWelcome(false);
            }
        }
        private void StatBoostTypeMove(RBYPokemon Attacker, RBYPokemon Defender, AttackType atk, int accuracy, bool sec = false)
        {
            var query = atk.Stats.Where(p => p.Boost < StatBoostDegree.MeDown);

            if (query.Count() != 0 && !sec)
            {
                Defender.LastDmg = 0;
                Defender.NonDmgHit();
                if (!HitOrMiss(Attacker.Accuracy, Defender.Evasion, accuracy) || Defender.IsMisted && !Unhittable(Defender))
                {
                    Displayer.AtkMissed();
                    return;
                }
            }

            foreach (var p in atk.Stats)
            {
                if (p.Boost < StatBoostDegree.MeDown)
                {
                    Defender.IncreaseStage(p.Stat, DetermineStatDegree(p.Boost));
                }
                else
                {
                    Attacker.IncreaseStage(p.Stat, DetermineStatDegree(p.Boost));
                }
            }
        }
 private void YouAreFrozen(RBYPokemon Defender)
 {
     if (Defender.CurrentStatus == StatusConditionInflicted.None)
     {
         Defender.Freeze();
         Displayer.Freezed(Defender.OwnerCall, Defender.Name);
     }
 }
 private void ConfuseLogic(RBYPokemon Defender)
 {
     if (!Defender.IsConfused)
     {
         Defender.TakeConfusion(RandomNumberGenerator(2, 5));
         Displayer.Confused(Defender.OwnerCall, Defender.Name);
     }
 }
Exemple #23
0
        private void StartDisplayer(Song song)
        {
            Displayer displayer = new Displayer(this, song);

            System.Threading.Thread dsiplayerThread = new System.Threading.Thread(new System.Threading.ThreadStart(displayer.Show));
            dsiplayerThread.IsBackground = true;
            dsiplayerThread.Start();
        }
 private void RecoilLogic(RBYPokemon Defender, RBYPokemon Attacker, int dmg)
 {
     if (Defender.IsAlive)
     {
         Attacker.TakeDamage(dmg / 10, false);
         Displayer.RecoilHappened(Attacker.OwnerCall, Attacker.Name);
     }
 }
Exemple #25
0
        private void ShowMofiyOptions()
        {
            IEnumerable <string> options = optionsMap.Values.Select(v => v.Item1);

            Console.Clear();
            Displayer.ShowOptions(
                hasEmptyLineAfterEachOption: true, options: options.ToArray());
        }
Exemple #26
0
        public override void NormalPoisonDmg()
        {
            int dmg = _HealthPoints / 16;

            dmg = dmg == 0 ? 1 : dmg;
            Displayer.RelayMessage($"{Name} took poison damage");
            TakeDamage(dmg);
        }
Exemple #27
0
        /// <summary>
        /// Preparations before running the game mode: "Player Vs. Player"
        /// </summary>
        private void PlayerVsPlayer()
        {
            Displayer.ClearWindow();

            Human human1 = new Human(string.Empty, Shape.X, UserInput);
            Human human2 = new Human(string.Empty, Shape.O, UserInput);

            RunGameMode(human1, human2); // Run the mode
        }
Exemple #28
0
        private void ModifyFinished()
        {
            ConfigRepo.UpdateUser(ConfigToModify);

            Displayer.ShowLine("修改完成!\r\n", 2);
            Displayer.PressAnyKeyToContinue();

            exitFunction = true;
        }
Exemple #29
0
 public void Execute()
 {
     Console.Clear();
     Displayer.ShowCutLine();
     Console.WriteLine();
     Displayer.ShowLine(RayConfig.RayConfigJObject.ToString(), addReturn: true);
     Displayer.ShowCutLine();
     Displayer.PressAnyKeyToContinue();
 }
Exemple #30
0
 public void SetConcerned()
 {
     if (isLocked)
     {
         return;
     }
     concerned = true;
     display   = CreateDisplay();
 }