예제 #1
0
    public bool Absorb(EnergyInfo energy)
    {
        AbsorbedEnergy.Add(energy.Color);

        for (int i = 0; i < ColorSequence.Length; i++)
        {
            if (i == AbsorbedEnergy.Count)
            {
                Debug.Log("Not enough energy yet");
                return(true);
            }

            if (ColorSequence[i] != AbsorbedEnergy[i])
            {
                Debug.Log("Energy signature did not match (expected " + ColorSequence[i] + ", got " + AbsorbedEnergy[i] + ")");
                Empty();
                return(false);
            }
            // Else, accept
            PartDestOpacity[i] = 64 / 255f;
        }

        Debug.Log("Energy sequence is complete!");

        AbsorbedEnergy.Clear();
        Pico.CycleLevels(NextLevel);
        return(true);
    }
예제 #2
0
        /// <summary>
        /// обработать ряд и получить характеристики по всему ряду
        /// </summary>
        /// <param name="range"></param>
        /// <param name="totalRange"></param>
        /// <returns></returns>
        public static EnergyInfo ProcessRange(RawRange range, RawRange totalRange = null)
        {
            double density = range.AirDensity;

            totalRange = totalRange ?? range;

            if (range.Count == 0)
            {
                return(null);
            }
            EnergyInfo res = new EnergyInfo();

            res.FromDate               = range[0].Date;
            res.ToDate                 = range.Last().Date;
            res.PowerDensity           = getAveragePower(range, density);
            res.V0                     = getAverageSpeed(range);
            res.StandardDeviationSpeed = getSigmV(res.V0, range);
            res.Vmax                   = getMaxSpeed(range);
            res.Vmin                   = getMinSpeed(range);
            res.EnergyDensity          = res.PowerDensity * 8760d;
            res.Cv                     = res.StandardDeviationSpeed / res.V0;
            res.VeybullGamma           = getVeybullGamma(res.Cv);
            res.VeybullBeta            = getVeybullBeta(res.V0, res.VeybullGamma);
            res.ExtremalSpeed          = getExtremalSpeed(res.V0, res.VeybullGamma);
            res.ExpectancyDeviation    = getExpectancyDeviation(range, totalRange);

            return(res);
        }
예제 #3
0
    public bool Absorb(EnergyInfo energy)
    {
        AbsorbedEnergy.Add(energy.Color);

        for (int i = 0; i < ColorSequence.Length; i++)
        {
            if (i == AbsorbedEnergy.Count)
            {
                Debug.Log("Not enough energy yet");
                return true;
            }

            if (ColorSequence[i] != AbsorbedEnergy[i])
            {
                Debug.Log("Energy signature did not match (expected " + ColorSequence[i] + ", got " + AbsorbedEnergy[i] + ")");
                Empty();
                return false;
            }
            // Else, accept
            PartDestOpacity[i] = 64 / 255f;
        }

        Debug.Log("Energy sequence is complete!");

        AbsorbedEnergy.Clear();
        Pico.CycleLevels(NextLevel);
        return true;
    }
예제 #4
0
        public static void OnDroneCountChange()
        {
            movementJobHandle.Complete();
            energyJobHandle.Complete();
            _Transforms.Dispose();
            _Transforms = new TransformAccessArray(0);
            foreach (Drone drone in Drones.Values)
            {
                _Transforms.Add(drone.transform);
            }
            _JobInfoArray.Dispose();
            _JobInfoArray = new NativeArray <MovementInfo>(_Transforms.length, Allocator.Persistent);
            _EnergyInfoArray.Dispose();
            _EnergyInfoArray = new NativeArray <EnergyInfo>(_Transforms.length, Allocator.Persistent);
            _PreviousPositions.Dispose();
            _PreviousPositions = new NativeArray <Vector3>(_Transforms.length, Allocator.Persistent);
            int j = 0;

            foreach (Drone drone in Drones.Values)
            {
                _PreviousPositions[j] = drone.PreviousPosition;

                _JobInfoArray[j]    = new MovementInfo();
                _JobInfoArray[j]    = drone.GetMovementInfo(_JobInfoArray[j]);
                _EnergyInfoArray[j] = new EnergyInfo();
                _EnergyInfoArray[j] = drone.GetEnergyInfo(_EnergyInfoArray[j]);
                j++;
            }
        }
예제 #5
0
 public Player( )
 {
     PAccount    = new AccountInfo();
     PBalance    = new BalanceInfo();
     PEnergy     = new EnergyInfo();
     PCharacters = new CharacterInfo();
     PTactis     = new Tactics();
 }
예제 #6
0
        public EnergyInfo GetEnergyInfo(EnergyInfo info)
        {
            info.speed    = _Data.MaxSpeed;
            info.moveType = _Data.movement;
            info.pkgXArea = (_Data.job == 0) ? 1 : GetJob().PackageXArea;
            info.pkgWgt   = (_Data.job == 0) ? 0 : GetJob().PackageWeight;

            return(info);
        }
예제 #7
0
        /// <summary>
        /// сохранить энергетические характеристики в файл csv
        /// </summary>
        /// <param name="fileName">имя файла</param>
        /// <param name="range_info">характеристики по ряду наблюдений</param>
        /// <param name="ext_info">характеристики по градациям</param>
        /// <param name="stat_directions">повторяемость направлений</param>
        /// <param name="stat_speeds">повторяемость скоростей</param>
        /// <param name="append">если истина, то файл будет дописан</param>
        /// <param name="caption">заголовок, который будет записан в начале</param>
        /// <param name="month">значение графы месяц</param>
        /// <param name="year">значение графы год</param>
        /// <param name="amount">количество измерений в ряде</param>
        private void saveEnergyInfoLine(
            string fileName,
            EnergyInfo range_info,
            EnergyInfo ext_info,
            StatisticalRange <WindDirections16> stat_directions,
            StatisticalRange <GradationItem> stat_speeds,
            string caption,
            string year,
            string month,
            int amount,
            bool append
            )
        {
            StreamWriter sw = new StreamWriter(fileName, append, Encoding.UTF8);

            //запись заголовка
            if (!string.IsNullOrEmpty(caption))
            {
                sw.WriteLine(caption);
            }

            if (range_info == null || ext_info == null || stat_directions == null || stat_speeds == null)
            {
                sw.Close();
                return;
            }

            //  "Год;Месяц;кол-во изм;0.75;2.5;4.5;6.5;8.5;10.5;12.5;14.5;16.5;19;22.5;26.5;31.5;37.5;43.5;Vmin;Vmax;Vср.год;Vэкст50,м/с;δ(P);Cv(V);Nвал уд.;Эвал уд.;С;СВ;В;ЮВ;Ю;ЮЗ;З;СЗ;штиль";
            string line = $"{year};{month};{amount}";

            //повторяемости скоростей ветра
            for (int j = 0; j < stat_speeds.Keys.Count; j++)
            {
                line += ";" + (stat_speeds.Values[j] * 100).ToString("0.00");
            }

            //по ряду наблюдений
            line += string.Format(";{0:f2};{1:f2};{2:f2};{3:f2};{4:f2};{5:f2};{6:f2};{7:f2};{8:f2};{9:f2};{10:f2}",
                                  range_info.Vmin, range_info.Vmax, range_info.V0, range_info.ExtremalSpeed, range_info.ExpectancyDeviation, range_info.Cv,
                                  range_info.StandardDeviationSpeed, range_info.VeybullGamma, range_info.VeybullBeta, range_info.PowerDensity, range_info.EnergyDensity);

            //повторяемости направлений ветра
            List <Enum> rs = WindDirections16.Calm.GetEnumItems().GetRange(0, 17);

            for (int j = 0; j < rs.Count; j++)
            {
                WindDirections16 rhumb = (WindDirections16)rs[j];
                int index = stat_directions.Keys.IndexOf(rhumb);
                if (index == -1)
                {
                    continue;
                }
                line += ";" + (stat_directions.Values[index] * 100).ToString("0.00");
            }
            sw.WriteLine(line);
            sw.Close();
        }
예제 #8
0
        /// <summary>
        /// обновление всех элементов в соответствии с выбранными параметрами
        /// </summary>
        private void refreshInfo()
        {
            RawRange tempr = range.GetRange(
                radioButtonSelectPeriod.Checked,
                radioButtonSelectYearMonth.Checked,
                dateTimePickerFrom.Value,
                dateTimePickerTo.Value,
                comboBoxYear.SelectedItem,
                comboBoxMonth.SelectedItem
                );

            if (tempr == null)
            {
                throw new Exception("что-то совсем не так!!");
            }

            //расчет параметров
            try
            {
                range_info      = StatisticEngine.ProcessRange(tempr, range);
                stat_speeds     = StatisticEngine.GetExpectancy(tempr, Vars.Options.CurrentSpeedGradation);
                stat_directions = StatisticEngine.GetDirectionExpectancy(tempr, GradationInfo <WindDirections16> .Rhumb16Gradations);
                exp_info        = StatisticEngine.ProcessRange(stat_speeds);
            }
            catch (Exception ex)
            {
                _ = MessageBox.Show(this, ex.Message, "Расчёт энергетических характеристик", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (range_info == null || exp_info == null)
            {
                _ = MessageBox.Show(this, "Для заданного ряда невозможно расчитать характеристики на выбранном интервале", "Расчёт энергетических характеристик", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            //вывод параметров
            labelEnergyDensity.Text          = (range_info.EnergyDensity / 1000).ToString("0.00") + " кВт*ч/м^2";
            labelPowerDensity.Text           = range_info.PowerDensity.ToString("0.00") + " Вт/м^2";
            labelCv.Text                     = range_info.Cv.ToString("0.000");
            labelV0.Text                     = range_info.V0.ToString("0.0") + " м/с";
            labelExtremalSpeed.Text          = range_info.ExtremalSpeed.ToString("0.0") + " м/с";
            labelVmax.Text                   = range_info.Vmax.ToString("0.0") + " м/с";
            labelVmin.Text                   = range_info.Vmin.ToString("0.0") + " м/с";
            labelStandardDeviationSpeed.Text = range_info.StandardDeviationSpeed.ToString("0.000") + " м/с";
            labelGamma.Text                  = range_info.VeybullGamma.ToString("0.000");
            labelBeta.Text                   = range_info.VeybullBeta.ToString("0.000") + " м/с";
            labelAirDensity.Text             = tempr.AirDensity.ToString("0.000") + " кг/м^3" + (Vars.Options.CalculateAirDensity ? " (расчёт)" : "");

            labelEnergyDensityTV.Text = (exp_info.EnergyDensity / 1000).ToString("0.00") + " кВт*ч/м^2";
            labelPowerDensityTV.Text  = exp_info.PowerDensity.ToString("0.00") + " Вт/м^2";
            labelCvTV.Text            = exp_info.Cv.ToString("0.000");
            labelV0TV.Text            = exp_info.V0.ToString("0.0") + " м/с";
            labelGammaTV.Text         = exp_info.VeybullGamma.ToString("0.000");
            labelBetaTV.Text          = exp_info.VeybullBeta.ToString("0.000") + " м/с";
        }
 public MetaInfo(BinaryReader br)
 {
     Unknown3 = br.ReadUInt32();
     Title    = new TitleInfo(br);
     Guild    = new GuildInfo(br);
     Unknown4 = br.ReadUInt32();
     Stats    = new StatsInfo(br);
     Unknown5 = br.ReadUInt16();
     Unknown6 = br.ReadByte();
     Unknown7 = br.ReadUInt16();
     Unknown8 = br.ReadUInt16();
     Energy   = new EnergyInfo(br);
     Unknown9 = br.ReadBytes(13);
 }
예제 #10
0
        public void Draw(SpriteBatch spriteBatch)
        {
            // Draw Tiles
            for (int i = 0; i < Tiles.Count; i++)
            {
                for (int j = 0; j < Tiles[i].Count; j++)
                {
                    Tiles[i][j].Draw(spriteBatch);
                }
            }

            // Selected
            if (Selected != null)
            {
                spriteBatch.Draw(TextureManager.selected, Selected.Position, null, Color.White, 0f, new Vector2(TextureManager.selected.Width / 2, TextureManager.selected.Height / 2), 1f, SpriteEffects.None, 0f);
            }

            // Game objects
            foreach (GameObject go in GameObjects)
            {
                go.Draw(spriteBatch);
            }

            // Infobuttons
            ModuleInfo.Draw(spriteBatch);
            TileboardInfo.Draw(spriteBatch);
            EnergyInfo.Draw(spriteBatch);

            if (!Started)
            {
                Text.TextDifferentColor(spriteBatch, "|W|Press enter to start", new Vector2(Globals.ScreenSize.X / 2, 10), 1.3f, TextureManager.SpriteFont20, true);
                if (EnemyDifficulty == Difficulty.Boss)
                {
                    spriteBatch.DrawString(TextureManager.SpriteFont20, "Warning! The boss has special modules,\nHover over them to read.\nAnd remember,\nyou can not flee from the boss.", new Vector2(10, Globals.CombatScreenSize.Y / 2 - 10), Color.White);
                }
            }

            if (EnemyDifficulty != Difficulty.Boss)
            {
                Flee.Draw(spriteBatch);
            }
        }
예제 #11
0
        private void NewShip(ShipModel shipModel)
        {
            ShipType = shipModel;
            var @base = BaseInfo;

            Name       = @base.Name;
            Identifier = string.Empty;
            Fuel       = new Fuel();
            Cargo      = new CargoInfo {
                Max = @base.Cargo
            };
            EnergyManagement = new EnergyInfo(new byte[] { 4, 4, 4 });
            Flags            = ShipStatusFlags.Docked;
            Hull             = new HullInfo {
                UnladenMass = @base.Mass
            };
            MaxJumpRange = @base.JumpRange;
            IsHot        = false;
            Rebuy        = null;
        }
예제 #12
0
        /// <summary>
        /// запись одной строки в лист ВЭК. Возвращет число элементов в этой строке
        /// </summary>
        /// <param name="worksheet">страница для записи</param>
        /// <param name="line">строка</param>
        /// <param name="range_info">характеристики по ряду наблюдений</param>
        /// <param name="ext_info">характеристики по градациям</param>
        /// <param name="stat_directions">повторяемость направлений</param>
        /// <param name="stat_speeds">повторяемость скоростей</param>
        /// <param name="year">год</param>
        /// <param name="month">месяц</param>
        /// <param name="amount">число измерений</param>
        /// <returns>количество добавленных ячеек</returns>
        private int saveEnergyInfoLine(ExcelWorksheet worksheet,
                                       int line,
                                       EnergyInfo range_info,
                                       EnergyInfo ext_info,
                                       StatisticalRange <WindDirections16> stat_directions,
                                       StatisticalRange <GradationItem> stat_speeds,
                                       string year,
                                       string month,
                                       int amount)
        {
            if (range_info == null || ext_info == null || stat_directions == null || stat_speeds == null)
            {
                return(0);
            }

            //  "Год;Месяц;кол-во изм;0.75;2.5;4.5;6.5;8.5;10.5;12.5;14.5;16.5;19;22.5;26.5;31.5;37.5;43.5;Vmin;Vmax;Vср.год;Vэкстр.50, м/с;δ(P);Cv(V);Nвал уд.;Эвал уд.;С;СВ;В;ЮВ;Ю;ЮЗ;З;СЗ;штиль";
            List <object> values = new List <object>()
            {
                year, month, amount
            };

            //повторяемости скоростей ветра
            for (int j = 0; j < stat_speeds.Keys.Count; j++)
            {
                values.Add(Math.Round((stat_speeds.Values[j] * 100), 2));
            }

            //по ряду наблюдений
            values.AddRange(new List <object>()
            {
                Math.Round(range_info.Vmin, 2),
                Math.Round(range_info.Vmax, 2),
                Math.Round(range_info.V0, 2),
                Math.Round(range_info.ExtremalSpeed, 2),
                Math.Round(range_info.ExpectancyDeviation, 2),
                Math.Round(range_info.Cv, 2),
                Math.Round(range_info.StandardDeviationSpeed, 2),
                Math.Round(range_info.VeybullGamma, 2),
                Math.Round(range_info.VeybullBeta, 2),
                Math.Round(range_info.PowerDensity, 2),
                Math.Round(range_info.EnergyDensity, 2)
            });

            //повторяемости направлений ветра
            List <Enum> rs = WindDirections16.Calm.GetEnumItems().GetRange(0, 17);

            for (int j = 0; j < rs.Count; j++)
            {
                WindDirections16 rhumb = (WindDirections16)rs[j];
                int index = stat_directions.Keys.IndexOf(rhumb);
                if (index == -1)
                {
                    continue;
                }
                values.Add(Math.Round((stat_directions.Values[index] * 100), 2));
            }

            //запись всех значений
            for (int j = 1; j <= values.Count; j++)
            {
                worksheet.Cells[line, j].Value = values[j - 1];
            }

            return(values.Count);
        }
예제 #13
0
        /// <summary>
        /// сохранение ВЭК
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="range"></param>
        public override void SaveEnergyInfo(string filename, RawRange range)
        {
            using (ExcelPackage excelPackage = new ExcelPackage())
            {
                //Set some properties of the Excel document
                excelPackage.Workbook.Properties.Author  = "Wind Energy";
                excelPackage.Workbook.Properties.Title   = range.Name;
                excelPackage.Workbook.Properties.Created = DateTime.Now;
                //Create the WorkSheet
                ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Лист 1");

                List <object> years = new List <object>();
                foreach (RawItem item in range)
                {
                    if (!years.Contains(item.Date.Year))
                    {
                        years.Add(item.Date.Year);
                    }
                }

                double totalAverageSpeed = range.Average((t) => t.Speed);

                //формирование заголовка
                List <string> cap = new List <string>()
                {
                    "Год", "Месяц", "Кол-во измерений"
                };
                foreach (GradationItem grad in Vars.Options.CurrentSpeedGradation.Items)
                {
                    cap.Add(grad.Average.ToString("0.00"));
                }
                cap.AddRange(new string[] { "Vmin, м/с", "Vmax, м/с", "Vср, м/с", "Vэкстр.50, м/с", "δ(P)", "Cv(V)", "𝜎(V)", "γ", "β", "Nвал уд., Вт/м^2", "Эвал уд., Вт*ч/м^2" });
                foreach (WindDirections16 wd in WindDirections16.Calm.GetEnumItems().GetRange(0, 17))
                {
                    cap.Add(wd.Description());
                }


                //ЗАПИСЬ ФАЙЛА
                //запись заголовка
                for (int j = 1; j <= cap.Count; j++)
                {
                    worksheet.Cells[1, j].Value = cap[j - 1];
                }
                worksheet.Cells[1, 1, 1, cap.Count].Style.Font.Bold        = true;
                worksheet.Cells[1, 1, 1, cap.Count].Style.Fill.PatternType = ExcelFillStyle.Solid;
                worksheet.Cells[1, 1, 1, cap.Count].Style.Fill.BackgroundColor.SetColor(Color.Gray);
                worksheet.View.FreezePanes(2, 3);

                //запись данных обо всём периоде
                EnergyInfo ri1 = StatisticEngine.ProcessRange(range);
                StatisticalRange <WindDirections16> sd1 = StatisticEngine.GetDirectionExpectancy(range, GradationInfo <WindDirections16> .Rhumb16Gradations);
                StatisticalRange <GradationItem>    ss1 = StatisticEngine.GetExpectancy(range, Vars.Options.CurrentSpeedGradation);
                EnergyInfo ei1   = StatisticEngine.ProcessRange(ss1);
                int        cells = saveEnergyInfoLine(worksheet, 2, ri1, ei1, sd1, ss1, "Все года", "Все месяцы", range.Count);
                worksheet.Cells[2, 1, 2, cells].Style.Font.Bold        = true;
                worksheet.Cells[2, 1, 2, cells].Style.Fill.PatternType = ExcelFillStyle.Solid;
                worksheet.Cells[2, 1, 2, cells].Style.Fill.BackgroundColor.SetColor(Color.LightGray);

                //запись данных для каждого года
                int line = 3;
                foreach (int year in years) //цикл по годам
                {
                    //для каждого месяца в году
                    for (int mt = 0; mt <= 12; mt++) //по месяцам, начиная со всех
                    {
                        Months   month = (Months)mt;
                        RawRange rn    = range.GetRange(false, true, DateTime.Now, DateTime.Now, year, month.Description());
                        if (rn == null || rn.Count == 0)
                        {
                            continue;
                        }
                        EnergyInfo ri = StatisticEngine.ProcessRange(rn, range);
                        StatisticalRange <WindDirections16> sd = StatisticEngine.GetDirectionExpectancy(rn, GradationInfo <WindDirections16> .Rhumb16Gradations);
                        StatisticalRange <GradationItem>    ss = StatisticEngine.GetExpectancy(rn, Vars.Options.CurrentSpeedGradation);
                        EnergyInfo ei = StatisticEngine.ProcessRange(ss);
                        cells = saveEnergyInfoLine(worksheet, line, ri, ei, sd, ss, year.ToString(), month.Description(), rn.Count);
                        if (Math.IEEERemainder(mt + 1, 2) == 0 || mt == 0) //на нечетных строках добавляем серый фон
                        {
                            worksheet.Cells[line, 1, line, cells].Style.Fill.PatternType = ExcelFillStyle.Solid;
                            worksheet.Cells[line, 1, line, cells].Style.Fill.BackgroundColor.SetColor(Color.LightGray);
                        }
                        if (month == Months.All) //для суммарной информации по году выделение жирным
                        {
                            worksheet.Cells[line, 1, line, cells].Style.Font.Bold = true;
                        }
                        line++;
                    }
                }

                //запись данных для каждого месяца отдельно
                line += 3;
                //для каждого месяца в году
                for (int mt = 1; mt <= 12; mt++) //по месяцам
                {
                    Months   month = (Months)mt;
                    RawRange rn    = range.GetRange(false, true, DateTime.Now, DateTime.Now, "Все", month.Description());
                    if (rn == null || rn.Count == 0)
                    {
                        continue;
                    }
                    EnergyInfo ri = StatisticEngine.ProcessRange(rn, range);
                    StatisticalRange <WindDirections16> sd = StatisticEngine.GetDirectionExpectancy(rn, GradationInfo <WindDirections16> .Rhumb16Gradations);
                    StatisticalRange <GradationItem>    ss = StatisticEngine.GetExpectancy(rn, Vars.Options.CurrentSpeedGradation);
                    EnergyInfo ei = StatisticEngine.ProcessRange(ss);
                    cells = saveEnergyInfoLine(worksheet, line, ri, ei, sd, ss, "Все года", month.Description(), rn.Count);
                    if (Math.IEEERemainder(mt + 1, 2) == 0 || mt == 0) //на нечетных строках добавляем серый фон
                    {
                        worksheet.Cells[line, 1, line, cells].Style.Fill.PatternType = ExcelFillStyle.Solid;
                        worksheet.Cells[line, 1, line, cells].Style.Fill.BackgroundColor.SetColor(Color.LightGray);
                    }
                    line++;
                }


                //Save your file
                FileInfo fi = new FileInfo(filename);
                excelPackage.SaveAs(fi);
            }
        }
예제 #14
0
        internal ShipStatus(EliteDangerousAPI api)
        {
            api.GameEvents.LoadGame += (s, e) =>
            {
                lock (_lock)
                {
                    ShipId     = e.ShipId;
                    ShipType   = e.ShipModel;
                    Name       = e.ShipName;
                    Identifier = e.ShipIdent;
                    Fuel.Main  = e.FuelLevel;
                    Fuel.Max   = e.FuelCapacity;

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.GameEvents.Status += (s, e) =>
            {
                lock (_lock)
                {
                    Flags            = e.Flags;
                    Fuel             = e.Fuel ?? Fuel;
                    EnergyManagement = new EnergyInfo(e.Pips);
                    FireGroup        = e.FireGroup;
                    Cargo.Current    = e.Cargo;
                    if (e.Cargo > Cargo.Max)
                    {
                        Cargo.Max = Convert.ToInt64(Math.Round(e.Cargo, MidpointRounding.AwayFromZero));
                    }

                    if (GetFlag(Flags, 25))
                    {
                        CurrentVehicle = VehicleType.Fighter;
                    }
                    else if (GetFlag(Flags, 26))
                    {
                        CurrentVehicle = VehicleType.SRV;
                    }
                    else
                    {
                        CurrentVehicle = VehicleType.Ship;
                    }

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.ShipEvents.VehicleSwitch += (s, e) =>
            {
                lock (_lock)
                {
                    if (CurrentVehicle != e.To)
                    {
                        CurrentVehicle = e.To;
                        api.InvokeShipStatusChanged(this);
                    }
                }
            };

            api.StationEvents.SetUserShipName += (s, e) =>
            {
                lock (_lock)
                {
                    Name       = e.UserShipName;
                    Identifier = e.UserShipId;

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.StationEvents.ShipyardNew += (s, e) =>
            {
                lock (_lock)
                {
                    ShipId = e.NewShipId;
                    NewShip(e.ShipModel);

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.StationEvents.ShipyardSwap += (s, e) =>
            {
                lock (_lock)
                {
                    ShipId = e.ShipId;
                    NewShip(e.ShipModel);

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.StationEvents.ShipyardBuy += (s, e) =>
            {
                lock (_lock)
                {
                    ShipId = 0;
                    NewShip(e.ShipModel);

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.ShipEvents.Loadout += (s, e) =>
            {
                lock (_lock)
                {
                    if (ShipId != e.ShipId)
                    {
                        ShipId   = e.ShipId;
                        ShipType = e.ShipModel;
                    }

                    Name       = e.ShipName;
                    Identifier = e.ShipIdent;

                    if (e.FuelCapacity != null)
                    {
                        Fuel.Main      = e.FuelCapacity.Main;
                        Fuel.Reservoir = e.FuelCapacity.Reserve;
                    }

                    Cargo.Max = e.CargoCapacity;
                    IsHot     = e.Hot ?? false;

                    Hull.Value        = e.HullValue;
                    Hull.Health       = (byte)Math.Round(e.HullHealth * 100);
                    Hull.UnladenMass  = e.UnladenMass;
                    Hull.ModulesValue = e.ModulesValue;
                    Hull.Modules      = e.Modules;
                    MaxJumpRange      = e.MaxJumpRange;
                    Rebuy             = e.Rebuy;

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.ShipEvents.LaunchFighter += (s, e) =>
            {
                lock (_lock)
                {
                    FighterLaunched += 1;

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.ShipEvents.DockFighter += (s, e) =>
            {
                lock (_lock)
                {
                    FighterLaunched -= 1;

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.ShipEvents.LaunchSrv += (s, e) =>
            {
                lock (_lock)
                {
                    SrvLaunched += 1;

                    api.InvokeShipStatusChanged(this);
                }
            };

            api.ShipEvents.DockSrv += (s, e) =>
            {
                lock (_lock)
                {
                    SrvLaunched -= 1;

                    api.InvokeShipStatusChanged(this);
                }
            };
        }
예제 #15
0
        /// <summary>
        /// Сохранение ВЭК в формате CSV
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="range"></param>
        public override void SaveEnergyInfo(string filename, RawRange range)
        {
            List <object> years = new List <object>();

            foreach (RawItem item in range)
            {
                if (!years.Contains(item.Date.Year))
                {
                    years.Add(item.Date.Year);
                }
            }

            //формирование заголовка
            string cap = "Год;Месяц;кол-во изм";

            foreach (GradationItem grad in Vars.Options.CurrentSpeedGradation.Items)
            {
                cap += ";" + grad.Average.ToString("0.00");
            }
            cap += ";Vmin, м/с;Vmax, м/с;Vср, м/с;Vэкст50,м/с;Cv(V);𝜎(V);параметр γ;параметр β;Nвал уд., Вт/м^2;Эвал уд., Вт*ч/м^2";
            foreach (WindDirections16 wd in WindDirections16.Calm.GetEnumItems().GetRange(0, 17))
            {
                cap += ";" + wd.Description();
            }

            //запись в файл
            saveEnergyInfoLine(filename, null, null, null, null, cap, "", "", 0, false); //запись заголовка

            //запись данных обо всём периоде
            EnergyInfo ri1 = StatisticEngine.ProcessRange(range);
            StatisticalRange <WindDirections16> sd1 = StatisticEngine.GetDirectionExpectancy(range, GradationInfo <WindDirections16> .Rhumb16Gradations);
            StatisticalRange <GradationItem>    ss1 = StatisticEngine.GetExpectancy(range, Vars.Options.CurrentSpeedGradation);
            EnergyInfo ei1 = StatisticEngine.ProcessRange(ss1);

            saveEnergyInfoLine(filename, ri1, ei1, sd1, ss1, null, "Все года", "Все месяцы", range.Count, true);

            //запись данных для каждого года
            foreach (int year in years) //цикл по годам
            {
                //для каждого месяца в году
                for (int mt = 0; mt <= 12; mt++)//по месяцам, начиная со всех
                {
                    Months   month = (Months)mt;
                    RawRange rn    = range.GetRange(false, true, DateTime.Now, DateTime.Now, year, month.Description());
                    if (rn == null || rn.Count == 0)
                    {
                        continue;
                    }
                    EnergyInfo ri = StatisticEngine.ProcessRange(rn, range);
                    StatisticalRange <WindDirections16> sd = StatisticEngine.GetDirectionExpectancy(rn, GradationInfo <WindDirections16> .Rhumb16Gradations);
                    StatisticalRange <GradationItem>    ss = StatisticEngine.GetExpectancy(rn, Vars.Options.CurrentSpeedGradation);
                    EnergyInfo ei = StatisticEngine.ProcessRange(ss);
                    saveEnergyInfoLine(filename, ri, ei, sd, ss, null, year.ToString(), month.Description(), rn.Count, true);
                }
            }

            //запись данных по месяцам
            saveEnergyInfoLine(filename, null, null, null, null, ";", "", "", 0, true);
            saveEnergyInfoLine(filename, null, null, null, null, ";", "", "", 0, true);
            saveEnergyInfoLine(filename, null, null, null, null, ";", "", "", 0, true);
            for (int mt = 1; mt <= 12; mt++)//по месяцам, начиная со всех
            {
                Months   month = (Months)mt;
                RawRange rn    = range.GetRange(false, true, DateTime.Now, DateTime.Now, "Все", month.Description());
                if (rn == null || rn.Count == 0)
                {
                    continue;
                }
                EnergyInfo ri = StatisticEngine.ProcessRange(rn, range);
                StatisticalRange <WindDirections16> sd = StatisticEngine.GetDirectionExpectancy(rn, GradationInfo <WindDirections16> .Rhumb16Gradations);
                StatisticalRange <GradationItem>    ss = StatisticEngine.GetExpectancy(rn, Vars.Options.CurrentSpeedGradation);
                EnergyInfo ei = StatisticEngine.ProcessRange(ss);
                saveEnergyInfoLine(filename, ri, ei, sd, ss, null, "Все года", month.Description(), rn.Count, true);
            }
        }
예제 #16
0
 public bool AddEnergy(EnergyInfo energy)
 {
     TemporaryEnergy.Add(energy);
     return(true);
 }
예제 #17
0
        public void Update()
        {
            // Update tiles
            if (Started && !Player.Dead)
            {
                // Hull flash possible match
                timeSinceLastMatch++;
                if (Player.ShipHull.FlashPossibleTiles && timeSinceLastMatch > 240)
                {
                    timeSinceLastMatch = 0;
                    List <Tile> possibleMatches = CheckPossibleMatches();
                    possibleMatches[Globals.Randomizer.Next(0, possibleMatches.Count())].Flash = 145;
                }

                bool canSelect = true;
                for (int i = 0; i < Tiles.Count; i++)
                {
                    for (int j = 0; j < Tiles[i].Count; j++)
                    {
                        Tiles[i][j].TilePosition = new Point(i, j);
                        Tiles[i][j].UpdateLevel(this);

                        if (!Tiles[i][j].Hidden)
                        {
                            // Above hidden
                            if (j < BoardSize.Y - 1 && Tiles[i][j + 1].Hidden && Tiles[i][j + 1].Size < 0.1)
                            {
                                if (Tiles[i][j].Mine)
                                {
                                    Tiles[i][j].Mine = false;
                                }

                                Tile temp = Tiles[i][j];
                                Tiles[i][j]     = Tiles[i][j + 1];
                                Tiles[i][j + 1] = temp;
                            }

                            // Select
                            if (canSelect && Globals.MState.LeftButton == ButtonState.Pressed && Globals.PrevMState.LeftButton == ButtonState.Released && Globals.MRectangle.Intersects(Tiles[i][j].Box) && !Tiles.Any(Column => Column.Any(item => item.Moving == true)))
                            {
                                canSelect = false;
                                if (Selected == null)
                                {
                                    Selected = Tiles[i][j];
                                }
                                else if (Selected == Tiles[i][j])
                                {
                                    Selected = null;
                                }
                                else
                                {
                                    // Check if pressed tile next to selected
                                    if (CheckAdjacent(i, j))
                                    {
                                        Tile temp = Tiles[i][j];
                                        Tiles[i][j]               = Selected;
                                        Tiles[i][j].Moving        = true;
                                        Tiles[i][j].ManuallyMoved = 180;
                                        Tiles[Selected.TilePosition.X][Selected.TilePosition.Y]               = temp;
                                        Tiles[Selected.TilePosition.X][Selected.TilePosition.Y].Moving        = true;
                                        Tiles[Selected.TilePosition.X][Selected.TilePosition.Y].ManuallyMoved = 180;

                                        // Check if swap is matching
                                        if (!CheckSingleMatch(i, j, Tiles) && !CheckSingleMatch(Selected.TilePosition.X, Selected.TilePosition.Y, Tiles))
                                        {
                                            Tiles[i][j]        = Tiles[Selected.TilePosition.X][Selected.TilePosition.Y];
                                            Tiles[i][j].Moving = false;
                                            Tiles[Selected.TilePosition.X][Selected.TilePosition.Y]        = Selected;
                                            Tiles[Selected.TilePosition.X][Selected.TilePosition.Y].Moving = false;
                                            GameObjects.Add(new Text(Tiles[i][j].Position - (Tiles[i][j].Position - Tiles[Selected.TilePosition.X][Selected.TilePosition.Y].Position), "Invalid Swap!", Color.Red, 60, 2, false, TextureManager.SpriteFont20));
                                        }
                                        Selected = null;
                                    }
                                    else
                                    {
                                        Selected = Tiles[i][j];
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (Tiles[i][j].ManuallyMoved >= 0)
                            {
                                Tiles[i][j].ManuallyMoved = -1;
                            }

                            // "New" tile if hidden on top layer
                            if (j == 0)
                            {
                                Player player = (Player)GameObjects.First(item => item is Player);
                                Tiles[i][j].UnHide(player);
                            }
                        }
                    }
                }

                CheckMatch();

                // Modifiers

                if (HasModifier(Modifier.Asteroid))
                {
                    modifierTimer--;
                    // spawn rock if possible to move
                    if (modifierTimer < 0 && Globals.Randomizer.Next(0, 1001) < 3 && !(Player.ShipLocation == Location.left && !CheckPossibleMatches().Any(item => item.Type == TileType.right)) &&
                        !(Player.ShipLocation == Location.right && !CheckPossibleMatches().Any(item => item.Type == TileType.left)) &&
                        !(Player.ShipLocation == Location.middle && !CheckPossibleMatches().Any(item => item.Type == TileType.left) && !CheckPossibleMatches().Any(item => item.Type == TileType.right)))
                    {
                        modifierTimer = 120;
                        ToAdd.Add(new Rock(Player, this));
                    }
                }
                if (HasModifier(Modifier.Sun))
                {
                    modifierTimer--;
                    if (modifierTimer < 0 && Globals.Randomizer.Next(0, 1001) < 3)
                    {
                        modifierTimer = 120;
                        CombatText("The sun is heating up!");
                        Player.SetDamageOverTime(3, 6, 0);
                        if (GameObjects.Any(item => item is Enemy))
                        {
                            Enemy enemy = (Enemy)GameObjects.First(item => item is Enemy);
                            enemy.SetDamageOverTime(1, 6, 0);
                        }
                    }
                }
                if (HasModifier(Modifier.Satellite))
                {
                    Player.Energy.Change(0.04f);
                }
                if (HasModifier(Modifier.BlackHole))
                {
                    modifierTimer--;
                    if (modifierTimer < 0 && Globals.Randomizer.Next(0, 1001) < 4)
                    {
                        modifierTimer = 300;
                        CombatText("The tiles are heating up!");
                        for (int i = 0; i < Globals.Randomizer.Next(3, 7); i++)
                        {
                            while (true)
                            {
                                Point randomTile  = new Point(Globals.Randomizer.Next(0, BoardSize.X), Globals.Randomizer.Next(0, BoardSize.Y));
                                Point randomTile2 = new Point(Globals.Randomizer.Next(0, BoardSize.X), Globals.Randomizer.Next(0, BoardSize.Y));
                                while (randomTile.X == randomTile2.X && randomTile.Y == randomTile2.Y)
                                {
                                    randomTile2 = new Point(Globals.Randomizer.Next(0, BoardSize.X), Globals.Randomizer.Next(0, BoardSize.Y));
                                }
                                Tile temp = Tiles[randomTile.X][randomTile.Y];
                                Tiles[randomTile.X][randomTile.Y]   = Tiles[randomTile2.X][randomTile2.Y];
                                Tiles[randomTile2.X][randomTile2.Y] = temp;
                                if (!CheckSingleMatch(randomTile.X, randomTile.Y, Tiles) && !CheckSingleMatch(randomTile2.X, randomTile2.Y, Tiles))
                                {
                                    break;
                                }
                                else
                                {
                                    Tiles[randomTile2.X][randomTile2.Y] = Tiles[randomTile.X][randomTile.Y];
                                    Tiles[randomTile.X][randomTile.Y]   = temp;
                                }
                            }
                        }
                    }
                }
            }
            else if (Globals.KState.IsKeyDown(Keys.Enter))
            {
                Started = true;
            }

            // Game objects
            foreach (GameObject go in GameObjects)
            {
                go.UpdateLevel(this);
            }

            // Add
            foreach (GameObject toAdd in ToAdd)
            {
                GameObjects.Add(toAdd);
            }
            ToAdd.Clear();

            // Remove
            for (int i = GameObjects.Count - 1; i >= 0; i--)
            {
                if (GameObjects[i].Dead && !(GameObjects[i] is Player))
                {
                    if (GameObjects[i] is Enemy)
                    {
                        Player.GainExperience((int)EnemyDifficulty * 45 + 50 + Globals.Randomizer.Next(5, 10));
                        if (Rewards.Count() > 0)
                        {
                            foreach (Item reward in Rewards)
                            {
                                Player.AddItem(reward);
                            }
                            SceneManager.mapScene.NewItems.Flash = 10;
                        }
                        Player.Move = true;
                        Player.Health.Change(1);
                    }
                    GameObjects.RemoveAt(i);
                }
            }

            // Infobuttons
            ModuleInfo.Update();
            TileboardInfo.Update();
            EnergyInfo.Update();

            // Flee
            Flee.Update();
            if (Flee.Press() && EnemyDifficulty != Difficulty.Boss)
            {
                if (Player.ItemInInventory("Flee"))
                {
                    Player.GetItemInInventory("Flee").UseItem(Player, Player.GetItemInInventory("Flee"));
                }
            }
            if (Player.OutsideScreen())
            {
                Player.Move      = false;
                Player.Speed     = 0;
                Player.Position  = new Vector2(300, Globals.ScreenSize.Y - Player.Texture.Height);
                Player.Direction = Player.StandardDirection;
                LeaveLevel(GameObjects.Any(item => item is Enemy));
                Player.BonusDamageOneFight = 0;
            }
        }
예제 #18
0
 public bool AddEnergy(EnergyInfo energy)
 {
     TemporaryEnergy.Add(energy);
     return true;
 }