Exemplo n.º 1
1
		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 );
			}
		}
Exemplo n.º 2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            Type = (BarrelType)reader.ReadByte();
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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;
     }
 }
Exemplo n.º 5
0
    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);
    }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
 /// <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);
 }
Exemplo n.º 9
0
        public SupplyBarrel(BarrelType type)
            : base(0x2CDD)
        {
            Name   = GetName(type);
            Weight = 10.0;

            InitContents(type);
            SetType(type);
        }
Exemplo n.º 10
0
		public SupplyBarrel( BarrelType type )
			: base( 0x2CDD )
		{
			Name = GetName( type );
			Weight = 10.0;

			InitContents( type );
			SetType( type );
		}
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
        public Sprite GetBarrelImage(BarrelType barrelType)
        {
            switch (barrelType)
            {
            case BarrelType.Simple:
                return(GetImagePrefab(BarrelPrefabRoot, SimpleBarrel));

            case BarrelType.Modern:
                return(GetImagePrefab(BarrelPrefabRoot, ModernBarrel));
            }

            return(null);
        }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
    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();
    }
Exemplo n.º 15
0
    private BarrelType UpdateLoadingTime(BarrelType bal)
    {
        if (bal.loadingTimeLeft > 0)
        {
            bal.loadingTimeLeft -= Time.deltaTime;
            bal.loaded           = false;
        }

        else
        {
            bal.loaded = true;
        }

        return(bal);
    }
Exemplo n.º 16
0
    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);
    }
Exemplo n.º 17
0
		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;
		}
Exemplo n.º 18
0
    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);
    }
Exemplo n.º 19
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();

			Type = (BarrelType)reader.ReadByte();
		} 
Exemplo n.º 20
0
 public Barrel(string spritePrefabName, BarrelType type, Properties properties)
     : base(spritePrefabName, "Prefabs/Weapons/Weapon Parts/Barrels/", properties)
 {
     this.type = type;
 }
Exemplo n.º 21
0
        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);
                }
            }
        }
Exemplo n.º 22
0
        /// <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;
                    }
                }
            }
        }
Exemplo n.º 23
0
		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;
		}