private void down_Pushed(object sender, EventArgs e)
 {
     if (Down != null)
     {
         Down.Invoke(this, e);
     }
 }
Beispiel #2
0
        internal void Update(float x, float y, ulong updateTick)
        {
            lastState = thisState;

            X = x;
            Y = y;

            Left.UpdateWithValue(Mathf.Clamp01(-X), updateTick, StateThreshold);
            Right.UpdateWithValue(Mathf.Clamp01(X), updateTick, StateThreshold);

            if (InputManager.InvertYAxis)
            {
                Up.UpdateWithValue(Mathf.Clamp01(-Y), updateTick, StateThreshold);
                Down.UpdateWithValue(Mathf.Clamp01(Y), updateTick, StateThreshold);
            }
            else
            {
                Up.UpdateWithValue(Mathf.Clamp01(Y), updateTick, StateThreshold);
                Down.UpdateWithValue(Mathf.Clamp01(-Y), updateTick, StateThreshold);
            }

            thisState = Up.State || Down.State || Left.State || Right.State;

            if (thisState != lastState)
            {
                UpdateTick = updateTick;
            }
        }
Beispiel #3
0
        public void InitializeGameState()
        {
            //Player
            player = new Player();

            //Enemies
            squadronContainer = new List <ISquadron>();

            //Squadrons
            squad = new Squad();
            squad.CreateEnemies(ImageStride.CreateStrides(4,
                                                          Path.Combine("Assets", "Images", "BlueMonster.png")));

            boss = new Boss();
            boss.CreateEnemies(ImageStride.CreateStrides(4,
                                                         Path.Combine("Assets", "Images", "BlueMonster.png")));


            //Add to enemies
            squadronContainer.Add(squad);
            squadronContainer.Add(boss);
//            squadronContainer.Add(invasion);

            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));

            explosions = new AnimationContainer(10);

            //Movement
            down = new Down();

            eventBus = GalagaBus.GetBus();
            eventBus.Subscribe(GameEventType.PlayerEvent, player);
        }
 public DirectionalCellBitmap(AnimatedCellBitmapSetLayers cellBitmapSet)
 {
     Up    = cellBitmapSet ?? throw new ArgumentNullException(nameof(cellBitmapSet));
     Right = Up.Generate90DegreesRotatedClone();
     Down  = Right.Generate90DegreesRotatedClone();
     Left  = Down.Generate90DegreesRotatedClone();
 }
    public void init(char[] songCorrectCharacters, Text nextNotesText)
    {
        // Map characters to correct Input KeyCodes
        characterKeyMap = new Dictionary <char, KeyCode>();
        characterKeyMap.Add('W', KeyCode.UpArrow);
        characterKeyMap.Add('A', KeyCode.LeftArrow);
        characterKeyMap.Add('S', KeyCode.DownArrow);
        characterKeyMap.Add('D', KeyCode.RightArrow);

        // Arrays of song chars; "beats" and directions
        oldStrokes = new char[songCorrectCharacters.Length];
        this.songCorrectCharacters = songCorrectCharacters;

        // Initialize commands objects which updates the UI
        upAction    = new Up();
        leftAction  = new Left();
        downAction  = new Down();
        rightAction = new Right();
        failAction  = new Fail();
        endAction   = new End();

        // Map Input KeyCode to a certain command
        keyActionMap = new Dictionary <KeyCode, ArrowEventAction>();
        keyActionMap.Add(KeyCode.UpArrow, upAction);
        keyActionMap.Add(KeyCode.LeftArrow, leftAction);
        keyActionMap.Add(KeyCode.DownArrow, downAction);
        keyActionMap.Add(KeyCode.RightArrow, rightAction);

        // Text element for displaying next notes
        this.nextNotesText = nextNotesText;
        displayNextNotes(6);
    }
Beispiel #6
0
 public void CheckBinds(out float right, out float left, out float down, out float up)
 {
     right = Right.Axis(GamepadIndex, 0f);
     left  = Left.Axis(GamepadIndex, 0f);
     down  = Down.Axis(GamepadIndex, 0f);
     up    = Up.Axis(GamepadIndex, 0f);
 }
 private void PollMovement()
 {
     Up.Update();
     Left.Update();
     Down.Update();
     Right.Update();
 }
Beispiel #8
0
 /// <summary>
 /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled.
 /// </summary>
 void FixedUpdate()
 {
     Up.Update();
     Down.Update();
     Left.Update();
     Right.Update();
 }
Beispiel #9
0
        private void RegistEvent()
        {
            inputHandler.Click += data => { if (Enable)
                                            {
                                                Click?.Invoke(this, data);
                                            }
            };

            inputHandler.Enter += data => { if (Enable)
                                            {
                                                Enter?.Invoke(this, data);
                                            }
            };
            inputHandler.Exit += data => { if (Enable)
                                           {
                                               Exit?.Invoke(this, data);
                                           }
            };

            inputHandler.Down += data => { if (Enable)
                                           {
                                               Down?.Invoke(this, data);
                                           }
            };
            inputHandler.Up += data => { if (Enable)
                                         {
                                             Up?.Invoke(this, data);
                                         }
            };
        }
Beispiel #10
0
    void Swipe()
    {
        Vector2 delta = Input.GetTouch(0).deltaPosition; //фмксируем дельту тачеи

        if (Mathf.Abs(delta.x) > Mathf.Abs(delta.y))     //тач по горизонтали
        {
            if (delta.x > 0)                             //свеип вправо
            {
                Right?.Invoke();
            }
            else //свеип влево
            {
                Left?.Invoke();
            }
        }
        else //тач по вертикали
        {
            if (delta.y > 0) //свеип вверх
            {
                Up?.Invoke();
            }
            else //свеип вниз
            {
                Down?.Invoke();
            }
        }
    }
Beispiel #11
0
        public override void Invoke()
        {
            Up.Clear();
            bool inputexists = false;

            foreach (var key in Input)
            {
                inputexists = true;
                break;
            }
            if (inputexists)
            {
                Up.AddRange(Pressed);
            }
            else
            {
                Up.AddRange(Pressed.Where(k => Input.All(kk => k.KeyCode != kk.KeyCode)));
            }

            Down.Clear();
            if (Pressed.Count == 0)
            {
                Down.AddRange(Input);
            }
            else
            {
                Down.AddRange(Input.Where(k => Pressed.All(kk => k.KeyCode != kk.KeyCode)));
            }

            Pressed.Clear();
            Pressed.AddRange(Input);

            Execute = Enabled && (Up.Count > 0 || Down.Count > 0);
            base.Invoke();
        }
Beispiel #12
0
 protected static void OnDown()
 {
     if (Down != null)
     {
         Down.Invoke();
     }
 }
Beispiel #13
0
    public FSMState CreateState(FSM fsm, string stateName)
    {
        FSMState state = null;

        if (stateName.Equals("Down"))
        {
            state = new Down(fsm);
        }
        else if (stateName.Equals("Up"))
        {
            state = new Up(fsm);
        }
        else if (stateName.Equals("Left"))
        {
            state = new Left(fsm);
        }
        else if (stateName.Equals("Right"))
        {
            state = new Right(fsm);
        }
        else if (stateName.Equals("Jump"))
        {
            state = new Jump(fsm);
        }
        return(state);
    }
Beispiel #14
0
        internal void UpdateState(bool onHold)
        {
            IsDown = false;
            IsUp   = false;

            if (IsHold)
            {
                if (!onHold)
                {
                    IsUp = true;

                    UpOnce?.Invoke();
                    UpOnce = null;
                    Up?.Invoke();
                }
            }
            else
            {
                if (onHold)
                {
                    IsDown = true;
                    DownOnce?.Invoke();
                    DownOnce = null;
                    Down?.Invoke();
                }
            }

            IsHold = onHold;
            if (onHold)
            {
                HoldOnce?.Invoke();
                HoldOnce = null;
                Hold?.Invoke();
            }
        }
        public GameRunning()
        {
            isGameOver = false;

            player = new Player(new DynamicShape(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f)),
                                new Image(Path.Combine("Assets", "Images", "Player.png")));
            score        = new Score(new Vec2F(0.02f, 0.7f), new Vec2F(0.3f, 0.3f));
            enemyStrides = ImageStride.CreateStrides(4,
                                                     Path.Combine("Assets", "Images", "BlueMonster.png"));
            squiggleSquadron = new SquiggleSquadron(6);
            AddEnemies();

            noMove     = new NoMove();
            down       = new Down();
            zigZagDown = new ZigZagDown();

            playerShots = new List <PlayerShot>();
            // Preloads the bullet image
            bullet           = new Image(Path.Combine("Assets", "Images", "BulletRed2.png"));
            explosionStrides = ImageStride.CreateStrides(8, Path.Combine("Assets", "Images", "Explosion.png"));
            // Here the constructor is given the argument 6 since that is the total amount of enemies.
            explosions = new AnimationContainer(6);
            //backGroundImage = new Entity(new StationaryShape(new Vec2F(0.2f, 0.2f), new Vec2F(0.5f, 0.5f)), new Image("Assets/Images/TitleImage.png"));
            GalagaBus.GetBus().Subscribe(GameEventType.MovementEvent, player);
        }
Beispiel #16
0
            public Package ClientReceive()
            {
                Package package;

                Down.TryDequeue(out package);
                return(package);
            }
Beispiel #17
0
        public void DownTest()
        {
            var down = new Down();

            Assert.AreEqual(-(1 / 3), down.Charge);
            Assert.AreEqual(0, down.Strangeness);
        }
Beispiel #18
0
        void JoystickUpdated(object sender, IChangeResult <JoystickPosition> e)
        {
            if (e.New.Horizontal < 0.2f)
            {
                Left.SetBrightness(0f);
                Right.SetBrightness(0f);
            }
            if (e.New.Vertical < 0.2f)
            {
                Up.SetBrightness(0f);
                Down.SetBrightness(0f);
            }

            if (e.New.Horizontal > 0)
            {
                Left.SetBrightness(e.New.Horizontal.Value);
            }
            else
            {
                Right.SetBrightness(Math.Abs(e.New.Horizontal.Value));
            }

            if (e.New.Vertical > 0)
            {
                Down.SetBrightness(Math.Abs(e.New.Vertical.Value));
            }
            else
            {
                Up.SetBrightness(Math.Abs(e.New.Vertical.Value));
            }

            Console.WriteLine($"({e.New.Horizontal.Value}, {e.New.Vertical.Value})");
        }
Beispiel #19
0
 public void Draw(Effect effect)
 {
     if (UpVisible)
     {
         Up.Draw(effect);
     }
     if (DownVisible)
     {
         Down.Draw(effect);
     }
     if (ForwardVisible)
     {
         Forward.Draw(effect);
     }
     if (BackwardVisible)
     {
         Backward.Draw(effect);
     }
     if (LeftVisible)
     {
         Left.Draw(effect);
     }
     if (RightVisible)
     {
         Right.Draw(effect);
     }
 }
Beispiel #20
0
        private void DrawTilesInverse(GameTime gametime, SpriteBatch spriteBatch)
        {
            Left.DrawTilesLeft(gametime, spriteBatch);
            Down.DrawTilesDown(gametime, spriteBatch);


            Vector2 position = new Vector2(0, 0);

            // For each Tile position
            for (int y = Height - 1; y >= 0; --y)
            {
                for (int x = 0; x < Width; ++x)
                {
                    Texture2D texture = null;
                    texture = tiles[x, y].Texture;

                    position = new Vector2(tiles[x, y].Position.X, tiles[x, y].Position.Y);

                    tiles[x, y].tileAnimation.DrawTile(gametime, spriteBatch, position, SpriteEffects.None, 0.1f);
                }
            }


            lock (tilesTemporaney)
            {
                foreach (Tile item in tilesTemporaney)
                {
                    Vector2 p = new Vector2(item.Position.X, item.Position.Y);
                    item.tileAnimation.DrawTile(gametime, spriteBatch, p, SpriteEffects.None, 0.1f);
                }
            }
        }
Beispiel #21
0
        public void InitializeGameState()
        {
            stateMachine = new StateMachine();
            player       = new Player(this,
                                      shape: new DynamicShape(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f)),
                                      image: new Image(Path.Combine("Assets", "Images", "Player.png")));

            GalagaBus.GetBus().InitializeEventBus(new List <GameEventType>()
            {
                GameEventType.PlayerEvent
            });

            GalagaBus.GetBus().Subscribe(GameEventType.PlayerEvent, player);

            enemyStrides =
                ImageStride.CreateStrides(4, Path.Combine("Assets", "Images", "BlueMonster.png"));
            enemies = new EntityContainer <Enemy>();

            PlayerShot  = new Image(Path.Combine("Assets", "Images", "BlueMonster.png"));
            playerShots = new EntityContainer <PlayerShot>();

            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));
            explosions = new AnimationContainer(40);

            score = new Score(new Vec2F(0.43f, -0.12f), new Vec2F(0.2f, 0.2f));

            v_Formation = new V_Formation();
            v_Formation.CreateEnemies(enemyStrides);
            enemies = v_Formation.Enemies;

            down       = new Down();
            zigzagdown = new ZigZagDown();
            noMove     = new NoMove();
        }
Beispiel #22
0
        public void NotNullDiscriminator()
        {
            ISession     s  = OpenSession();
            ITransaction t  = s.BeginTransaction();
            Up           up = new Up();

            up.Id1 = "foo";
            up.Id2 = 1231;
            Down down = new Down();

            down.Id1   = "foo";
            down.Id2   = 3211;
            down.Value = 123123121;
            s.Save(up);
            s.Save(down);
            t.Commit();
            s.Close();

            s = OpenSession();
            t = s.BeginTransaction();
            IList list = s.CreateQuery("from Up up order by up.Id2 asc").List();

            Assert.IsTrue(list.Count == 2);
            Assert.IsFalse(list[0] is Down);
            Assert.IsTrue(list[1] is Down);
            list = s.CreateQuery("from Down down").List();
            Assert.IsTrue(list.Count == 1);
            Assert.IsTrue(list[0] is Down);
            s.Delete("from Up up");
            t.Commit();
            s.Close();
        }
Beispiel #23
0
        public void ProcessKeyInput(double deltaTime)
        {
            var pressedKeys = appender.Input.GetPressedKeys();

            bool isShiftPressed = appender.Input.IsKeyPressed(Keys.LeftShift) ||
                                  appender.Input.IsKeyPressed(Keys.RightShift);


            foreach (Keys key in pressedKeys)
            {
                if (!ShouldHandleKey(key, deltaTime))
                {
                    continue;
                }

                char convertedChar;
                if (KeyboardUtils.KeyToString(key, isShiftPressed, out convertedChar))
                {
                    if (!appender.ShouldHandleKey(key, convertedChar))
                    {
                        continue;
                    }
                    KeyPressed.RaiseEvent(this, convertedChar);
                }
                else
                {
                    switch (key)
                    {
                    case Keys.Back:
                        BackSpace.RaiseEvent(this, EventArgs.Empty);
                        break;

                    case Keys.Delete:
                        Delete.RaiseEvent(this, EventArgs.Empty);
                        break;

                    case Keys.Left:
                        Left.RaiseEvent(this, EventArgs.Empty);
                        break;

                    case Keys.Right:
                        Right.RaiseEvent(this, EventArgs.Empty);
                        break;

                    case Keys.Up:
                        Up.RaiseEvent(this, EventArgs.Empty);
                        break;

                    case Keys.Down:
                        Down.RaiseEvent(this, EventArgs.Empty);
                        break;

                    case Keys.Enter:
                        Insert.RaiseEvent(this, EventArgs.Empty);
                        break;
                    }
                }
            }
        }
        public ControllerXbox360(params int[] joystickId)
        {
            AddButton(Controls.A);
            AddButton(Controls.B);
            AddButton(Controls.X);
            AddButton(Controls.Y);
            AddButton(Controls.RB);
            AddButton(Controls.LB);
            AddButton(Controls.LStickClick);
            AddButton(Controls.RStickClick);
            AddButton(Controls.Start);
            AddButton(Controls.Back);
            AddButton(Controls.RT);
            AddButton(Controls.LT);
            AddButton(Controls.Up);
            AddButton(Controls.Down);
            AddButton(Controls.Left);
            AddButton(Controls.Right);

            AddAxis(Controls.LStick);
            AddAxis(Controls.RStick);
            AddAxis(Controls.DPad);
            AddAxis(Controls.Triggers);

            foreach (var joy in joystickId)
            {
                A.AddJoyButton(0, joy);
                B.AddJoyButton(1, joy);
                X.AddJoyButton(2, joy);
                Y.AddJoyButton(3, joy);
                LB.AddJoyButton(4, joy);
                RB.AddJoyButton(5, joy);
                Back.AddJoyButton(6, joy);
                Start.AddJoyButton(7, joy);
                LeftStickClick.AddJoyButton(8, joy);
                RightStickClick.AddJoyButton(9, joy);

                RT.AddAxisButton(AxisButton.ZMinus, joy);
                LT.AddAxisButton(AxisButton.ZPlus, joy);

                LeftStick.AddJoyAxis(JoyAxis.X, JoyAxis.Y, joy);
                RightStick.AddJoyAxis(JoyAxis.U, JoyAxis.R, joy);
                DPad.AddJoyAxis(JoyAxis.PovX, JoyAxis.PovY, joy);
                Triggers.AddJoyAxis(JoyAxis.Z, JoyAxis.Z, joy);

                Up
                .AddAxisButton(AxisButton.YMinus, joy)
                .AddAxisButton(AxisButton.PovYMinus, joy);
                Down
                .AddAxisButton(AxisButton.YPlus, joy)
                .AddAxisButton(AxisButton.PovYPlus, joy);
                Right
                .AddAxisButton(AxisButton.XPlus, joy)
                .AddAxisButton(AxisButton.PovXPlus, joy);
                Left
                .AddAxisButton(AxisButton.XMinus, joy)
                .AddAxisButton(AxisButton.PovXMinus, joy);
            }
        }
Beispiel #25
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem item = listView1.SelectedItems[listView1.SelectedItems.Count - 1];


                string DirName = "";

                FileSystem dirinfo = item.Tag as FileSystem;

                if (dirinfo != null)
                {
                    if (dirinfo.FileType == FileType.Dir)
                    {
                        DirName = dirinfo.FullName;
                    }
                    else
                    {
                        if (MessageBox.Show("是否下载文件:" + dirinfo.Name + "?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            FileSystem downFile = (this.listView1.SelectedItems[this.listView1.SelectedItems.Count - 1].Tag as FileSystem);

                            if (downFile != null)
                            {
                                Down down = new Down()
                                {
                                    FullName = downFile.FullName
                                };

                                SocketManager.Send(BufferFormatV2.FormatFCA(down, Deflate.Compress));
                            }
                        }

                        return;
                    }
                }
                else
                {
                    DiskInfo info = item.Tag as DiskInfo;

                    if (info != null)
                    {
                        DirName = info.Name;
                    }
                }


                Dir tmp = new Dir()
                {
                    DirName        = DirName,
                    FileSystemList = new List <FileSystem>(),
                    IsSuccess      = false,
                    Msg            = ""
                };

                SocketManager.Send(BufferFormatV2.FormatFCA(tmp, Deflate.Compress));
            }
        }
Beispiel #26
0
 public override void Draw(SpriteBatch batch)
 {
     base.Draw(batch);
     Left.Draw(batch);
     Right.Draw(batch);
     Up.Draw(batch);
     Down.Draw(batch);
 }
Beispiel #27
0
 public DownFile(Down down)
 {
     this.down = down;
     InitializeComponent();
     this.FormClosed += new FormClosedEventHandler(DownFile_FormClosed);
     IsCheckTable     = new List <CheckB>();
     this.Text       += "---" + down.FullName;
 }
Beispiel #28
0
        public MainPage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Required;

            Down.AddHandler(PointerPressedEvent, new PointerEventHandler(Down_Pressed), true);
            Down.AddHandler(PointerReleasedEvent, new PointerEventHandler(Down_Released), true);
        }
Beispiel #29
0
 private void AlignCarWithGround()
 {
     if (Down.IsColliding())
     {
         var n = Down.GetCollisionNormal().Normalized();
         GlobalTransform = GlobalTransform.InterpolateWith(GlobalTransform.LookingAtWithY(n), .1f);
     }
 }
Beispiel #30
0
        public static void OnDown(Point p)
        {
            _previousPosX = p.X;
            _previousPosY = p.Y;

            _panJustBegun = true;
            Down?.Invoke(p);
        }