예제 #1
0
 public WeaponAttachDetail(WeaponGroup weaponGroup, Bone bone, Vector3 position, Vector3 rotation)
 {
     WeaponGroup = weaponGroup;
     Bone        = bone;
     Position    = position;
     Rotation    = rotation;
 }
예제 #2
0
    public override bool handleClick(GameObject newObj, Vector3 mousePos)
    {
        if (newObj == null)
        {
            // moving there
            gameObject.GetComponent <Propelled> ().moveToCoords(mousePos);
            return(true);
        }

        if (newObj.tag == gameObject.tag)
        {
            // we're on the same side, which means just switch to that object
            return(false);
        }
        for (int i = 0; i < weaponGroupStatus.Length; i++)
        {
            if (weaponGroupStatus[i])
            {
                foreach (GameObject token in weaponGroup[i])
                {
                    token.GetComponent <Weapon>().setTarget(newObj);
                    token.GetComponent <Weapon>().hideFiringArcs();
                }
            }
        }
        WeaponGroup.DeselectWeaponGroups();
        return(true);
    }
예제 #3
0
 internal static void RemoveGroupForHammer(ModuleHammer hammer, WeaponGroup group)
 {
     if (ModuleWeaponGroupController.groups_for_hammer.TryGetValue(hammer, out var groups))
     {
         groups.Remove(group);
     }
 }
예제 #4
0
        public static SortedWeaponGroup GetGroup(WeaponGroup group)
        {
            switch (group)
            {
            case WeaponGroup.Melee:
                return(new SortedWeaponGroup("Melee", WEAPONS_MELEE));

            case WeaponGroup.Pistol:
                return(new SortedWeaponGroup("Pistol", WEAPONS_PISTOL));

            case WeaponGroup.MG:
                return(new SortedWeaponGroup("Machine Gun", WEAPONS_MACHINEGUN));

            case WeaponGroup.AssaultRifle:
                return(new SortedWeaponGroup("Assault Rifle", WEAPONS_ASSAULTRIFLE));

            case WeaponGroup.Shotgun:
                return(new SortedWeaponGroup("Shotgun", WEAPONS_SHOTGUN));

            case WeaponGroup.Sniper:
                return(new SortedWeaponGroup("Sniper", WEAPONS_SNIPER));

            case WeaponGroup.Heavy:
                return(new SortedWeaponGroup("Heavy", WEAPONS_HEAVY));

            case WeaponGroup.Thrown:
                return(new SortedWeaponGroup("Throwable", WEAPONS_THROWN));

            default:
                return(null);
            }
        }
예제 #5
0
        private void CraftAmmo()
        {
            _craftWeaponsMenu.Clear();
            WeaponGroup[] weaponGroups3 = (WeaponGroup[])Enum.GetValues(typeof(WeaponGroup));
            weaponGroups3 = (from w in weaponGroups3
                             where (int)w != 1595662460 && (int)w != -1609580060 && (int)w != -728555052 && (int)w != -942583726
                             select w).ToArray();
            List <WeaponGroup> list = weaponGroups3.ToList();

            list.Add(GTA.WeaponGroup.AssaultRifle);
            weaponGroups3 = list.ToArray();
            WeaponGroup[] array = weaponGroups3;
            for (int i = 0; i < array.Length; i++)
            {
                WeaponGroup weaponGroup = array[i];
                UIMenuItem  menuItem    = new UIMenuItem(string.Format("{0}", ((int)weaponGroup == 970310034) ? "Assult Rifle" : ((object)weaponGroup).ToString()), $"Craft ammo for {weaponGroup}");
                menuItem.SetLeftBadge(UIMenuItem.BadgeStyle.Ammo);
                int required = GetRequiredPartsForWeaponGroup(weaponGroup);
                menuItem.Description = $"Required Weapon Parts: ~y~{required}~s~";
                _craftWeaponsMenu.AddItem(menuItem);
                menuItem.Activated += delegate
                {
                    InventoryItemBase inventoryItemBase = PlayerInventory.Instance.ItemFromName("Weapon Parts");
                    if (inventoryItemBase != null)
                    {
                        if (inventoryItemBase.Amount >= required)
                        {
                            WeaponHash[] array2 = (WeaponHash[])Enum.GetValues(typeof(WeaponHash));
                            WeaponHash   val    = Array.Find(array2, (WeaponHash h) => PlayerPed.Weapons.HasWeapon(h) && PlayerPed.Weapons[h].Group == weaponGroup);
                            GTA.Weapon   val2   = PlayerPed.Weapons[val];
                            if (val2 != null)
                            {
                                int num = 10 * required;
                                if (val2.Ammo + num <= val2.MaxAmmo)
                                {
                                    PlayerPed.Weapons.Select(val2);
                                    if (val2.Ammo + num > val2.MaxAmmo)
                                    {
                                        val2.Ammo = val2.MaxAmmo;
                                    }
                                    else
                                    {
                                        GTA.Weapon obj = val2;
                                        obj.Ammo = obj.Ammo + num;
                                    }
                                    PlayerInventory.Instance.AddItem(inventoryItemBase, -required, ItemType.Resource);
                                }
                            }
                        }
                        else
                        {
                            UI.Notify("Not enough weapon parts.");
                        }
                    }
                };
            }
            _craftWeaponsMenu.Visible = !_craftWeaponsMenu.Visible;
        }
예제 #6
0
 public void Awake()
 {
     if (Instance == null)
         Instance = this;
     else
     {
         Debug.LogWarning("Instance group is not null");
         Destroy(gameObject);
     }
 }
예제 #7
0
 public Weapon(string name, int proficiencyBonus, Dice damage, string range, WeaponGroup group, WeaponProperties properties, int basePrice, WeaponCategory category, bool isTwoHanded, int enhancementBonus)
 {
     this.name             = name;
     this.proficiencyBonus = proficiencyBonus;
     this.damage           = damage;
     this.range            = range;
     this.group            = group;
     this.properties       = properties;
     this.enhancementBonus = enhancementBonus;
     this.basePrice        = basePrice;
     this.category         = category;
     this.isTwoHanded      = isTwoHanded;
 }
예제 #8
0
        public static string GetWeaponGroupName(WeaponGroup group)
        {
            switch (group)
            {
            case WeaponGroup.HeavyBlade:
                return("Heavy Blade");

            case WeaponGroup.LightBlade:
                return("Light Blade");

            default:
                return(Enum.Format(typeof(WeaponGroup), group, "G"));
            }
        }
        /// <summary>
        ///     At object creation time we assume that the freelancer player has connected to the
        ///     proxy server and is expecting the normal freelancer server login sequence. This
        ///     class manages this message exchange until they select a character at which point
        ///     the controller will establish a connection to a slave freelancer server and
        ///     forward traffic between the two.
        /// </summary>
        /// <param name="dplayid"></param>
        /// <param name="log"></param>
        /// <param name="flplayerid"></param>
        /// <param name="runner"></param>
        public Player(Session dplayid, ILogController log, uint flplayerid, DPGameRunner runner)
        {
            DPSess     = dplayid;
            Log        = log;
            FLPlayerID = flplayerid;
            Runner     = runner;
            Ship       = new Old.Object.Ship.Ship(runner)
            {
                player = this
            };
            Wgrp = new WeaponGroup();

            _state = DPCLoginState.Instance();
            _state.EnterState(this);
        }
예제 #10
0
        private void OnTankPostSpawn()
        {
            if (data == null)
            {
                return;
            }
            var blockman = base.block.tank.blockman;

            foreach (var group in data.groups)
            {
                var actual_group = new WeaponGroup()
                {
                    name    = group.name,
                    keyCode = (KeyCode)group.keyCode
                };

                var weapons = group.positions.Select(p =>
                {
                    var block = blockman.GetBlockAtPosition(p);
                    if (block)
                    {
                        var weapon = new WeaponWrapper(block);
                        if (weapon.hammer)
                        {
                            if (ModuleWeaponGroupController.groups_for_hammer.TryGetValue(weapon.hammer, out var groups))
                            {
                                groups.Add(actual_group);
                            }
                            else
                            {
                                ModuleWeaponGroupController.groups_for_hammer.Add(weapon.hammer, new List <ModuleWeaponGroupController.WeaponGroup>()
                                {
                                    actual_group
                                });
                            }
                        }
                        return(weapon);
                    }
                    return(null);
                }).Where(ww => ww != null).ToList();

                actual_group.weapons = weapons;

                groups.Add(actual_group);
            }
            base.block.tank.ResetPhysicsEvent.Unsubscribe(this.OnTankPostSpawn);
        }
예제 #11
0
        public int FindWeapon(WeaponGroup group)
        {
            switch (group)
            {
            case WeaponGroup.Main:
                return(FindAnyMainWeapon());

            case WeaponGroup.Melee:
                return(FindAnyMeleeWeapon());

            case WeaponGroup.Secondary:
                return(FindAnySecondaryWeapon());

            default:
                return(-1);
            }
        }
예제 #12
0
        private void UnequipCurrentWeapon()
        {
            if (_activeWeaponIndex != -1)
            {
                PlayerWeapon current = _weaponSlot.Weapon;
                WeaponGroup  group   = current.Properties.weaponGroup;

                _activeWeaponIndex = -1;

                if (group == WeaponGroup.Main)
                {
                    _activeMainIndex = -1;
                }

                else if (group == WeaponGroup.Melee)
                {
                    _activeMeleeIndex = -1;
                }

                else if (group == WeaponGroup.Secondary)
                {
                    _activeSecondaryIndex = -1;
                }


                _weaponSlot.Weapon = null;

                current.gameObject.SetActive(false);
                current.transform.SetParent(transform);
                current.transform.localPosition = Vector3.zero;
                current.transform.rotation      = transform.rotation;

                _activeAmmo      = null;
                _activeAmmoIndex = -1;
                UpdateAmmoHUD();

                _uiHUD.ShowResult(true, "Current Weapon Unequipped");
            }

            else
            {
                _uiHUD.ShowResult(false, "No Weapon to Unequip");
            }
        }
예제 #13
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is WeaponGroup))
            {
                return("");
            }

            WeaponGroup   group   = (WeaponGroup)value;
            List <string> results = new List <string>();

            foreach (WeaponGroup iGroup in Enum.GetValues(typeof(WeaponGroup)))
            {
                if ((group & iGroup) == iGroup)
                {
                    results.Add(Utility.GetWeaponGroupName(iGroup));
                }
            }

            return(String.Join(", ", results.ToArray()));
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            weaponGroup = 0;

            foreach (UIElement element in gridGroups.Children)
            {
                if (!(element is CheckBox))
                {
                    continue;
                }

                CheckBox checkbox = (CheckBox)element;

                if (checkbox.IsChecked == true)
                {
                    weaponGroup |= (WeaponGroup)checkbox.Tag;
                }
            }

            DialogResult = true;
        }
예제 #15
0
    public bool ChangeWeapon(WeaponGroup.WeaponType weaponType, int index, WeaponHand weaponHand)
    {
        // Remove weapon first
        RemoveWeapon(weaponHand);

        Transform weaponPrefab;
        if (WeaponGroup.Instance.GetWeapon(index, prof, out weaponPrefab, weaponType))
        {
            Transform w;
            switch (weaponHand)
            {
                case WeaponHand.Left:
                    w = Instantiate(weaponPrefab, weaponHandLeft.position, weaponHandLeft.rotation) as Transform;
                    currentWeaponLeft = w;
                    w.parent = weaponHandLeft;
                    break;
                case WeaponHand.Right:
                    w = Instantiate(weaponPrefab, weaponHandRight.position, weaponHandRight.rotation) as Transform;
                    currentWeaponRight = w;
                    w.parent = weaponHandRight;
                    break;
                case WeaponHand.Both:
                    w = Instantiate(weaponPrefab, weaponHandLeft.position, weaponHandLeft.rotation) as Transform;
                    currentWeaponLeft = w;
                    w.parent = weaponHandLeft;

                    w = Instantiate(weaponPrefab, weaponHandRight.position, weaponHandRight.rotation) as Transform;
                    currentWeaponRight = w;
                    w.parent = weaponHandRight;
                    break;
            }
            // Weapon equipped
            return true;
        }
        else
        {
            return false;
        }
    }
        public EditWeaponGroupWindow(WeaponGroup weaponGroup)
        {
            InitializeComponent();

            WeaponGroup[] groups = (WeaponGroup[])Enum.GetValues(typeof(WeaponGroup));

            for (int i = 0; i < groups.Length; i++)
            {
                gridGroups.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
            }

            gridGroups.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            gridGroups.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            for (int i = 0; i < groups.Length; i++)
            {
                WeaponGroup group = groups[i];

                CheckBox checkbox = new CheckBox {
                    Content = Utility.GetWeaponGroupName(group), Tag = group, Margin = new Thickness(0, 5, 0, 0), MinWidth = 150
                };
                Grid.SetRow(checkbox, i / 2);
                Grid.SetColumn(checkbox, i % 2);

                if ((weaponGroup & group) == group)
                {
                    checkbox.IsChecked = true;
                }

                gridGroups.Children.Add(checkbox);
            }
        }
예제 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SilverNeedle.Equipment.Weapon"/> class.
 /// </summary>
 /// <param name="name">Name of the weapon.</param>
 /// <param name="weight">Weight of the weapon.</param>
 /// <param name="damage">Damage represented as dice (1d4, 2d6, 1d12).</param>
 /// <param name="damageType">Damage type.</param>
 /// <param name="critThreat">Crit threat range.</param>
 /// <param name="critMod">Crit mod.</param>
 /// <param name="range">Range in feet.</param>
 /// <param name="type">Type of weapon.</param>
 /// <param name="group">Group of weapon.</param>
 /// <param name="level">Level of weapon (martial, simple, exotic).</param>
 public Weapon(
     string name,
     float weight,
     string damage,
     DamageTypes damageType,
     int critThreat,
     int critMod,
     int range,
     WeaponType type,
     WeaponGroup group,
     WeaponTrainingLevel level)
 {
     this.Name             = name;
     this.Weight           = weight;
     this.Damage           = damage;
     this.DamageType       = damageType;
     this.CriticalThreat   = critThreat == 0 ? 20 : critThreat;
     this.CriticalModifier = critMod == 0 ? 2 : critMod;
     this.Range            = range;
     this.Type             = type;
     this.Group            = group;
     this.Level            = level;
 }
예제 #18
0
        public static void Draw(LayerInfo layer)
        {
            // draw borders
            Terminal.Color(Colors.BorderColor);
            layer.DrawBorders(new BorderInfo
            {
                TopLeftChar     = '┌',
                BottomLeftChar  = '└',
                BottomRightChar = '┴',
                TopChar         = '─', // 196
                BottomChar      = '─',
                LeftChar        = '│'  // 179
            });

            var player = (Mech)Game.Player;
            int y      = 1;

            Terminal.Color(Colors.Text);
            layer.Print(y, "The Pilot");
            y += 2;

            Terminal.Color(golden);
            Terminal.Layer(1);
            DrawBar(layer, 0, y, layer.Width, 0, '░');

            Terminal.Layer(2);
            layer.Print(y, "Energy");
            y++;

            var ph            = player.PartHandler;
            int coolBarLength = (int)(layer.Width * ph.Coolant / ph.GetMaxCoolant());

            Terminal.Color(Color.LightSkyBlue);
            Terminal.Layer(1);
            DrawBar(layer, 0, y, coolBarLength, 0, '░');

            Terminal.Layer(2);
            layer.Print(y, $"Coolant");
            y++;

            Terminal.Color(Color.DarkOrange);
            Terminal.Layer(4);
            layer.Print(y, "Heat");

            DrawHeatBar(layer, 4, y, player);
            y += 2;

            Terminal.Color(Colors.Text);
            foreach (Part p in player.PartHandler)
            {
                // Ignore weapons for now - we draw them with their weapon groups
                if (p.Has <ActivateComponent>())
                {
                    continue;
                }

                Terminal.Color(Colors.Text);
                Terminal.Layer(1);
                DrawBar(layer, 1, y, layer.Width - 1, 0, '░');

                Terminal.Layer(2);
                layer.Print(1, y++, p.Name);

                y++;
                y = DrawPart(layer, y, p);
                y++;
            }

            y++;
            WeaponGroup wg = player.PartHandler.WeaponGroup;

            for (int i = 0; i < wg.Groups.Length; i++)
            {
                List <Part> group = wg.Groups[i];
                if (group.Count == 0)
                {
                    continue;
                }

                Terminal.Color(golden);
                layer.Print(y++, $"Weapon Group {i + 1}");
                layer.Print(y++, $"────────────────────");
                int currWeaponIndex = wg.NextIndex(i);

                for (int j = 0; j < group.Count; j++)
                {
                    // TODO: it's possible to run out of space, in which case we would need scrolling
                    // we just truncate and not worry about it for now
                    if (y + 6 > layer.Height)
                    {
                        break;
                    }

                    Part p = group[j];
                    p.Get <ActivateComponent>().MatchSome(w =>
                    {
                        double cooldown = layer.Width - layer.Width * w.CurrentCooldown / w.Cooldown;
                        if (cooldown < 0)
                        {
                            cooldown = 0;
                        }

                        if (w.CurrentCooldown == 0)
                        {
                            Terminal.Color(brightGreen);
                        }
                        else
                        {
                            Terminal.Color(Color.LightGreen.Blend(Color.LightSalmon, 1 - cooldown / layer.Width));
                        }

                        if (currWeaponIndex == j)
                        {
                            layer.Put(0, y, 0xE011);
                        }

                        Terminal.Layer(1);
                        DrawBar(layer, 1, y, cooldown - 1, 0, '░');

                        Terminal.Layer(2);
                        layer.Print(1, y++, p.Name);
                        Terminal.Layer(1);

                        y++;
                        y = DrawPart(layer, y, p);
                        y++;
                    });
                }
            }
        }
예제 #19
0
 public override void loseClickFocus()
 {
     MainGUIMgr.SelectNothing();
     WeaponGroup.HideWeaponGroups();
 }
예제 #20
0
 private int GetRequiredPartsForWeaponGroup(WeaponGroup group)
 {
     return((!_requiredAmountDictionary.ContainsKey(group)) ? 1 : _requiredAmountDictionary[group]);
 }
예제 #21
0
    void Detonate(WeaponInstance Instance) // This can be handled with logic on the prefab itself
    {
        if (Instance.design.ExplosionEffectPrefab != null)
        {
            Instantiate(
                Instance.design.ExplosionEffectPrefab,
                Instance.gameObject.transform.position,
                Instance.gameObject.transform.rotation);
        }

        // IF there is another weapon to create
        if (Instance.groupIndex < SelectedWeapon.WeaponGroups.Length - 1)
        {
            // Get next iteration of weapon
            WeaponGroup NextInstance = SelectedWeapon.WeaponGroups[Instance.groupIndex + 1];

            print(NextInstance.Count);

            // Calculate number of weapons to create
            int weaponCount = Random.Range(
                NextInstance.Count - NextInstance.CountVariation,
                NextInstance.Count + NextInstance.CountVariation);

            // Loop runs for each new weapon
            for (int i = 0; i < weaponCount; i++)
            {
                Vector2 velocity = Instance.rigidbody.velocity;

                float AddForceX = 0;
                float AddForceY = 0;

                if (NextInstance.Bidirectional)
                {
                    print("Bidirectional");
                    AddForceX = Random.Range(NextInstance.SpreadHorizontal, -NextInstance.SpreadHorizontal);
                    AddForceY = Random.Range(NextInstance.SpreadVertical, -NextInstance.SpreadVertical);
                }
                else if (NextInstance.EvenSpread)
                {
                    print("Even Spread");
                    AddForceX = (NextInstance.SpreadHorizontal / weaponCount) * i;
                    AddForceY = (NextInstance.SpreadVertical / weaponCount) * i;
                }
                else if (NextInstance.Bidirectional && NextInstance.EvenSpread)
                {
                }
                else
                {
                }

                CreateWeaponInstance(
                    Instance.gameObject.transform.position,
                    velocity,
                    Instance.groupIndex + 1,
                    NextInstance.ImpulseForce,
                    AddForceX,
                    AddForceY
                    );
            }
        }

        Destroy(Instance.gameObject);
        InstanceList.Remove(Instance);
    }
예제 #22
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }
예제 #23
0
 public FireEventData(WeaponGroup weaponGroup, int weaponIndex)
 {
     group     = weaponGroup;
     itemIndex = weaponIndex;
 }
        /// <summary>
        ///     Load the specified character file, resetting all character specific
        ///     content for this player and notifying all players of the name.
        /// </summary>
        /// <param name="account">Player account</param>
        /// <param name="log"></param>
        /// <returns>Returns null on successful load otherwise returns error message as a string.</returns>
        public string LoadCharFile(Account account, ILogController log)
        {
            if (account == null)
            {
                log.AddLog(LogType.ERROR, "Broken account found!");
                return("Account is null!");
            }
            //null checks made earlier
            // ReSharper disable once PossibleInvalidOperationException
            PlayerAccount = account;
            Wgrp          = new WeaponGroup();

// ReSharper disable once PossibleNullReferenceException
            Name  = PlayerAccount.CharName;
            Money = PlayerAccount.Money;

            var arch = ArchetypeDB.Find(PlayerAccount.Ship);

            if (arch is ShipArchetype)
            {
                Ship.Arch = arch;
            }
            else
            {
                return("invalid ship");
            }

            if (ShipState.RepGroup == "")
            {
                Ship.faction = new Faction();
            }
            else
            {
                Ship.faction = UniverseDB.FindFaction(ShipState.RepGroup);
                if (Ship.faction == null)
                {
                    return("invalid faction");
                }
            }

            Ship.System = UniverseDB.FindSystem(PlayerAccount.System);
            if (Ship.System == null)
            {
                return("invalid system");
            }

            if (ShipState.Base == null)
            {
                Ship.Basedata = null;
            }
            else
            {
                Ship.Basedata = UniverseDB.FindBase(ShipState.Base);
                if (Ship.Basedata == null)
                {
                    return("invalid base");
                }
            }

            if (ShipState.LastBase == "")
            {
                Ship.RespawnBasedata = null;
                return("no respawn base");
            }

            Ship.RespawnBasedata = UniverseDB.FindBase(ShipState.LastBase);
            if (Ship.RespawnBasedata == null)
            {
                return("invalid respawn base");
            }



            if (Ship.Basedata == null)
            {
                if (ShipState.Position != null)
                {
                    Ship.Position = ShipState.Position;
                }

                if (ShipState.Rotate != null)
                {
                    Ship.Orientation = Matrix.EulerDegToMatrix(ShipState.Rotate);
                }
            }

            //TODO: why ShipState.Hull is always true
            Ship.Health = ShipState.Hull;
            if (Ship.Health <= 0)
            {
                Ship.Health = 0.05f;
            }

            Ship.voiceid = FLUtility.CreateID(Appearance.Voice);

            //TODO: calculate rank
// ReSharper disable once PossibleNullReferenceException
            Ship.Rank = PlayerAccount.Rank;

            Ship.com_body      = Appearance.Body;
            Ship.com_head      = Appearance.Head;
            Ship.com_lefthand  = Appearance.LeftHand;
            Ship.com_righthand = Appearance.RightHand;

            Ship.Items.Clear();

            uint hpid = 34;

            foreach (var set in Equipment)
            {
                var si = new ShipItem
                {
                    arch    = ArchetypeDB.Find(set.Arch),
                    hpname  = set.HpName,
                    health  = set.Health,
                    count   = 1,
                    mission = false,
                    mounted = true,
                    hpid    = hpid++
                };
                Ship.Items[si.hpid] = si;
            }

            foreach (var set in Cargo)
            {
                var si = new ShipItem
                {
                    arch    = ArchetypeDB.Find(set.Arch),
                    hpname  = "",
                    count   = set.Count,
                    health  = 1.0f,
                    mission = false,
                    mounted = false,
                    hpid    = hpid++
                };
                Ship.Items[si.hpid] = si;
            }

            Ship.Reps.Clear();


            foreach (var set in RepDictionary)
            {
                float rep     = set.Value;
                var   faction = UniverseDB.FindFaction(set.Key);
                if (faction == null)
                {
// ReSharper disable once PossibleNullReferenceException
                    log.AddLog(LogType.ERROR, "error: faction not found char={0} faction={1}", account.CharName,
                               set.Value);
                }
                else
                {
                    Ship.Reps[faction] = rep;
                }
            }


            //Visits.Clear();
            //foreach (var set in Visits)
            //{
            //    Visits[set.Key] = set.Value;
            //}

            Ship.CurrentAction = null;

            return(null);
        }
예제 #25
0
파일: Pilot.cs 프로젝트: weichx/Deviant
 public void SelectWeapon()
 {
     if(weaponSystem != null && weaponSystem.weaponGroups[0] != null) {
         activeWeaponGroup = weaponSystem.weaponGroups[0];
     }
 }
 private int GetRequiredPartsForWeaponGroup(WeaponGroup group)
 {
     return(this._requiredAmountDictionary.ContainsKey(group) ? this._requiredAmountDictionary[group] : 1);
 }
예제 #27
0
        /// <summary>
        ///     Converts old INI-based savefile to a new SQLite row.
        /// </summary>
        /// <returns>Account on success; otherwise null.</returns>
        public Account LoadCharFile(string path, ILogController log)
        {
            Wgrp = new WeaponGroup();

            var charfile = new FLDataFile(path, true);

            var name  = charfile.GetSetting("Player", "name").UniStr(0);
            var money = charfile.GetSetting("Player", "money").UInt(0);

            var accArch = charfile.GetSetting("Player", "ship_archetype").UInt(0);

            var accSendDeathMsg       = bool.Parse((string)charfile.GetSetting("Player", "senddeath").Values[0]);
            var accSendSystemDeathMsg = bool.Parse((string)charfile.GetSetting("Player", "sendsystemdeath").Values[0]);


            string accFaction;

            if (charfile.SettingExists("Player", "rep_group"))
            {
                accFaction = charfile.GetSetting("Player", "rep_group").Str(0);
            }
            else
            {
                // empty but legal faction
                accFaction = "";
            }


            var accSystem = charfile.GetSetting("Player", "system").Str(0);

            string accBase;

            if (charfile.SettingExists("Player", "base"))
            {
                accBase = charfile.GetSetting("Player", "base").Str(0);
            }
            else
            {
                accBase = null;
            }

            var accLastBase = charfile.GetSetting("Player", "last_base").Str(0);

            Vector accPosition = null;
            Vector accRotate   = null;

            if (accBase == null)
            {
                if (charfile.SettingExists("Player", "pos"))
                {
                    accPosition = charfile.GetSetting("Player", "pos").Vector();
                }

                if (charfile.SettingExists("Player", "rotate"))
                {
                    accRotate = charfile.GetSetting("Player", "rotate").Vector();
                }
            }

            float health;

            if (charfile.SettingExists("Player", "base_hull_status"))
            {
                health = charfile.GetSetting("Player", "base_hull_status").Float(0);
                if (health <= 0)
                {
                    health = 0.05f;
                }
            }
            else
            {
                health = 1;
            }

            string accVoiceID = charfile.GetSetting("Player", "voice").Str(0);

            //Ship.Rank = Charfile.GetSetting("Player", "rank").UInt(0); // fixme, calculate this

            var accComBody      = charfile.GetSetting("Player", "com_body").UInt(0);
            var accComHead      = charfile.GetSetting("Player", "com_head").UInt(0);
            var accComLefthand  = charfile.GetSetting("Player", "com_lefthand").UInt(0);
            var accComRighthand = charfile.GetSetting("Player", "com_righthand").UInt(0);

            var equip    = charfile.GetSettings("Player", "equip");
            var accEquip = equip.Select(set => new Equipment {
                Arch = set.UInt(0), HpName = set.Str(1), Health = set.Float(2)
            }).ToList();

            var cargo    = charfile.GetSettings("Player", "cargo");
            var accCargo = cargo.Select(set => new Cargo {
                Arch = set.UInt(0), Count = set.UInt(1)
            }).ToList();

            Dictionary <string, float> accRep = charfile.GetSettings("Player", "house").ToDictionary(set => set.Str(1), set => set.Float(0));

            var accVisits = charfile.GetSettings("Player", "visit").ToDictionary(set => set.UInt(0), set => set.UInt(1));

            var acc = new Account
            {
                CharName = name,
                Money    = (Int32)money,
                Ship     = accArch,
                System   = accSystem
            };

            using (var stream = new MemoryStream())
            {
                Serializer.Serialize(stream, accRep);
                acc.RepList = Convert.ToBase64String(stream.ToArray());
            }

            using (var stream = new MemoryStream())
            {
                Serializer.Serialize(stream, accVisits);
                acc.Visits = Convert.ToBase64String(stream.ToArray());
            }

            using (var stream = new MemoryStream())
            {
                Serializer.Serialize(stream, accCargo);
                acc.Cargo = Convert.ToBase64String(stream.ToArray());
            }

            using (var stream = new MemoryStream())
            {
                Serializer.Serialize(stream, accEquip);
                acc.Equipment = Convert.ToBase64String(stream.ToArray());
            }

            var ap = new Appearance
            {
                Body      = accComBody,
                Head      = accComHead,
                LeftHand  = accComLefthand,
                RightHand = accComRighthand,
                Voice     = accVoiceID
            };

            using (var stream = new MemoryStream())
            {
                Serializer.Serialize(stream, ap);
                acc.Appearance = Convert.ToBase64String(stream.ToArray());
            }

            var ss = new ShipState
            {
                Base     = accBase,
                Hull     = health,
                LastBase = accLastBase,
                Position = accPosition,
                RepGroup = accFaction,
                Rotate   = accRotate
            };

            using (var stream = new MemoryStream())
            {
                Serializer.Serialize(stream, ss);
                acc.ShipState = Convert.ToBase64String(stream.ToArray());
            }

            var sets = new Dictionary <string, bool>
            {
                { @"senddeath", accSendDeathMsg },
                { @"sendsystemdeath", accSendSystemDeathMsg }
            };

            using (var stream = new MemoryStream())
            {
                Serializer.Serialize(stream, sets);
                acc.Settings = Convert.ToBase64String(stream.ToArray());
            }


            //TODO: figure out where's ID is stored
            //acc.ID =

            return(acc);
        }
예제 #28
0
 public override void clicked()
 {
     MainGUIMgr.SelectShip(gameObject);
     WeaponGroup.ShowWeaponGroups(weaponGroup[0] != null, weaponGroup[1] != null,
                                  weaponGroup[2] != null, weaponGroup[3] != null, this);
 }
예제 #29
0
 public Weapon(string name, int proficiencyBonus, Dice damage, string range, WeaponGroup group, WeaponProperties properties, WeaponCategory category)
     : this(name, proficiencyBonus, damage, range, group, properties, 0, category, false, 0)
 {
 }
예제 #30
0
 public Weapon(string name, int proficiencyBonus, Dice damage, string range, WeaponGroup group, WeaponProperties properties, WeaponCategory category, int basePrice, bool isTwoHanded)
     : this(name, proficiencyBonus, damage, range, group, properties, basePrice, category, isTwoHanded, 0)
 {
 }