Ejemplo n.º 1
0
        public static void InitSynergyForm(Gun original)
        {
            Gun gun = ETGMod.Databases.Items.NewGun("Synergy Lich's Gun", "lichsgun2");

            Game.Items.Rename("outdated_gun_mods:synergy_lich's_gun", "spapi:lichs_gun+master_of_the_gungeon");
            GunExt.SetShortDescription(gun, "Bullet Dance");
            GunExt.SetLongDescription(gun, "This is Gun from Gungeon Master.");
            GunExt.SetupSprite(gun, null, "lichsgun2_idle_001", 10);
            GunExt.SetAnimationFPS(gun, gun.shootAnimation, 12);
            GunExt.AddProjectileModuleFrom(gun, "klobb", true, false);
            gun.DefaultModule.shootStyle    = ProjectileModule.ShootStyle.SemiAutomatic;
            gun.DefaultModule.angleVariance = 0;
            gun.DefaultModule.ammoType      = GameUIAmmoType.AmmoType.MEDIUM_BULLET;
            InputGuidedProjectile projectile = CopyFields <InputGuidedProjectile>(UnityEngine.Object.Instantiate((PickupObjectDatabase.GetById(183) as Gun).DefaultModule.projectiles[0]));

            projectile.trackingSpeed = 500f;
            projectile.dumbfireTime  = -1f;
            projectile.gameObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(projectile.gameObject);
            UnityEngine.Object.DontDestroyOnLoad(projectile);
            gun.DefaultModule.projectiles[0] = projectile;
            projectile.baseData.damage       = 8f;
            projectile.shouldRotate          = true;
            projectile.name           = "LichsGun2_Projectile";
            projectile.baseData.range = 40f;
            projectile.baseData.speed = 22f;
            SetProjectileSpriteRight(projectile, "lichsgun_projectile_001", 6, 6, false, tk2dBaseSprite.Anchor.MiddleCenter, true, false, null, null, null, null, (PickupObjectDatabase.GetById(183) as Gun).DefaultModule.projectiles[0]);
            gun.reloadClipLaunchFrame             = 0;
            gun.DefaultModule.cooldownTime        = 0.1f;
            gun.DefaultModule.numberOfShotsInClip = 17;
            for (int i = 0; i < gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames.Length; i++)
            {
                gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames[i].triggerEvent = true;
                tk2dSpriteDefinition def = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames[i].spriteCollection.spriteDefinitions[gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames[i].spriteId];
                Vector2 offset           = new Vector2(((float)synergyFireOffsets[i].x) / 16f, ((float)synergyFireOffsets[i].y) / 16f);
                LichsBookItem.MakeOffset(def, offset);
            }
            for (int i = 0; i < gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames.Length; i++)
            {
                gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames[i].triggerEvent = true;
                tk2dSpriteDefinition def = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames[i].spriteCollection.spriteDefinitions[gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames[i].spriteId];
                Vector2 offset           = new Vector2(((float)synergyReloadOffsets[i].x) / 16f, ((float)synergyReloadOffsets[i].y) / 16f);
                LichsBookItem.MakeOffset(def, offset);
            }
            gun.gunSwitchGroup     = "Colt1851";
            gun.gunHandedness      = GunHandedness.HiddenOneHanded;
            gun.muzzleFlashEffects = original.muzzleFlashEffects;
            gun.reloadTime         = 1.1f;
            gun.SetBaseMaxAmmo(700);
            gun.quality = PickupObject.ItemQuality.SPECIAL;
            gun.barrelOffset.transform.localPosition = new Vector3(1.1875f, 0.5625f, 0f);
            gun.gunClass = GunClass.PISTOL;
            ETGMod.Databases.Items.Add(gun, null, "ANY");
            AdvancedTransformGunSynergyProcessor processor = original.gameObject.AddComponent <AdvancedTransformGunSynergyProcessor>();

            processor.NonSynergyGunId = original.PickupObjectId;
            processor.SynergyGunId    = gun.PickupObjectId;
            processor.SynergyToCheck  = "Master of Gungeon";
        }
Ejemplo n.º 2
0
        public static void Init()
        {
            Gun gun = ETGMod.Databases.Items.NewGun("Lich's Gun", "lichsgun");

            Game.Items.Rename("outdated_gun_mods:lich's_gun", "spapi:lichs_gun");
            GunExt.SetShortDescription(gun, "Bullet Dance");
            GunExt.SetLongDescription(gun, "This is Gun from Gungeon Master.");
            GunExt.SetupSprite(gun, null, "lichsgun_idle_001", 10);
            GunExt.SetAnimationFPS(gun, gun.shootAnimation, 12);
            GunExt.AddProjectileModuleFrom(gun, "klobb", true, false);
            gun.DefaultModule.shootStyle    = ProjectileModule.ShootStyle.SemiAutomatic;
            gun.DefaultModule.angleVariance = 0;
            gun.DefaultModule.ammoType      = GameUIAmmoType.AmmoType.MEDIUM_BULLET;
            InputGuidedProjectile projectile = CopyFields <InputGuidedProjectile>(UnityEngine.Object.Instantiate((PickupObjectDatabase.GetById(183) as Gun).DefaultModule.projectiles[0]));

            projectile.trackingSpeed = 500f;
            projectile.dumbfireTime  = -1f;
            projectile.gameObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(projectile.gameObject);
            UnityEngine.Object.DontDestroyOnLoad(projectile);
            gun.DefaultModule.projectiles[0] = projectile;
            projectile.baseData.damage       = 5f;
            projectile.shouldRotate          = true;
            projectile.name           = "LichsGun_Projectile";
            projectile.baseData.range = 18f;
            projectile.baseData.speed = 22f;
            SetProjectileSpriteRight(projectile, "lichsgun_projectile_001", 6, 6, false, tk2dBaseSprite.Anchor.MiddleCenter, true, false, null, null, null, null, (PickupObjectDatabase.GetById(183) as Gun).DefaultModule.projectiles[0]);
            gun.reloadClipLaunchFrame             = 0;
            gun.DefaultModule.cooldownTime        = 0.1f;
            gun.DefaultModule.numberOfShotsInClip = 6;
            for (int i = 0; i < gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames.Length; i++)
            {
                gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames[i].triggerEvent = true;
                tk2dSpriteDefinition def = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames[i].spriteCollection.spriteDefinitions[gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames[i].spriteId];
                Vector2 offset           = new Vector2(((float)fireOffsets[i].x) / 16f, ((float)fireOffsets[i].y) / 16f);
                LichsBookItem.MakeOffset(def, offset);
            }
            for (int i = 0; i < gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames.Length; i++)
            {
                gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames[i].triggerEvent = true;
                tk2dSpriteDefinition def = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames[i].spriteCollection.spriteDefinitions[gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames[i].spriteId];
                Vector2 offset           = new Vector2(((float)reloadOffsets[i].x) / 16f, ((float)reloadOffsets[i].y) / 16f);
                LichsBookItem.MakeOffset(def, offset);
            }
            tk2dSpriteAnimationClip reloadClip = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation);

            reloadClip.frames = new tk2dSpriteAnimationFrame[0];
            foreach (string text in reloadFrames)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame {
                    spriteCollection = ETGMod.Databases.Items.WeaponCollection, spriteId = ETGMod.Databases.Items.WeaponCollection.GetSpriteIdByName(text)
                };
                reloadClip.frames = reloadClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            tk2dSpriteAnimationClip shootClip = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation);

            shootClip.frames = new tk2dSpriteAnimationFrame[0];
            foreach (string text in shootFrames)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame {
                    spriteCollection = ETGMod.Databases.Items.WeaponCollection, spriteId = ETGMod.Databases.Items.WeaponCollection.GetSpriteIdByName(text)
                };
                shootClip.frames = shootClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            VFXPool muzzleFlashVfx = new VFXPool {
                type = VFXPoolType.All
            };
            VFXComplex complex = new VFXComplex();
            VFXObject  vfxObj  = new VFXObject
            {
                alignment       = VFXAlignment.Fixed,
                attached        = false,
                orphaned        = true,
                persistsOnDeath = false,
                destructible    = true,
                usesZHeight     = true,
                zHeight         = -0.25f
            };
            List <int> muzzleFlashIds = new List <int>
            {
                VFXCollection.GetSpriteIdByName("lichsgun_vfx_001"),
                VFXCollection.GetSpriteIdByName("lichsgun_vfx_002"),
                VFXCollection.GetSpriteIdByName("lichsgun_vfx_003"),
                VFXCollection.GetSpriteIdByName("lichsgun_vfx_004")
            };
            GameObject muzzleFlashVfxObject = new GameObject("LichsGunMuzzleflash");

            muzzleFlashVfxObject.AddComponent <tk2dSprite>().SetSprite(VFXCollection, muzzleFlashIds[0]);
            muzzleFlashVfxObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(muzzleFlashVfxObject);
            UnityEngine.Object.DontDestroyOnLoad(muzzleFlashVfxObject);
            tk2dSpriteAnimator animator = muzzleFlashVfxObject.AddComponent <tk2dSpriteAnimator>();

            SpriteBuilder.AddAnimation(animator, muzzleFlashVfxObject.GetComponent <tk2dBaseSprite>().Collection, muzzleFlashIds, "flash", tk2dSpriteAnimationClip.WrapMode.Once).fps = 16;
            animator.playAutomatically = true;
            animator.DefaultClipId     = animator.GetClipIdByName("flash");
            SpriteAnimatorKiller killer = muzzleFlashVfxObject.AddComponent <SpriteAnimatorKiller>();

            killer.fadeTime             = -1f;
            killer.delayDestructionTime = -1f;
            killer.animator             = animator;
            foreach (int id in muzzleFlashIds)
            {
                LichsBookItem.ConstructOffsetsFromAnchor(VFXCollection.spriteDefinitions[id], tk2dBaseSprite.Anchor.MiddleLeft);
            }
            vfxObj.effect          = muzzleFlashVfxObject;
            complex.effects        = new VFXObject[] { vfxObj };
            muzzleFlashVfx.effects = new VFXComplex[] { complex };
            gun.gunSwitchGroup     = "SAA";
            gun.muzzleFlashEffects = muzzleFlashVfx;
            gun.reloadTime         = 1.1f;
            gun.SetBaseMaxAmmo(350);
            gun.quality = PickupObject.ItemQuality.D;
            gun.barrelOffset.transform.localPosition = new Vector3(1.1875f, 0.5625f, 0f);
            gun.gunClass = GunClass.PISTOL;
            ETGMod.Databases.Items.Add(gun, null, "ANY");
            InitSynergyForm(gun);
        }