コード例 #1
0
 public PlayerHit(string hitID, Rectangle casterRect, Vector2 direction, GameplayScreen gpScreen, int dmgModifier)
 {
     fileManager      = new FileManager();
     moveAnimation    = new Animation();
     ssAnimation      = new SpriteSheetAnimation();
     moveSpeed        = 150;
     this.hitID       = hitID;
     this.casterRect  = casterRect;
     this.direction   = direction;
     this.gpScreen    = gpScreen;
     this.dmgModifier = dmgModifier;
 }
コード例 #2
0
        public override void LoadContent(ContentManager content, InputManager inputManager)
        {
            base.LoadContent(content, inputManager);
            fileManager   = new FileManager();
            moveAnimation = new Animation();
            ssAnimation   = new SpriteSheetAnimation();
            moveSpeed     = 150;
            Vector2 tempFrames = Vector2.Zero;

            fileManager.LoadContent("Load/Player.cme", attributes, contents);
            for (int i = 0; i < attributes.Count; i++)
            {
                for (int j = 0; j < attributes[i].Count; j++)
                {
                    switch (attributes[i][j])
                    {
                    case "Health":
                        Health = int.Parse(contents[i][j]);
                        Console.WriteLine("My health = " + Health);
                        break;

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

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

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

                    case "Position":
                        string[] positions = contents[i][j].Split(' ');
                        Position = new Vector2(int.Parse(positions[0]), int.Parse(positions[1]));
                        break;
                    }
                }
            }
            moveAnimation.Frames = new Vector2(4, 4);
            moveAnimation.LoadContent(content, image, "", Position);
            hpBar = new HealthBar(content, Health, Position + new Vector2(0, moveAnimation.FrameHeight));
            hpBar.SetHealth(Health);
        }
コード例 #3
0
ファイル: MenuManager.cs プロジェクト: lukaszjanyga/PWGame
        public void LoadContent(ContentManager content, string id)
        {
            this.content   = new ContentManager(content.ServiceProvider, "Content");
            menuItems      = new List <string>();
            animationTypes = new List <string>();
            menuImages     = new List <Texture2D>();
            animation      = new List <Animation>();
            fileManager    = new FileManager();
            attributes     = new List <List <string> >();
            contents       = new List <List <string> >();
            linkType       = new List <string>();
            linkID         = new List <string>();
            fadeAnimation  = new FadeAnimation();
            ssAnimation    = new SpriteSheetAnimation();
            itemNumber     = 0;
            align          = "";
            fileManager.LoadContent("Load/Menus.cme", attributes, contents, id);


            for (int i = 0; i < attributes.Count; i++)
            {
                for (int j = 0; j < attributes[i].Count; j++)
                {
                    switch (attributes[i][j])
                    {
                    case "Font":
                        font = this.content.Load <SpriteFont>(contents[i][j]);
                        break;

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

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

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

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

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

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

                    case "Align":
                        align = contents[i][j];
                        break;

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

                    case "LinkID":
                        linkID.Add(contents[i][j]);
                        break;
                    }
                }
            }

            SetMenuItems();
            SetAnimations();
        }
コード例 #4
0
ファイル: Enemy.cs プロジェクト: lukaszjanyga/PWGame
        public override void LoadContent(ContentManager content, InputManager inputManager)
        {
            base.LoadContent(content, inputManager);
            fileManager   = new FileManager();
            moveAnimation = new Animation();
            ssAnimation   = new SpriteSheetAnimation();
            moveSpeed     = 150;
            Vector2 totalFrames       = Vector2.Zero;
            Vector2 modelFrames       = Vector2.Zero;
            Vector2 modelFramesOffset = Vector2.Zero;

            VisionRange = 150;

            fileManager.LoadContent("Load/" + enemyID + ".cme", attributes, contents);
            for (int i = 0; i < attributes.Count; i++)
            {
                for (int j = 0; j < attributes[i].Count; j++)
                {
                    //[Image][TotalFrames][ModelFrames][ModelFramesOffset][Health][Damage]
                    switch (attributes[i][j])
                    {
                    case "Health":
                        Health = int.Parse(contents[i][j]);
                        break;

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

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

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

                    case "Damage":
                        damage = int.Parse(contents[i][j]);
                        break;

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

                    case "DecisionCounter":
                        decisionCounterLimit = int.Parse(contents[i][j]);
                        break;

                    case "DropRate":
                        dropRate = int.Parse(contents[i][j]);
                        break;

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

            int cellHeight = image.Height / (int)totalFrames.Y;
            int cellWidth  = image.Width / (int)totalFrames.X;

            Color[] imageData = new Color[image.Width * image.Height];
            image.GetData <Color>(imageData);
            Rectangle sourceRect = new Rectangle(cellWidth * (int)modelFramesOffset.X, cellHeight * (int)modelFramesOffset.Y,
                                                 cellWidth * (int)modelFrames.X, cellHeight * (int)modelFrames.Y);

            Color[] imagePiece = GetImageData(imageData, image.Width, sourceRect);

            Texture2D subtexture = new Texture2D(image.GraphicsDevice, sourceRect.Width, sourceRect.Height);

            image.Dispose();
            image = subtexture;
            subtexture.SetData <Color>(imagePiece);

            moveAnimation.Frames = modelFrames;
            moveAnimation.LoadContent(content, image, enemyID, Position);
            hpBar = new HealthBar(content, Health, Position + new Vector2(0, moveAnimation.FrameHeight));
            hpBar.SetHealth(Health);
        }