示例#1
0
    //-----------------------------------------------------------------------------------------------------------
    private void AddInputToList(EInput pressed)
    {
        previousInput.Add(pressed);

        //Update facing direction
        m_facingDirection = pressed;
    }
示例#2
0
        public override void Physics(EInput input)
        {
            Renderer.SetObjects(map.GetVisuals());
            switch (input)
            {
            case EInput.moveForward:
                if (selection != 0)
                {
                    --selection;
                }
                SetSelection();
                break;

            case EInput.moveBackward:
                if (selection != 6)
                {
                    ++selection;
                }
                SetSelection();
                break;

            case EInput.attack:
            case EInput.enter:
                Action();
                break;

            case EInput.escape:
                System.Environment.Exit(0);
                break;
            }
        }
示例#3
0
        public void StartTimer(Player player, EInput inputType, UC_View_BuyControl bay)
        {
            Player    = player;
            InputType = inputType;
            Bay       = bay;

            if (inputType == EInput.Player1Keys || inputType == EInput.Player2Keys)
            {
                StaticVaribl.MainPage.KeyDown   += MainPage_KeyDown;
                StaticVaribl.MainPage.KeyUp     += MainPage_KeyUp;
                StaticVaribl.MainPage.LostFocus += MainPage_LostFocus;
            }

            //if (inputType == EInput.Joist1 ||
            //    inputType == EInput.Joist2 ||
            //    inputType == EInput.Joist3 ||
            //    inputType == EInput.Joist4)
            //{
            //    _keyTimerPlayer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(0.15) };
            //    _keyTimerPlayer.Tick += _keyTimerPlayer_Tick;
            //    _keyTimerPlayer.Start();
            //}
            _keyTimerPlayer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(0.1)
            };
            _keyTimerPlayer.Tick += _keyTimerPlayer_Tick;
            _keyTimerPlayer.Start();
        }
示例#4
0
 public static void UnsubscribeClientInputChange(EInput _eInput, NotifyClientInputChange _nCallback)
 {
     if (s_cInstance.m_mClientInputCallbacks.ContainsKey(_eInput))
     {
         s_cInstance.m_mClientInputCallbacks[_eInput].Remove(_nCallback);
     }
 }
示例#5
0
        public override void Physics(EInput input)
        {
            Renderer.SetObjects(map.GetVisuals());
            switch (input)
            {
            case EInput.moveForward:
                if (selection != 0)
                {
                    --selection;
                }
                SetSelection();
                break;

            case EInput.moveBackward:
                if (selection != 2)
                {
                    ++selection;
                }
                SetSelection();
                break;

            case EInput.attack:
            case EInput.enter:
                Action();
                break;

            case EInput.escape:
                global::Game.gameState = new Menu();
                break;
            }
        }
示例#6
0
        public override void Physics(EInput input)
        {
            Renderer.SetObjects(map.GetVisuals());
            switch (input)
            {
            case EInput.moveForward:
                if (selection != 0)
                {
                    --selection;
                }
                SetSelection();
                break;

            case EInput.moveBackward:
                if (selection != list.Count / 3 - 2)
                {
                    ++selection;
                }
                SetSelection();
                break;

            case EInput.attack:
            case EInput.enter:
                Action();
                break;

            case EInput.escape:
                global::Game.gameState = new Menu();
                break;
            }
            ((Image.Bar)hud[0].Image).SetProgressPercentage(selection / (float)(list.Count / 3 - 2));
        }
示例#7
0
 public ELabelInput(string title, float width_title, string input_lab, float width_input, float height = DEFAULT_HEIGHT) : base(width_title + width_input, height)
 {
     title_lab = new ELabel(title, width_title);
     _input    = new EInput(input_lab, width_input);
     AddComponent(title_lab, 0, 0);
     AddComponentRight(_input, title_lab);
     show_box = false;
 }
示例#8
0
 public override void Physics(EInput input)
 {
     Renderer.SetObjects(map.GetVisuals());
     if (input != EInput.none)
     {
         global::Game.gameState = new Menu();
     }
 }
示例#9
0
    public static void SubscribeClientInputChange(EInput _eInput, NotifyClientInputChange _nCallback)
    {
        if (!s_cInstance.m_mClientInputCallbacks.ContainsKey(_eInput))
        {
            s_cInstance.m_mClientInputCallbacks.Add(_eInput, new List <NotifyClientInputChange>());
        }

        s_cInstance.m_mClientInputCallbacks[_eInput].Add(_nCallback);
    }
示例#10
0
        public static void TriggerEvent(EInput eventName)
        {
            UnityEvent thisEvent = null;

            if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.Invoke();
            }
        }
示例#11
0
    //-----------------------------------------------------------------------------------------------------------
    private void RemoveInputFromList(EInput pressed)
    {
        previousInput.Remove(pressed);

        //Update facing direction
        if (previousInput.Count > 0)
        {
            m_facingDirection = GetLastInputFromList();
        }
    }
示例#12
0
 public override void Physics(EInput input)
 {
     switch (input)
     {
     case EInput.inventory:
     case EInput.escape:
         global::Game.gameState = game;
         break;
     }
 }
示例#13
0
        public override void Physics(EInput input)
        {
            //if (input == EInput.none)
            Renderer.SetObjects(map.GetVisuals());
            switch (input)
            {
            case EInput.moveForward:
                if (hero.Move(hero.Position + new Vector2d16(0, -1)))
                {
                    Renderer.worldPosition._2 -= 1;
                }
                break;

            case EInput.moveBackward:
                if (hero.Move(hero.Position + new Vector2d16(0, 1)))
                {
                    Renderer.worldPosition._2 += 1;
                }
                break;

            case EInput.moveLeft:
                if (hero.Move(hero.Position + new Vector2d16(-2, 0)))
                {
                    Renderer.worldPosition._1 -= 2;
                }
                break;

            case EInput.moveRight:
                if (hero.Move(hero.Position + new Vector2d16(2, 0)))
                {
                    Renderer.worldPosition._1 += 2;
                }
                break;

            case EInput.use:
                System.Console.Beep();
                break;

            case EInput.attack:
                System.Console.Beep();
                System.Console.Beep();
                System.Console.Beep();
                break;

            case EInput.inventory:
                global::Game.gameState = new Inventory(this);
                break;

            case EInput.escape:
                global::Game.gameState = new Menu();
                Renderer.worldPosition = new Vector2d16(0, 0);
                break;
            }
        }
示例#14
0
    void InvokeInputEvent(EInput _eInput, bool _bDown)
    {
        if (m_mInputCallbacks.ContainsKey(_eInput))
        {
            List <NotifyInputChange> aSubscribers = m_mInputCallbacks[_eInput];

            foreach (NotifyInputChange cSubscriber in aSubscribers)
            {
                cSubscriber(_eInput, _bDown);
            }
        }
    }
示例#15
0
    void InvokeClientInputEvent(EInput _eInput, ulong _ulPlayerId, bool _bDown)
    {
        if (m_mClientInputCallbacks.ContainsKey(_eInput))
        {
            List <NotifyClientInputChange> aSubscribers = m_mClientInputCallbacks[_eInput];

            foreach (NotifyClientInputChange cSubscriber in aSubscribers)
            {
                cSubscriber(_eInput, _ulPlayerId, _bDown);
            }
        }
    }
示例#16
0
 void StoreInput(EInput newInput)
 {
     if (bOpenBuffer)
     {
         nextInput = newInput;
     }
     else if (nextInput == EInput.NONE)
     {
         nextInput = newInput;
         ExecuteInput();
     }
 }
示例#17
0
        public static void StopListening(EInput eventName, UnityAction listener)
        {
            if (eventManager == null)
            {
                return;
            }
            UnityEvent thisEvent = null;

            if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.RemoveListener(listener);
            }
        }
示例#18
0
        public static void StartListening(EInput eventName, UnityAction listener)
        {
            UnityEvent thisEvent = null;

            if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.AddListener(listener);
            }
            else
            {
                thisEvent = new UnityEvent();
                thisEvent.AddListener(listener);
                instance.eventDictionary.Add(eventName, thisEvent);
            }
        }
示例#19
0
        public override void Physics(EInput input)
        {
            Renderer.SetObjects(map.GetVisuals());
            switch (input)
            {
            case EInput.moveForward:
                if (hero.Move(hero.Position + new Vector2d16(0, -1)))
                {
                    Renderer.worldPosition._2 -= 1;
                }
                break;

            case EInput.moveBackward:
                if (hero.Move(hero.Position + new Vector2d16(0, 1)))
                {
                    Renderer.worldPosition._2 += 1;
                }
                break;

            case EInput.moveLeft:
                if (hero.Move(hero.Position + new Vector2d16(-2, 0)))
                {
                    Renderer.worldPosition._1 -= 2;
                }
                break;

            case EInput.moveRight:
                if (hero.Move(hero.Position + new Vector2d16(2, 0)))
                {
                    Renderer.worldPosition._1 += 2;
                }
                break;

            case EInput.use:
                System.Console.Beep();
                break;

            case EInput.attack:
                System.Console.Beep();
                System.Console.Beep();
                System.Console.Beep();
                break;

            case EInput.escape:
                Renderer.worldPosition = new Vector2d16(0, 0);
                break;
            }
        }
示例#20
0
        /// <summary>
        /// Performs a round of combat based on player and enemy inputs. 
        /// </summary>
        /// <param name="userInput">Player's input</param>
        /// <param name="enemyInput">Enemy's input</param>
        /// <param name="player">Player</param>
        /// <param name="enemy">Enemy</param>
        /// <returns></returns>
        public string Battle(EInput userInput, EInput enemyInput, Character player, Character enemy)
        {
            output = "";
            if (combat == true)
            {
                BattleAction(userInput, enemyInput, player, enemy);
            }

            if ((player.Health > 0) == true && (enemy.Health > 0) == false)
            {
                player.Health += roll.Next(1, 11);
                output = output + "\nYou win!";
            }
            else if ((player.Health > 0) == false)
                output = output + "\n You have died!";
            return output;
        }
示例#21
0
        public override void OnUpdate()
        {
            if (EInput.IsKey(OpenTK.Input.Key.W))
            {
                actor.position += (actor.forward - actor.position) * (float)ETime.DeltaTime * MovementSpeed * (EInput.IsKey(OpenTK.Input.Key.ShiftLeft) ? Run : 1);
            }
            if (EInput.IsKey(OpenTK.Input.Key.S))
            {
                actor.position += (actor.backward - actor.position) * (float)ETime.DeltaTime * MovementSpeed * (EInput.IsKey(OpenTK.Input.Key.ShiftLeft) ? Run : 1);
            }
            if (EInput.IsKey(OpenTK.Input.Key.A))
            {
                actor.position += (actor.leftward - actor.position) * (float)ETime.DeltaTime * MovementSpeed * (EInput.IsKey(OpenTK.Input.Key.ShiftLeft) ? Run : 1);
            }
            if (EInput.IsKey(OpenTK.Input.Key.D))
            {
                actor.position += (actor.rightward - actor.position) * (float)ETime.DeltaTime * MovementSpeed * (EInput.IsKey(OpenTK.Input.Key.ShiftLeft) ? Run : 1);
            }
            if (EInput.IsKey(OpenTK.Input.Key.Q))
            {
                actor.position += (actor.upward - actor.position) * (float)ETime.DeltaTime * MovementSpeed * (EInput.IsKey(OpenTK.Input.Key.ShiftLeft) ? Run : 1);
            }
            if (EInput.IsKey(OpenTK.Input.Key.E))
            {
                actor.position += (actor.downward - actor.position) * (float)ETime.DeltaTime * MovementSpeed * (EInput.IsKey(OpenTK.Input.Key.ShiftLeft) ? Run : 1);
            }
            if (EInput.IsKey(OpenTK.Input.Key.Up))
            {
                actor.rotate = Quaternion.Multiply(actor.rotate, Quaternion.FromEulerAngles(RotateSpeed * (float)ETime.DeltaTime, 0, 0));
            }
            if (EInput.IsKey(OpenTK.Input.Key.Down))
            {
                actor.rotate = Quaternion.Multiply(actor.rotate, Quaternion.FromEulerAngles(-RotateSpeed * (float)ETime.DeltaTime, 0, 0));
            }
            if (EInput.IsKey(OpenTK.Input.Key.Left))
            {
                actor.rotate = Quaternion.Multiply(actor.rotate, Quaternion.FromEulerAngles(0, RotateSpeed * (float)ETime.DeltaTime, 0));
            }
            if (EInput.IsKey(OpenTK.Input.Key.Right))
            {
                actor.rotate = Quaternion.Multiply(actor.rotate, Quaternion.FromEulerAngles(0, -RotateSpeed * (float)ETime.DeltaTime, 0));
            }

            base.OnUpdate();
        }
示例#22
0
        public IEnumerator UGUIPanel_HasButtonTest()
        {
            EventSystem.current = new GameObject().AddComponent <EventSystem>();
            UGUIPanel_Test pTestPanel   = new GameObject().AddComponent <UGUIPanel_Test>();
            Button         pButtonTest  = new GameObject(EInput.Button_Test.ToString()).AddComponent <Button>();
            Button         pButtonTest2 = new GameObject(EInput.Button_Test2.ToString()).AddComponent <Button>();

            pButtonTest.transform.SetParent(pTestPanel.transform);
            pButtonTest2.transform.SetParent(pTestPanel.transform);
            pTestPanel.EventOnAwake_Force();

            eLastInput = EInput.None;
            Assert.AreEqual(eLastInput, EInput.None);

            pButtonTest.OnPointerClick(new PointerEventData(EventSystem.current));
            Assert.AreEqual(eLastInput, EInput.Button_Test);

            pButtonTest2.OnPointerClick(new PointerEventData(EventSystem.current));
            Assert.AreEqual(eLastInput, EInput.Button_Test2);

            yield break;
        }
示例#23
0
        public override void Physics(EInput input)
        {
            Renderer.SetObjects(map.GetVisuals());
            switch (input)
            {
            case EInput.moveForward:
                if (selection != 0)
                {
                    --selection;
                }
                SetSelection();
                break;

            case EInput.moveBackward:
                if (selection != 4)
                {
                    ++selection;
                }
                SetSelection();
                break;

            case EInput.moveRight:
                IncrementSelection(true);
                break;

            case EInput.moveLeft:
                IncrementSelection(false);
                break;

            case EInput.attack:
            case EInput.enter:
                Action();
                break;

            case EInput.escape:
                global::Game.gameState = new Settings();
                break;
            }
        }
示例#24
0
        public EInput GetInput()
        {
            ConsoleKeyInfo info   = Console.ReadKey(true);
            EInput         result = EInput.Unassigned;

            switch (info.Key)
            {
            case ConsoleKey.W:
                result = EInput.Up;
                break;

            case ConsoleKey.S:
                result = EInput.Down;
                break;

            case ConsoleKey.A:
                result = EInput.Left;
                break;

            case ConsoleKey.D:
                result = EInput.Right;
                break;

            case ConsoleKey.Spacebar:
                result = EInput.Fire1;
                break;

            case ConsoleKey.Enter:
                result = EInput.Fire2;
                break;

            case ConsoleKey.Escape:
                result = EInput.ESC;
                break;
            }
            return(result);
        }
示例#25
0
        //---------------------------------------------------------------------------

        public float GetValue(EInput input, PlayerIndex playerIndex)
        {
            switch (input)
            {
            case EInput.GAMEPAD_A:
                return(GamePad.GetState(playerIndex).Buttons.A == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_B:
                return(GamePad.GetState(playerIndex).Buttons.B == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_X:
                return(GamePad.GetState(playerIndex).Buttons.X == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_Y:
                return(GamePad.GetState(playerIndex).Buttons.Y == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_BUMPER_LEFT:
                return(GamePad.GetState(playerIndex).Buttons.LeftShoulder == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_BUMPER_RIGHT:
                return(GamePad.GetState(playerIndex).Buttons.RightShoulder == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_THUMBSTICK_LEFT:
                return(GamePad.GetState(playerIndex).Buttons.LeftStick == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_THUMBSTICK_LEFT_LEFT:
                return(MathHelper.Clamp(-GamePad.GetState(playerIndex).ThumbSticks.Left.X, 0.0f, 1.0f));

            case EInput.GAMEPAD_THUMBSTICK_LEFT_RIGHT:
                return(MathHelper.Clamp(GamePad.GetState(playerIndex).ThumbSticks.Left.X, 0.0f, 1.0f));

            case EInput.GAMEPAD_THUMBSTICK_LEFT_UP:
                return(MathHelper.Clamp(GamePad.GetState(playerIndex).ThumbSticks.Left.Y, 0.0f, 1.0f));

            case EInput.GAMEPAD_THUMBSTICK_LEFT_DOWN:
                return(MathHelper.Clamp(-GamePad.GetState(playerIndex).ThumbSticks.Left.Y, 0.0f, 1.0f));

            case EInput.GAMEPAD_THUMBSTICK_RIGHT:
                return(GamePad.GetState(playerIndex).Buttons.RightStick == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_THUMBSTICK_RIGHT_LEFT:
                return(MathHelper.Clamp(-GamePad.GetState(playerIndex).ThumbSticks.Right.X, 0.0f, 1.0f));

            case EInput.GAMEPAD_THUMBSTICK_RIGHT_RIGHT:
                return(MathHelper.Clamp(GamePad.GetState(playerIndex).ThumbSticks.Right.X, 0.0f, 1.0f));

            case EInput.GAMEPAD_THUMBSTICK_RIGHT_UP:
                return(MathHelper.Clamp(-GamePad.GetState(playerIndex).ThumbSticks.Right.Y, 0.0f, 1.0f));

            case EInput.GAMEPAD_THUMBSTICK_RIGHT_DOWN:
                return(MathHelper.Clamp(GamePad.GetState(playerIndex).ThumbSticks.Right.Y, 0.0f, 1.0f));

            case EInput.GAMEPAD_TRIGGER_LEFT:
                return(GamePad.GetState(playerIndex).Triggers.Left);

            case EInput.GAMEPAD_TRIGGER_RIGHT:
                return(GamePad.GetState(playerIndex).Triggers.Right);

            case EInput.GAMEPAD_DPAD_LEFT:
                return(GamePad.GetState(playerIndex).DPad.Left == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_DPAD_RIGHT:
                return(GamePad.GetState(playerIndex).DPad.Right == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_DPAD_UP:
                return(GamePad.GetState(playerIndex).DPad.Up == ButtonState.Pressed ? 1.0f : 0.0f);

            case EInput.GAMEPAD_DPAD_DOWN:
                return(GamePad.GetState(playerIndex).DPad.Down == ButtonState.Pressed ? 1.0f : 0.0f);

            default:
                if (m_KeyboardMapping.ContainsKey(input))
                {
                    return(Keyboard.GetState().IsKeyDown(m_KeyboardMapping[input]) ? 1.0f : 0.0f);
                }
                return(0.0f);
            }
        }
示例#26
0
 public int Combat(EInput input, Character defender)
 {
     int output = 0;
        switch (input)
        {
        case EInput.Attack:
            output = Attack();
            if (defender.Defense < output)
            {
                defender.Defense = 0;
                defender.Health -= Math.Max((output - defender.Defense), 0);
            }
            else
                defender.Defense -= output;
            break;
        case EInput.Defend:
            output = Defend();
            break;
        case EInput.Magic:
            output = Magic();
            if (defender.Defense < output)
            {
                defender.Defense = 0;
                defender.Health -= Math.Max((output - defender.Defense), 0);
            }
            else
                defender.Defense -= output;
            break;
        case EInput.Potion:
            output = Potion();
            break;
        }
        return output;
 }
示例#27
0
 public string Get(EInput _enum)
 {
     return(InputMapping [_enum]);
 }
示例#28
0
 /// <summary>
 /// Used for processing input.
 /// </summary>
 public abstract void Physics(EInput input);
示例#29
0
        /// <summary>
        /// Executes player and enemy actions.
        /// </summary>
        /// <param name="firstInput">Player action</param>
        /// <param name="secondInput">Enemy action</param>
        /// <param name="first">Player</param>
        /// <param name="second">Enemy</param>
        /// <returns></returns>
        public string BattleAction(EInput firstInput, EInput secondInput, Character first, Character second)
        {
            string whoFirst = "You ";
            string whoSecond = "They ";
            Console.WriteLine(first.Dexterity + "\n" + second.Dexterity);
            if (first.Dexterity > second.Dexterity)
            {
                whoFirst = "They ";
                Console.WriteLine("swap");
                whoSecond = "You ";
            }
            if (first.Health > 0)
            {
                int firstOut = first.Combat(firstInput, second);

                if (firstInput == EInput.Potion)
                    output = output + "\n" + whoFirst + "heal for " + firstOut + ".";
                else if (firstInput == EInput.Defend)
                    output = output + "\n" + whoFirst + "defend for " + firstOut + ".";
                else
                    output = output + "\n" + whoFirst + "deal " + firstOut + " damage.";
            }
            else
                combat = false;

            if (second.Health > 0)
            {
                int secondOut = second.Combat(secondInput, first);

                if (secondInput == EInput.Potion)
                    output = output + "\n" + whoSecond + "heal for " + secondOut + ".";
                else if (secondInput == EInput.Defend)
                    output = output + "\n" + whoSecond + "defend for " + secondOut + ".";
                else
                    output = output + "\n" + whoSecond + "deal " + secondOut + " damage.";
            }
            else
                combat = false;
            return output;
        }
示例#30
0
        public override void Physics(EInput input)
        {
            if (input == EInput.attack)
            {
                constant = !constant;
            }
            if (!constant & input == EInput.none)
            {
                return;
            }
            if (input == EInput.escape)
            {
                global::Game.gameState = new Menu();
                Renderer.worldPosition = new Vector2d16(0, 0);
                return;
            }
            Renderer.SetObjects(map.GetVisuals());
            if (frame == actions.Length - 1)
            {
                return;
            }
            switch (actions[++frame])
            {
            case 'w':
                if (hero.Move(hero.position + new Vector2d16(0, -1)))
                {
                    Renderer.worldPosition._2 -= 1;
                }
                break;

            case 's':
                if (hero.Move(hero.position + new Vector2d16(0, 1)))
                {
                    Renderer.worldPosition._2 += 1;
                }
                break;

            case 'a':
                if (hero.Move(hero.position + new Vector2d16(-2, 0)))
                {
                    Renderer.worldPosition._1 -= 2;
                }
                break;

            case 'd':
                if (hero.Move(hero.position + new Vector2d16(2, 0)))
                {
                    Renderer.worldPosition._1 += 2;
                }
                break;

            case 'e':
                System.Console.Beep();
                break;

            case ' ':
                System.Console.Beep();
                System.Console.Beep();
                System.Console.Beep();
                break;
            }
        }
示例#31
0
 public static bool IsInputDown(ulong _ulPlayerId, EInput _eInput)
 {
     return((s_cInstance.m_mPlayerStates[_ulPlayerId].ulInput & (ulong)1 << (int)_eInput) > 0);
 }
示例#32
0
 public static bool IsInputDown(EInput _eInput)
 {
     return(Input.GetKey(s_cInstance.m_aKeyBindings[(int)_eInput]));
 }
示例#33
0
 public static void SetKeyBinding(EInput _eInput, KeyCode _eKeyCode)
 {
     s_cInstance.m_aKeyBindings[(int)_eInput] = _eKeyCode;
 }