示例#1
0
        private void EndState(FireState state)
        {
            switch (state)
            {
            case FireState.Charging:
                m_aiActor.BehaviorVelocity           = Vector2.zero;
                m_aiActor.CollisionKnockbackStrength = m_cachedKnockback;
                m_aiActor.CollisionDamage            = m_cachedDamage;
                m_aiActor.CollisionVFX         = m_cachedVfx;
                m_aiActor.NonActorCollisionVFX = m_cachedNonActorWallVfx;
                if (m_trailVfx)
                {
                    ParticleKiller component = m_trailVfx.GetComponent <ParticleKiller>();
                    if (component)
                    {
                        component.StopEmitting();
                    }
                    else
                    {
                        SpawnManager.Despawn(m_trailVfx);
                    }
                    m_trailVfx = null;
                }
                m_aiActor.DoDustUps      = m_cachedDoDustUps;
                m_aiActor.DustUpInterval = m_cachedDustUpInterval;
                m_aiActor.PathableTiles  = m_cachedPathableTiles;
                if (switchCollidersOnCharge)
                {
                    m_enemyCollider.CollisionLayer = CollisionLayer.EnemyCollider;
                    m_enemyHitbox.Enabled          = true;
                    m_projectileCollider.Enabled   = false;
                }
                if (m_bulletSource != null)
                {
                    m_bulletSource.ForceStop();
                }
                m_aiAnimator.EndAnimationIf(chargeAnim);
                break;

            default:
                return;
            }
        }
示例#2
0
        private void BeginState(FireState state)
        {
            switch (state)
            {
            case FireState.Idle:
                if (HideGun)
                {
                    m_aiShooter.ToggleGunAndHandRenderers(true, "ChargeBehavior");
                }
                m_aiActor.BehaviorOverridesVelocity = false;
                m_aiAnimator.LockFacingDirection    = false;
                break;

            case FireState.Priming:
                if (HideGun)
                {
                    m_aiShooter.ToggleGunAndHandRenderers(false, "ChargeBehavior");
                }
                m_aiAnimator.PlayUntilFinished(primeAnim, true, null, -1f, false);
                if (primeTime > 0f)
                {
                    m_timer = primeTime;
                }
                else
                {
                    m_timer = m_aiAnimator.CurrentClipLength;
                }
                if (stopDuringPrime)
                {
                    m_aiActor.ClearPath();
                    m_aiActor.BehaviorOverridesVelocity = true;
                    m_aiActor.BehaviorVelocity          = Vector2.zero;
                }
                else
                {
                    m_aiActor.BehaviorOverridesVelocity = true;
                    m_aiActor.BehaviorVelocity          = m_aiActor.specRigidbody.Velocity;
                }
                break;

            case FireState.Charging:
                if (HideGun)
                {
                    m_aiShooter.ToggleGunAndHandRenderers(false, "ChargeBehavior");
                }
                m_chargeTime = 0f;
                Vector2 vector = m_aiActor.TargetRigidbody.specRigidbody.GetUnitCenter(ColliderType.HitBox);
                if (leadAmount > 0f)
                {
                    Vector2 b = vector + m_aiActor.TargetRigidbody.specRigidbody.Velocity * 0.75f;
                    b      = BraveMathCollege.GetPredictedPosition(vector, m_aiActor.TargetVelocity, m_aiActor.specRigidbody.UnitCenter, chargeSpeed);
                    vector = Vector2.Lerp(vector, b, leadAmount);
                }
                m_aiActor.ClearPath();
                m_aiActor.BehaviorOverridesVelocity = true;
                m_currentSpeed                       = ((chargeAcceleration <= 0f) ? chargeSpeed : 0f);
                m_chargeDirection                    = (vector - m_aiActor.specRigidbody.UnitCenter).ToAngle();
                m_aiActor.BehaviorVelocity           = BraveMathCollege.DegreesToVector(m_chargeDirection, m_currentSpeed);
                m_aiAnimator.LockFacingDirection     = true;
                m_aiAnimator.FacingDirection         = m_chargeDirection;
                m_aiActor.CollisionKnockbackStrength = chargeKnockback;
                m_aiActor.CollisionDamage            = chargeDamage;
                if (hitVfx)
                {
                    VFXObject vfxobject = new VFXObject();
                    vfxobject.effect = hitVfx;
                    VFXComplex vfxcomplex = new VFXComplex();
                    vfxcomplex.effects = new VFXObject[] { vfxobject };
                    VFXPool vfxpool = new VFXPool();
                    vfxpool.type           = VFXPoolType.Single;
                    vfxpool.effects        = new VFXComplex[] { vfxcomplex };
                    m_aiActor.CollisionVFX = vfxpool;
                }
                if (nonActorHitVfx)
                {
                    VFXObject vfxobject2 = new VFXObject();
                    vfxobject2.effect = nonActorHitVfx;
                    VFXComplex vfxcomplex2 = new VFXComplex();
                    vfxcomplex2.effects = new VFXObject[] { vfxobject2 };
                    VFXPool vfxpool2 = new VFXPool();
                    vfxpool2.type    = VFXPoolType.Single;
                    vfxpool2.effects = new VFXComplex[] { vfxcomplex2 };
                    m_aiActor.NonActorCollisionVFX = vfxpool2;
                }
                m_aiActor.PathableTiles = (CellTypes.FLOOR | CellTypes.PIT);
                if (switchCollidersOnCharge)
                {
                    m_enemyCollider.CollisionLayer = CollisionLayer.TileBlocker;
                    m_enemyHitbox.Enabled          = false;
                    m_projectileCollider.Enabled   = true;
                }
                m_aiActor.DoDustUps      = chargeDustUps;
                m_aiActor.DustUpInterval = chargeDustUpInterval;
                m_aiAnimator.PlayUntilFinished(chargeAnim, true, null, -1f, false);
                if (launchVfx)
                {
                    SpawnManager.SpawnVFX(launchVfx, m_aiActor.specRigidbody.UnitCenter, Quaternion.identity);
                }
                if (trailVfx)
                {
                    m_trailVfx = SpawnManager.SpawnParticleSystem(trailVfx, m_aiActor.sprite.WorldCenter, Quaternion.Euler(0f, 0f, m_chargeDirection));
                    if (trailVfxParent)
                    {
                        m_trailVfx.transform.parent = trailVfxParent;
                    }
                    else
                    {
                        m_trailVfx.transform.parent = m_aiActor.transform;
                    }
                    ParticleKiller component = m_trailVfx.GetComponent <ParticleKiller>();
                    if (component != null)
                    {
                        component.Awake();
                    }
                }
                if (bulletScript != null && !bulletScript.IsNull)
                {
                    Fire();
                }
                m_aiActor.specRigidbody.ForceRegenerate(null, null);
                break;

            case FireState.Bouncing:
                m_aiAnimator.PlayUntilFinished(hitAnim, true, null, -1f, false);
                break;
            }
        }
示例#3
0
            private IEnumerator fail()
            {
                isFiring = true;
                this.m_aiActor.MovementSpeed = 0;
                this.m_aiActor.aiAnimator.PlayUntilFinished("attack_right");
                bool BadCode = true;

                while (this.m_aiActor.aiAnimator.IsPlaying("attack_right"))
                {
                    if (this.m_aiActor.spriteAnimator.CurrentFrame == 4 && BadCode)
                    {
                        BadCode = false;
                        bool PlayerHasSynergy = false;
                        if (Owner)
                        {
                            PlayerHasSynergy = Owner.PlayerHasActiveSynergy("Robot Influence");
                        }
                        for (int counter = 0; counter < (PlayerHasSynergy ? 18 : 12); counter++)
                        {
                            Projectile projectile2 = ((Gun)ETGMod.Databases.Items[88]).DefaultModule.projectiles[0];
                            GameObject gameObject  = SpawnManager.SpawnProjectile(projectile2.gameObject, this.m_aiActor.sprite.WorldCenter, Quaternion.Euler(0f, 0f, ((PlayerHasSynergy ? 20 : 30) * counter)), true);
                            Projectile component   = gameObject.GetComponent <Projectile>();
                            if (component != null)
                            {
                                component.baseData.damage = 5;
                                component.Owner           = Owner;
                                component.Shooter         = Owner.specRigidbody;
                                Owner.DoPostProcessProjectile(component);

                                BulletStatusEffectItem batteryBullets = (BulletStatusEffectItem)PickupObjectDatabase.GetById(410);
                                CoreDamageTypes        damageType     = batteryBullets.DamageTypesToAdd;
                                if (batteryBullets.AddsDamageType)
                                {
                                    component.damageTypes |= damageType;
                                }

                                GameObject particles = batteryBullets.ParticlesToAdd;
                                if (particles)
                                {
                                    GameObject particleObject = SpawnManager.SpawnVFX(particles, true);
                                    particleObject.transform.parent        = component.transform;
                                    particleObject.transform.localPosition = new Vector3(0f, 0f, 0.5f);
                                    ParticleKiller particleComponent = particleObject.GetComponent <ParticleKiller>();
                                    if (particleComponent != null)
                                    {
                                        particleComponent.Awake();
                                    }
                                }
                            }
                        }
                    }
                    yield return(null);
                }
                isFiring = false;
                this.m_aiActor.MovementSpeed = 5;
                this.attackTimer             = this.TickDelay;
                if (Owner && Owner.PlayerHasActiveSynergy("If the robot's paid"))
                {
                    float Nuts = Mathf.Min((float)Owner.carriedConsumables.Currency / 150, 1);
                    this.attackTimer -= Nuts;
                }
                yield break;
            }