Exemple #1
0
        public override void AI()
        {
            dims.Y = 0;
            for (int k = 0; 1 == 1; k++)
            {
                dims.Y++;
                if (Main.tileSolid[Main.tile[((int)projectile.position.X + 4) / 16, (int)(projectile.position.Y + k) / 16].type] && Main.tile[(int)projectile.position.X / 16, (int)(projectile.position.Y + k) / 16].active())
                {
                    break;
                }
            }

            foreach (Player player in Main.player.Where(player => player.active))
            {
                if (Collision.CheckAABBvAABBCollision(projectile.position, dims, player.position, player.Hitbox.Size()) && !player.ActiveAbility <Wisp>())
                {
                    player.Hurt(PlayerDeathReason.ByCustomReason(player.name + " was zapped to death."), 50, 0);
                    player.velocity.X = (player.velocity.Length() <= 8) ? (-Vector2.Normalize(player.velocity) * 8).X : player.velocity.X * -1;
                    player.velocity.Y = 0.1f;

                    Projectile proj = Main.projectile.FirstOrDefault(p => p.owner == player.whoAmI && Main.projHook[p.type]);
                    if (proj != null)
                    {
                        proj.timeLeft = 0;
                    }

                    player.GetHandler().ActiveAbility?.Deactivate();
                }
            }

            projectile.timeLeft = 2;
            if (!parent.active())
            {
                projectile.timeLeft = 0;
            }

            //Dust
            if (Main.time % 15 == 0)
            {
                Vector2   startpos = projectile.Center + new Vector2(8, -8);
                Vector2[] joints   = new Vector2[(int)dims.Y / 20 + 1];
                joints[0] = startpos;
                joints[(int)dims.Y / 20] = startpos + new Vector2(0, dims.Y);

                for (int k = 1; k < joints.Count(); k++)
                {
                    if (k < joints.Count() - 1)
                    {
                        joints[k].X = startpos.X + Main.rand.NextFloat(-16, 16);
                        joints[k].Y = startpos.Y + k * 20 + Main.rand.NextFloat(-5, 5);
                    }
                    for (float k2 = 0; k2 <= 1; k2 += 0.1f)
                    {
                        Dust.NewDustPerfect(Vector2.Lerp(joints[k], joints[k - 1], k2), DustType <Dusts.Gold>(), null, 0, default, 0.5f);
Exemple #2
0
        public override void AI()
        {
            projectile.rotation += (float)Math.PI / 120f * (projectile.velocity.X > 0 ? 1 : -1);
            Player player = Main.player[projectile.owner];

            if (Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, player.position, player.Size))
            {
                player.HealEffect(2, false);
                projectile.Kill();
                player.statLife += 2;
            }
        }
Exemple #3
0
        public override void AI()
        {
            for (int m = projectile.oldPos.Length - 1; m > 0; m--)
            {
                projectile.oldPos[m] = projectile.oldPos[m - 1];
            }
            projectile.oldPos[0] = projectile.position;

            if (projectile.frame < 5)
            {
                if (projectile.frameCounter++ > 3)
                {
                    projectile.frameCounter = 0;
                    projectile.frame++;
                }
            }
            else
            {
                projectile.frame = 5;
            }

            if (internalAI[0]++ > 60)
            {
                if (projectile.ai[0] == 0)
                {
                    if (projectile.velocity.X < 16)
                    {
                        projectile.velocity.X += .1f;
                    }
                }
                else if (projectile.ai[0] == 1)
                {
                    if (projectile.velocity.X > -16)
                    {
                        projectile.velocity.X -= .1f;
                    }
                    projectile.direction = projectile.spriteDirection = -1;
                }

                Projectile clearCheck = Main.projectile[(int)projectile.ai[1]];
                if (Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, clearCheck.position, clearCheck.Size))
                {
                    for (int m = 0; m < 80; m++)
                    {
                        Dust.NewDust(projectile.position, projectile.width, projectile.height, 32, 0f, 0f, 100, new Color(32, 32, 46), 1.6f);
                    }
                    clearCheck.Kill();
                    projectile.Kill();
                }
            }
        }
Exemple #4
0
            protected override void DrawChildren(SpriteBatch spriteBatch)
            {
                Vector2 position1   = this.Parent.GetDimensions().Position();
                Vector2 dimensions1 = new Vector2(this.Parent.GetDimensions().Width, this.Parent.GetDimensions().Height);

                foreach (UIElement element in this.Elements)
                {
                    Vector2 position2   = element.GetDimensions().Position();
                    Vector2 dimensions2 = new Vector2(element.GetDimensions().Width, element.GetDimensions().Height);
                    if (Collision.CheckAABBvAABBCollision(position1, dimensions1, position2, dimensions2))
                    {
                        element.Draw(spriteBatch);
                    }
                }
            }
Exemple #5
0
            protected override void DrawChildren(SpriteBatch spriteBatch)
            {
                Vector2 position   = Parent.GetDimensions().Position();
                Vector2 dimensions = new Vector2(Parent.GetDimensions().Width, Parent.GetDimensions().Height);

                foreach (UIElement current in Elements)
                {
                    Vector2 position2   = current.GetDimensions().Position();
                    Vector2 dimensions2 = new Vector2(current.GetDimensions().Width, current.GetDimensions().Height);
                    if (Collision.CheckAABBvAABBCollision(position, dimensions, position2, dimensions2))
                    {
                        current.Draw(spriteBatch);
                    }
                }
            }
Exemple #6
0
            // Token: 0x06001B8F RID: 7055 RVA: 0x00431328 File Offset: 0x0042F528
            protected override void DrawChildren(SpriteBatch spriteBatch)
            {
                var position   = this.Parent.GetDimensions().Position();
                var dimensions = new Vector2(this.Parent.GetDimensions().Width, this.Parent.GetDimensions().Height);

                foreach (var uielement in this.Elements)
                {
                    var position2   = uielement.GetDimensions().Position();
                    var dimensions2 = new Vector2(uielement.GetDimensions().Width, uielement.GetDimensions().Height);
                    if (Collision.CheckAABBvAABBCollision(position, dimensions, position2, dimensions2))
                    {
                        uielement.Draw(spriteBatch);
                    }
                }
            }
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float p = 0;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(),
                                                     targetHitbox.Size(),
                                                     (projectile.Center + HeadOffPos) + QwertyMethods.PolarVector(-13, HeadPos.ToRotation()),
                                                     (projectile.Center + HeadOffPos) + QwertyMethods.PolarVector(28, HeadPos.ToRotation()),
                                                     34,
                                                     ref p
                                                     ) || Collision.CheckAABBvAABBCollision(targetHitbox.TopLeft(),
                                                                                            targetHitbox.Size(),
                                                                                            (projectile.Center + HeadOffPos),
                                                                                            new Vector2(1, 1)));
        }
Exemple #8
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (runOnce)
            {
                spinDirection = player.direction;
                speed         = projectile.velocity.Length();
                maxSpeed      = speed;
                runOnce       = false;
            }
            projectile.rotation += MathHelper.ToRadians(maxSpeed * spinDirection);
            if (returnToPlayer)
            {
                timerAfterReturning++;
                if (timerAfterReturning == 30)
                {
                    for (int k = 0; k < 200; k++)
                    {
                        projectile.localNPCImmunity[k] = 0;
                    }
                }

                if (Collision.CheckAABBvAABBCollision(player.position, player.Size, projectile.position, projectile.Size))
                {
                    projectile.Kill();
                }
                projectile.tileCollide = false;
                //projectile.friendly = false;
                projectile.velocity = QwertyMethods.PolarVector(speed, (player.Center - projectile.Center).ToRotation());
                speed += decceleration;
                if (speed > maxSpeed)
                {
                    speed = maxSpeed;
                }
            }
            else
            {
                projectile.velocity = projectile.velocity.SafeNormalize(-Vector2.UnitY) * speed;
                speed -= decceleration;
                if (speed < 1f)
                {
                    returnToPlayer = true;
                }
            }
            //Main.NewText("MaxSpeed: " + maxSpeed);
            //Main.NewText("speed: " + speed);
        }
Exemple #9
0
            protected override void DrawChildren(SpriteBatch spriteBatch)
            {
                Vector2 position   = Parent.GetDimensions().Position();
                Vector2 dimensions = new Vector2(Parent.GetDimensions().Width, Parent.GetDimensions().Height);

                for (int i = 0; i < Elements.Count; i++)
                {
                    UIElement current     = Elements[i];
                    Vector2   position2   = current.GetDimensions().Position();
                    Vector2   dimensions2 = new Vector2(current.GetDimensions().Width, ((UIMessage)current).height);
                    if (Collision.CheckAABBvAABBCollision(position, dimensions, position2, dimensions2))
                    {
                        current.Draw(spriteBatch);
                    }
                }
            }
            protected override void DrawChildren(SpriteBatch spriteBatch)
            {
                Vector2 vector2  = this.Parent.GetDimensions().Position();
                Vector2 vector21 = new Vector2(this.Parent.GetDimensions().Width, this.Parent.GetDimensions().Height);

                for (int i = 0; i < this.Elements.Count; i++)
                {
                    UIElement element  = this.Elements[i];
                    Vector2   vector22 = element.GetDimensions().Position();
                    Vector2   vector23 = new Vector2(element.GetDimensions().Width, element.GetDimensions().Height);
                    if (!Collision.CheckAABBvAABBCollision(vector2, vector21, vector22, vector23))
                    {
                        continue;
                    }
                    element.Draw(spriteBatch);
                }
            }
        public static void Draw(ref int num, SpriteBatch sb)
        {
            Vector2   vector    = new Vector2(Main.screenWidth - 212, 142 + 256);
            Texture2D texture2D =
                ModContent.GetTexture("DynamicDungeon/DungeonAssets/DungeonEditorAssets/EditorButton");

            if (Collision.CheckAABBvAABBCollision(vector, texture2D.Size(), new Vector2(Main.mouseX, Main.mouseY), Vector2.One) && (Main.mouseItem.stack < 1 || Main.mouseItem.dye > 0))
            {
                num = 4;
            }
            if (num == 4)
            {
                sb.Draw(texture2D, vector, null, Main.OurFavoriteColor, 0f, new Vector2(2f), 0.9f, SpriteEffects.None, 0f);
            }
            sb.Draw(texture2D, vector, null, Color.White, 0f, Vector2.Zero, 0.9f, SpriteEffects.None, 0f);
            UILinkPointNavigator.SetPosition(305, vector + texture2D.Size() * 0.75f);
        }
Exemple #12
0
 public override void AI()
 {
     if (Main.rand.Next(8) == 0)
     {
         Dust d = Main.dust[Dust.NewDust(projectile.Center, 0, 0, mod.DustType("GlassSmoke"))];
         d.velocity *= .1f;
         d.noGravity = true;
         d.position  = projectile.Center;
         d.shader    = GameShaders.Armor.GetSecondaryShader(Main.player[projectile.owner].dye[3].dye, Main.player[projectile.owner]);
     }
     for (int k = 0; k < 200; k++)
     {
         if (!Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, Main.npc[k].position, Main.npc[k].Size))
         {
             projectile.localNPCImmunity[k] = 0;
         }
     }
 }
Exemple #13
0
 // Change the way of collision check of the projectile
 public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
 {
     if (projectile.ai[1] != -1)
     {
         Player  player = Main.player[projectile.owner];
         Vector2 unit   = projectile.velocity;
         float   point  = 0f;
         // Run an AABB versus Line check to look for collisions, look up AABB collision first to see how it works
         // It will look for collisions on the given line using AABB
         if (Collision.CheckAABBvAABBCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projHitbox.TopLeft(), projHitbox.Size()))
         {
             return(true);
         }
         return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), new Vector2(shooter.Center.X, shooter.Center.Y),
                                                  new Vector2(shooter.Center.X, shooter.Center.Y) + unit * Distance, 6, ref point));
     }
     return(false);
 }
Exemple #14
0
        public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
        {
            if (Slam)
            {
                crit = true;
            }
            if (Collision.CheckAABBvAABBCollision(target.position, target.Size, projectile.position, projectile.Size))
            {
                damage = (int)(damage * 1.5f);
                for (int i = 0; i < 8; i++)
                {
                    Vector2 vel = Main.rand.NextFloat(6.28f).ToRotationVector2();
                    vel *= Main.rand.NextFloat(2, 5);
                    ImpactLine line = new ImpactLine(target.Center - (vel * 10), vel, Color.Green, new Vector2(0.25f, Main.rand.NextFloat(0.75f, 1.75f) * 1.5f), 70);
                    line.TimeActive = 30;
                    ParticleHandler.SpawnParticle(line);
                }
                float progress = Timer / SwingTime;                 //How far the projectile is through its swing
                if (Slam)
                {
                    progress = EaseFunction.EaseCubicInOut.Ease(progress);
                }

                if (Slam && progress > 0.4f && progress < 0.6f)
                {
                    if (Owner.GetModPlayer <MyPlayer>().Shake < 5)
                    {
                        Owner.GetModPlayer <MyPlayer>().Shake += 5;
                    }
                    for (int j = 0; j < 14; j++)
                    {
                        int timeLeft = Main.rand.Next(20, 40);

                        StarParticle particle = new StarParticle(
                            target.Center,
                            Main.rand.NextVector2Circular(10, 7),
                            Color.Lerp(new Color(106, 255, 35), new Color(18, 163, 85), Main.rand.NextFloat()),
                            Main.rand.NextFloat(0.15f, 0.3f),
                            timeLeft);
                        ParticleHandler.SpawnParticle(particle);
                    }
                }
            }
        }
Exemple #15
0
        public override void AI()
        {
            for (int m = projectile.oldPos.Length - 1; m > 0; m--)
            {
                projectile.oldPos[m] = projectile.oldPos[m - 1];
            }
            projectile.oldPos[0] = projectile.position;
            if (projectile.frame < 5)
            {
                if (projectile.frameCounter++ > 3)
                {
                    projectile.frameCounter = 0;
                    projectile.frame++;
                }
            }
            else
            {
                projectile.frame = 5;
            }

            if (internalAI[0]++ > 90)
            {
                if (projectile.ai[0] == 0)
                {
                    if (projectile.velocity.Y < 12)
                    {
                        projectile.velocity.Y += .05f;
                    }
                }
                else if (projectile.ai[0] == 1)
                {
                    if (projectile.velocity.Y > -12)
                    {
                        projectile.velocity.Y -= .05f;
                    }
                    projectile.direction = projectile.spriteDirection = -1;
                }

                Projectile clearCheck = Main.projectile[(int)projectile.ai[1]];
                if (Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, clearCheck.position, clearCheck.Size))
                {
                    for (int m = 0; m < 40; m++)
                    {
                        Dust.NewDust(projectile.position, projectile.width, projectile.height, 32, 0f, 0f, 100, default, 1.6f);
Exemple #16
0
            protected override void DrawChildren(SpriteBatch spriteBatch)
            {
                Vector2 position1 = this.Parent.GetDimensions().Position();
                Vector2 dimensions1;

                // ISSUE: explicit reference operation
                ((Vector2)@dimensions1).\u002Ector(this.Parent.GetDimensions().Width, this.Parent.GetDimensions().Height);
                foreach (UIElement element in this.Elements)
                {
                    Vector2 position2 = element.GetDimensions().Position();
                    Vector2 dimensions2;
                    // ISSUE: explicit reference operation
                    ((Vector2)@dimensions2).\u002Ector(element.GetDimensions().Width, element.GetDimensions().Height);
                    if (Collision.CheckAABBvAABBCollision(position1, dimensions1, position2, dimensions2))
                    {
                        element.Draw(spriteBatch);
                    }
                }
            }
 public override void AI()
 {
     if (runOnce)
     {
         runOnce = false;
         projectile.localNPCImmunity[(int)projectile.ai[0]] = 0;
     }
     if (effectPotency > 0)
     {
         Dust.NewDust(projectile.position, projectile.width, projectile.height, dust);
         Player player = Main.player[projectile.owner];
         projectile.velocity = (player.Center - projectile.Center).SafeNormalize(-Vector2.UnitY) * 12f;
         if (Collision.CheckAABBvAABBCollision(player.position, player.Size, projectile.position, projectile.Size))
         {
             PlayerBenifit(effectPotency, player);
             projectile.Kill();
         }
     }
 }
Exemple #18
0
        /// <summary>
        /// </summary>
        /// <param name="pos">Page icon drawing position</param>
        /// <returns>true if the page icon is under the mouse</returns>
        private bool DrawPageIcons(Vector2 pos)
        {
            pos.X += 92f;
            pos.Y += 2f;
            float scale = 0.8f;

            var  tex       = buttonTextures[Main.EquipPage == EquipPage ? 1 : 0].Value;
            bool highlight = false;

            if (Collision.CheckAABBvAABBCollision(pos, tex.Size(), Main.MouseScreen, Vector2.One) &&
                (Main.mouseItem.stack < 1 || UtilityAccessories.GetHandler(Main.mouseItem) != null || Main.mouseItem.dye > 0))
            {
                highlight = true;
                Main.spriteBatch.Draw(buttonTextures[2].Value, pos, null, Main.OurFavoriteColor, 0f, new Vector2(2f), scale, SpriteEffects.None, 0f);
                Main.HoverItem     = new Item();
                Main.hoverItemName = Language.GetTextValue("Mods.UtilitySlots.PageName");
            }
            Main.spriteBatch.Draw(tex, pos, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
            return(highlight);
        }
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.channel)
            {
                FlyTo(QwertysRandomContent.LocalCursor[projectile.owner]);
            }
            else
            {
                acceleration           = maxSpeed;
                projectile.tileCollide = false;
                FlyTo(player.Center);
                if (Collision.CheckAABBvAABBCollision(player.position, player.Size, projectile.position, projectile.Size))
                {
                    projectile.Kill();
                }
            }
            projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2;
        }
Exemple #20
0
        private static bool DrawItem(Item item, Vector2 position, float scale, Color color)
        {
            Main.instance.LoadItem(item.type);
            Texture2D tex    = TextureAssets.Item[item.type].Value;
            Rectangle region = (Main.itemAnimations[item.type] == null) ? tex.Frame() : Main.itemAnimations[item.type].GetFrame(tex);

            var nominalSize = 32f;

            if (region.Width > nominalSize || region.Height > nominalSize)
            {
                scale *= MathF.Min(nominalSize / region.Height, nominalSize / region.Width);
            }

            position += new Vector2(nominalSize, nominalSize) * scale / 2f;
            var origin = region.Size() / 2f;

            Main.spriteBatch.Draw(tex, position, region, item.GetAlpha(color), 0f, origin, scale, SpriteEffects.None, 0f);
            Main.spriteBatch.Draw(tex, position, region, item.GetColor(color), 0f, origin, scale, SpriteEffects.None, 0f);

            return(Collision.CheckAABBvAABBCollision(position - region.Size() * scale / 2f, region.Size() * scale, Main.MouseScreen, Vector2.One));
        }
Exemple #21
0
 public override void PreUpdate()
 {
     for (int j = (int)(player.position.Y / 16) - 3; j <= (int)(player.position.Y / 16) + 3; j++)
     {
         for (int i = (int)(player.position.X / 16) - 3; i <= (int)(player.position.X / 16) + 3; i++)
         {
             if (i > 0 && j > 0 && (Main.tile[i, j].type == mod.TileType("VitricOre") || Main.tile[i, j].type == mod.TileType("VitricOreFloat")) && Main.tile[i, j].frameX == 0 && Main.tile[i, j].frameY == 0)
             {
                 for (float f = 0; f <= 1; f += 1 / 30f)
                 {
                     Vector2 lerped = Vector2.Lerp(player.position, player.oldPosition, f);
                     if (Collision.CheckAABBvAABBCollision(lerped, new Vector2(32, 48), new Vector2(i * 16, j * 16), new Vector2(32, 48)) && player.GetModPlayer <AbilityHandler>().ability is Dash && player.GetModPlayer <AbilityHandler>().ability.Active)
                     {
                         f = 2;
                         WorldGen.KillTile(i, j);
                     }
                 }
             }
         }
     }
 }
 public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
 {
     if (projectile.ai[1] >= 90f && projectile.ai[1] < 240f)
     {
         for (int x = -2400; x <= 2400; x += 160)
         {
             for (int y = -2400; y <= 2400; y += 160)
             {
                 if (x == 0 && y == 0)
                 {
                     continue;
                 }
                 Vector2 testPos = projectile.position + new Vector2(x, y);
                 if (Collision.CheckAABBvAABBCollision(testPos, new Vector2(projectile.width, projectile.height), new Vector2(targetHitbox.X, targetHitbox.Y), new Vector2(targetHitbox.Width, targetHitbox.Height)))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemple #23
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (runOnce)
            {
                spinDirection = player.direction;
                speed         = projectile.velocity.Length();
                maxSpeed      = speed;
                runOnce       = false;
            }
            Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("LuneDust"));
            projectile.rotation += MathHelper.ToRadians(maxSpeed * spinDirection);
            if (returnToPlayer)
            {
                if (Collision.CheckAABBvAABBCollision(player.position, player.Size, projectile.position, projectile.Size))
                {
                    projectile.Kill();
                }
                projectile.tileCollide = false;
                //projectile.friendly = false;
                projectile.velocity = QwertyMethods.PolarVector(speed, (player.Center - projectile.Center).ToRotation());
                speed += decceleration;
                if (speed > maxSpeed)
                {
                    speed = maxSpeed;
                }
            }
            else
            {
                projectile.velocity = projectile.velocity.SafeNormalize(-Vector2.UnitY) * speed;
                speed -= decceleration;
                if (speed < 1f)
                {
                    returnToPlayer = true;
                }
            }
        }
            public override void AI()
            {
                if (runOnce)
                {
                    direction = projectile.velocity.ToRotation();

                    runOnce = false;
                }
                Player player = Main.player[projectile.owner];

                for (int k = 0; k < 200; k++)
                {
                    possibleTarget = Main.npc[k];
                    distance       = (possibleTarget.Center - projectile.Center).Length();
                    if (distance < maxDistance && possibleTarget.active && !possibleTarget.dontTakeDamage && !possibleTarget.friendly && possibleTarget.lifeMax > 5 && !possibleTarget.immortal && Collision.CanHit(projectile.Center, 0, 0, possibleTarget.Center, 0, 0))
                    {
                        target      = Main.npc[k];
                        foundTarget = true;


                        maxDistance = (target.Center - projectile.Center).Length();
                    }
                    if (!Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, possibleTarget.position, possibleTarget.Size))
                    {
                        projectile.localNPCImmunity[k] = 0;
                    }
                }
                if (foundTarget)
                {
                    direction = QwertyMethods.SlowRotation(direction, (target.Center - projectile.Center).ToRotation(), 10f);
                }
                projectile.velocity = new Vector2((float)Math.Cos(direction) * speed, (float)Math.Sin(direction) * speed);
                foundTarget         = false;
                maxDistance         = 10000f;
                Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("CaeliteDust"));
                projectile.rotation += (float)Math.PI / 7.5f;
            }
Exemple #25
0
 public override void NearbyEffects(int i, int j, bool closer)
 {
     if (Main.tile[i, j].frameX == 0 && Main.tile[i, j].frameY == 0)
     {
         foreach (Player player in Main.player)
         {
             if (Collision.CheckAABBvAABBCollision(player.position, player.Size, new Vector2(i * 16, j * 16 - 45), new Vector2(368, 64)) && player.GetModPlayer <AbilityHandler>().ability is Smash && !LegendWorld.SealOpen)
             {
                 LegendWorld.SealOpen = true;
                 player.GetModPlayer <AbilityHandler>().ability.OnExit();
                 player.GetModPlayer <AbilityHandler>().ability = null;
                 player.velocity.Y = -20;
             }
         }
         if (LegendWorld.SealOpen)
         {
             Main.tileSolid[Type] = false;
         }
         else
         {
             Main.tileSolid[Type] = true;
         }
     }
 }
Exemple #26
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (runOnce)
            {
                shader = player.ArmorSetDye();
                //Main.NewText(shader);
                runOnce = false;
            }
            //Main.NewText(projectile.timeLeft + ", " + player.ArmorSetDye());
            //projectile.rotation += (float)Math.PI / 30;
            timer++;
            if ((timer > 10 && player.GetModPlayer <crestSet>().justSummonedMoon) || !player.GetModPlayer <crestSet>().setBonus)
            {
                projectile.Kill();
            }
            Dust dust = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("LuneDust"))];

            dust.shader = GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player);
            for (int i = 0; i < 200; i++)
            {
                if (Main.projectile[i].ranged && Main.projectile[i].owner == projectile.owner && Collision.CheckAABBvAABBCollision(Main.projectile[i].position, new Vector2(Main.projectile[i].width, Main.projectile[i].height), projectile.position, new Vector2(projectile.width, projectile.height)))
                {
                    Main.projectile[i].GetGlobalProjectile <moonBoost>().boosted = true;
                }
            }
        }
Exemple #27
0
        public override void AI()
        {
            Dust dust = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("CaeliteDust"))];

            dust.scale = .5f;
            if (runOnce)
            {
                if (projectile.ai[1] < 0)
                {
                    spinDirection    = -1;
                    projectile.ai[1] = Math.Abs(projectile.ai[1]);
                }
                runOnce = false;
            }
            projectile.ai[1]      = Math.Abs(projectile.ai[1]);
            parent                = Main.projectile[(int)projectile.ai[1]];
            projectile.position.X = parent.Center.X - (int)(Math.Cos(projectile.ai[0]) * radius) - projectile.width / 2;
            projectile.position.Y = parent.Center.Y - (int)(Math.Sin(projectile.ai[0]) * radius) - projectile.height / 2;
            projectile.ai[0]     += (float)Math.PI / 120 * spinDirection;
            for (int p = 0; p < 1000; p++)
            {
                clearCheck = Main.projectile[p];
                if (clearCheck.friendly && clearCheck.type != mod.ProjectileType("PunnishFist") && !clearCheck.sentry && clearCheck.minionSlots <= 0 && Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, clearCheck.position, clearCheck.Size))
                {
                    clearCheck.Kill();
                }
            }
            if (!parent.active || parent.type != mod.ProjectileType("RingCenter"))
            {
                projectile.Kill();
            }
            frameTimer++;
            if (frameTimer > 10)
            {
                projectile.frame++;
                if (projectile.frame >= Main.projFrames[projectile.type])
                {
                    projectile.frame = 0;
                }
                frameTimer = 0;
            }
        }
Exemple #28
0
 public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
 {
     if (projectile.ai[0] > 32 && projectile.ai[0] < 100)
     {
         Player  player = Main.player[projectile.owner];
         float   rot    = projectile.rotation - 1.57f + (0.785f * player.direction * (int)player.gravDir);
         Vector2 unit   = rot.ToRotationVector2();
         Vector2 vector = player.RotatedRelativePoint(player.position + new Vector2(player.width / 2, 20), true);
         float   point  = 0f;
         if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), vector, vector + unit * 140 * projectile.scale, 40 * projectile.scale, ref point))
         {
             return(true);
         }
         if (player.velocity.Y * player.gravDir > 3 && projectile.localAI[1] > 0 && Collision.CheckAABBvAABBCollision(player.Center - new Vector2((player.width / 2) + 2, 0), new Vector2(player.width + 4, ((player.height / 2) + 4) * player.gravDir), targetHitbox.TopLeft(), targetHitbox.Size()))
         {
             if (player.immuneTime < 6)
             {
                 player.immune        = true;
                 player.immuneNoBlink = true;
                 player.immuneTime    = 6;
             }
             return(true);
         }
     }
     return(false);
 }
        public override void AI()
        {
            Player player = Main.player[projectile.owner];
            //Main.NewText(moveTo);
            QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(mod);

            if (modPlayer.PlatinumDagger)
            {
                projectile.timeLeft = 2;
            }
            distanceFromPlayer = (player.Center - projectile.Center).Length();
            timer++;
            switch (AttackMode)
            {
            case idle:
                projectile.tileCollide = true;
                attackTimer++;
                if (timer > 60)
                {
                    if (Main.netMode != 2 && projectile.owner == Main.myPlayer)
                    {
                        projectile.ai[0] = Main.rand.Next(0, 80);
                        projectile.ai[1] = Main.rand.Next(-80, 80);
                        if (Main.netMode == 1)
                        {
                            QwertysRandomContent.ProjectileAIUpdate(projectile);
                        }
                        projectile.netUpdate = true;
                    }
                    timer = 0;
                }
                moveTo = new Vector2(player.Center.X + projectile.ai[1], player.Center.Y - projectile.ai[0]);
                if (attackTimer > attackCooldown)
                {
                    if (QwertyMethods.ClosestNPC(ref target, targetMaxDistanceFromPlayer, player.Center, false, player.MinionAttackTargetNPC))
                    {
                        chargeTime = (int)((targetMaxDistanceFromPlayer + 100) / chargeSpeed);
                        for (int k = 0; k < 200; k++)
                        {
                            projectile.localNPCImmunity[k] = 0;
                        }
                        projectile.velocity = (target.Center - projectile.Center).SafeNormalize(-Vector2.UnitY) * chargeSpeed;
                        attackTimer         = 0;
                        AttackMode          = charging;
                    }
                }
                if (distanceFromPlayer > maxDistanceFromPlayer)
                {
                    AttackMode = returning;
                }
                break;

            case charging:
                projectile.tileCollide = true;
                attackTimer++;
                if (attackTimer > chargeTime)
                {
                    AttackMode  = returning;
                    attackTimer = 0;
                    //projectile.velocity = Vector2.Zero;
                }
                break;

            case returning:
                projectile.tileCollide = false;
                moveTo = player.Center;
                if (Collision.CheckAABBvAABBCollision(player.position, player.Size, projectile.position, projectile.Size))
                {
                    AttackMode = idle;
                }
                break;
            }
            if (AttackMode == charging)
            {
                projectile.friendly = true;
                projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2;
            }
            else
            {
                projectile.friendly  = false;
                projectile.velocity += (moveTo - projectile.Center).SafeNormalize(-Vector2.UnitY) * acceleration;
                if (projectile.velocity.Length() > maxSpeed)
                {
                    projectile.velocity = (moveTo - projectile.Center).SafeNormalize(-Vector2.UnitY) * maxSpeed;
                }
                projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, projectile.velocity.ToRotation() + (float)Math.PI / 2, 3);
            }

            //projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2;
        }
Exemple #30
0
 public static bool CheckDash(Player player, Rectangle hitbox)
 {
     return(Collision.CheckAABBvAABBCollision(player.Hitbox.TopLeft(), player.Hitbox.Size(), hitbox.TopLeft(), hitbox.Size()) && player.GetModPlayer <AbilityHandler>().dash.Active);
 }