Esempio n. 1
0
        protected override void Update()
        {
            if (this.m_extantOrbital != null & Owner)
            {
                if (Owner.IsInCombat && extantBeam == null)
                {
                    extantBeam = BeamToolbox.FreeFireBeamFromAnywhere(InfraredBeam, Owner, this.m_extantOrbital, Vector2.zero, false, 0, float.MaxValue);
                    extantBeam.projectile.gameObject.AddComponent <AlwaysPointAwayFromPlayerBeam>();
                    if (Owner.PlayerHasActiveSynergy("Infraredder Guon Stone"))
                    {
                        extantBeam.projectile.baseData.damage *= 2;
                    }
                    if (Owner.PlayerHasActiveSynergy("Xenochrome"))
                    {
                        extantBeam.GetComponent <BasicBeamController>().penetration++;
                        extantBeam.GetComponent <BasicBeamController>().reflections++;
                    }
                }

                else if (!Owner.IsInCombat && extantBeam != null)
                {
                    extantBeam.CeaseAttack();
                    extantBeam = null;
                }
            }
            else if (((m_extantOrbital == null) || (Owner == null)) && extantBeam != null)
            {
                extantBeam.CeaseAttack();
                extantBeam = null;
            }
            base.Update();
        }
Esempio n. 2
0
 public override void PostProcessProjectile(Projectile projectile)
 {
     if (projectile.ProjectilePlayerOwner())
     {
         PlayerController player = projectile.ProjectilePlayerOwner();
         if (player.PlayerHasActiveSynergy("Infrared Camera"))
         {
             foreach (PassiveItem item in player.passiveItems)
             {
                 if (item is InfraredGuonStone)
                 {
                     GameObject orbital = (item as InfraredGuonStone).GimmeOrbital();
                     if (orbital != null)
                     {
                         float angle = 0;
                         for (int i = 0; i < 8; i++)
                         {
                             BeamToolbox.FreeFireBeamFromAnywhere(InfraredGuonStone.InfraredBeam, player, orbital, Vector2.zero, false, angle, 1);
                             angle += 45;
                         }
                     }
                 }
             }
         }
     }
     base.PostProcessProjectile(projectile);
 }
        public static BeamController FreeFireBeamFromAnywhere(Projectile projectileToSpawn, PlayerController owner, GameObject otherShooter, Vector2 fixedPosition, bool usesFixedPosition, float targetAngle, float duration, bool skipChargeTime = false, bool followDirOnProjectile = false, float angleOffsetFromProjectileAngle = 0)
        {
            Vector2 sourcePos             = Vector2.zero;
            SpeculativeRigidbody rigidBod = null;

            if (usesFixedPosition)
            {
                sourcePos = fixedPosition;
            }
            else
            {
                if (otherShooter.GetComponent <SpeculativeRigidbody>())
                {
                    rigidBod = otherShooter.GetComponent <SpeculativeRigidbody>();
                }
                else if (otherShooter.GetComponentInChildren <SpeculativeRigidbody>())
                {
                    rigidBod = otherShooter.GetComponentInChildren <SpeculativeRigidbody>();
                }

                if (rigidBod)
                {
                    sourcePos = rigidBod.UnitCenter;
                }
            }
            if (sourcePos != Vector2.zero)
            {
                GameObject gameObject = SpawnManager.SpawnProjectile(projectileToSpawn.gameObject, sourcePos, Quaternion.identity, true);
                Projectile component  = gameObject.GetComponent <Projectile>();
                component.Owner = owner;
                BeamController component2 = gameObject.GetComponent <BeamController>();
                if (skipChargeTime)
                {
                    component2.chargeDelay     = 0f;
                    component2.usesChargeDelay = false;
                }
                component2.Owner       = owner;
                component2.HitsPlayers = false;
                component2.HitsEnemies = true;
                Vector3 vector = BraveMathCollege.DegreesToVector(targetAngle, 1f);
                if (otherShooter != null && !usesFixedPosition && otherShooter.GetComponent <Projectile>() && followDirOnProjectile)
                {
                    component2.Direction = (otherShooter.GetComponent <Projectile>().Direction.ToAngle() + angleOffsetFromProjectileAngle).DegreeToVector2();
                }
                else
                {
                    component2.Direction = vector;
                }
                component2.Origin = sourcePos;
                GameManager.Instance.Dungeon.StartCoroutine(BeamToolbox.HandleFreeFiringBeam(component2, rigidBod, fixedPosition, usesFixedPosition, targetAngle, duration, followDirOnProjectile, angleOffsetFromProjectileAngle));
                return(component2);
            }
            else
            {
                ETGModConsole.Log("ERROR IN BEAM FREEFIRE CODE. SOURCEPOS WAS NULL, EITHER DUE TO INVALID FIXEDPOS OR SOURCE GAMEOBJECT.");
                return(null);
            }
        }
Esempio n. 4
0
            private IEnumerator DoLaserAttack()
            {
                isAttacking = true;
                this.aiAnimator.PlayUntilFinished("attack", false, null, -1f, false);
                yield return(new WaitForSeconds(0.5f));

                //Start Firing Lasers
                this.aiActor.MovementSpeed *= 0.0001f;
                this.aiAnimator.PlayForDuration("contattack", 1);
                Projectile beamToFire = LaserBullets.SimpleRedBeam.projectile;

                if (UnityEngine.Random.value <= 0.5f)
                {
                    int angle = 135;
                    for (int i = 0; i < 4; i++)
                    {
                        BeamController beam = BeamToolbox.FreeFireBeamFromAnywhere(beamToFire, this.m_owner, this.gameObject, Vector2.zero, false, angle, 1, true);
                        Projectile     beamprojcomponent = beam.GetComponent <Projectile>();
                        beamprojcomponent.baseData.damage *= 3f;
                        if (PassiveItem.IsFlagSetForCharacter(this.Owner, typeof(BattleStandardItem)))
                        {
                            beamprojcomponent.baseData.damage *= BattleStandardItem.BattleStandardCompanionDamageMultiplier;
                        }
                        if (this.Owner.CurrentGun && this.Owner.CurrentGun.LuteCompanionBuffActive)
                        {
                            beamprojcomponent.baseData.damage *= 2;
                        }
                        angle -= 90;
                    }
                }
                else
                {
                    int angle = 180;
                    for (int i = 0; i < 4; i++)
                    {
                        BeamController beam = BeamToolbox.FreeFireBeamFromAnywhere(beamToFire, this.m_owner, this.gameObject, Vector2.zero, false, angle, 1, true);
                        Projectile     beamprojcomponent = beam.GetComponent <Projectile>();
                        beamprojcomponent.baseData.damage *= 3f;
                        if (PassiveItem.IsFlagSetForCharacter(this.Owner, typeof(BattleStandardItem)))
                        {
                            beamprojcomponent.baseData.damage *= BattleStandardItem.BattleStandardCompanionDamageMultiplier;
                        }
                        if (this.Owner.CurrentGun && this.Owner.CurrentGun.LuteCompanionBuffActive)
                        {
                            beamprojcomponent.baseData.damage *= 2;
                        }
                        angle -= 90;
                    }
                }
                yield return(new WaitForSeconds(1f));

                //Stop shit
                isAttacking = false;
                timer       = 1.5f;
                this.aiActor.MovementSpeed /= 0.0001f;
                yield break;
            }
        private IEnumerator HentaiTime()
        {
            yield return(new WaitForSeconds(1));

            BeamToolbox.FreeFireBeamFromAnywhere((PickupObjectDatabase.GetById(474) as Gun).DefaultModule.projectiles[0], self.ProjectilePlayerOwner(), self.gameObject, Vector2.zero, false, 90, 5, true);
            BeamToolbox.FreeFireBeamFromAnywhere((PickupObjectDatabase.GetById(474) as Gun).DefaultModule.projectiles[0], self.ProjectilePlayerOwner(), self.gameObject, Vector2.zero, false, -45, 5, true);
            BeamToolbox.FreeFireBeamFromAnywhere((PickupObjectDatabase.GetById(474) as Gun).DefaultModule.projectiles[0], self.ProjectilePlayerOwner(), self.gameObject, Vector2.zero, false, -135, 5, true);
            yield return(new WaitForSeconds(6));

            Die();
            yield break;
        }
        private void DoLaser(FlippableCover obj)
        {
            SpeculativeRigidbody rigidBody = obj.GetComponentInChildren <SpeculativeRigidbody>();

            PlayerController owner  = base.Owner;
            Vector2          vector = DungeonData.GetIntVector2FromDirection(obj.DirectionFlipped).ToVector2();
            BeamController   cont   = BeamToolbox.FreeFireBeamFromAnywhere(lasa, owner, obj.gameObject, rigidBody.UnitCenter, false, vector.ToAngle(), 20, true);


            GameObject gameObject = SpawnManager.SpawnProjectile(lasa.gameObject, rigidBody.UnitCenter, Quaternion.identity, true);
            Projectile component  = gameObject.GetComponent <Projectile>();

            component.Owner = owner;
            BeamController component2 = gameObject.GetComponent <BeamController>();

            component2.chargeDelay     = 0f;
            component2.usesChargeDelay = false;
            component2.Owner           = owner;
            component2.HitsPlayers     = false;
            component2.HitsEnemies     = true;
            component2.Direction       = vector;
            component2.Origin          = rigidBody.UnitCenter;
            GameManager.Instance.Dungeon.StartCoroutine(HandleFreeFiringBeam(component2, rigidBody, 20));
        }
Esempio n. 7
0
        /// <summary>
        /// Adds a tiled trail to the Projectile
        /// </summary>
        /// <param name="timeTillAnimStart">How long after spawning until the trail will begin to play it's animation, if it has one.</param>
        public static void AddTrailToProjectile(this Projectile target, string spritePath, Vector2 colliderDimensions, Vector2 colliderOffsets, List <string> animPaths = null, int animFPS = -1, List <string> startAnimPaths = null, int startAnimFPS = -1, float timeTillAnimStart = -1, float cascadeTimer = -1, float softMaxLength = -1, bool destroyOnEmpty = false)
        {
            try
            {
                GameObject newTrailObject = new GameObject();
                newTrailObject.InstantiateAndFakeprefab();
                newTrailObject.transform.parent = target.transform;

                float convertedColliderX = colliderDimensions.x / 16f;
                float convertedColliderY = colliderDimensions.y / 16f;
                float convertedOffsetX   = colliderOffsets.x / 16f;
                float convertedOffsetY   = colliderOffsets.y / 16f;

                int             spriteID    = SpriteBuilder.AddSpriteToCollection(spritePath, ETGMod.Databases.Items.ProjectileCollection);
                tk2dTiledSprite tiledSprite = newTrailObject.GetOrAddComponent <tk2dTiledSprite>();

                tiledSprite.SetSprite(ETGMod.Databases.Items.ProjectileCollection, spriteID);
                tk2dSpriteDefinition def = tiledSprite.GetCurrentSpriteDef();
                def.colliderVertices = new Vector3[] {
                    new Vector3(convertedOffsetX, convertedOffsetY, 0f),
                    new Vector3(convertedColliderX, convertedColliderY, 0f)
                };

                def.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.MiddleLeft);

                tk2dSpriteAnimator  animator  = newTrailObject.GetOrAddComponent <tk2dSpriteAnimator>();
                tk2dSpriteAnimation animation = newTrailObject.GetOrAddComponent <tk2dSpriteAnimation>();
                animation.clips  = new tk2dSpriteAnimationClip[0];
                animator.Library = animation;

                TrailController trail = newTrailObject.AddComponent <TrailController>();

                //---------------- Sets up the animation for the main part of the trail
                if (animPaths != null)
                {
                    BeamToolbox.SetupBeamPart(animation, animPaths, "trail_mid", animFPS, null, null, def.colliderVertices);
                    trail.animation     = "trail_mid";
                    trail.usesAnimation = true;
                }
                else
                {
                    trail.usesAnimation = false;
                }

                if (startAnimPaths != null)
                {
                    BeamToolbox.SetupBeamPart(animation, startAnimPaths, "trail_start", startAnimFPS, null, null, def.colliderVertices);
                    trail.startAnimation     = "trail_start";
                    trail.usesStartAnimation = true;
                }
                else
                {
                    trail.usesStartAnimation = false;
                }

                //Trail Variables
                if (softMaxLength > 0)
                {
                    trail.usesSoftMaxLength = true; trail.softMaxLength = softMaxLength;
                }
                if (cascadeTimer > 0)
                {
                    trail.usesCascadeTimer = true; trail.cascadeTimer = cascadeTimer;
                }
                if (timeTillAnimStart > 0)
                {
                    trail.usesGlobalTimer = true; trail.globalTimer = timeTillAnimStart;
                }
                trail.destroyOnEmpty = destroyOnEmpty;
            }
            catch (Exception e)
            {
                ETGModConsole.Log(e.ToString());
            }
        }