예제 #1
0
        // * Indlæser diverse animationer STATISK (kaldes af GameController) så de ikke genindlæses i hver instans
        public static void InitializeGraphics()
        {
            Animations = new Dictionary<string, GameSprite>();
            string imageRoot = GameController.imageRoot + "/jeep";

            // * Flydende bevægelsesanimationer for en jeep
            List<string> directionDirs = new List<string>(8);
            directionDirs.Add("up-upright");
            directionDirs.Add("upright-right");
            directionDirs.Add("right-downright");
            directionDirs.Add("downright-down");
            directionDirs.Add("down-downleft");
            directionDirs.Add("downleft-left");
            directionDirs.Add("left-upleft");
            directionDirs.Add("upleft-up");

            foreach(string direction in directionDirs)
            {
                GameSprite moveSprite = new GameSprite();
                List<GameSprite> sprites = new List<GameSprite>();
                for(int i = 1; i <= 5; i++)
                {
                    string imagePath = imageRoot + "/" + direction + "/jeep " + i + ".png";
                    if(File.Exists(imagePath))
                    {
                        SpriteImage spriteImg = new SpriteImage(imagePath, Color.Transparent);
                        SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                        moveSprite.AddFrame(spriteFrame);
                    }
                    else
                        throw new FileNotFoundException("404 on " + imagePath);
                }
                Animations.Add("drive_" + direction, moveSprite);
            }
        }
예제 #2
0
        // * Indlæser diverse animationer STATISK (kaldes af GameController) så de ikke genindlæses i hver instans
        public static void InitializeGraphics()
        {
            Animations = new Dictionary<string, GameSprite>();
            string rifleRoot = GameController.imageRoot + "/rifle_infantry";

            List<string> directionDirs = new List<string>(8);
            directionDirs.Add("up");
            directionDirs.Add("upright");
            directionDirs.Add("right");
            directionDirs.Add("downright");
            directionDirs.Add("down");
            directionDirs.Add("downleft");
            directionDirs.Add("left");
            directionDirs.Add("upleft");

            foreach(string direction in directionDirs)
            {
                GameSprite runSprite = new GameSprite();
                List<GameSprite> sprites = new List<GameSprite>();
                for(int i = 1; i <= 6; i++)
                {
                    string imagePath = rifleRoot + "/run/" + direction + "/" + i + ".png";
                    if(File.Exists(imagePath))
                    {
                        SpriteImage spriteImg = new SpriteImage(imagePath, Color.Transparent);
                        SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                        runSprite.AddFrame(spriteFrame);
                    }
                    else
                        throw new FileNotFoundException("404 on " + imagePath);
                }
                Animations.Add("run_" + direction, runSprite);
            }

            GameSprite dieSprite = new GameSprite();
            // * Gentag ikke, afspil kun død én gang,
            // * hvorefter IsDonePlaying angiver om vi officielt kan slette enheden
            dieSprite.RepeatCount = 0;
            for(int i = 1; i <= 7; i++)
            {
                string imagePath = rifleRoot + "/die/right/" + i + ".png";
                if(File.Exists(imagePath))
                {
                    SpriteImage spriteImg = new SpriteImage(imagePath, Color.Transparent);
                    SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                    dieSprite.AddFrame(spriteFrame);
                }
                else
                    throw new FileNotFoundException("404 on " + imagePath);
            }
            Animations.Add("die_right", dieSprite);

            GameSprite standSprite = new GameSprite();
            for(int i = 1; i <= 1; i++)
            {
                string imagePath = rifleRoot + "/stand/right.png";
                if(File.Exists(imagePath))
                {
                    SpriteImage spriteImg = new SpriteImage(imagePath, Color.Transparent);
                    SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                    standSprite.AddFrame(spriteFrame);
                }
                else
                    throw new FileNotFoundException("404 on " + imagePath);
            }
            Animations.Add("stand_right", standSprite);

            foreach(string direction in directionDirs)
            {
                GameSprite attackSprite = new GameSprite();
                attackSprite.RepeatCount = 0;
                for(int i = 1; i <= 8; i++)
                {
                    string imagePath = rifleRoot + "/attack/" + direction + "/" + i + ".png";
                    if(File.Exists(imagePath))
                    {
                        SpriteImage spriteImg = new SpriteImage(imagePath, Color.Transparent);
                        SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                        attackSprite.AddFrame(spriteFrame);
                    }
                    else
                        throw new FileNotFoundException("404 on " + imagePath);
                }
                Animations.Add("attack_" + direction, attackSprite);
            }

            GameSprite piffSprite = new GameSprite();
            piffSprite.RepeatCount = 0;
            for(int i = 0; i <= 3; i++)
            {
                string imagePath = GameController.resourceRoot + "/images/gunfire/piffpiff " + i + ".png";
                if(File.Exists(imagePath))
                {
                    SpriteImage spriteImg = new SpriteImage(imagePath, Color.Transparent);
                    SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                    piffSprite.AddFrame(spriteFrame);
                }
                else
                    throw new FileNotFoundException("404 on " + imagePath);
            }
            Animations.Add("piff", piffSprite);
        }
예제 #3
0
        // * Indlæser diverse animationer STATISK (kaldes af GameController) så de ikke genindlæses i hver instans
        public static void InitializeGraphics()
        {
            Animations = new Dictionary<string, GameSprite>();
            string barracksRoot = GameController.imageRoot + "/barracks";

            GameSprite constructSprite = new GameSprite();
            constructSprite.RepeatCount = 0;
            for(int i = 0; i <= 12; i++)
            {
                string imagePath = barracksRoot + "/make/barrmake " + i + ".png";
                if(File.Exists(imagePath))
                {
                    SpriteImage spriteImg = new SpriteImage(imagePath, Color.Transparent);
                    SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                    constructSprite.AddFrame(spriteFrame);
                }
                else
                    throw new FileNotFoundException("404");
            }
            Animations.Add("make", constructSprite);
        }
예제 #4
0
 public SpriteFrame(SpriteImage image, int delay)
 {
     this.spriteImage = image;
     this.delay = delay;
 }