Example #1
0
 public override void ChargeUpEffects()
 {
     foreach (Projectile proj in Main.projectile.Where(testby => testby.active && testby.owner == projectile.owner && testby.type == ModContent.ProjectileType <MandalaSummonProj>()))
     {
         proj.damage = projectile.damage;
         MandalaSummonProj proj2 = proj.modProjectile as MandalaSummonProj;
         proj2.throwing = 5;
     }
 }
Example #2
0
            public void Draw(SpriteBatch spriteBatch, MandalaSummonProj owner, float alpha, Vector2 pos = default)
            {
                Vector2 asteriodSize = new Vector2(asteriod.Width, asteriod.Height / 2);

                spriteBatch.Draw(asteriod, (pos == default ? Position : pos) - Main.screenPosition, new Rectangle(0, 0, (int)asteriodSize.X, (int)asteriodSize.Y), Color.White * alpha, angle, asteriodSize / 2f, scale * owner.projectile.scale, SpriteEffects.None, 0);
            }
Example #3
0
            public void Update(MandalaSummonProj owner)
            {
                time     += 1;
                stateVar += 1;

                switch (state)
                {
                //Intro
                case 100:
                    armLerpGoal = 0f;
                    position   += (followPosition - position) * 0.025f;
                    if (stateVar >= 100)
                    {
                        ChangeState(0);
                    }
                    break;

                //Punching
                case 1:
                    armLerpGoal = 1;
                    Vector2 there = Position;

                    chargeIn     += (1.20f - chargeIn) / 4f;
                    chargeIn      = Math.Min(chargeIn, 1f);
                    chargeInDist += 1f;

                    spinFriction += (0f - spinFriction) / 4f;

                    if (stateVar < 5)
                    {
                        velocity += Vector2.Normalize(direction) * MathHelper.Clamp(stateVar / 12f, 0f, 1f) * 720f;
                    }

                    if (stateVar >= 10 || cooldown > 0)
                    {
                        ChangeState(10);
                        //armLerpGoal = 1f;
                    }
                    break;

                //Grabbing Asteriod
                case 2:
                    armLerpGoal = 0;
                    armLerp    /= 1.25f;

                    velocity *= 0.98f;

                    if (rockToGrab == null || !rockToGrab.active || rockToGrab.type != ModContent.ProjectileType <MandalaAsteriodProj>())
                    {
                        ChangeState(10);
                        //armLerpGoal = 1f;
                    }
                    else
                    {
                        position = rockToGrab.Center;

                        rockToGrab.ai[0]     = 10;
                        rockToGrab.netUpdate = true;

                        if ((rockToGrab.Center - Position).Length() < 8 && armLerp < 0.02f)
                        {
                            ChangeState(3);
                        }
                    }
                    break;

                //Grabbed Asteriod, tossing
                case 3:

                    if (stateVar > 20)
                    {
                        velocity += Vector2.Normalize(direction) * MathHelper.Clamp((stateVar - 20) / 20f, 0f, 1f) * 16f;
                    }
                    else
                    {
                        position += (followPosition - position) / 16f;
                    }

                    if (rockToGrab == null || !rockToGrab.active || rockToGrab.type != ModContent.ProjectileType <MandalaAsteriodProj>())
                    {
                        ChangeState(10);
                        //armLerpGoal = 1f;
                    }
                    else
                    {
                        rockToGrab.Center = Position;
                        rockToGrab.ai[0]  = 10;
                        if (stateVar > 30)
                        {
                            SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_JavelinThrowersAttack, (int)Position.X, (int)Position.Y);
                            if (sound != null)
                            {
                                sound.Pitch = 0.5f;
                            }

                            rockToGrab.ai[0]     = 60;
                            rockToGrab.damage    = owner.projectile.damage;
                            rockToGrab.velocity  = (Vector2.Normalize(velocity) * 8f) + player.velocity / 4f;
                            rockToGrab.netUpdate = true;
                            ChangeState(10);
                            //armLerpGoal = 1f;
                        }
                    }
                    break;

                //Retracting
                case 10:
                    if (stateVar > 10)
                    {
                        armLerpGoal = 1f;
                        velocity   += (followPosition - position) * (0.025f + (stateVar / 6000f));
                    }

                    chargeIn      = MathHelper.Clamp(chargeIn + (-0.25f - chargeIn) / 8f, 0f, 1f);
                    chargeInDist *= 0.98f;

                    velocity *= 0.85f;

                    spinFriction += (0f - spinFriction) / 60f;

                    if (stateVar >= 30)
                    {
                        ChangeState(0);
                    }
                    break;

                //Idle
                case 0:
                    position     += (followPosition - position) * 0.025f;
                    direction     = (player.MountedCenter + owner.eyeCurrentLook) - Position;
                    spinFriction += (1f - spinFriction) / 30f;
                    armLerpGoal   = 1f;
                    cooldown      = 0;
                    chargeIn      = MathHelper.Clamp(chargeIn + (-0.20f - chargeIn) / 5f, 0f, 1f);
                    chargeInDist  = 0;
                    rockToGrab    = null;

                    if (owner.throwing > 0)
                    {
                        int slowerThrowing = (int)(owner.PunchRate * 1.25f);
                        int offset         = (int)(player.SGAPly().timer + (slowerThrowing * Percent));
                        if (offset % slowerThrowing == 0)
                        {
                            Projectile[] rocks = owner.GrabbableAsteriods.Where(testby => (testby.Center - player.Center).LengthSquared() < 409600).OrderBy(testby => (testby.Center - Position).LengthSquared()).ToArray();

                            if (rocks.Length > 0)
                            {
                                rockToGrab = rocks[0];
                                ChangeState(2);
                            }
                        }
                    }

                    if (owner.punching > 0)
                    {
                        int offset = (int)(player.SGAPly().timer + (owner.PunchRate * Percent));
                        if (offset % owner.PunchRate == 0)
                        {
                            SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_JavelinThrowersAttack, (int)Position.X, (int)Position.Y);
                            if (sound != null)
                            {
                                sound.Pitch = 0.5f;
                            }
                            ChangeState(1);
                        }
                    }

                    break;
                }

                despawnTimer = 10;
                armLerp      = MathHelper.Clamp(armLerp + (Math.Sign(armLerpGoal - armLerp) * 0.025f), 0f, 1f);
                angle       += angleSpin * spinFriction;
                position    += velocity;
                velocity    *= friction;
            }