Ejemplo n.º 1
0
        public override void HandleResource(InputState input, ResourceBuilding resourceBuilding)
        {
            Control control = Controls.Selection;
            if ((control != null && control.Name.Contains("Unload")) ||
                ((input.IsNewKeyPress(Keys.F, null)) ||
                    (input.IsNewKeyPress(Keys.C, null))))
            {
                _parachuteBox.HandleInput(Position);

                IsWithinTargetRange = false;
                if (_parachuteBox.Bounds.Intersects(resourceBuilding.Bounds)) {

                    /*Color[] buildingTextureData = new Color[resourceBuilding.Texture.Width * resourceBuilding.Texture.Height];
                    resourceBuilding.Texture.GetData(buildingTextureData);

                    if (IntersectPixels(_parachuteBox.Bounds,
                                        _parachuteBox.TextureData,
                                        resourceBuilding.Bounds,
                                        buildingTextureData)) */{
                        IsWithinTargetRange = true;
                    }
                }
            }

            base.HandleResource(input, resourceBuilding);
        }
Ejemplo n.º 2
0
        public virtual void LoadResource(string resourceType, ResourceBuilding resourceBuilding)
        {
            PropertyInfo resourceProperty = resourceBuilding.GetType().GetProperty(resourceType);
            PropertyInfo resourceCargoProperty = GetType().GetProperty(resourceType + "Cargo");

            int resourceValue = (int) (resourceProperty.GetValue(resourceBuilding, null));
            int resourceCargoValue = (int)(resourceCargoProperty.GetValue(this, null));

            if (FoodCargo + MedicineCargo < Capacity &&
                resourceValue >= AmountPerCargo) {

                resourceCargoProperty.SetValue(this,
                    Convert.ChangeType(resourceCargoValue + 1, resourceCargoProperty.PropertyType),
                    null);
                resourceProperty.SetValue(resourceBuilding,
                    Convert.ChangeType(resourceValue - AmountPerCargo, resourceProperty.PropertyType),
                    null);
            }
        }
Ejemplo n.º 3
0
        public virtual void UnloadResource(string resourceType, ResourceBuilding resourceBuilding)
        {
            PropertyInfo resourceProperty = resourceBuilding.GetType().GetProperty(resourceType);
            PropertyInfo resourceCargoProperty = GetType().GetProperty(resourceType + "Cargo");

            int resourceValue = (int)(resourceProperty.GetValue(resourceBuilding, null));
            int resourceCargoValue = (int)(resourceCargoProperty.GetValue(this, null));

            if (resourceCargoValue > 0 && resourceBuilding.IsAlive) {
                if (IsWithinTargetRange) {
                    resourceCargoProperty.SetValue(this,
                    Convert.ChangeType(resourceCargoValue - 1, resourceCargoProperty.PropertyType),
                    null);
                    resourceProperty.SetValue(resourceBuilding,
                    Convert.ChangeType(resourceValue + AmountPerCargo, resourceProperty.PropertyType),
                    null);
                }
            }
        }
Ejemplo n.º 4
0
        public virtual void HandleResource(InputState input, ResourceBuilding resourceBuilding)
        {
            Control control = Controls.Selection;
            if ((control != null && control.Name == "LoadFood") ||
                (input.CurrentKeyboardStates[1].IsKeyDown(Keys.LeftControl) &&
                    input.IsNewKeyPress(Keys.F, null)))
            {
                LoadResource("Food", resourceBuilding);
                _sfxLoading.Play();
            }
            else if ((control != null && control.Name == "LoadMedicine") ||
                (input.CurrentKeyboardStates[1].IsKeyDown(Keys.LeftControl) &&
                   input.IsNewKeyPress(Keys.C, null)))
            {
                LoadResource("Medicine", resourceBuilding);
                _sfxLoading.Play();
            }
            else if ((control != null && control.Name == "UnloadFood") ||
                (input.IsNewKeyPress(Keys.F, null)))
            {
                UnloadResource("Food", resourceBuilding);
                _sfxUnloading.Play();
            }
            else if ((control != null && control.Name == "UnloadMedicine") ||
                (input.IsNewKeyPress(Keys.C, null)))
            {
                UnloadResource("Medicine", resourceBuilding);
                _sfxUnloading.Play();
            }

            if (control != null) control.IsSelected = false;
        }