Esempio n. 1
0
    public static void Init()
    {
        if (isInit == true)
        {
            return;
        }
        isInit = true;

        var texture1 = PngLoader.LoadPNG("Customize/Frame/StrikerFrame.png");

        StrikerFrame = Sprite.Create(texture1, new Rect(0, 0, texture1.width, texture1.height), new Vector2(0.5f, 0.5f));

        var texture2 = PngLoader.LoadPNG("Customize/Frame/AbilityStrikerFrame.png");

        AbilityStrikerFrame = Sprite.Create(texture2, new Rect(0, 0, texture2.width, texture2.height), new Vector2(0.5f, 0.5f));

        var texture3 = PngLoader.LoadPNG("Customize/Frame/SupportFrame.png");

        SupportFrame = Sprite.Create(texture3, new Rect(0, 0, texture3.width, texture3.height), new Vector2(0.5f, 0.5f));

        var texture4 = PngLoader.LoadPNG("Customize/Frame/EventFrame.png");

        EventFrame = Sprite.Create(texture4, new Rect(0, 0, texture4.width, texture4.height), new Vector2(0.5f, 0.5f));

        var texture5 = PngLoader.LoadPNG("Customize/Frame/JOKERFrame.png");

        JOKERFrame = Sprite.Create(texture5, new Rect(0, 0, texture5.width, texture5.height), new Vector2(0.5f, 0.5f));
    }
 public PlayerShotHandler(GraphicsDevice device, ContentManager content, GraphicsDevice graphicsDevice)
 {
     laserShotTexture = PngLoader.Load(device, "Content/LaserShotsOrange.png");
     this.playerShotDefinitionList = new PlayerLaserShotUpgradeStatusList();
     this.spriteBatch         = new SpriteBatch(graphicsDevice);
     this.playerLaserShotList = new List <PlayerLaserShot>();
 }
 public void LoadBackGround(GraphicsDevice device, ContentManager content)
 {
     //Load Background
     backgroundSprite1   = PngLoader.Load(device, "Content/GalaxyBackgroundLarge_1920x1080.png");
     backgroundSprite2   = PngLoader.Load(device, "Content/GalaxyBackgroundLarge_1920x1080.png");
     background1Position = new Vector2(0, 0);
     background2Position = new Vector2(0, 0 - backgroundSprite1.Height);
 }
Esempio n. 4
0
        public void Save(Stream stream)
        {
            if (ScopedObject.Find <FrameBuffer>() != this)
            {
                throw new InvalidOperationException("FBO must be active to save its contents.");
            }

            var img = new byte[_size.Width * _size.Height * 4];

            GL.PixelStore(PixelStoreParameter.PackAlignment, 4);
            GL.ReadPixels(0, 0, _size.Width, _size.Height, PixelFormat.Rgba, PixelType.UnsignedByte, img);
            var buf = PngLoader.Encode(img, Size);

            stream.Write(buf, 0, buf.Length);
        }
Esempio n. 5
0
        public void InitializeAndLoadPlayer(GraphicsDevice device, ContentManager content, Vector2 initalPosition, SpriteBatch hbSpriteBatch)
        {
            this.playerPosition         = initalPosition;
            this.playerHealth           = 100;
            this.playerBaseDamage       = 25;
            this.playerDamageMultiplier = 1f;
            this.playerResultingDamage  = (int)(this.playerBaseDamage * this.playerDamageMultiplier);
            this.playerTexture          = PngLoader.Load(device, "Content/SpaceshipPlayer.png");
            this.healthbarXCorrection   = 5;

            float   hbScale = 0.4f;
            Vector2 initialPlayerHBPosition = (this.playerPosition + (new Vector2(((((playerTexture.Width * this.shipScale.X) / 2) - (((HealthBar.healthBarTexture.Width * hbScale) / 2) + 5)) + healthbarXCorrection), (playerTexture.Height * this.shipScale.X) + 7)));

            playerHealthBar = new HealthBar(hbSpriteBatch, initialPlayerHBPosition, this.playerHealth, hbScale);
        }
Esempio n. 6
0
        public static void ConvertPngToShp(string[] args)
        {
            var dest   = args[1].Split('-').First() + ".shp";
            var frames = args.Skip(1).Select(a => PngLoader.Load(a));

            var size = frames.First().Size;

            if (frames.Any(f => f.Size != size))
            {
                throw new InvalidOperationException("All frames must be the same size");
            }

            using (var destStream = File.Create(dest))
                ShpReader.Write(destStream, size, frames.Select(f => f.ToBytes()));

            Console.WriteLine(dest + " saved.");
        }
Esempio n. 7
0
        public static void ConvertPngToShp(string[] args)
        {
            var src   = args[1];
            var dest  = Path.ChangeExtension(src, ".shp");
            var width = int.Parse(args[2]);

            var srcImage = PngLoader.Load(src);

            if (srcImage.Width % width != 0)
            {
                throw new InvalidOperationException("Bogus width; not a whole number of frames");
            }

            using (var destStream = File.Create(dest))
                ShpWriter.Write(destStream, width, srcImage.Height,
                                srcImage.ToFrames(width));
        }
        public void Run(ModData modData, string[] args)
        {
            var inputFiles = GlobArgs(args).OrderBy(a => a).ToList();
            var dest       = inputFiles[0].Split('-').First() + ".shp";
            var frames     = inputFiles.Select(a => PngLoader.Load(a));

            var size = frames.First().Size;

            if (frames.Any(f => f.Size != size))
            {
                throw new InvalidOperationException("All frames must be the same size");
            }

            using (var destStream = File.Create(dest))
                ShpTDSprite.Write(destStream, size, frames.Select(f => ToBytes(f)));

            Console.WriteLine(dest + " saved.");
        }
        public SpriteSheet Load(GraphicsDevice device, string imageResource)
        {
            var texture = PngLoader.Load(device, $"Content/{imageResource}");

            var dataFile = Path.Combine(
                this.contentManager.RootDirectory,
                Path.ChangeExtension(imageResource, "txt"));

            var dataFileLines = this.ReadDataFile(dataFile);

            var sheet = new SpriteSheet();

            foreach (
                var cols in
                from row in dataFileLines
                where !string.IsNullOrEmpty(row) && !row.StartsWith("#")
                select row.Split(';'))
            {
                if (cols.Length != 10)
                {
                    throw new InvalidDataException("Incorrect format data in spritesheet data file");
                }

                var isRotated       = int.Parse(cols [1]) == 1;
                var name            = cols[0];
                var sourceRectangle = new Rectangle(
                    int.Parse(cols[2]),
                    int.Parse(cols[3]),
                    int.Parse(cols[4]),
                    int.Parse(cols[5]));
                var size = new Vector2(
                    int.Parse(cols[6]),
                    int.Parse(cols[7]));
                var pivotPoint = new Vector2(
                    float.Parse(cols[8]),
                    float.Parse(cols[9]));
                var sprite = new SpriteFrame(texture, sourceRectangle, size, pivotPoint, isRotated);

                sheet.Add(name, sprite);
            }

            return(sheet);
        }
Esempio n. 10
0
    static void LoadCards()
    {
        // フォルダー列挙
        var directory = System.IO.Directory.GetParent(Application.dataPath).ToString() + "/CardDatas";

        string[] subFolders = oulFile.EnumDirectory(directory);

        // 曲の分の配列確保
        //cardDatas = new CardData[subFolders.Length];
        cardDatas           = new Queue <CardData>();
        createOnlyCardDatas = new Queue <CardData>();

        int deckCardNo   = 0;
        int createCardNo = 0;

        for (int i = 0; i < subFolders.Length; i++)
        {
            var cardData = new CardData();

            var folderName = subFolders[i];

            // フォルダー名=保存
            //m_aCardDatas[i].folderName = folderName;

            var path = directory + "/" + folderName;

            // テキスト情報読み込み
            {
                //Debug.Log(path + "/info.txt");

                //oulFile.OutPutLog(Application.dataPath + "/log.txt", "テキストオープン\r\n");

                //oulFile.OutPutLog(path + "/log.txt", "キテルグマ");

                var loader = new TextLoader();
                loader.LoadText(path + "/info.txt");

                //oulFile.OutPutLog(Application.dataPath + "/log.txt", "テキストロード開始\r\n");

                // 読み飛ばし用
                string skip;

                // 生成専用かどうか分岐
                skip = loader.ReadString();
                Debug.Assert(skip == "[CREATE_ONLY]", "生成専用テキストがない");
                skip = loader.ReadString();
                if (skip == "ON")
                {
                    cardData.id = createCardNo++;
                    createOnlyCardDatas.Enqueue(cardData);
                }
                else
                {
                    cardData.id = deckCardNo++;
                    cardDatas.Enqueue(cardData);
                }

                // カードタイプ(ファイターor効果ファイターorイベント)
                skip = loader.ReadString();
                Debug.Assert(skip == "[TYPE]", "カードID" + i + "のテキストずれてるクマ");
                var cardType = (CardType)loader.ReadInt();
                switch (cardType)
                {
                case CardType.Fighter:
                    cardData.fighterCard = new FighterCard();
                    break;

                case CardType.AbilityFighter:
                    cardData.abilityFighterCard = new AbilityFighterCard();
                    break;

                case CardType.Joker:
                    cardData.jokerCard = new JokerCard();
                    break;

                case CardType.Support:
                    cardData.supportCard = new SupportCard();
                    break;

                case CardType.Connect:
                    cardData.connectCard = new ConnectCard();
                    break;

                case CardType.Intercept:
                    cardData.interceptCard = new InterceptCard();
                    break;

                default:
                    ExceptionMessage.MessageBox("text error.", "card type error." + folderName);
                    break;
                }

                cardData.cardType = cardType;

                // カード名
                skip = loader.ReadString();
                Debug.Assert(skip == "[NAME]", "カードID" + i + "のテキストずれてるクマ");
                cardData.cardName = loader.ReadString();

                // レア度
                skip = loader.ReadString();
                Debug.Assert(skip == "[RARE]", "カードID" + i + "のテキストずれてるクマ");
                cardData.rarelity = (Rarelity)loader.ReadInt();

                // 効果テキスト
                skip = loader.ReadString();
                Debug.Assert(skip == "[A_TEXT]", "カードID" + i + "のテキストずれてるクマ");
                while (true)
                {
                    var str = loader.ReadLine();
                    if (str == "")
                    {
                        continue;
                    }
                    if (str == "[F_TEXT]")
                    {
                        break;
                    }

                    cardData.abilityText += str + "\r\n";
                }

                // フレーバーテキスト
                skip = loader.ReadString();
                while (true)
                {
                    var str = loader.ReadLine();
                    if (str == "")
                    {
                        continue;
                    }
                    if (str.ToCharArray()[0] == '[')
                    {
                        break;
                    }

                    cardData.flavorText += str + "\r\n";
                }

                // パワー
                //skip = loader.ReadString();
                cardData.power = loader.ReadInt();

                // タイプによって分岐
                switch (cardType)
                {
                case CardType.Fighter:
                {
                    // 種族
                    skip = loader.ReadLine();
                    // 種族の個数
                    int numSyuzoku = loader.ReadInt();
                    cardData.fighterCard.syuzokus = new Syuzoku[numSyuzoku];
                    // 個数に応じて読み込み
                    for (int j = 0; j < numSyuzoku; j++)
                    {
                        cardData.fighterCard.syuzokus[j] = (Syuzoku)loader.ReadInt();
                    }
                }
                break;

                case CardType.AbilityFighter:
                {
                    var abilityFighterCard = cardData.abilityFighterCard;

                    // 種族
                    skip = loader.ReadLine();
                    // 種族の個数
                    int numSyuzoku = loader.ReadInt();
                    abilityFighterCard.syuzokus = new Syuzoku[numSyuzoku];
                    // 個数に応じて読み込み
                    for (int j = 0; j < numSyuzoku; j++)
                    {
                        abilityFighterCard.syuzokus[j] = (Syuzoku)loader.ReadInt();
                    }

                    // 効果読み込み
                    skip = loader.ReadString();
                    var numAbility = loader.ReadInt();
                    abilityFighterCard.abilityDatas = new CardAbilityData[numAbility];
                    for (int j = 0; j < numAbility; j++)
                    {
                        abilityFighterCard.abilityDatas[j] = new CardAbilityData();
                        LoadAbility(loader, out abilityFighterCard.abilityDatas[j]);
                    }
                }
                break;

                case CardType.Joker:
                    // 効果
                {
                    var jokerCard = cardData.GetJokerCard();

                    // [NEW] 今は種族考慮せず
                    //// 種族
                    //skip = loader.ReadLine();
                    //// 種族の個数
                    //int numSyuzoku = loader.ReadInt();
                    //jokerCard.syuzokus = new Syuzoku[numSyuzoku];
                    //// 個数に応じて読み込み
                    //for (int j = 0; j < numSyuzoku; j++)
                    //    abilityFighterCard.syuzokus[j] = (Syuzoku)loader.ReadInt();


                    // 効果
                    var numAbility = loader.ReadInt();
                    jokerCard.abilityDatas = new CardAbilityData[numAbility];
                    for (int j = 0; j < numAbility; j++)
                    {
                        jokerCard.abilityDatas[j] = new CardAbilityData();
                        LoadAbility(loader, out jokerCard.abilityDatas[j]);
                    }
                }
                break;

                case CardType.Support:
                case CardType.Connect:
                case CardType.Intercept:
                {
                    var eventCard = cardData.GetEventCard();

                    // 効果
                    var numAbility = loader.ReadInt();
                    eventCard.abilityDatas = new CardAbilityData[numAbility];
                    for (int j = 0; j < numAbility; j++)
                    {
                        eventCard.abilityDatas[j] = new CardAbilityData();
                        LoadAbility(loader, out eventCard.abilityDatas[j]);
                    }
                }
                break;
                }
            }

            // キャラ画像
            var texture = PngLoader.LoadPNG(path + "/image.png");
            if (texture)
            {
                cardData.image = /*texture;*/ Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
            }

            //Debug.Log("カードID" + i + "番の読み込みが完了");
        }
    }