private void ShowWork(object sender, System.Windows.RoutedEventArgs e)
        {
            ICommand command = new FlyCommand();

            command.Execute(ExampleBlock);
            command = new JumpCommand();
            command.Execute(ExampleBlock);
        }
Exemplo n.º 2
0
 private void Jump(StateManager states)
 {
     if (states.coll.collisions.below)
     {
         if (states.jumpTimer < Time.realtimeSinceStartup)
         {
             states.jumpTimer = Time.realtimeSinceStartup + jumpFrequency;
             int num = Random.Range(0, 100);
             if (num <= jumpChance)
             {
                 jumpCom.Execute(states.gameObject);
             }
         }
     }
 }
Exemplo n.º 3
0
 private void OnSumbitCommandAction()
 {
     try {
         JumpCommand.Execute(input);
         input = "";
     }
     catch (JumpCommandException e) {
         shockPixel = 2;
         Invoke("StopShock", 0.2f);
         Debug.LogError("Execute Failed: " + e.Message);
     }
     catch  {
         shockPixel = 2;
         Invoke("StopShock", 0.2f);
         throw;
     }
 }
Exemplo n.º 4
0
        //-----------------------------------------------------------------
        private void MainWindow_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Space)
            {
                MainWindow.JumpCommand jump = new JumpCommand();
                jump.Execute();
            }

            if (e.Key == Key.W)
            {
                ClimbCommand climb = new ClimbCommand();
                climb.Execute();
            }
            if (e.Key == Key.F)
            {
                FireCommand fire = new FireCommand();
                fire.Execute();
            }
        }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        commandStream = new CommandStream();
        commandRecord = new Dictionary <ObjectBase, List <CommandStream> > ();


        CommandConversion Do_FrieCommand = (ObjectBase playObj) => {
            FrieCommand frie = new FrieCommand();
            frie.Execute(playObj);
            commandRecord [playObj].Add(frie);
        };

        CommandConversion Do_EludeCommand = (ObjectBase playObj) => {
            EludeCommand elude = new EludeCommand();
            elude.Execute(playObj);
            commandRecord [playObj].Add(elude);
        };

        CommandConversion Do_JumpCommand = (ObjectBase playObj) => {
            JumpCommand jump = new JumpCommand();
            jump.Execute(playObj);
            commandRecord [playObj].Add(jump);
        };

        CommandConversion Do_SupplementCommand = (ObjectBase playObj) => {
            SupplementCommand supplement = new SupplementCommand();
            supplement.Execute(playObj);
            commandRecord [playObj].Add(supplement);
        };

        CommandConversion Do_WalkCommand = (ObjectBase playObj) => {
            WalkCommand walk = new WalkCommand();
            walk.Execute(playObj);
            commandRecord [playObj].Add(walk);
        };

        CommandRoute.Add(CommandType.EludeCommand, Do_EludeCommand);
        CommandRoute.Add(CommandType.FrieCommand, Do_FrieCommand);
        CommandRoute.Add(CommandType.JumpCommand, Do_JumpCommand);
        CommandRoute.Add(CommandType.SupplementCommand, Do_SupplementCommand);
        CommandRoute.Add(CommandType.WalkCommand, Do_WalkCommand);
    }
Exemplo n.º 6
0
 private void Update()
 {
     if (Input.GetButtonDown("Jump"))
     {
         jumpCom.Execute(gameObject);
     }
     else if (Input.GetKeyDown(KeyCode.S))
     {
         crouchCom.Execute(gameObject);
     }
     else if (Input.GetKeyDown(KeyCode.Mouse0))
     {
         attackCom.Execute(gameObject);
     }
     else if (Input.GetKeyDown(KeyCode.Mouse1))
     {
         specialCom.Execute(gameObject);
     }
     else if (Input.GetKeyDown(KeyCode.B))
     {
         altSpecialCom.Execute(gameObject);
     }
     else if (Input.GetKeyDown(KeyCode.Q))
     {
         mindControlCom.Execute(gameObject);
     }
     else if (Input.GetKey(KeyCode.A))
     {
         leftCom.Execute(gameObject);
     }
     else if (Input.GetKey(KeyCode.D))
     {
         rightCom.Execute(gameObject);
     }
     else
     {
         idleCom.Execute(gameObject);
     }
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            try
            {
                Director director = new Director();

                HeroBuilder builder = new ElfHeroBuilder();

                Hero myHero = director.create(builder);

                Console.WriteLine(myHero.ToString());

                IHero friendlyHero = myHero.Clone();

                Console.WriteLine(friendlyHero.ToString());

                Console.Write("Введите кол-во создаваемых объектов -> ");
                var counter = int.Parse(Console.ReadLine());

                Console.Write("Введите тип создаваемых объектов ( 1 - пешие воины, 2 - всадники ) -> ");
                var type = int.Parse(Console.ReadLine());
                if (type != 1 && type != 2)
                {
                    throw new Exception("Введен неверный тип юнита");
                }

                ArmyOfEnemies army = new ArmyOfEnemies();

                if (type == 1)
                {
                    for (int i = 0; i < counter; i++)
                    {
                        army.AddNewEnemy(new Unit(new FootEnemyFactory()));
                    }
                }
                else if (type == 2)
                {
                    for (int i = 0; i < counter; i++)
                    {
                        army.AddNewEnemy(new Unit(new EquestrianEnemyFactory()));
                    }
                }

                foreach (var item in army.list)
                {
                    Console.WriteLine(item.ToString());
                }

                // Lab02 start here

                Console.WriteLine();
                Console.WriteLine();


                Horse horse = new Horse();

                myHero.Move(horse);

                Ally ally = new Ally();

                AllyAdapter adapter = new AllyAdapter(ally);

                myHero.Move(adapter);



                Personage personage = new ElfPersonage();

                Console.WriteLine(personage.Name);

                personage = new ExtraArmorPers(personage);

                Console.WriteLine(personage.Name);



                string nameOfMap = "Пустыня";
                Map    map       = new Map(nameOfMap);

                map.Draw();

                map.AddComponent(myHero);

                IComponent component = map.Find("Main Hero");

                Console.WriteLine(component.Title);
                Console.WriteLine();

                // Lab03 start here

                GameHistory game = new GameHistory();

                Command jumpCommand = new JumpCommand(myHero);
                Command runCommand  = new RunCommand(myHero);

                while (true)
                {
                    char Symbol = Char.Parse(Console.ReadLine());

                    if (Symbol == 'q')
                    {
                        jumpCommand.Execute();
                        myHero.HandleInput(Symbol);
                    }
                    else if (Symbol == 'w')
                    {
                        runCommand.Execute();
                        myHero.HandleInput(Symbol);
                    }
                    else if (Symbol == 's')
                    {
                        game.History.Push(myHero.SaveState());
                    }
                    else
                    {
                        break;
                    }
                }

                myHero.RestoreState(game.History.Pop());

                Console.ReadLine();
            }
            catch (Exception e) {
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }