Esempio n. 1
0
 void GetPlanets_OnInput(object sender, OnInput e)
 {
     if (counter != 0)
         return;
     PlayerType player = (PlayerType)(int)this.Inputs["Player"].Data;
     list = new List<Planet>();
     bool includeMy = (bool)this.Inputs["IncludeMy"].Data;
     bool includeEnemy = (bool)this.Inputs["IncludeEnemy"].Data;
     bool includeNeutral = (bool)this.Inputs["IncludeNeutral"].Data;
     counter = 0;
     if (includeMy)
     {
         list.AddRange(from p in GameBase.GameManager.State.Planets where p.Owner == player select p);
     }
     if (includeEnemy)
     {
         list.AddRange(from p in GameBase.GameManager.State.Planets where p.Owner != player && p.Owner != PlayerType.Neutral select p);
     }
     if (includeNeutral)
     {
         list.AddRange(from p in GameBase.GameManager.State.Planets where p.Owner == PlayerType.Neutral select p);
     }
     if (list.Count > 0)
     {
         this.Outputs["For Each"].Call(list[0].Id);
         counter = 1;
     }
 }
Esempio n. 2
0
        private void OnChange(TStructure value, Member <TStructure, TMember> member, ChangeEventArgs args)
        {
            string s = args.Value?.ToString() ?? "";

            OnRawInput?.Invoke(value, s);
            OnInput?.Invoke(value, Parser.Invoke(value, member, s));
        }
Esempio n. 3
0
        public void ListenInput()
        {
            var horizontalMovement = Input.GetAxisRaw("Horizontal");
            var verticalMovement   = Input.GetAxisRaw("Vertical");
            var mouseWheel         = Input.GetAxis("Mouse ScrollWheel");

            var hadMovement = Math.Abs(horizontalMovement) > InputThroughput ||
                              Math.Abs(verticalMovement) > InputThroughput;

            var shoot = Input.GetButton("Fire1") ? InputType.Shoot : InputType.None;
            var dodge = Input.GetButton("Jump") ? InputType.Dodge : InputType.None;
            var melee = Input.GetButton("Fire2") ? InputType.Melee : InputType.None;

            var movement  = hadMovement ? InputType.Movement : InputType.None;
            var changeGun = Math.Abs(mouseWheel) > 0.01 ? InputType.ChangeGun : InputType.None;

            var changeGunValue = new InputData()
            {
                FloatValue = mouseWheel
            };
            var movementValue = new InputData()
            {
                Vector2Value = new Vector2(horizontalMovement, verticalMovement)
            };

            var actionsList = BuildActionList(changeGunValue, movementValue, shoot, dodge, melee, movement, changeGun);

            OnInput?.Invoke(actionsList);
        }
Esempio n. 4
0
        /// <summary>
        /// Occurs whenever a keyboard key is pressed.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyboardKeyEventArgs e)
        {
            if (e.IsRepeat)
            {
                return;
            }

            int i = Array.IndexOf(this.keybinds, e.Key);

            if (i < 0)
            {
                this.paused ^= e.Key == Key.P;
                this.step   |= e.Key == Key.O;
                return;
            }

            this.keys &= ((byte)(~(1 << i)));

            // Try catch hack because OpenTK catches all exceptions that come from this function...
            // so there wouldn't be a way to tell that it was thrown if this wasn't here. Re-throw
            // the exception anyway in case that changes.
            try
            {
                OnInput?.Invoke(this, new InputEventArgs(this.keys));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
        }
Esempio n. 6
0
 void OnNext(object sender, OnInput e)
 {
     if (counter < list.Count)
     {
         this.Outputs["For Each"].Call(list[counter++].Id);
     }
     else
         counter = 0;
 }
        private async Task _removeFile()
        {
            _value = null;
            await ValueChanged.InvokeAsync(new ChangeEventArgs { Value = _value });

            await OnInput.InvokeAsync(new ChangeEventArgs { Value = _value });

            await InvokeAsync(StateHasChanged);
        }
Esempio n. 8
0
        private void OnChange(TStructure value, ChangeEventArgs args)
        {
            string v = args.Value?.ToString() ?? "";

            OnInput?.Invoke(value, v == ""
                ? default
                : DateTime.ParseExact(v, "yyyy-MM-dd", CultureInfo.InvariantCulture)
                            );
        }
        private async Task _onSelectHandler(TItem item)
        {
            _value = item;

            await OnInput.InvokeAsync(new ChangeEventArgs { Value = _value });

            await ValueChanged.InvokeAsync(new ChangeEventArgs { Value = _value });

            await InvokeAsync(StateHasChanged);
        }
Esempio n. 10
0
        private async Task _clearLinkHandler()
        {
            _value = null;
            await ValueChanged.InvokeAsync(new ChangeEventArgs { Value = _value });

            await OnInput.InvokeAsync(new ChangeEventArgs { Value = _value });

            await JsService.ClearFlatPickrDateTime(Id);

            await InvokeAsync(StateHasChanged);
        }
Esempio n. 11
0
 void OnSend(object sender, OnInput e)
 {
     int Forces = (int)this.Inputs["Forces"].Data;
     Vector2 Position = (Vector2)this.Inputs["Position"].Data;
     int Destination = (int)this.Inputs["Distination"].Data;
     Planet DestinationPlanet = null;
     foreach (Planet planet in VelesConflict.Shared.GameBase.GameManager.State.Planets)
     {
         if (planet.Id == Destination)
             DestinationPlanet = planet;
     }
     VelesConflict.Shared.GameBase.GameManager.SendFleet(Forces,(PlayerType)(int)this.Inputs["Owner"].Data, Position, DestinationPlanet);
     this.Outputs["Done"].Call(null);
 }
Esempio n. 12
0
 void OnSetPosition(object sender, OnInput e)
 {
     if (Planet != null)
     {
         Planet.Position = (Vector2)e.Data;
     }
 }
Esempio n. 13
0
 void OnSetOwner(object sender, OnInput e)
 {
     if (Planet != null)
     {
         Planet.Owner = (PlayerType)e.Data;
     }
 }
Esempio n. 14
0
 void OnSetForces(object sender, OnInput e)
 {
     if (Planet != null)
     {
         Planet.Forces = (int)e.Data;
     }
 }
Esempio n. 15
0
        void OnLoad(object sender, OnInput e)
        {
            int NewID = (int)this.Inputs["ID"].Data;
            if (Planet != null)
            {
                Planet.Captured -= OnCaptured;
            }
            Planet = (from P in VelesConflict.Shared.GameBase.GameManager.State.Planets where P.Id == NewID select P).First();
            Planet.Captured += OnCaptured;

            this.Outputs["Forces"].Call((int)Planet.Forces);
            this.Outputs["Owner"].Call((int)Planet.Owner);
            this.Outputs["Position"].Call(Planet.Position);
            ForcesPrevious = Planet.Forces;
        }