Exemplo n.º 1
0
        public static BulletBase Create(BulletAsset BulletAsset, WeaponRanged weaponRanged)
        {
            BulletBase BulletBase;

            // 弾の種類を判断
            switch (BulletAsset.BulletType)
            {
            // 弾
            case BulletType.Projectile:
                BulletBase = new BulletProjectile(BulletAsset, weaponRanged);
                Debug.Log("Bulletrojectile");
                break;

            // レーザー
            case BulletType.Lazer:
                BulletBase = new BulletProjectileLaser(BulletAsset, weaponRanged);
                Debug.Log("BulletLaser");
                break;

            default:
                BulletBase = null;
                break;
            }

            BulletBase.weaponRanged = weaponRanged;

            return(BulletBase);
        }
Exemplo n.º 2
0
    public void SetUp(WeaponRanged w)
    {
        Bullet b = w.bullet.GetComponent <Bullet>();

        texts[0].text = w.name;
        texts[1].text = "Spread: " + w.spread;
        texts[2].text = "Recoil: " + w.recoil;
        texts[3].text = "Damage: " + b.damage;
        texts[4].text = "Bullet speed: " + b.speed;
        texts[5].text = "Bullet Reach: " + b.time;

        img.sprite = w.GetComponentInChildren <SpriteRenderer>().sprite;
    }
Exemplo n.º 3
0
    public bool AddWeapon(string weaponName, int mags)
    {
        if (string.IsNullOrEmpty(weaponName))
        {
            return(false);
        }

        if (!AttachRightBack)
        {
            Debug.Log("Missing an attachPoint");
            return(false);
        }

        Debug.Log("Getting " + weaponName + " for " + gameObject.name);
        GameObject weaponObj = gameManager.GetEquipment(weaponName);

        if (!weaponObj)
        {
            return(false);
        }

        Weapon weapon = weaponObj.GetComponent <Weapon>();

        weaponObj.transform.SetParent(AttachRightBack, false);

        if (weapon)
        {
            weapon.Init(this);
            unitAttack.AddWeapon(weapon, !weapon.isSecondary);
            unitAttack.DrawWeapon(weapon);

            WeaponRanged weaponRanged = weaponObj.GetComponent <WeaponRanged>();
            if (weaponRanged)
            {
                weaponRanged.AddMagazines(mags);
            }

            if (weapon.animOverride)
            {
                animator.runtimeAnimatorController = weapon.animOverride;
            }
        }
        else
        {
            return(false);
        }
        return(true);
    }
Exemplo n.º 4
0
    public void Init(WeaponRanged parent)
    {
        weapon       = parent;
        background   = transform.Find("Background").GetComponent <Image>();
        ammoCount    = transform.Find("AmmoCount").GetComponent <Text>();
        magazineIcon = transform.Find("MagazineIcon").GetComponent <Image>();
        canvas       = GetComponent <CanvasGroup>();
        connector    = transform.Find("Line").GetComponent <LineRenderer>();
        connectorDot = transform.Find("Dot").GetComponent <Image>();
        Text label = transform.Find("WeaponLabel").GetComponent <Text>();

        label.text = weapon.name.ToUpper();

        IsOpen  = false;
        UIColor = startColor;
    }
Exemplo n.º 5
0
 public BulletProjectileLaser(BulletAsset asset, WeaponRanged weaponRanged) : base(asset, weaponRanged)
 {
 }
Exemplo n.º 6
0
 protected BulletBase(BulletAsset asset, WeaponRanged weaponRanged)
 {
     BulletPara   = asset.BulletParameter;
     BulletPrefab = asset.BulletPrefab;
     LaserPrefab  = asset.LaserPrefab;
 }
Exemplo n.º 7
0
        private static WeaponRanged MakeRow(ThingDef d, bool hasCombatExtended, Type ammoUserType = null)
        {
            var row = new WeaponRanged {
                Label = d.LabelCap, Description = d.DescriptionDetailed, MarketValue = d.BaseMarketValue, ItemsOnMap = d.CountOnMap()
            };

            row.TechLevel = d.techLevel.ToStringHuman().CapitalizeFirst();

            try
            {
                row.TexturePath = d.modContentPack.RootDir + @"\Textures\" + d.graphicData.texPath;
            }
            catch
            {
            }

            try
            {
                var accuracyTouch  = d.GetStatValueAbstract(StatDefOf.AccuracyTouch).ToPercent();
                var accuracyShort  = d.GetStatValueAbstract(StatDefOf.AccuracyShort).ToPercent();
                var accuracyMedium = d.GetStatValueAbstract(StatDefOf.AccuracyMedium).ToPercent();
                var accuracyLong   = d.GetStatValueAbstract(StatDefOf.AccuracyLong).ToPercent();
                var cooldown       = d.GetStatValueAbstract(StatDefOf.RangedWeapon_Cooldown);
                var mass           = d.BaseMass;

                var   verb                   = d.Verbs.OfType <VerbProperties>().FirstOrDefault();
                int   damage                 = getDamageAmount(d, verb.defaultProjectile.projectile);
                int   burstShotCount         = verb.burstShotCount > 0 ? verb.burstShotCount : 1;
                int   ticksBetweenBurstShots = verb.ticksBetweenBurstShots > 0 ? verb.ticksBetweenBurstShots : 10;
                float warmup                 = verb.warmupTime;
                float maxRange               = verb.range;
                float minRange               = verb.minRange;
                float burstShotFireRate      = (float)Math.Round(60f / verb.ticksBetweenBurstShots.TicksToSeconds());

                row.CanCraft       = d.CanCraft();
                row.Dps            = getDps(damage, burstShotCount, cooldown, warmup, ticksBetweenBurstShots);
                row.Rpm            = burstShotFireRate;
                row.Damage         = damage;
                row.BurstShotCount = burstShotCount;
                row.MaxRange       = maxRange;
                row.Cooldown       = cooldown;
                row.WarmupTime     = warmup;
                row.Accuracy       = getAccuracyStr(minRange, maxRange, accuracyTouch, accuracyShort, accuracyMedium, accuracyLong);

                if (hasCombatExtended)
                {
                    var ceAmmo = d.comps.FirstOrDefault(x => x.GetType() == ammoUserType); // d.GetCompProperties<CompProperties_AmmoUser>()
                    row.DamageType = ceAmmo != null?Traverse.Create(ceAmmo).Field("ammoSet").Field("label").GetValue <string>() : verb.defaultProjectile.projectile.damageDef.label;

                    row.CE_SightsEfficiency = d.GetStatValueAbstract(StatDef.Named("SightsEfficiency")).ToPercent();
                    row.CE_ShotSpread       = d.GetStatValueAbstract(StatDef.Named("ShotSpread"));
                    row.CE_SwayFactor       = d.GetStatValueAbstract(StatDef.Named("SwayFactor"));
                    row.CE_OneHanded        = d.weaponTags?.Contains("CE_OneHandedWeapon") ?? false;
                }
                else
                {
                    row.DamageType = verb.defaultProjectile.projectile.damageDef.label;
                }

                if (d.weaponTags != null)
                {
                    row.WeaponTags = string.Join("; ", d.weaponTags.OrderBy(x => x).ToArray());
                }
            }
            catch (Exception e)
            {
                Log.Error($"{d.LabelCap} - {e.Message} - {e.StackTrace}");
            }

            return(row);
        }