示例#1
0
文件: Entity.cs 项目: HedgeDog/Game
        public virtual void LoadContent(ContentManager content, List <string> attributes, List <string> contents, InputManager input)
        {
            this.content = new ContentManager(content.ServiceProvider, "Content");

            moveAnimation    = new SpriteSheetAnimation();
            gravity          = 8f;
            velocity         = Vector2.Zero;
            syncTilePosition = false;
            activateGravity  = true;
            attackAnimations = new List <SpriteSheetAnimation>();
            animationOffset  = Vector2.Zero;
            prevOffset       = Vector2.Zero;
            isAttacking      = false;
            tempAnimation    = moveAnimation;


            for (int i = 0; i < attributes.Count; i++)
            {
                switch (attributes[i])
                {
                case "Health":
                    health = int.Parse(contents[i]);
                    break;

                case "Frames":
                    string[] frames = contents[i].Split(' ');
                    moveAnimation.Frames = new Vector2(int.Parse(frames[0]), int.Parse(frames[1]));
                    break;

                case "Image":
                    image = this.content.Load <Texture2D>(contents[i]);
                    break;

                case "Position":
                    frames   = contents[i].Split(' ');
                    position = new Vector2(int.Parse(frames[0]), int.Parse(frames[1]));
                    break;

                case "MoveSpeed":
                    moveSpeed = float.Parse(contents[i]);
                    break;

                case "Range":
                    range = int.Parse(contents[i]);
                    break;
                }
            }

            moveAnimation.LoadContent(content, image, "", position);
        }
示例#2
0
        public virtual void LoadContent(ContentManager content, List <string> attributes, List <string> contents, InputManager input)
        {
            this.content  = new ContentManager(content.ServiceProvider, "Content");
            moveAnimation = new Animation();
            ssAnimation   = new SpriteSheetAnimation();
            // base settings for both enemy and player
            // switch cas to contol the type and values
            for (int i = 0; i < attributes.Count; i++)
            {
                switch (attributes[i])
                {
                case "Health":
                    health = int.Parse(contents[i]);
                    break;

                case "Frames":
                    string[] frames = contents[i].Split(',');
                    moveAnimation.Frames = new Vector2(int.Parse(frames[0]), int.Parse(frames[1]));
                    break;

                case "Image":
                    image = this.content.Load <Texture2D>(contents[i]);
                    break;

                case "Position":
                    frames   = contents[i].Split(',');
                    position = new Vector2(int.Parse(frames[0]), int.Parse(frames[1]));
                    break;

                case "MoveSpeed":
                    moveSpeed = float.Parse(contents[i]);
                    break;

                case "Range":
                    range = int.Parse(contents[i]);
                    break;
                }
            }


            // applying seetings for the player and enemy
            gravity          = 100f;
            velocity         = Vector2.Zero;
            syncTilePosition = false;
            activateGravity  = true;
            moveAnimation.LoadContent(content, image, "", position);
        }
示例#3
0
        public void LoadContent(ContentManager content, string id)
        {
            this.content   = new ContentManager(content.ServiceProvider, "Content");
            menuItems      = new List <string>();
            animationTypes = new List <string>();
            linkType       = new List <string>();
            linkID         = new List <string>();
            menuImages     = new List <Texture2D>();
            animation      = new List <Animation>();
            itemNumber     = 0;
            fAnimation     = new FadeAnimation();
            ssAnimation    = new SpriteSheetAnimation();

            position = Vector2.Zero;

            fileManager = new FileManager();
            // loading in the filename for Menu.txt
            fileManager.LoadContent("Load/Menu.txt", id);
            // switch case for the menu types and values
            for (int i = 0; i < fileManager.Attributes.Count; i++)
            {
                for (int j = 0; j < fileManager.Attributes[i].Count; j++)
                {
                    switch (fileManager.Attributes[i][j])
                    {
                    case "Font":
                        font = this.content.Load <SpriteFont>(fileManager.Contents[i][j]);
                        break;

                    case "Item":
                        menuItems.Add(fileManager.Contents[i][j]);
                        break;

                    case "Image":
                        menuImages.Add(this.content.Load <Texture2D>(fileManager.Contents[i][j]));
                        break;

                    case "Axis":
                        axis = int.Parse(fileManager.Contents[i][j]);
                        break;

                    case "Position":
                        string[] temp = fileManager.Contents[i][j].Split(' ');
                        position = new Vector2(float.Parse(temp[0]), float.Parse(temp[1]));
                        break;

                    case "Source":
                        temp   = fileManager.Contents[i][j].Split(' ');
                        source = new Rectangle(int.Parse(temp[0]), int.Parse(temp[1]), int.Parse(temp[2]), int.Parse(temp[3]));
                        break;

                    case "Animation":
                        animationTypes.Add(fileManager.Contents[i][j]);
                        break;

                    case "Align":
                        align = fileManager.Contents[i][j];
                        break;

                    case "LinkType":
                        linkType.Add(fileManager.Contents[i][j]);
                        break;

                    case "LinkID":
                        linkID.Add(fileManager.Contents[i][j]);
                        break;
                    }
                }
            }
            SetMenuItems();
            SetAnimations();
        }