Example #1
0
    public Ingot GetIngot(int pIdGame, int pIdPlayer, int pIdIngot)
    {
        Ingot i = new Ingot();

        string        conn = "URI=file:" + Application.streamingAssetsPath + "/AdvScrabble.db";  //Path to database.
        IDbConnection dbconn;

        dbconn = (IDbConnection) new SqliteConnection(conn);
        dbconn.Open();         //Open connection to the database.
        IDbCommand dbcmd    = dbconn.CreateCommand();
        string     sqlQuery = String.Format("SELECT * FROM ingot where id_game = \"{0}\" and id_player = \"{1}\" and id_ingot = \"{2}\"", pIdGame, pIdPlayer, pIdIngot);

        dbcmd.CommandText = sqlQuery;
        IDataReader reader = dbcmd.ExecuteReader();

        while (reader.Read())
        {
            i.Id_ingot   = reader.GetInt32(2);
            i.Coin_count = reader.GetInt32(3);
        }
        reader.Close();
        reader = null;
        dbcmd.Dispose();
        dbcmd = null;
        dbconn.Close();
        dbconn = null;

        return(i);
    }
Example #2
0
 public Player(int id_player, string name, Sprite picture, Heart heart, Ingot ingot, List <MessageGroup> list_message_group, List <Bonus> listBonus, List <RegisterMap> listRegMap, List <LevelState> listStateLevel, List <Achievement> listAchievements)
 {
     this.id_player          = id_player;
     this.name               = name;
     this.picture            = picture;
     this.heart              = heart;
     this.ingot              = ingot;
     this.list_message_group = list_message_group;
     this.listBonus          = listBonus;
     this.listRegMap         = listRegMap;
     this.listStateLevel     = listStateLevel;
     this.listAchievements   = listAchievements;
 }
Example #3
0
    public override Ingot CopyItem(int quantity)
    {
        var copy = new Ingot
        {
            Id          = Id,
            Name        = Name,
            Rarity      = Rarity,
            Value       = Value,
            Description = Description,
            Quantity    = quantity
        };

        return(copy);
    }
    private void AddNewObjectButton_Click(object sender, RoutedEventArgs e)
    {
        Save();

        var nextId = (GameAssets.Ingots.Max(x => x.Id as int?) ?? 0) + 1;

        _dataContext = new Ingot
        {
            Id = nextId
        };
        ContentSelectionBox.SelectedIndex = -1;
        RefreshStaticValuesPanel();

        DeleteObjectButton.Visibility = Visibility.Visible;
    }
Example #5
0
    public void UpdateIngot(int pIdGame, int pIdPlayer, Ingot i)
    {
        string conn = "URI=file:" + Application.streamingAssetsPath + "/AdvScrabble.db";         //Path to database.

        using (IDbConnection dbconn = new SqliteConnection(conn))
        {
            dbconn.Open();

            using (IDbCommand dbcmd = dbconn.CreateCommand())
            {
                string sqlQuery = String.Format("UPDATE ingot SET id_game = \"{0}\", id_player = \"{1}\", id_ingot = \"{2}\", count_coin = \"{3}\" WHERE id_game = \"{0}\" AND id_player = \"{1}\" AND  id_ingot = \"{2}\"", pIdGame, pIdPlayer, i.Id_ingot, i.Coin_count);
                dbcmd.CommandText = sqlQuery;
                dbcmd.ExecuteScalar();
                dbconn.Close();
            }
        }
    }
    private void ContentSelectionBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var selectedName = (e.Source as ComboBox)?.SelectedValue?.ToString();

        if (selectedName is null)
        {
            return;
        }

        if (_dataContext is not null)
        {
            Save();
        }

        _dataContext = GameAssets.Ingots.FirstOrDefault(x => x.Name == selectedName);
        RefreshStaticValuesPanel();
        DeleteObjectButton.Visibility = Visibility.Visible;
    }
    private void DeleteObjectButton_Click(object sender, RoutedEventArgs e)
    {
        Save();

        var objectToDelete = GameAssets.Ingots.FirstOrDefault(x => x.Id == int.Parse((_controls["IdBox"] as TextBox).Text));

        var result = MessageBox.Show($"Are you sure you want to delete {objectToDelete.Name}? This action will close ContentManager, check Logs directory (for missing references after deleting).", "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question);

        if (result == MessageBoxResult.No)
        {
            return;
        }

        GameAssets.Ingots.Remove(objectToDelete);

        PopulateContentSelectionBox();
        ContentSelectionBox.SelectedIndex = -1;
        _currentPanel.Children.Clear();
        DeleteObjectButton.Visibility = Visibility.Hidden;
        _dataContext = null;

        Application.Current.MainWindow.Close();
    }
Example #8
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (mainCockpit != null)
            {
                IMyTextSurface surface = mainCockpit.GetSurface(0);
                surface.ContentType = ContentType.TEXT_AND_IMAGE;
                surface.FontSize    = 7.7f;

                MyFixedPoint            currentCargoVolume = 0;
                MyFixedPoint            maxCargoVolume     = 0;
                List <IMyTerminalBlock> cargoContainers    = new List <IMyTerminalBlock>();
                IMyTerminalBlock        controlBlock;
                List <IMyTerminalBlock> gridBlocks          = new List <IMyTerminalBlock>();
                List <IMyThrust>        reverseIonThrusters = new List <IMyThrust>();

                float  brakingTime;
                float  brakingDistance;
                float  maxAcceleration;
                float  reverseThrustersForce = 0;
                float  totalMass;
                double currentSpeed;

                GridTerminalSystem.GetBlocks(gridBlocks);

                controlBlock = gridBlocks.Find(x => x.CustomName.Contains("[MAIN]"));

                foreach (IMyTerminalBlock _block in gridBlocks)
                {
                    if (_block is IMyCargoContainer || _block is IMyShipConnector || _block is IMyShipDrill)
                    {
                        cargoContainers.Add(_block as IMyTerminalBlock);
                    }

                    if (_block is IMyThrust && _block.WorldMatrix.Forward == controlBlock.WorldMatrix.Forward)
                    {
                        reverseIonThrusters.Add(_block as IMyThrust);
                        reverseThrustersForce += (_block as IMyThrust).MaxEffectiveThrust;
                    }
                }

                totalMass       = (controlBlock as IMyShipController).CalculateShipMass().TotalMass;
                maxAcceleration = reverseThrustersForce / totalMass;
                currentSpeed    = (controlBlock as IMyShipController).GetShipSpeed();
                brakingTime     = (float)currentSpeed / maxAcceleration;
                brakingDistance = (maxAcceleration * brakingTime * brakingTime) / 2;

                foreach (IMyTerminalBlock _container in cargoContainers)
                {
                    maxCargoVolume     += _container.GetInventory().MaxVolume;
                    currentCargoVolume += _container.GetInventory().CurrentVolume;
                }

                double cargoSpace = ((double)currentCargoVolume / (double)maxCargoVolume * 100);

                surface.WriteText($"Cargo Load: {Math.Round(cargoSpace, 2)}%\n" +
                                  $"Until stop: {Math.Round(brakingTime)} s. {Math.Round(brakingDistance)} m.");
            }

            List <IMyTerminalBlock> blocksWithInventory = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType(blocksWithInventory, x => x.HasInventory);

            foreach (IMyTerminalBlock block in blocksWithInventory)
            {
                IMyInventory           inventory = block.GetInventory();
                List <MyInventoryItem> items     = new List <MyInventoryItem>();
                inventory.GetItems(items);

                foreach (MyInventoryItem item in items)
                {
                    switch (item.Type.TypeId)
                    {
                    case "MyObjectBuilder_Ore":
                        Ore ore = ores.Find(x => x.SubtypeId == item.Type.SubtypeId);
                        if (ore != null)
                        {
                            ore.Amount += item.Amount;
                        }
                        else
                        {
                            Echo($"{item.Type.TypeId == "MyObjectBuilder_Ore"} - {item.Type.SubtypeId}");
                        }
                        break;

                    case "MyObjectBuilder_Ingot":
                        Ingot ingot = ingots.Find(x => x.SubtypeId == item.Type.SubtypeId);
                        if (ingot != null)
                        {
                            ingot.Amount += item.Amount;
                        }
                        else
                        {
                            Echo($"{item.Type.TypeId == "MyObjectBuilder_Ore"} - {item.Type.SubtypeId}");
                        }
                        break;
                    }
                }
            }

            IMyTextPanel oreDisplay   = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(OreDisplayName);
            IMyTextPanel ingotDisplay = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(IngotDisplayName);

            if (oreDisplay != null)
            {
                string output = "Ores :\n";

                foreach (Ore ore in ores)
                {
                    output    += $" {ore.SubtypeId} : {ore.Amount.ToIntSafe()}\n";
                    ore.Amount = 0;
                }

                oreDisplay.WriteText(output);
            }

            if (ingotDisplay != null)
            {
                string output = "Ingots:\n";

                foreach (Ingot ingot in ingots)
                {
                    output      += $" {ingot.SubtypeId} : {ingot.Amount.ToIntSafe()}\n";
                    ingot.Amount = 0;
                }

                ingotDisplay.WriteText(output);
            }

            List <IMyJumpDrive> jumpDrives = new List <IMyJumpDrive>();

            GridTerminalSystem.GetBlocksOfType(jumpDrives);

            if (jumpDrives[0] != null)
            {
                IMyTextPanel text = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(JumpDriveDisplay);

                if (text != null)
                {
                    float currentStoredPower = (jumpDrives[0].CurrentStoredPower / jumpDrives[0].MaxStoredPower) * 100;
                    text.WriteText($"Drive Charge: {currentStoredPower:000.00}%");

                    if (currentStoredPower == 100)
                    {
                        text.FontColor = Color.Green;
                    }
                    else if (currentStoredPower < 100)
                    {
                        text.FontColor = Color.Orange;
                    }
                }
            }

            foreach (Airlock airlock in airlocks)
            {
                airlock.Check();
            }
        }
        private static bool Prefix(NetworkInstanceId parentId, ulong ownerSteamId, string prefabName)
        {
            DynamicThing dynamicThing  = NetworkThing.Find(parentId) as DynamicThing;
            DynamicThing dynamicThing2 = (DynamicThing)Thing.FindPrefab(prefabName);
            bool         flag          = !dynamicThing2;

            if (!flag)
            {
                Vector3      vector        = dynamicThing.RigidBody.worldCenterOfMass + dynamicThing.ThingTransform.forward * 1f;
                Quaternion   rotation      = Quaternion.AngleAxis(180f, dynamicThing.ThingTransform.up);
                DynamicThing dynamicThing3 = OnServer.Create(dynamicThing2, vector, rotation, ownerSteamId, null);
                Stackable    stackable     = dynamicThing3 as Stackable;
                bool         flag2         = stackable;
                if (flag2)
                {
                    stackable.NetworkQuantity = stackable.MaxQuantity;
                }
                BatteryCell batteryCell = dynamicThing3 as BatteryCell;
                bool        flag3       = batteryCell;
                if (flag3)
                {
                    batteryCell.PowerStored = batteryCell.PowerMaximum;
                }
                Ingot ingot = dynamicThing3 as Ingot;
                bool  flag4 = ingot;
                if (flag4)
                {
                    ingot.NetworkQuantity = ingot.MaxQuantity;
                }
                CreditCard creditCard = dynamicThing3 as CreditCard;
                bool       flag5      = creditCard;
                if (flag5)
                {
                    creditCard.Currency = 8000f;
                }
                DirtCanister dirtCanister = dynamicThing3 as DirtCanister;
                bool         flag6        = dirtCanister;
                if (flag6)
                {
                    dirtCanister.AddDirtCheat(8000f);
                }

                //Creative mode addition
                if (WorldManager.Instance.GameMode == GameMode.Creative)
                {
                    int colorcan = -1;
                    foreach (var chel in Human.AllHumans) //catch idea of search in lists from liz's AtomicBatteryPatch
                    {
                        if (chel.OwnerSteamId == dynamicThing3.OwnerSteamId)
                        {
                            Human parentHuman = null;
                            parentHuman = chel;
                            bool suitis = (parentHuman.Suit == null || parentHuman == null);
                            if (!suitis)
                            {
                                //Debug.LogError("Builder catched");
                                colorcan = (int)(Math.Round(parentHuman.Suit.OutputSetting - 51f)); //pressure 50 = CustomColorIndex -1 default
                                if (colorcan > 11)
                                {
                                    colorcan = 11;
                                }
                                else if (colorcan < -1)
                                {
                                    colorcan = -1;
                                }
                            }
                        }
                    }
                    if (dynamicThing3.PaintableMaterial != null)
                    {
                        OnServer.SetCustomColor(dynamicThing3, colorcan);
                    }
                }
            }


            return(false);
        }