コード例 #1
0
ファイル: ShootingLine.cs プロジェクト: Crapsky233/Entrogic
        public override void AI()
        {
            // 污染之灵
            NPC elemental = Main.npc[(int)projectile.ai[1]];

            // 保险
            if (elemental == null || elemental.type != NPCType <PollutionElemental>() || elemental.active == false)
            {
                projectile.active = false;
                projectile.Kill();
                projectile.netUpdate = true;
                return;
            }
            Player player = Main.player[elemental.target];

            projectile.Center = elemental.Center;
            projectile.ai[0]++;
            if (projectile.ai[0] == 15 && Main.netMode != NetmodeID.MultiplayerClient)
            {
                // 射击
                foreach (var rotation in rotates)
                {
                    Vector2 vec    = rotation.ToRotationVector2();
                    int     bullet = Projectile.NewProjectile(projectile.Center, vec * 0.9f, ProjectileType <ContimatedSpike>(), 40, 2f);
                    if (Main.dedServ)
                    {
                        NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, bullet);
                    }
                }
                projectile.active = false;
                projectile.Kill();
            }
            if (projectile.ai[0] == 1 && Main.netMode != NetmodeID.MultiplayerClient)
            {
                // 选取
                float startRadius = ModHelper.GetFromToRadians(projectile.Center, player.Center);
                float endRadius   = ModHelper.GetFromToRadians(projectile.Center, player.Center) + MathHelper.TwoPi;
                for (float rotation = startRadius; rotation < endRadius; rotation += MathHelper.TwoPi / 12f)
                {
                    rotates.Add(rotation);

                    // 特效
                    Vector2 vec  = rotation.ToRotationVector2();
                    int     proj = Projectile.NewProjectile(projectile.Center, vec, ProjectileType <EffectRay>(), 0, 0f, projectile.owner);
                    Main.projectile[proj].ai[1] = projectile.whoAmI;
                    if (Main.dedServ)
                    {
                        NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj);
                    }
                }
            }
        }
コード例 #2
0
        public override void Update(GameTime gameTime, Player attackPlayer, NPC attackNPC)
        {
            //if (LifeSpan > 4.96 && LifeSpan <= 5.1f)
            //    Velocity += -ModHelper.GetFromToVector(CardGameUI.ToUIPos(Center), TargetPosition) * 0.4f;
            //else if (LifeSpan <= 5.1f)
            Velocity += ModHelper.GetFromToVector(CardGameUI.ToUIPos(Center), TargetPosition) * 0.9f;
            _rotation = MathHelper.ToRadians(45f) + ModHelper.GetFromToRadians(CardGameUI.ToUIPos(Center), TargetPosition);

            if (Vector2.Distance(CardGameUI.ToUIPos(Center), TargetPosition) < 20f)
            {
                IsRemoved = true;
                CardFightableNPC fightNPC = (CardFightableNPC)attackNPC.modNPC;
                fightNPC.CardGameHealth -= 120 / 5; // 总伤害120,,因为一射5个
            }
            base.Update(gameTime, attackPlayer, attackNPC);
        }