Ejemplo n.º 1
0
        public GuidedMissileLauncher(WeaponTargeting weapon)
        {
            m_weaponTarget      = weapon;
            m_relayPart         = RelayClient.GetOrCreateRelayPart(m_weaponTarget.CubeBlock);
            this._initialTarget = NoTarget.Instance;

            MyWeaponBlockDefinition defn = (MyWeaponBlockDefinition)CubeBlock.GetCubeBlockDefinition();

            Vector3[] points        = new Vector3[3];
            Vector3   forwardAdjust = Vector3.Forward * WeaponDescription.GetFor(CubeBlock).MissileSpawnForward;

            points[0] = CubeBlock.LocalAABB.Min + forwardAdjust;
            points[1] = CubeBlock.LocalAABB.Max + forwardAdjust;
            points[2] = CubeBlock.LocalAABB.Min + Vector3.Up * defn.Size.Y * CubeBlock.CubeGrid.GridSize + forwardAdjust;

            MissileSpawnBox = BoundingBox.CreateFromPoints(points);
            if (m_weaponTarget.myTurret != null)
            {
                Log.TraceLog("original box: " + MissileSpawnBox);
                MissileSpawnBox.Inflate(CubeBlock.CubeGrid.GridSize * 2f);
            }

            Log.TraceLog("MissileSpawnBox: " + MissileSpawnBox);

            myInventory = ((MyEntity)CubeBlock).GetInventoryBase(0);

            Registrar.Add(weapon.CubeBlock, this);
            m_weaponTarget.GuidedLauncher = true;

            m_gameCooldownTime = TimeSpan.FromSeconds(60d / MyDefinitionManager.Static.GetWeaponDefinition(defn.WeaponDefinitionId).WeaponAmmoDatas[(int)MyAmmoType.Missile].RateOfFire);
            Log.TraceLog("m_gameCooldownTime: " + m_gameCooldownTime);

            CubeBlock.AppendingCustomInfo += CubeBlock_AppendingCustomInfo;
        }
Ejemplo n.º 2
0
        public void OnShoot(Vector2 forward, float speed, WeaponDescription weapon) {
            // suppress unity warnings
            // todo: reserve for other use
            if(hasShot)
                return;
            hasShot = true;

            if(forward.sqrMagnitude < .001f)
                return;

            forward.Normalize();
            // local right is pointing at forward(param)
            rb.AddForce(forward * speed, ForceMode2D.Impulse);
            // todo: set ui rotation

            // todo: use SO
            if(bms.Remove(BulletModifier.Xiandan)) {
                const int shotnum = 5;
                const float spreadDeg = 15;
                for(var i = 0; i < shotnum; ++i) {
                    var rot = Quaternion.AngleAxis(Random.Range(-spreadDeg, spreadDeg), Vector3.forward);
                    BulletUtils.ShootBullet(gameObject,
                                            transform,
                                            rot * forward,
                                            weapon,
                                            bms);
                }
            }
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            base.Initialize();

            _primaryWeaponDescription   = Registry.WeaponDescriptions[(int)_player.PrimaryWeaponType];
            _secondaryWeaponDescription = Registry.WeaponDescriptions[(int)_player.SecondaryWeaponType];

            _shootTimer.Completed += () => _canShoot = true;
        }
Ejemplo n.º 4
0
    public WeaponDescription spawnWeaponDescription()
    {
        GameObject instance = Instantiate(m_WeaponDescriptionPrefab, Vector3.zero, Quaternion.identity) as GameObject;

        instance.transform.SetParent(m_WeaponDescriptionParent, false);
        WeaponDescription script = instance.GetComponent <WeaponDescription> ();

        script.init();
        return(script);
    }
Ejemplo n.º 5
0
 public PrimaryWeapon(WeaponDescription description, Rectangle playerRectangle, int index)
 {
     _index          = index;
     _description    = description;
     PlayerRectangle = playerRectangle;
     Speed           = (int)description.Speed;
     Interval        = description.Interval;
     Damage          = description.Damage;
     Acceleration    = description.Acceleration;
     AssetName       = description.AssetName;
 }
Ejemplo n.º 6
0
	public void initDescription()
	{
		m_Description = UiManager.Instance.spawnWeaponDescription ();
		m_Description.setDamage (m_WeaponFeatures.m_Damage,m_WeaponFeatures.m_ShotNumber);
		m_Description.setEnergy (m_WeaponFeatures.m_EnergyCost);
		if (m_WeaponFeatures.m_IsPiercing) {
			m_Description.addPassive ("PiercePassive");
		}
		foreach (WeaponEffect effect in m_WeaponFeatures.m_WeaponEffects) {
			m_Description.addPassive (effect.getPassiveName (), effect.getPassiveValue ());
		}
		m_Description.gameObject.SetActive (false);
	}
        private static void ItemDefinitionCopyBuilder(ItemDefinition sourceItemDefinition, string name, string weaponType, List <string> weaponTags)
        {
            Guid           newGuid             = GuidHelper.Create(ModGuidNamespace, name);
            ItemDefinition builtItemDefinition = ScriptableObject.CreateInstance <ItemDefinition>();

            Traverse.Create(builtItemDefinition).Field("name").SetValue(name);
            WeaponDescription sourceWeaponDescription = (WeaponDescription)Traverse.Create(sourceItemDefinition).Field("weaponDefinition").GetValue();

            Traverse.Create(sourceWeaponDescription).Field("weaponType").SetValue(weaponType);
            Traverse.Create(sourceWeaponDescription).Field("weaponTags").SetValue(weaponTags);

            builtItemDefinition.name = name;
            Traverse.Create(builtItemDefinition).Field("inDungeonEditor").SetValue(sourceItemDefinition.InDungeonEditor);
            Traverse.Create(builtItemDefinition).Field("merchantCategory").SetValue(sourceItemDefinition.MerchantCategory);
            Traverse.Create(builtItemDefinition).Field("weight").SetValue(sourceItemDefinition.Weight);
            Traverse.Create(builtItemDefinition).Field("slotTypes").SetValue(sourceItemDefinition.SlotTypes);
            Traverse.Create(builtItemDefinition).Field("slotsWhereActive").SetValue(sourceItemDefinition.SlotsWhereActive);
            Traverse.Create(builtItemDefinition).Field("forceEquipSlot").SetValue(sourceItemDefinition.ForceEquipSlot);
            Traverse.Create(builtItemDefinition).Field("stackSize").SetValue(sourceItemDefinition.StackSize);
            Traverse.Create(builtItemDefinition).Field("defaultStackCount").SetValue(sourceItemDefinition.DefaultStackCount);
            Traverse.Create(builtItemDefinition).Field("costs").SetValue(sourceItemDefinition.Costs);
            Traverse.Create(builtItemDefinition).Field("itemTags").SetValue(sourceItemDefinition.ItemTags);
            Traverse.Create(builtItemDefinition).Field("activeTags").SetValue(sourceItemDefinition.ActiveTags);
            Traverse.Create(builtItemDefinition).Field("inactiveTags").SetValue(sourceItemDefinition.InactiveTags);
            Traverse.Create(builtItemDefinition).Field("requiredAttunementClasses").SetValue(sourceItemDefinition.RequiredAttunementClasses);
            Traverse.Create(builtItemDefinition).Field("staticProperties").SetValue(sourceItemDefinition.StaticProperties);
            Traverse.Create(builtItemDefinition).Field("armorDefinition").SetValue(sourceItemDefinition.ArmorDescription);
            Traverse.Create(builtItemDefinition).Field("isWeapon").SetValue(sourceItemDefinition.IsWeapon);
            Traverse.Create(builtItemDefinition).Field("ammunitionDefinition").SetValue(sourceItemDefinition.AmmunitionDescription);
            Traverse.Create(builtItemDefinition).Field("usableDeviceDescription").SetValue(sourceItemDefinition.UsableDeviceDescription);
            Traverse.Create(builtItemDefinition).Field("toolDefinition").SetValue(sourceItemDefinition.ToolDescription);
            Traverse.Create(builtItemDefinition).Field("starterPackDefinition").SetValue(sourceItemDefinition.StarterPackDescription);
            Traverse.Create(builtItemDefinition).Field("containerItemDefinition").SetValue(sourceItemDefinition.ContainerItemDescription);
            Traverse.Create(builtItemDefinition).Field("lightSourceItemDefinition").SetValue(sourceItemDefinition.LightSourceItemDescription);
            Traverse.Create(builtItemDefinition).Field("focusItemDefinition").SetValue(sourceItemDefinition.FocusItemDescription);
            Traverse.Create(builtItemDefinition).Field("wealthPileDefinition").SetValue(sourceItemDefinition.WealthPileDescription);
            Traverse.Create(builtItemDefinition).Field("spellbookDefinition").SetValue(sourceItemDefinition.SpellbookDescription);
            Traverse.Create(builtItemDefinition).Field("documentDescription").SetValue(sourceItemDefinition.DocumentDescription);
            Traverse.Create(builtItemDefinition).Field("foodDescription").SetValue(sourceItemDefinition.FoodDescription);
            Traverse.Create(builtItemDefinition).Field("factionRelicDescription").SetValue(sourceItemDefinition.FactionRelicDescription);
            Traverse.Create(builtItemDefinition).Field("personalityFlagOccurences").SetValue(sourceItemDefinition.PersonalityFlagOccurences);
            Traverse.Create(builtItemDefinition).Field("soundEffectDescriptionOverride").SetValue(sourceItemDefinition.SoundEffectDescription);
            Traverse.Create(builtItemDefinition).Field("soundEffectOnHitDescriptionOverride").SetValue(sourceItemDefinition.SoundEffectOnHitDescription);
            Traverse.Create(builtItemDefinition).Field("itemPresentation").SetValue(sourceItemDefinition.ItemPresentation);
            Traverse.Create(builtItemDefinition).Field("guiPresentation").SetValue(sourceItemDefinition.GuiPresentation);
            Traverse.Create(builtItemDefinition).Field("guid").SetValue(newGuid.ToString());
            DatabaseRepository.GetDatabase <ItemDefinition>().Add(builtItemDefinition);
        }
Ejemplo n.º 8
0
        private static WeaponDescription InitWeaponDescription(WeaponType type, string color, int id)
        {
            WeaponDescription desc = new WeaponDescription();

            desc.Id         = id;
            desc.SoundAsset = "";
            switch (type)
            {
            case WeaponType.Burst:
                desc.AssetName    = "Weapons/Burst/burst_blue";
                desc.WeaponType   = type;
                desc.Interval     = 45;
                desc.Damage       = 15;
                desc.Speed        = 6;
                desc.Acceleration = new Vector2(2.0f, 2.0f);
                break;

            case WeaponType.Laser:
                desc.AssetName    = "Weapons/Lasers/laser_green";
                desc.WeaponType   = type;
                desc.Interval     = 250;
                desc.Damage       = 55;
                desc.Speed        = 6;
                desc.Acceleration = new Vector2(0, 2.0f);
                break;

            case WeaponType.Missile:
                desc.AssetName    = "Weapons/Missile/missile";
                desc.WeaponType   = type;
                desc.Interval     = 1500;
                desc.Damage       = 105;
                desc.Speed        = 6;
                desc.Acceleration = new Vector2(0, 2.0f);
                break;

            case WeaponType.Sphere:
                desc.AssetName    = "Weapons/Sphere/sphere_blue";
                desc.WeaponType   = type;
                desc.Interval     = 75;
                desc.Damage       = 15;
                desc.Speed        = 8;
                desc.Acceleration = new Vector2(2.0f, 2.0f);
                break;
            }

            return(desc);
        }
Ejemplo n.º 9
0
        public static BulletMove ShootBullet(GameObject bulletPrefab,
                                             Transform bulletGenPoint,
                                             Vector2 forward,
                                             WeaponDescription currWeapon,
                                             HashSet <BulletModifier> overrideModifiers = null)
        {
            var bullet = GameObject.Instantiate(bulletPrefab, bulletGenPoint.position, bulletGenPoint.rotation);

            SetDebugTint(bullet, currWeapon.bulletTint);

            var bulletMove = bullet.GetComponent <BulletMove>();

            bulletMove.SetBulletModifiers(overrideModifiers ?? BulletModifierUI.Instance.BulletModifiers);
            bulletMove.OnShoot(forward, 10, currWeapon);

            return(bulletMove);
        }
Ejemplo n.º 10
0
 public static bool IsGuidedMissileLauncher(IMyCubeBlock block)
 {
     return(block is IMyUserControllableGun && WeaponDescription.GetFor(block).GuidedMissileLauncher);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Saves the weapon.
        /// </summary>
        /// <returns>Weapon Object</returns>
        public Weapon SaveWeapon()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "InsertUpdate_Weapon";
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponID", SqlDbType.Int, WeaponID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponName", SqlDbType.VarChar, WeaponName.ToString(), 50));
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponTypeID", SqlDbType.Int, WeaponTypeID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponSizeID", SqlDbType.Int, WeaponSizeID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Cost", SqlDbType.Int, Cost.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@RateOfFire", SqlDbType.VarChar, RateOfFire.ToString(), 3));
                command.Parameters.Add(dbconn.GenerateParameterObj("@DamageDieNumber", SqlDbType.Int, DamageDieNumber.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@DamageDieType", SqlDbType.Int, DamageDieType.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Stun", SqlDbType.Bit, Stun.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@StunDieNumber", SqlDbType.Int, DamageDieNumber.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@StunDieType", SqlDbType.Int, DamageDieType.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponDescription", SqlDbType.Text, WeaponDescription.ToString(), 4000));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Weight", SqlDbType.Decimal, Weight.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@BookID", SqlDbType.Int, BookID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponProficiencyFeatID", SqlDbType.Int, WeaponProficiencyFeatID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@EmplacementPoints", SqlDbType.Int, EmplacementPoints.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@DoubleWeapon", SqlDbType.Bit, DoubleWeapon.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@AreaOfAttack", SqlDbType.Bit, AreaOfAttack.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Accurate", SqlDbType.Bit, AreaOfAttack.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Inaccurate", SqlDbType.Bit, AreaOfAttack.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Slugthrower", SqlDbType.Bit, Slugthrower.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@RequiresSeperateAmmo", SqlDbType.Bit, RequiresSeperateAmmo.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ExtraDamage", SqlDbType.Bit, ExtraDamage.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ExtraStunDamage", SqlDbType.Bit, ExtraStunDamage.ToString(), 0));

                result = command.ExecuteReader();

                result.Read();
                SetReaderToObject(ref result);
            }
            catch
            {
                Exception e = new Exception();
                this._insertUpdateOK = false;
                this._insertUpdateMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this);
        }
Ejemplo n.º 12
0
 private void UpdateImage(WeaponDescription desc)
 {
     weaponImage.sprite = desc.onHandSprite;
 }
Ejemplo n.º 13
0
    public static void CreateAsset()
    {
        WeaponDescription desc = ScriptableObjectUtil.CreateAsset <WeaponDescription>();

        desc.type = ItemTypes.Weapon;
    }
            static void Postfix(RulesetCharacterHero __instance, ref RulesetAttackMode __result, ref WeaponDescription weaponDescription)
            {
                DamageForm           firstDamageForm = __result.EffectDescription.FindFirstDamageForm();
                WeaponTypeDefinition element         = DatabaseRepository.GetDatabase <WeaponTypeDefinition>().GetElement(weaponDescription.WeaponType);
                int originalAbilityScoreModifier     = AttributeDefinitions.ComputeAbilityScoreModifier(__instance.Attributes[__result.AbilityScore].CurrentValue);

                __result.AbilityScore = element.WeaponProximity == RuleDefinitions.AttackProximity.Melee ? "Strength" : "Dexterity";
                if (weaponDescription.WeaponTags.Contains("Finesse") && __instance.GetAttribute("Dexterity").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue)
                {
                    __result.AbilityScore = "Dexterity";
                }
                if (weaponDescription.WeaponTags.Contains("Knowledge") && __instance.GetAttribute("Intelligence").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue)
                {
                    __result.AbilityScore = "Intelligence";
                }
                if (weaponDescription.WeaponTags.Contains("Intuition") && __instance.GetAttribute("Wisdom").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue)
                {
                    __result.AbilityScore = "Wisdom";
                }
                if (weaponDescription.WeaponTags.Contains("Vigor") && __instance.GetAttribute("Constitution").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue)
                {
                    __result.AbilityScore = "Constitution";
                }
                if (weaponDescription.WeaponTags.Contains("Influence") && __instance.GetAttribute("Charisma").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue)
                {
                    __result.AbilityScore = "Charisma";
                }

                int abilityScoreModifier = AttributeDefinitions.ComputeAbilityScoreModifier(__instance.Attributes[__result.AbilityScore].CurrentValue);

                Predicate <RuleDefinitions.TrendInfo> predicate = FindAbilityScoreTrend;
                int ability_score_to_hit_trend_index            = __result.ToHitBonusTrends.FindIndex(predicate);
                int ability_score_damage_bonus_trend_index      = firstDamageForm.DamageBonusTrends.FindIndex(predicate);

                if (ability_score_to_hit_trend_index >= 0)
                {
                    __result.ToHitBonus -= originalAbilityScoreModifier;
                    __result.ToHitBonus += abilityScoreModifier;
                    __result.ToHitBonusTrends.RemoveAt(ability_score_to_hit_trend_index);
                    __result.ToHitBonusTrends.Add(new RuleDefinitions.TrendInfo(abilityScoreModifier, RuleDefinitions.FeatureSourceType.AbilityScore, __result.AbilityScore, (object)null));
                }

                if (ability_score_damage_bonus_trend_index >= 0)
                {
                    firstDamageForm.DamageBonusTrends.RemoveAt(ability_score_damage_bonus_trend_index);
                    firstDamageForm.BonusDamage -= originalAbilityScoreModifier;
                    firstDamageForm.BonusDamage += abilityScoreModifier;
                    firstDamageForm.DamageBonusTrends.Add(new RuleDefinitions.TrendInfo(abilityScoreModifier, RuleDefinitions.FeatureSourceType.AbilityScore, __result.AbilityScore, (object)null));
                }
            }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseWeapon"/> class.
        /// </summary>
        /// <param name="game">The game to spawn this weapon in.</param>
        /// <param name="weaponDescription">The weapon description.</param>
        /// <param name="name">The name of the weapon</param>
        public BaseWeapon(ICanyonShooterGame game, WeaponHolderType weaponHolderType, string weaponDescription, WeaponManager weaponManager, string name) : base(game, name)
        {
            this.game        = game;
            manager          = weaponManager;
            WeaponHolderType = weaponHolderType;

            if (weaponDescription == String.Empty)
            {
                return;
            }

            // Load Weapon Description
            desc = game.Content.Load <WeaponDescription>("Content\\Weapons\\" + weaponDescription);

            // Load Model
            if (desc.Model != String.Empty)
#pragma warning disable DoNotCallOverridableMethodsInConstructor
            {
                SetModel(desc.Model);
            }
#pragma warning restore DoNotCallOverridableMethodsInConstructor

            // Load AmmoType
            ammoType = (AmmoType)Enum.Parse(typeof(AmmoType), desc.AmmoType);

            // Load Ammo
            Ammo += desc.DefaultAmmo;
            //if (desc.AmmoReloadCount > desc.DefaultAmmo)
            //{
            //    ammoInMagazine = desc.DefaultAmmo;
            //    Ammo = 0;
            //}
            //else
            //{
            //    ammoInMagazine = desc.AmmoReloadCount;
            //    Ammo += desc.DefaultAmmo - desc.AmmoReloadCount;
            //}

            // Load Sounds:
            if (desc.SoundFiring != String.Empty)
            {
                soundFiring        = game.Sounds.CreateSound(desc.SoundFiring);
                soundFiring.Parent = this;
            }
            if (desc.SoundStartFire != String.Empty)
            {
                soundStartFire        = game.Sounds.CreateSound(desc.SoundStartFire);
                soundStartFire.Parent = this;
            }
            if (desc.SoundStopFire != String.Empty)
            {
                soundStopFire        = game.Sounds.CreateSound(desc.SoundStopFire);
                soundStopFire.Parent = this;
            }
            if (desc.SoundReload != String.Empty)
            {
                soundReload        = game.Sounds.CreateSound(desc.SoundReload);
                soundReload.Parent = this;
            }
            if (desc.SoundAmmoEmpty != String.Empty)
            {
                soundAmmoEmpty        = game.Sounds.CreateSound(desc.SoundAmmoEmpty);
                soundAmmoEmpty.Parent = this;
            }
            state = WeaponState.NOTHING;
        }