我的terraria mod不起作用 [英] My terraria mod isnt working

查看:196
本文介绍了我的terraria mod不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:

错误CS0103:当前上下文中不存在方法名称



我的代码:

I am receiving this error:
error CS0103: The name 'Methods' does not exist in the current context

My code:

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SwordsMod.NPCs.Bosses
{
    public class Optime : ModNPC
    {
        int attackTimer = 0;
        int spread1timer = 150;
        int spread2timer = 151;
        int rapid1timer = 151;
        int rapid2timer = 151;

        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("O P T I M E");
            Main.npcFrameCount[npc.type] = Main.npcFrameCount[3];
        }

        public override void SetDefaults()
        {
            npc.width = 78;
            npc.height = 104;
            npc.damage = 999999;
            npc.defense = 8;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 0f;
            npc.knockBackResist = 0f;
            npc.aiStyle = -1;
            animationType = -1;
            npc.boss = true;
            npc.noGravity = true;
            npc.noTileCollide = true;
            npc.aiStyle = -1;
            npc.lifeMax = Main.expertMode ? 3000 : 5000;

        }
        int useJitterMethod = 1; //set this to 1 for method 1 set it to 2 for method 2
        //variables used for both methods
        Vector2 moveTo;
        float flyDirection;
        //settings for both methods
        float heightAbovePlayer = 200;
        //variables used for jitter method 1

        //settings for jitter method 1
        float acceleration = .8f; // acceleration rate
        float maxSpeed = 7f; //max speed


        //variables used for jitter method 2
        float currentFlyDirection;
        //settings for jitter method 2
        float speed = 12; //how fast it moves
        float rotationSpeed = 20; //rotation speed in degrees per frame
        public override void AI()
        {
            //look at stuff.cs for information on the SlowRotation and PolarVector
            Player player = Main.player[npc.target];
            npc.TargetClosest(true);
            moveTo = new Vector2(player.Center.X, player.Center.Y - heightAbovePlayer);

            flyDirection = (moveTo - npc.Center).ToRotation();

            if (useJitterMethod == 1)//jitter method 1 Acceleration
            {

                npc.velocity = Methods.PolarVector(acceleration, flyDirection);  
                                                                                       
                if (npc.velocity.Length() > maxSpeed)
                {
                    npc.velocity = npc.velocity.SafeNormalize(-Vector2.UnitY) * maxSpeed;
                }
            }

            if (useJitterMethod == 2) //jitter method 2 slowed direction change
            {


                currentFlyDirection = Methods.SlowRotation(currentFlyDirection, flyDirection, rotationSpeed); 
                npc.velocity = Methods.PolarVector(speed, currentFlyDirection); 

            }

            attackTimer++;
            if (attackTimer == 300)
            {
                switch (Main.rand.Next(1, 5))
                {
                    case 1:
                        {
                            spread1timer = 0;
                            break;
                        }
                    case 2:
                        {
                            spread2timer = 0;
                            break;
                        }
                    case 3:
                        {
                            rapid1timer = 0;
                            break;
                        }
                    case 4:
                        {
                            rapid2timer = 0;
                            break;
                        }
                }
                attackTimer = 0;
            }
            spread1timer++;
            if (spread1timer == 30 || spread1timer == 60 || spread1timer == 90 || spread1timer == 120 || spread1timer == 150)
            {
                for (int i = 0; i < 10; i++)
                {
                    float Speed = 12f;
                    int type = mod.ProjectileType("Happfiier");
                    float rotation = ((((float)Math.PI / 5) * i) + (float)Math.Atan2(npc.Center.Y - 10, npc.Center.X - 10));
                    int proj = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, 999999, 0f, 0);
                    Main.projectile[proj].tileCollide = false;
                }
            }
        }
        public override void FindFrame(int frameHeight)
        {
            npc.spriteDirection = 0;
            npc.rotation = 0;
            npc.spriteDirection = npc.direction;
            npc.frameCounter++;
            if (npc.frameCounter >= 8) // ticks per frame
            {
                npc.frame.Y = (npc.frame.Y / frameHeight + 1) % Main.npcFrameCount[npc.type] * 104;
                npc.frameCounter = 0;
            }
        }
    }
}





我尝试了什么:



我尝试过大写,拼写,没有任何效果。



What I have tried:

I tried capitalization, spelling, and nothing has worked.

推荐答案

嗯,错误消息表明您在项目的任何位置都没有名为Methods的类,无论是在您自己的代码文件中,还是在代码顶部的using语句中导入的任何命名空间中。
Well, the error message says that you don't have a class called "Methods" anywhere in your project, either in your own code files or in any namespace that you imported in your "using" statements at the top of the code.


你试图在方法类中调用类似静态方法的内容,但是你还没有通过<导入类的定义code>使用指令。

You are trying to call what look like static methods in the Methods class, but you have not imported a definition of the class via a using directive.
currentFlyDirection = Methods.SlowRotation(currentFlyDirection, flyDirection, rotationSpeed);
npc.velocity = Methods.PolarVector(speed, currentFlyDirection);



查看课程文档。


Check the documentation for the class.


这篇关于我的terraria mod不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆