Exemple #1
0
 public Player(SpriteFont font, TileMap map, SceneObjectParent parent, SpriteImage[] simage, float pixelPerSecSpeed = 0)
     : base(map, parent, simage, pixelPerSecSpeed)
 {
     Vector2 sz = simage[0].GetCurrentImageSize();
     SetHandle(new Vector2(sz.X / 2, sz.Y / 2));
     Registry.Require<GraphicsDeviceManager>();
     gmgr = Registry.Lookup<GraphicsDeviceManager>();
     this.font = font;
 }
Exemple #2
0
 /// <summary>
 /// This creates a sprite with the passed in image
 /// </summary>
 /// <param name="parent">The parent scene graph object</param>
 /// <param name="image">The image to draw for the sprite</param>
 public BasicSprite(SceneObjectParent parent, Texture2D image)
     : base(parent)
 {
     this.image = new SimpleSpriteImage(image);
 }
Exemple #3
0
 /// <summary>
 /// This creates a sprite with the passed in image
 /// </summary>
 /// <param name="parent">The parent scene graph object</param>
 /// <param name="image">The image to draw for the sprite</param>
 public BasicSprite(SceneObjectParent parent, SpriteImage simage)
     : base(parent)
 {
     this.image = simage;
 }
Exemple #4
0
 protected void SetImage(SpriteImage simage)
 {
     this.image = simage;
 }
Exemple #5
0
 /// <summary>
 /// <summary>
 /// This creates a sprite with no image
 /// Note that the Scenegraph itself is a SceneObjectParent and represents
 /// the root of the scenegraph
 /// </summary>
 /// <param name="parent">The parent scene graph object</param>
 public BasicSprite(SceneObjectParent parent)
     : base(parent)
 {
     this.image = null;
 }
 public BasicTilemapSprite(TileMap map, SceneObjectParent parent, SpriteImage simage)
     : base(parent, simage)
 {
     tileMap = map;
 }
Exemple #7
0
 private SpriteImage[] GetPlayerImages()
 {
     SpriteImage[] images = new SpriteImage[3];
     SimpleSpriteImage img = new SimpleSpriteImage(Content.Load<Texture2D>("Player"));
     images[0] = img;
     images[1] = img;
     images[2] = img;
     return images;
 }
Exemple #8
0
 public JumpingPlayer(SpriteFont font, TileMap map, SceneObjectParent parent, SpriteImage[] simage, float pixelPerSecSpeed = 0)
     : base(font, map, parent, simage, pixelPerSecSpeed)
 {
 }
Exemple #9
0
    public override void LoadModel()
    {
        towerAsset = GameLoader.Instance.LoadAssetSync("Resources/Prefabs/ArrowTower.prefab");
        towerObj   = towerAsset.GameObjectAsset;
        towerObj.transform.position = this.towerInfo.GetPosition();
        if (towerObj.GetComponent <ClickInfo>() == null)
        {
            ClickInfo clickInfo = towerObj.AddComponent <ClickInfo>();
            clickInfo.OnInit(ClickType.Tower, this.towerInfo.Id, FingerDown);
        }
        else
        {
            ClickInfo clickInfo = towerObj.GetComponent <ClickInfo>();
            clickInfo.OnInit(ClickType.Tower, this.towerInfo.Id, FingerDown);
        }
        //加载塔身图片
        GameObject towerBaseObj = towerObj.transform.Find("ArrowTowerBase").gameObject;
        Vector3    towerBasePos = towerBaseObj.transform.position;

        towerBasePos.z += 5f;
        towerBaseObj.transform.position = towerBasePos;
        if (towerBaseObj.GetComponent <SpriteImage>() != null)
        {
            towerBase = towerBaseObj.GetComponent <SpriteImage>();
        }
        else
        {
            towerBase = towerBaseObj.AddComponent <SpriteImage>();
        }
        towerBase.OnInit(towerInfo.towerBase);
        //加载射手1
        GameObject shooterObj1 = towerObj.transform.Find("ArrowShooter1").gameObject;

        if (shooterObj1.GetComponent <Animate>() != null)
        {
            shooter1 = shooterObj1.GetComponent <Animate>();
        }
        else
        {
            shooter1 = shooterObj1.AddComponent <Animate>();
        }
        shooter1.OnInit(towerInfo.shooter);
        shooter1.startAnimation("idle");
        //加载射手2
        GameObject shooterObj2 = towerObj.transform.Find("ArrowShooter2").gameObject;

        if (shooterObj2.GetComponent <Animate>() != null)
        {
            shooter2 = shooterObj2.GetComponent <Animate>();
        }
        else
        {
            shooter2 = shooterObj2.AddComponent <Animate>();
        }

        //根据塔基座大小增加碰撞盒
        BoxCollider collider;

        if (towerObj.GetComponent <BoxCollider>() == null)
        {
            collider      = towerObj.AddComponent <BoxCollider>();
            collider.size = new Vector3(towerBase.width, towerBase.height, 0.2f);
        }
        else
        {
            collider      = towerObj.GetComponent <BoxCollider>();
            collider.size = new Vector3(towerBase.width, towerBase.height, 0.2f);
        }
        shooter2.OnInit(towerInfo.shooter);
        shooter2.startAnimation("idle");
    }
Exemple #10
0
        public bool Export(Project _project, SpriteExporter _spriteExporter, SpriteImage _mainMenuBGImage)
        {
            bool success = false;

            try {
                if (!Directory.Exists(m_exportPath))
                {
                    Directory.CreateDirectory(m_exportPath);
                }
                //Text Files


                //Gib den SpriteImages einen unique Key und füge diesen Key beim Export für jede Benutzung einem Dictionary zu
                //Wenn Das Sprite scho einmal benutzt wurde, wird es trotzdem nurt einmal vermerkt.

                //ImageImports
                using (StreamWriter writer = new StreamWriter(Path.Combine(m_exportPath, "ImageImports.txt"), false)) {
                    for (int i = 0; i < _spriteExporter.SpriteCount; ++i)
                    {
                        writer.WriteLine(Path.GetFileName(_spriteExporter.SpritesArray[i].Image));
                    }
                    writer.Close();
                }

                //(Button)Sprite Imports
                using (StreamWriter writer = new StreamWriter(Path.Combine(m_exportPath, "SpriteImports.txt"), false)) {
                    for (int i = 0; i < _spriteExporter.ButtonSpriteCount; ++i)
                    {
                        writer.WriteLine(Path.GetFileName(_spriteExporter.ButtonSpritesArray[i].Image));
                    }
                    writer.Close();
                }

                //Storyboard
                using (IndentedTextWriter writer = new IndentedTextWriter(new StreamWriter(Path.Combine(m_exportPath, "Storyboard.txt"), false))) {
                    m_textBuilder.ExportStory(writer, _project, _spriteExporter);
                    writer.Close();
                }

                //Options Datei
                using (StreamWriter writer = new StreamWriter(Path.Combine(m_exportPath, "options.txt"), false)) {
                    SettingsViewModel    svm  = _project.ProjectSettingsViewModel;
                    FontManagerViewModel fmvm = _project.FontManagerViewModel;
                    writer.WriteLine($"WindowWidth: {svm.WindowWidth};");
                    writer.WriteLine($"WindowHeight: {svm.WindowHeight};");
                    writer.WriteLine($"TextBoxRed: {svm.TextBoxRed};");
                    writer.WriteLine($"TextBoxGreen: {svm.TextBoxGreen};");
                    writer.WriteLine($"TextBoxBlue: {svm.TextBoxBlue};");
                    writer.WriteLine($"TextBoxAlpha: {svm.TextBoxAlpha};");
                    writer.WriteLine($"Font: {fmvm.CurrentUsedFont.Font.Source}.ttf;");
                    writer.Write($"FontSize: {fmvm.FontSize};");                     //Last entry has to not contain new Line or Game loading will fail
                    writer.Close();
                }

                //Menu Files
                using (IndentedTextWriter writer = new IndentedTextWriter(new StreamWriter(Path.Combine(m_exportPath, "MainMenu.txt"), false))) {
                    m_textBuilder.ExportMainMenu(writer, _mainMenuBGImage, _spriteExporter);
                    writer.Close();
                }

                //SaveMenu
                using (IndentedTextWriter writer = new IndentedTextWriter(new StreamWriter(Path.Combine(m_exportPath, "SaveMenu.txt"), false))) {
                    var    base64EncodedBytes = Convert.FromBase64String("TWVudSB7CgoJTmFtZTogIlNhdmUgTWVudSI7CgoJQkdJbmRleDogMgoKCUl0ZW1zIHsKCQlCdXR0b24gewoJCQlUZXh0OiAiR28gQmFjayI7CgkJCUJ1dHRvbjogNjAwLCA1MDAsIDEwMCwgMjAwLCAwOwoJCQlUeXBlOiAxMTsKCQl9CgkJQnV0dG9uIHsKCQkJVGV4dDogIlRlbXAiOwoJCQlCdXR0b246IDUwLCAxNzAsIDUwLCAxMDAsIDA7CgkJCVR5cGU6IDc7CgkJfQoJCUJ1dHRvbiB7CgkJCVRleHQ6ICJUZW1wIjsKCQkJQnV0dG9uOiA1MCwgMjMwLCA1MCwgMTAwLCAwOwoJCQlUeXBlOiA3OwoJCX0KCQlCdXR0b24gewoJCQlUZXh0OiAiVGVtcCI7CgkJCUJ1dHRvbjogNTAsIDI5MCwgNTAsIDEwMCwgMDsKCQkJVHlwZTogNzsKCQl9CgoJCUJ1dHRvbiB7CgkJCVRleHQ6ICJUZW1wIjsKCQkJQnV0dG9uOiAyMDAsIDE3MCwgNTAsIDEwMCwgMDsKCQkJVHlwZTogNzsKCQl9CgkJQnV0dG9uIHsKCQkJVGV4dDogIlRlbXAiOwoJCQlCdXR0b246IDIwMCwgMjMwLCA1MCwgMTAwLCAwOwoJCQlUeXBlOiA3OwoJCX0KCQlCdXR0b24gewoJCQlUZXh0OiAiVGVtcCI7CgkJCUJ1dHRvbjogMjAwLCAyOTAsIDUwLCAxMDAsIDA7CgkJCVR5cGU6IDc7CgkJfQoJfQp9");
                    string exportString       = Encoding.UTF8.GetString(base64EncodedBytes);
                    writer.Write(exportString);
                    writer.Close();
                }
                //LoadMenu
                using (IndentedTextWriter writer = new IndentedTextWriter(new StreamWriter(Path.Combine(m_exportPath, "LoadMenu.txt"), false))) {
                    var    base64EncodedBytes = Convert.FromBase64String("TWVudSB7CgoJTmFtZTogIkxvYWQgTWVudSI7CgoJQkdJbmRleDogMgoKCUl0ZW1zIHsKCQlCdXR0b24gewoJCQlUZXh0OiAiR28gQmFjayI7CgkJCUJ1dHRvbjogNjAwLCA1MDAsIDEwMCwgMjAwLCAwOwoJCQlUeXBlOiAxMTsKCQl9CgkJQnV0dG9uIHsKCQkJVGV4dDogIlRlbXAiOwoJCQlCdXR0b246IDUwLCAxNzAsIDUwLCAxMDAsIDA7CgkJCVR5cGU6IDEyOwoJCX0KCQlCdXR0b24gewoJCQlUZXh0OiAiVGVtcCI7CgkJCUJ1dHRvbjogNTAsIDIzMCwgNTAsIDEwMCwgMDsKCQkJVHlwZTogMTI7CgkJfQoJCUJ1dHRvbiB7CgkJCVRleHQ6ICJUZW1wIjsKCQkJQnV0dG9uOiA1MCwgMjkwLCA1MCwgMTAwLCAwOwoJCQlUeXBlOiAxMjsKCQl9CgoJCUJ1dHRvbiB7CgkJCVRleHQ6ICJUZW1wIjsKCQkJQnV0dG9uOiAyMDAsIDE3MCwgNTAsIDEwMCwgMDsKCQkJVHlwZTogMTI7CgkJfQoJCUJ1dHRvbiB7CgkJCVRleHQ6ICJUZW1wIjsKCQkJQnV0dG9uOiAyMDAsIDIzMCwgNTAsIDEwMCwgMDsKCQkJVHlwZTogMTI7CgkJfQoJCUJ1dHRvbiB7CgkJCVRleHQ6ICJUZW1wIjsKCQkJQnV0dG9uOiAyMDAsIDI5MCwgNTAsIDEwMCwgMDsKCQkJVHlwZTogMTI7CgkJfQoJfQp9");
                    string exportString       = Encoding.UTF8.GetString(base64EncodedBytes);
                    writer.Write(exportString);
                    writer.Close();
                }
                //PauseMenu
                using (IndentedTextWriter writer = new IndentedTextWriter(new StreamWriter(Path.Combine(m_exportPath, "PauseMenu.txt"), false))) {
                    var    base64EncodedBytes = Convert.FromBase64String("TWVudSB7CgoJTmFtZTogIlBhdXNlIE1lbnUiOwoKCUJHSW5kZXg6IDIKCglJdGVtcyB7CgkJQnV0dG9uIHsKCQkJVGV4dDogIkJhY2sgdG8gR2FtZSI7CgkJCUJ1dHRvbjogNTAsIDUwLCAxMDAsIDIwMCwgMDsKCQkJVHlwZTogMTA7CgkJfQoJCUJ1dHRvbiB7CgkJCVRleHQ6ICJTYXZlIjsKCQkJQnV0dG9uOiA1MCwgMTEwLCA1MCwgMTAwLCAwOwoJCQlUeXBlOiAxNDsKCQl9CgkJQnV0dG9uIHsKCQkJVGV4dDogIkxvYWQiOwoJCQlCdXR0b246IDUwLCAxNzAsIDUwLCAxMDAsIDA7CgkJCVR5cGU6IDE1OwoJCX0KCQlCdXR0b24gewoJCQlUZXh0OiAiQmFjayB0byBNYWluIE1lbnUiOwoJCQlCdXR0b246IDUwLCAyMzAsIDUwLCAxMDAsIDA7CgkJCVR5cGU6IDEzOwoJCX0KCX0KfQ==");
                    string exportString       = Encoding.UTF8.GetString(base64EncodedBytes);
                    writer.Write(exportString);
                    writer.Close();
                }
                //Variables
                using (IndentedTextWriter writer = new IndentedTextWriter(new StreamWriter(Path.Combine(m_exportPath, "Variables.txt"), false))) {
                    m_textBuilder.ExportVariables(writer, _project.VariableManagerViewModel);
                    writer.Close();
                }

                //Copy Files
                string filename;
                string destFile;
                //Image Files
                for (int i = 0; i < _spriteExporter.SpriteCount; ++i)
                {
                    filename = Path.GetFileName(_spriteExporter.SpritesArray[i].Image);
                    destFile = Path.Combine(m_exportPath, filename);
                    File.Copy(_spriteExporter.SpritesArray[i].Image, destFile, true);
                }
                //Button Image Files
                for (int i = 0; i < _spriteExporter.ButtonSpriteCount; ++i)
                {
                    filename = Path.GetFileName(_spriteExporter.ButtonSpritesArray[i].Image);
                    destFile = Path.Combine(m_exportPath, filename);
                    File.Copy(_spriteExporter.ButtonSpritesArray[i].Image, destFile, true);
                }
                //TTF Font Files
                string path = _project.FontManagerViewModel.CurrentUsedFont.Font.BaseUri.OriginalString;
                filename = _project.FontManagerViewModel.CurrentUsedFont.Font.Source;
                destFile = Path.Combine(m_exportPath, filename + ".ttf");
                File.Copy(path, destFile, true);

                //bin Files
                path = Directory.GetCurrentDirectory() + @"\bin";
                DirectoryCopy(path, m_exportPath, false);

                return(success = true);
            } catch (Exception ex) {
                MessageBox.Show("Export failed! " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(success);
            }
        }
Exemple #11
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);
        }
Exemple #12
0
 public MOB(TileMap map, SceneObjectParent parent, SpriteImage simage, float pixelPerSecSpeed = 0)
     : base(map, parent, simage)
 {
     this.pixelPerSecSpeed = pixelPerSecSpeed;
 }
 public MultiImageSprite(SceneObjectParent parent, SpriteImage[] simage)
     : base(parent, simage[0])
 {
     images = simage;
 }
 public MultiImageSprite(SceneObjectParent parent, SpriteImage simage)
     : base(parent,simage)
 {
 }