private void InitContents( BarrelType type ) { Item item = null; byte count = (byte)Utility.RandomMinMax( 10, 30 ); for( byte i = 0; i < count; i++ ) { switch( type ) { default: case BarrelType.Arrows: item = new Arrow( Utility.RandomMinMax( 2, 6 ) ); break; case BarrelType.Bolts: item = new Bolt( Utility.RandomMinMax( 2, 6 ) ); break; case BarrelType.Farming: { if( i > 3 ) return; switch( Utility.Random( 3 ) ) { case 0: item = new Shovel(); break; case 1: item = new Scythe(); break; case 2: item = new Pitchfork(); break; } break; } case BarrelType.LargeMining: { if( i > 5 ) return; switch( Utility.Random( 5 ) ) { case 0: item = new Pitchfork(); break; case 1: case 2: item = new Shovel(); break; case 3: case 4: item = new Pickaxe(); break; } break; } case BarrelType.LargeWeapon1: case BarrelType.LargeWeapon2: case BarrelType.LargeWeapon3: { if( i > 6 ) return; switch( Utility.Random( 6 ) ) { case 0: item = new Spear(); break; case 1: item = new Halberd(); break; case 2: item = new Axe(); break; case 3: item = new ThinLongsword(); break; case 4: item = new WarAxe(); break; case 5: item = new VikingSword(); break; } break; } case BarrelType.Mining: { if( i > 3 ) return; item = new Pickaxe(); break; } case BarrelType.Spears: { if( i > 4 ) return; item = new Spear(); break; } case BarrelType.Weapons: { if( i > 3 ) return; switch( Utility.Random( 3 ) ) { case 0: item = new WarAxe(); break; case 1: item = new WarMace(); break; case 2: item = new Maul(); break; } break; } } if( item != null ) DropItem( item ); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); Type = (BarrelType)reader.ReadByte(); }
private string GetName(BarrelType type) { string name = ""; switch (type) { case BarrelType.Arrows: name = "a barrel of arrows"; break; case BarrelType.Bolts: name = "a barrel of bolts"; break; case BarrelType.Farming: name = "a farming supply barrel"; break; case BarrelType.LargeMining: name = "a large mining supply barrel"; break; case BarrelType.LargeWeapon1: name = "a large weapon barrel"; break; case BarrelType.LargeWeapon2: name = "a large weapon barrel"; break; case BarrelType.LargeWeapon3: name = "a large weapon barrel"; break; case BarrelType.Mining: name = "a mining supply barrel"; break; case BarrelType.Spears: name = "a barrel of spears"; break; default: case BarrelType.Weapons: name = "a barrel of weapons"; break; } return(name); }
void ReadFile(string filename) { try { var lines = FileIO.ReadDataTextFile(filename); var words = FileIO.Split(lines[1]); BarrelType type = (BarrelType)Convert.ToInt32(words[1]); _barrel = new Barrel(type); words = FileIO.Split(lines[2]); _barrel.ManufactureData.SerialNumber = words[1]; words = FileIO.Split(lines[3]); _axialLocation = Convert.ToDouble(words[1]); words = FileIO.Split(lines[4]); _currentPassCt = Convert.ToInt32(words[1]); words = FileIO.Split(lines[5]); _targetPassCt = Convert.ToInt32(words[1]); for (int i = 8; i < lines.Count; i++) { words = FileIO.Split(lines[i]); int index = Convert.ToInt32(words[0]); double theta = GeomUtilities.ToRadians(Convert.ToDouble(words[1])); double depth = Convert.ToDouble(words[2]); var dm = new DepthMeasurement(new PointCyl(), theta, index, depth); this.Add(dm); } _rasterCount = this.Count; } catch (Exception) { throw; } }
void FireShell(BarrelType gun) { // Position of shooting cannon Vector3 cannonPosition = gun.cannon.transform.position; // Position of current target Vector3 targetPosition = _target.transform.position; targetPosition += new Vector3(UnityEngine.Random.Range(-spread, spread), 0, UnityEngine.Random.Range(-spread, spread)); // Create a projectile at the end of cannon GameObject shell = Instantiate(shellPrefab); shell.GetComponent <ShellController>().damage = damage; shell.transform.SetParent(gun.cannon.transform); shell.transform.localPosition = _instantiateOffset; shell.transform.localRotation = Quaternion.Euler(new Vector3(0, 90, 0)); // line up shell with tge cannon shell.transform.parent = null; // Assign instanceID of shooting boat to shell controller shell.GetComponent <ShellController>().FiringBoat = gameObject; // Assign initial velocity of the shell based on target position and calculated flying time Rigidbody rb = shell.GetComponent <Rigidbody>(); rb.velocity = CalculateVelocity(targetPosition, cannonPosition, CalculateFlyingTime(cannonPosition, targetPosition)); ActivateCamera(shell); }
private void SetType(BarrelType type) { int itemId = 0; switch (type) { case BarrelType.Arrows: itemId = 0x2CDD; break; case BarrelType.Bolts: itemId = 0x2CDE; break; case BarrelType.Farming: itemId = 0x2CE5; break; case BarrelType.LargeMining: itemId = 0x2CE4; break; case BarrelType.LargeWeapon1: itemId = 0x2CE1; break; case BarrelType.LargeWeapon2: itemId = 0x2CE2; break; case BarrelType.LargeWeapon3: itemId = 0x2CE3; break; case BarrelType.Mining: itemId = 0x2CDC; break; case BarrelType.Spears: itemId = 0x2CE0; break; default: case BarrelType.Weapons: itemId = 0x2CDF; break; } ItemID = itemId; _type = type; }
/// <summary> /// Initializes a new instance of the <see cref="ChangingAttachmentsEventArgs"/> class. /// </summary> /// <param name="item"><inheritdoc cref="ChangingAttributesEventArgs.OldItem"/></param> /// <param name="newSight"><inheritdoc cref="ChangingAttributesEventArgs.NewSight"/></param> /// <param name="newBarrel"><inheritdoc cref="ChangingAttributesEventArgs.NewBarrel"/></param> /// <param name="newOther"><inheritdoc cref="ChangingAttributesEventArgs.NewOther"/></param> /// <param name="isAllowed"><inheritdoc cref="ChangingAttributesEventArgs.IsAllowed"/></param> public ChangingAttachmentsEventArgs(Inventory.SyncItemInfo item, SightType newSight, BarrelType newBarrel, OtherType newOther, bool isAllowed = true) : base(item, item, isAllowed) { NewSight = newSight; NewBarrel = newBarrel; NewOther = newOther; }
/// <summary> /// Initializes a new instance of the <see cref="ChangingAttachmentsEventArgs"/> class. /// </summary> /// <param name="item"><inheritdoc cref="ChangingAttributesEventArgs.OldItem"/></param> /// <param name="newSight"><inheritdoc cref="NewSight"/></param> /// <param name="newBarrel"><inheritdoc cref="NewBarrel"/></param> /// <param name="newOther"><inheritdoc cref="NewOther"/></param> /// <param name="isAllowed"><inheritdoc cref="ChangingAttributesEventArgs.IsAllowed"/></param> public ChangingAttachmentsEventArgs(Firearm item, SightType newSight, BarrelType newBarrel, OtherType newOther, bool isAllowed = true) : base(item, item, isAllowed) { NewSight = newSight; NewBarrel = newBarrel; NewOther = newOther; OldItem = (API.Features.Items.Firearm)Item.Get(item); }
public SupplyBarrel(BarrelType type) : base(0x2CDD) { Name = GetName(type); Weight = 10.0; InitContents(type); SetType(type); }
public SupplyBarrel( BarrelType type ) : base( 0x2CDD ) { Name = GetName( type ); Weight = 10.0; InitContents( type ); SetType( type ); }
public void Initialize(BarrelType type) { for (int i = 0; i < graphics.Length; i++) { graphics[i].SetActive(false); } graphics[type.graphicsIndex].SetActive(true); isExplosing = false; explosionSkill = type.explosionSkill; }
public Sprite GetBarrelImage(BarrelType barrelType) { switch (barrelType) { case BarrelType.Simple: return(GetImagePrefab(BarrelPrefabRoot, SimpleBarrel)); case BarrelType.Modern: return(GetImagePrefab(BarrelPrefabRoot, ModernBarrel)); } return(null); }
public void Initialize (string name = "NO_NAME_BARREL", InfusionType iType = InfusionType.Electric, BarrelType bType = BarrelType.Carbine, float bLength = 1.0f, float bScale = 0.0f) { moduleType = ModuleType.Barrel; moduleName = name; infusionType = iType; barrelType = bType; barrelLength = bLength; barrelScale = bScale; }
public override void OnInspectorGUI() { BarrelType barrel = target as BarrelType; //GUILayout.Label("Radius: " + barrel.Radius.ToString()); //this is so it can be (control + Z / Undo) SO.Update(); EditorGUILayout.PropertyField(propRadius); EditorGUILayout.PropertyField(propDamage); EditorGUILayout.PropertyField(propColor); SO.ApplyModifiedProperties(); }
private BarrelType UpdateLoadingTime(BarrelType bal) { if (bal.loadingTimeLeft > 0) { bal.loadingTimeLeft -= Time.deltaTime; bal.loaded = false; } else { bal.loaded = true; } return(bal); }
public /*override*/ void OnInspectorGUI_previous() { BarrelType barrel = (BarrelType)target; // Use 'targets' when [CanEditMultipleObjects] // Direct editing without Undo. barrel.Radius = EditorGUILayout.FloatField("Radius", barrel.Radius); // Using the undo system, is a better way. float newDamage = EditorGUILayout.FloatField("Damage", barrel.Damage); if (Math.Abs(newDamage - barrel.Damage) > .001f) { Undo.RecordObject(barrel, "Change barrel radius"); barrel.Damage = newDamage; } barrel.ExplosionColor = EditorGUILayout.ColorField("Color", barrel.ExplosionColor); }
private string GetName( BarrelType type ) { string name = ""; switch( type ) { case BarrelType.Arrows: name = "a barrel of arrows"; break; case BarrelType.Bolts: name = "a barrel of bolts"; break; case BarrelType.Farming: name = "a farming supply barrel"; break; case BarrelType.LargeMining: name = "a large mining supply barrel"; break; case BarrelType.LargeWeapon1: name = "a large weapon barrel"; break; case BarrelType.LargeWeapon2: name = "a large weapon barrel"; break; case BarrelType.LargeWeapon3: name = "a large weapon barrel"; break; case BarrelType.Mining: name = "a mining supply barrel"; break; case BarrelType.Spears: name = "a barrel of spears"; break; default: case BarrelType.Weapons: name = "a barrel of weapons"; break; } return name; }
public GameObject GetBarrel(RangeType rangeType) { if (barrelPool.Count < 1) { FillBarrelPool(); } Barrel newBarrel = barrelPool.Dequeue(); BarrelType type = config.barrelTypes[0]; for (int i = 0; i < config.barrelTypes.Length; i++) { if (config.barrelTypes[i].rangeType == rangeType) { type = config.barrelTypes[i]; break; } } newBarrel.noStartingInit = true; newBarrel.Initialize(type); return(newBarrel.gameObject); }
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); Type = (BarrelType)reader.ReadByte(); }
public Barrel(string spritePrefabName, BarrelType type, Properties properties) : base(spritePrefabName, "Prefabs/Weapons/Weapon Parts/Barrels/", properties) { this.type = type; }
private void InitContents(BarrelType type) { Item item = null; byte count = (byte)Utility.RandomMinMax(10, 30); for (byte i = 0; i < count; i++) { switch (type) { default: case BarrelType.Arrows: item = new Arrow(Utility.RandomMinMax(2, 6)); break; case BarrelType.Bolts: item = new Bolt(Utility.RandomMinMax(2, 6)); break; case BarrelType.Farming: { if (i > 3) { return; } switch (Utility.Random(3)) { case 0: item = new Shovel(); break; case 1: item = new Scythe(); break; case 2: item = new Pitchfork(); break; } break; } case BarrelType.LargeMining: { if (i > 5) { return; } switch (Utility.Random(5)) { case 0: item = new Pitchfork(); break; case 1: case 2: item = new Shovel(); break; case 3: case 4: item = new Pickaxe(); break; } break; } case BarrelType.LargeWeapon1: case BarrelType.LargeWeapon2: case BarrelType.LargeWeapon3: { if (i > 6) { return; } switch (Utility.Random(6)) { case 0: item = new Spear(); break; case 1: item = new Halberd(); break; case 2: item = new Axe(); break; case 3: item = new ThinLongsword(); break; case 4: item = new WarAxe(); break; case 5: item = new VikingSword(); break; } break; } case BarrelType.Mining: { if (i > 3) { return; } item = new Pickaxe(); break; } case BarrelType.Spears: { if (i > 4) { return; } item = new Spear(); break; } case BarrelType.Weapons: { if (i > 3) { return; } switch (Utility.Random(3)) { case 0: item = new WarAxe(); break; case 1: item = new WarMace(); break; case 2: item = new Maul(); break; } break; } } if (item != null) { DropItem(item); } } }
/// <summary> /// Sets barrel modification of the weapon. /// </summary> /// <param name="player">The player instance.</param> /// <param name="weapon">The weapon with attachment.</param> /// <param name="type">Type of the barrel.</param> public static void SetBarrel(this Player player, Inventory.SyncItemInfo weapon, BarrelType type) { WeaponManager wmanager = player.ReferenceHub.weaponManager; if (weapon.id.IsWeapon()) { WeaponManager.Weapon wep = wmanager.weapons.FirstOrDefault(wp => wp.inventoryID == weapon.id); if (wep != null) { string name = type.ToString("g").SplitCamelCase(); int weaponMod = wep.mod_barrels.Select((s, i) => new { s, i }).Where(e => e.s.name == name).Select(e => e.i).FirstOrDefault(); int weaponId = player.Inventory.items.FindIndex(s => s == weapon); weapon.modBarrel = weaponMod; if (weaponId > -1) { player.Inventory.items[weaponId] = weapon; } } } }
private void SetType( BarrelType type ) { int itemId = 0; switch( type ) { case BarrelType.Arrows: itemId = 0x2CDD; break; case BarrelType.Bolts: itemId = 0x2CDE; break; case BarrelType.Farming: itemId = 0x2CE5; break; case BarrelType.LargeMining: itemId = 0x2CE4; break; case BarrelType.LargeWeapon1: itemId = 0x2CE1; break; case BarrelType.LargeWeapon2: itemId = 0x2CE2; break; case BarrelType.LargeWeapon3: itemId = 0x2CE3; break; case BarrelType.Mining: itemId = 0x2CDC; break; case BarrelType.Spears: itemId = 0x2CE0; break; default: case BarrelType.Weapons: itemId = 0x2CDF; break; } ItemID = itemId; _type = type; }