protected Texture2D GetTexture(string key, out float aspect)
        {
            Game game = Game.Get();

            aspect = 0;
            if (game.cd.TryGet(key, out TokenData tokenData))
            {
                Vector2 texPos  = new Vector2(tokenData.x, tokenData.y);
                Vector2 texSize = new Vector2(tokenData.width, tokenData.height);
                return(ContentData.FileToTexture(tokenData.image, texPos, texSize));
            }
            else if (game.cd.TryGet(key, out PuzzleData puzzleData))
            {
                return(ContentData.FileToTexture(puzzleData.image));
            }
            else if (game.cd.TryGet(key, out ImageData imageData))
            {
                Vector2 texPos  = new Vector2(imageData.x, imageData.y);
                Vector2 texSize = new Vector2(imageData.width, imageData.height);
                return(ContentData.FileToTexture(imageData.image, texPos, texSize));
            }
            else if (game.cd.TryGet <TileSideData>(key, out var tileSideData))
            {
                aspect = tileSideData.aspect;
                return(ContentData.FileToTexture(tileSideData.image));
            }
            else if (File.Exists(Path.GetDirectoryName(game.quest.qd.questPath) + Path.DirectorySeparatorChar + key))
            {
                return(ContentData.FileToTexture(Path.GetDirectoryName(game.quest.qd.questPath) + Path.DirectorySeparatorChar + key));
            }
            return(null);
        }
예제 #2
0
    void AddMonster(Quest.Monster m, Game game)
    {
        Sprite mSprite;

        Texture2D newTex = ContentData.FileToTexture(m.monsterData.image);

        GameObject mImg = new GameObject("monsterImg" + m.monsterData.name);

        mImg.tag = "monsters";

        mImg.transform.parent = game.uICanvas.transform;

        RectTransform trans = mImg.AddComponent <RectTransform>();

        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (0.25f + offset) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
        offset += monsterSize + 0.5f;
        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
        mImg.AddComponent <CanvasRenderer>();

        UnityEngine.UI.Image image = mImg.AddComponent <UnityEngine.UI.Image>();
        icons.Add(m.monsterData.name, image);
        mSprite      = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
        image.sprite = mSprite;
        image.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

        UnityEngine.UI.Button button = mImg.AddComponent <UnityEngine.UI.Button>();
        button.interactable = true;
        button.onClick.AddListener(delegate { MonsterDiag(m.monsterData.name); });
    }
예제 #3
0
    // Add individual monster placements for hero count
    public void AddPlacedMonsters(EventManager.MonsterEvent me, int count)
    {
        // Get monster placement image
        Texture2D newTex = ContentData.FileToTexture(me.cMonster.imagePlace);

        // Check load worked
        if (newTex == null)
        {
            ValkyrieDebug.Log("Error: Cannot load monster image");
            Application.Quit();
        }

        // Get placement dimensions
        int x = 1;
        int y = 1;

        if (me.cMonster.ContainsTrait("medium") || me.cMonster.ContainsTrait("huge"))
        {
            x = 2;
        }
        if (me.cMonster.ContainsTrait("huge") || me.cMonster.ContainsTrait("massive"))
        {
            y = 2;
        }
        if (me.cMonster.ContainsTrait("massive"))
        {
            x = 3;
        }

        // All all placements
        foreach (string s in me.qMonster.placement[count])
        {
            AddPlacedMonsterImg(s, newTex, x, y);
        }
    }
예제 #4
0
        protected Texture2D GetTexture(string key, out float aspect)
        {
            Game game = Game.Get();

            aspect = 0;
            if (game.cd.tokens.ContainsKey(key))
            {
                Vector2 texPos  = new Vector2(game.cd.tokens[key].x, game.cd.tokens[key].y);
                Vector2 texSize = new Vector2(game.cd.tokens[key].width, game.cd.tokens[key].height);
                return(ContentData.FileToTexture(game.cd.tokens[key].image, texPos, texSize));
            }
            else if (game.cd.puzzles.ContainsKey(key))
            {
                return(ContentData.FileToTexture(game.cd.puzzles[key].image));
            }
            else if (game.cd.images.ContainsKey(key))
            {
                Vector2 texPos  = new Vector2(game.cd.images[key].x, game.cd.images[key].y);
                Vector2 texSize = new Vector2(game.cd.images[key].width, game.cd.images[key].height);
                return(ContentData.FileToTexture(game.cd.images[key].image, texPos, texSize));
            }
            else if (game.cd.tileSides.ContainsKey(key))
            {
                aspect = game.cd.tileSides[key].aspect;
                return(ContentData.FileToTexture(game.cd.tileSides[key].image));
            }
            else if (File.Exists(Path.GetDirectoryName(game.quest.qd.questPath) + "/" + key))
            {
                return(ContentData.FileToTexture(Path.GetDirectoryName(game.quest.qd.questPath) + "/" + key));
            }
            return(null);
        }
예제 #5
0
    public void UpdateImages()
    {
        if (icons == null)
        {
            return;
        }

        Game game = Game.Get();

        foreach (Quest.Hero h in game.quest.heroes)
        {
            UnityEngine.UI.Image image = icons[h.id];

            Texture2D newTex = Resources.Load("sprites/tokens/objective-token-black") as Texture2D;

            if (h.heroData != null)
            {
                newTex = ContentData.FileToTexture(h.heroData.image);
            }

            Sprite heroSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
            image.sprite = heroSprite;
            image.color  = Color.white;
        }
    }
예제 #6
0
    // Redraw images
    public void UpdateImages()
    {
        if (icons == null)
        {
            return;
        }
        if (icon_frames == null)
        {
            return;
        }

        Game game = Game.Get();

        foreach (Quest.Hero h in game.quest.heroes)
        {
            Texture2D frameTex = Resources.Load("sprites/borders/grey_frame") as Texture2D;
            if (game.gameType is MoMGameType)
            {
                frameTex = Resources.Load("sprites/borders/momframeempty") as Texture2D;
            }
            icons[h.id].color       = Color.clear;
            icon_frames[h.id].color = Color.clear;

            if (!game.quest.heroesSelected)
            {
                icon_frames[h.id].color = Color.white;
            }

            if (h.heroData != null)
            {
                frameTex = Resources.Load("sprites/borders/blue_frame") as Texture2D;
                if (game.gameType is MoMGameType)
                {
                    frameTex = Resources.Load("sprites/borders/momframe") as Texture2D;
                }
                Texture2D heroTex    = ContentData.FileToTexture(h.heroData.image);
                Sprite    heroSprite = null;
                if (heroTex != null)
                {
                    heroSprite = Sprite.Create(heroTex, new Rect(0, 0, heroTex.width, heroTex.height), Vector2.zero, 1);
                }
                if (heroSprite != null)
                {
                    icons[h.id].sprite = heroSprite;
                }
                icons[h.id].color       = Color.white;
                icon_frames[h.id].color = Color.white;
            }
            Sprite frameSprite = null;
            if (frameTex != null)
            {
                frameSprite = Sprite.Create(frameTex, new Rect(0, 0, frameTex.width, frameTex.height), Vector2.zero, 1);
            }
            if (frameSprite != null)
            {
                icon_frames[h.id].sprite = frameSprite;
            }
        }
    }
예제 #7
0
    public void Update()
    {
        Destroyer.Dialog();
        selected = new List <string>();
        Dictionary <string, string> setPacks = game.config.data.Get(game.gameType.TypeName() + "Packs");

        if (setPacks != null)
        {
            foreach (KeyValuePair <string, string> kv in setPacks)
            {
                selected.Add(kv.Key);
            }
        }

        // Name.  We should replace this with a banner
        DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 2), "Select Expansion Content");

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

        float x = 1;
        float y = 4;

        foreach (ContentData.ContentPack cp in game.cd.allPacks)
        {
            if (cp.id.Length > 0)
            {
                string id = cp.id;

                Texture2D tex    = ContentData.FileToTexture(cp.image);
                Sprite    sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1);

                if (selected.Contains(id))
                {
                    TextButton tb = new TextButton(new Vector2(x, y), new Vector2(6, 6), "", delegate { Unselect(id); });
                    tb.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite;
                    tb.background.GetComponent <UnityEngine.UI.Image>().color  = Color.white;
                }
                else
                {
                    TextButton tb = new TextButton(new Vector2(x, y), new Vector2(6, 6), "", delegate { Select(id); }, new Color(0.3f, 0.3f, 0.3f));
                    tb.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite;
                    tb.background.GetComponent <UnityEngine.UI.Image>().color  = new Color(0.3f, 0.3f, 0.3f);
                }
                x += 7;
                if (x > UIScaler.GetRight(-7))
                {
                    x  = 1;
                    y += 7;
                }
            }
        }

        new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Destroyer.MainMenu(); }, Color.red);
    }
예제 #8
0
    public void Update()
    {
        Destroyer.Dialog();
        Game game = Game.Get();

        UIElement ui = new UIElement();

        ui.SetLocation(UIScaler.GetHCenter(-18), 1, 36, 23);
        new UIElementBorder(ui);

        // Add a title to the page
        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-6), 1, 12, 3);
        ui.SetText(new StringKey("val", "ITEMS"));
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetLargeFont());

        UIElementScrollHorizontal scrollArea = new UIElementScrollHorizontal();

        scrollArea.SetLocation(UIScaler.GetHCenter(-17), 5, 34, 14);
        new UIElementBorder(scrollArea);

        float xOffset = 1;

        foreach (string s in game.quest.itemInspect.Keys)
        {
            string tmp      = s;
            var    itemData = game.cd.Get <ItemData>(s);

            ui = new UIElement(scrollArea.GetScrollTransform());
            ui.SetLocation(xOffset, 9, 8, 3);
            ui.SetButton(delegate { Inspect(tmp); });
            ui.SetText(itemData.name, Color.black);
            ui.SetBGColor(Color.white);

            Texture2D itemTex    = ContentData.FileToTexture(itemData.image);
            Sprite    itemSprite = Sprite.Create(itemTex, new Rect(0, 0, itemTex.width, itemTex.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect);
            ui = new UIElement(scrollArea.GetScrollTransform());
            ui.SetLocation(xOffset, 1, 8, 8);
            ui.SetButton(delegate { Inspect(tmp); });
            ui.SetImage(itemSprite);

            xOffset += 9;
        }
        scrollArea.SetScrollSize(xOffset);

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-4f), 24.5f, 8, 2);
        ui.SetText(CommonStringKeys.CLOSE);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Destroyer.Dialog);
        new UIElementBorder(ui);
    }
예제 #9
0
    public PuzzleImageWindow(EventManager.Event e)
    {
        eventData = e;
        Game game = Game.Get();

        game.cc.panDisable = true;

        questPuzzle = e.qEvent as QuestData.Puzzle;

        if (game.quest.puzzle.ContainsKey(questPuzzle.sectionName))
        {
            puzzle        = game.quest.puzzle[questPuzzle.sectionName] as PuzzleImage;
            previousMoves = puzzle.moves;
        }
        else
        {
            puzzle = new PuzzleImage(questPuzzle.puzzleLevel, questPuzzle.puzzleAltLevel);
        }

        height = 19f / questPuzzle.puzzleAltLevel;
        width  = 19f / questPuzzle.puzzleLevel;

        Texture2D newTex = null;

        if (game.cd.puzzles.ContainsKey(questPuzzle.imageType))
        {
            newTex = ContentData.FileToTexture(game.cd.puzzles[questPuzzle.imageType].image);
        }
        else
        {
            newTex = ContentData.FileToTexture(System.IO.Path.GetDirectoryName(game.quest.qd.questPath) + "/" + questPuzzle.imageType);
        }
        if (newTex.width > newTex.height)
        {
            height = height * newTex.height / newTex.width;
        }
        else
        {
            width = width * newTex.width / newTex.height;
        }

        imageSprite = new Sprite[questPuzzle.puzzleLevel][];
        for (int i = 0; i < questPuzzle.puzzleLevel; i++)
        {
            imageSprite[i] = new Sprite[questPuzzle.puzzleAltLevel];
            for (int j = 0; j < questPuzzle.puzzleAltLevel; j++)
            {
                imageSprite[i][j] = Sprite.Create(newTex, new Rect(i * newTex.width / questPuzzle.puzzleLevel, (questPuzzle.puzzleAltLevel - (j + 1)) * newTex.height / questPuzzle.puzzleAltLevel, newTex.width / questPuzzle.puzzleLevel, newTex.height / questPuzzle.puzzleAltLevel), Vector2.zero, 1);
            }
        }

        CreateWindow();
    }
예제 #10
0
        // Construct with quest info and reference to Game
        public Token(QuestData.Token questToken, Game gameObject) : base(gameObject)
        {
            qToken = questToken;

            string tokenName = qToken.tokenName;

            // Check that token exists
            if (!game.cd.tokens.ContainsKey(tokenName))
            {
                game.quest.log.Add(new Quest.LogEntry("Warning: Quest component " + qToken.sectionName + " is using missing token type: " + tokenName, true));
                // Catch for older quests with different types (0.4.0 or older)
                if (game.cd.tokens.ContainsKey("TokenSearch"))
                {
                    tokenName = "TokenSearch";
                }
            }

            // Get texture for token
            Vector2   texPos  = new Vector2(game.cd.tokens[tokenName].x, game.cd.tokens[tokenName].y);
            Vector2   texSize = new Vector2(game.cd.tokens[tokenName].width, game.cd.tokens[tokenName].height);
            Texture2D newTex  = ContentData.FileToTexture(game.cd.tokens[tokenName].image, texPos, texSize);

            // Create object
            unityObject     = new GameObject("Object" + qToken.sectionName);
            unityObject.tag = "board";

            unityObject.transform.parent = game.tokenCanvas.transform;

            // Create the image
            image = unityObject.AddComponent <UnityEngine.UI.Image>();
            Sprite tileSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);

            image.color  = new Color(1, 1, 1, 0);
            image.sprite = tileSprite;

            float PPS = game.cd.tokens[tokenName].pxPerSquare;

            if (PPS == 0)
            {
                PPS = (float)newTex.width;
            }

            // Set the size to the image size
            image.rectTransform.sizeDelta = new Vector2((float)newTex.width / PPS, (float)newTex.height / PPS);
            // Rotate around 0,0 rotation amount
            unityObject.transform.RotateAround(Vector3.zero, Vector3.forward, qToken.rotation);
            // Move to square
            unityObject.transform.Translate(new Vector3(qToken.location.x, qToken.location.y, 0), Space.World);

            game.tokenBoard.Add(this);
        }
예제 #11
0
    public static void DrawMonster(Quest.Monster monster, bool displayHealth = false)
    {
        Game game = Game.Get();

        Texture2D newTex          = ContentData.FileToTexture(monster.monsterData.image);
        Texture2D dupeTex         = Resources.Load("sprites/monster_duplicate_" + monster.duplicate) as Texture2D;
        Sprite    iconSprite      = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
        Sprite    duplicateSprite = null;

        if (dupeTex != null)
        {
            duplicateSprite = Sprite.Create(dupeTex, new Rect(0, 0, dupeTex.width, dupeTex.height), Vector2.zero, 1);
        }

        GameObject mImg = new GameObject("monsterImg" + monster.monsterData.name);

        mImg.tag = Game.DIALOG;
        mImg.transform.SetParent(game.uICanvas.transform);

        RectTransform trans = mImg.AddComponent <RectTransform>();

        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1f * UIScaler.GetPixelsPerUnit(), 8f * UIScaler.GetPixelsPerUnit());
        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 1f * UIScaler.GetPixelsPerUnit(), 8f * UIScaler.GetPixelsPerUnit());
        mImg.AddComponent <CanvasRenderer>();

        UnityEngine.UI.Image icon = mImg.AddComponent <UnityEngine.UI.Image>();
        icon.sprite = iconSprite;
        icon.rectTransform.sizeDelta = new Vector2(8f * UIScaler.GetPixelsPerUnit(), 8f * UIScaler.GetPixelsPerUnit());

        UnityEngine.UI.Image iconDupe = null;
        if (duplicateSprite != null)
        {
            GameObject mImgDupe = new GameObject("monsterDupe" + monster.monsterData.name);
            mImgDupe.tag = Game.DIALOG;
            mImgDupe.transform.SetParent(game.uICanvas.transform);

            RectTransform dupeFrame = mImgDupe.AddComponent <RectTransform>();
            dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 5f * UIScaler.GetPixelsPerUnit(), UIScaler.GetPixelsPerUnit() * 4f);
            dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 5f * UIScaler.GetPixelsPerUnit(), 4f * UIScaler.GetPixelsPerUnit());
            mImgDupe.AddComponent <CanvasRenderer>();

            iconDupe        = mImgDupe.AddComponent <UnityEngine.UI.Image>();
            iconDupe.sprite = duplicateSprite;
            iconDupe.rectTransform.sizeDelta = new Vector2(4f * UIScaler.GetPixelsPerUnit(), 4f * UIScaler.GetPixelsPerUnit());
        }

        if (displayHealth)
        {
            DrawMonsterHealth(monster, DrawMonster);
        }
    }
예제 #12
0
        private void CreateEditorTransparencyElements()
        {
            Game game = Game.Get();

            // Select language text
            UIElement ui = new UIElement(Game.DIALOG);

            ui.SetLocation(UIScaler.GetHCenter() - 8, 5, 16, 2);
            ui.SetText(SET_EDITOR_ALPHA);
            ui.SetTextAlignment(TextAnchor.MiddleCenter);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());

            Texture2D SampleTex    = ContentData.FileToTexture(game.cd.images[IMG_LOW_EDITOR_TRANSPARENCY].image);
            Sprite    SampleSprite = Sprite.Create(SampleTex, new Rect(0, 0, SampleTex.width, SampleTex.height), Vector2.zero, 1);

            ui = new UIElement(Game.DIALOG);
            ui.SetLocation(UIScaler.GetHCenter() - 3, 8, 6, 6);
            ui.SetButton(delegate { UpdateEditorTransparency(0.2f); });
            ui.SetImage(SampleSprite);
            if (game.editorTransparency == 0.2f)
            {
                new UIElementBorder(ui, Color.white);
            }

            SampleTex    = ContentData.FileToTexture(game.cd.images[IMG_MEDIUM_EDITOR_TRANSPARENCY].image);
            SampleSprite = Sprite.Create(SampleTex, new Rect(0, 0, SampleTex.width, SampleTex.height), Vector2.zero, 1);
            ui           = new UIElement(Game.DIALOG);
            ui.SetLocation(UIScaler.GetHCenter() - 3, 15, 6, 6);
            ui.SetButton(delegate { UpdateEditorTransparency(0.3f); });
            ui.SetImage(SampleSprite);
            if (game.editorTransparency == 0.3f)
            {
                new UIElementBorder(ui, Color.white);
            }

            SampleTex    = ContentData.FileToTexture(game.cd.images[IMG_HIGH_EDITOR_TRANSPARENCY].image);
            SampleSprite = Sprite.Create(SampleTex, new Rect(0, 0, SampleTex.width, SampleTex.height), Vector2.zero, 1);
            ui           = new UIElement(Game.DIALOG);
            ui.SetLocation(UIScaler.GetHCenter() - 3, 22, 6, 6);
            ui.SetButton(delegate { UpdateEditorTransparency(0.4f); });
            ui.SetImage(SampleSprite);
            if (game.editorTransparency == 0.4f)
            {
                new UIElementBorder(ui, Color.white);
            }
        }
예제 #13
0
    public void DrawItem()
    {
        if (eventData.qEvent.highlight)
        {
            return;
        }

        string item  = "";
        int    items = 0;

        foreach (string s in eventData.qEvent.addComponents)
        {
            if (s.IndexOf("QItem") == 0)
            {
                item = s;
                items++;
            }
        }
        if (items != 1)
        {
            return;
        }

        Game game = Game.Get();

        if (!game.quest.itemSelect.ContainsKey(item))
        {
            return;
        }

        var       selectedItemData = game.cd.Get <ItemData>(game.quest.itemSelect[item]);
        Texture2D tex    = ContentData.FileToTexture(selectedItemData.image);
        Sprite    sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect);

        UIElement ui = new UIElement();

        ui.SetLocation(UIScaler.GetHCenter(-21), 0.5f, 6, 6);
        ui.SetImage(sprite);

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-22.5f), 6.5f, 9, 1);
        ui.SetText(selectedItemData.name);
    }
예제 #14
0
        public MonsterIcon(Quest.Monster monster, int i = 0)
        {
            m     = monster;
            index = i;

            game = Game.Get();

            // Get monster image and grame
            Texture2D newTex = ContentData.FileToTexture(m.monsterData.image);
            // FIXME: should be game type specific
            Texture2D frameTex = Resources.Load("sprites/borders/Frame_Monster_1x1") as Texture2D;
            Texture2D dupeTex  = Resources.Load("sprites/monster_duplicate_" + m.duplicate) as Texture2D;

            iconSprite  = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
            frameSprite = Sprite.Create(frameTex, new Rect(0, 0, frameTex.width, frameTex.height), Vector2.zero, 1);
            if (dupeTex != null)
            {
                duplicateSprite = Sprite.Create(dupeTex, new Rect(0, 0, dupeTex.width, dupeTex.height), Vector2.zero, 1);
            }
        }
예제 #15
0
    // Add an item
    public void AddItem(Vector2 location, string item)
    {
        Game game = Game.Get();
        // Create object
        GameObject itemObject = new GameObject("item" + item);

        itemObject.tag = Game.DIALOG;
        itemObject.transform.SetParent(game.tokenCanvas.transform);

        // Create the image
        Texture2D newTex = ContentData.FileToTexture(game.cd.items[game.quest.itemSelect[item]].image);

        UnityEngine.UI.Image image = itemObject.AddComponent <UnityEngine.UI.Image>();
        Sprite iconSprite          = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);

        image.sprite = iconSprite;
        image.rectTransform.sizeDelta = new Vector2(1, 1);

        // Move to square
        itemObject.transform.Translate(new Vector3(location.x, location.y, 0), Space.World);
    }
예제 #16
0
    public void DrawItem()
    {
        if (eventData.qEvent.highlight)
        {
            return;
        }

        string item  = "";
        int    items = 0;

        foreach (string s in eventData.qEvent.addComponents)
        {
            if (s.IndexOf("QItem") == 0)
            {
                item = s;
                items++;
            }
        }
        if (items != 1)
        {
            return;
        }

        Game game = Game.Get();

        if (!game.quest.itemSelect.ContainsKey(item))
        {
            return;
        }

        Texture2D tex    = ContentData.FileToTexture(game.cd.items[game.quest.itemSelect[item]].image);
        Sprite    sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect);

        DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-21), 0.5f), new Vector2(6, 6), StringKey.NULL);

        db.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite;
        db.background.GetComponent <UnityEngine.UI.Image>().color  = Color.white;

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(-22), 6.5f), new Vector2(8, 1), game.cd.items[game.quest.itemSelect[item]].name);
    }
예제 #17
0
        // Construct with quest info and reference to Game
        public Token(QuestData.Token questToken, Game gameObject) : base(gameObject)
        {
            qToken = questToken;

            string tokenName = qToken.tokenName;

            // Check that token exists
            if (!game.cd.tokens.ContainsKey(tokenName))
            {
                Debug.Log("Warning: Quest component " + qToken.name + " is using missing token type: " + tokenName);
                // Catch for older quests with different types (0.4.0 or older)
                if (game.cd.tokens.ContainsKey("TokenSearch"))
                {
                    tokenName = "TokenSearch";
                }
            }

            // Get texture for token
            Vector2   texPos  = new Vector2(game.cd.tokens[tokenName].x, game.cd.tokens[tokenName].y);
            Vector2   texSize = new Vector2(game.cd.tokens[tokenName].width, game.cd.tokens[tokenName].height);
            Texture2D newTex  = ContentData.FileToTexture(game.cd.tokens[tokenName].image, texPos, texSize);

            // Create object
            unityObject     = new GameObject("Object" + qToken.name);
            unityObject.tag = "board";

            unityObject.transform.parent = game.tokenCanvas.transform;

            // Create the image
            image = unityObject.AddComponent <UnityEngine.UI.Image>();
            Sprite tileSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);

            image.color  = new Color(1, 1, 1, 0);
            image.sprite = tileSprite;
            image.rectTransform.sizeDelta = new Vector2(1f, 1f);
            // Move to square
            unityObject.transform.Translate(new Vector3(qToken.location.x, qToken.location.y, 0), Space.World);

            game.tokenBoard.Add(this);
        }
예제 #18
0
    // Monsters are only on the board during an event
    public void AddMonster(EventManager.MonsterEvent me)
    {
        Game game  = Game.Get();
        int  count = 0;

        // Get number of heroes
        foreach (Quest.Hero h in game.quest.heroes)
        {
            if (h.heroData != null)
            {
                count++;
            }
        }

        if (game.gameType is MoMGameType)
        {
            Texture2D newTex = ContentData.FileToTexture(me.cMonster.image);
            AddPlacedMonsterImg("", newTex, 1, 1, me.qEvent.location.x, me.qEvent.location.y);
        }
        // Check for a placement list at this hero count
        else if (me.qMonster.placement[count].Length == 0)
        {
            if (me.cMonster.ContainsTrait("lieutenant"))
            {
                Texture2D newTex = ContentData.FileToTexture(me.cMonster.image);
                AddPlacedMonsterImg("", newTex, 1, 1, me.qEvent.location.x, me.qEvent.location.y);
            }
            else
            {
                // group placement
                AddAreaMonster(me.qMonster);
            }
        }
        else
        {
            // Individual monster placement
            AddPlacedMonsters(me, count);
        }
    }
예제 #19
0
    // Create a button for a hero selection option
    public void HeroSelectButton(Vector2 position, HeroData hd, int id, bool disabled = false)
    {
        Sprite heroSprite;
        // Should be game type specific
        Texture2D newTex = Resources.Load("sprites/borders/grey_frame") as Texture2D;
        string    name   = "";

        // is this an empty hero option?
        if (hd != null)
        {
            newTex = ContentData.FileToTexture(hd.image);
            name   = hd.name;
        }

        GameObject heroImg = new GameObject("heroImg" + name);

        heroImg.tag = "dialog";

        Game game = Game.Get();

        heroImg.transform.parent = game.uICanvas.transform;

        RectTransform trans = heroImg.AddComponent <RectTransform>();

        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, position.y * UIScaler.GetPixelsPerUnit(), 4.25f * UIScaler.GetPixelsPerUnit());
        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, position.x * UIScaler.GetPixelsPerUnit(), 4.25f * UIScaler.GetPixelsPerUnit());
        heroImg.AddComponent <CanvasRenderer>();


        UnityEngine.UI.Image image = heroImg.AddComponent <UnityEngine.UI.Image>();
        heroSprite   = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
        image.sprite = heroSprite;
        image.rectTransform.sizeDelta = new Vector2(4.25f * UIScaler.GetPixelsPerUnit(), 4.25f * UIScaler.GetPixelsPerUnit());

        UnityEngine.UI.Button button = heroImg.AddComponent <UnityEngine.UI.Button>();
        button.interactable = !disabled;
        button.onClick.AddListener(delegate { SelectHero(id, name); });
    }
예제 #20
0
    void AddHero(Quest.Hero h, Game game)
    {
        Sprite heroSprite;

        string    heroName = h.id.ToString();
        Texture2D newTex   = Resources.Load("sprites/tokens/objective-token-black") as Texture2D;

        if (h.heroData != null)
        {
            newTex   = ContentData.FileToTexture(h.heroData.image);
            heroName = h.heroData.name;
        }

        GameObject heroImg = new GameObject("heroImg" + heroName);

        heroImg.tag = "herodisplay";

        heroImg.transform.parent = game.uICanvas.transform;

        RectTransform trans = heroImg.AddComponent <RectTransform>();

        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (0.25f + offset) * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        offset += heroSize + 0.5f;
        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0.25f * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        heroImg.AddComponent <CanvasRenderer>();

        UnityEngine.UI.Image image = heroImg.AddComponent <UnityEngine.UI.Image>();
        icons.Add(h.id, image);
        heroSprite   = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
        image.sprite = heroSprite;
        image.rectTransform.sizeDelta = new Vector2(heroSize * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());

        UnityEngine.UI.Button button = heroImg.AddComponent <UnityEngine.UI.Button>();
        button.interactable = true;
        button.onClick.AddListener(delegate { HeroDiag(h.id); });
    }
예제 #21
0
    // Add a hero
    void AddHero(Quest.Hero h, Game game)
    {
        Sprite heroSprite;
        Sprite frameSprite;

        Texture2D frameTex = Resources.Load("sprites/borders/grey_frame") as Texture2D;

        if (game.gameType is MoMGameType)
        {
            frameTex = Resources.Load("sprites/borders/momframeempty") as Texture2D;
        }

        string heroName = h.id.ToString();

        if (h.heroData != null)
        {
            frameTex = Resources.Load("sprites/borders/blue_frame") as Texture2D;
            if (game.gameType is MoMGameType)
            {
                frameTex = Resources.Load("sprites/borders/momframe") as Texture2D;
            }
            heroName = h.heroData.name.Translate();
        }

        GameObject heroFrame = new GameObject("heroFrame" + heroName);

        heroFrame.tag = "herodisplay";
        heroFrame.transform.SetParent(game.uICanvas.transform);
        RectTransform transFrame = heroFrame.AddComponent <RectTransform>();

        transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (0.25f + offset) * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0.25f * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        heroFrame.AddComponent <CanvasRenderer>();

        UnityEngine.UI.Image imageFrame = heroFrame.AddComponent <UnityEngine.UI.Image>();
        icon_frames.Add(h.id, imageFrame);
        frameSprite       = Sprite.Create(frameTex, new Rect(0, 0, frameTex.width, frameTex.height), Vector2.zero, 1);
        imageFrame.sprite = frameSprite;
        imageFrame.rectTransform.sizeDelta = new Vector2(heroSize * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());

        UnityEngine.UI.Button buttonFrame = heroFrame.AddComponent <UnityEngine.UI.Button>();
        buttonFrame.interactable = true;
        buttonFrame.onClick.AddListener(delegate { HeroDiag(h.id); });

        GameObject heroImg = new GameObject("heroImg" + heroName);

        heroImg.tag = "herodisplay";
        heroImg.transform.SetParent(game.uICanvas.transform);
        RectTransform trans = heroImg.AddComponent <RectTransform>();

        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (0.25f + offset) * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        if (game.quest.heroes.Count > 5)
        {
            offset += 22f / game.quest.heroes.Count;
        }
        else
        {
            offset += heroSize + 0.5f;
        }
        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0.25f * UIScaler.GetPixelsPerUnit(), heroSize * UIScaler.GetPixelsPerUnit());
        heroImg.AddComponent <CanvasRenderer>();
        UnityEngine.UI.Image image = heroImg.AddComponent <UnityEngine.UI.Image>();

        icons.Add(h.id, image);
        image.rectTransform.sizeDelta = new Vector2(heroSize * UIScaler.GetPixelsPerUnit() * 0.8f, heroSize * UIScaler.GetPixelsPerUnit() * 0.8f);
        if (game.gameType is MoMGameType)
        {
            image.rectTransform.sizeDelta = new Vector2(heroSize * UIScaler.GetPixelsPerUnit() * 0.9f, heroSize * UIScaler.GetPixelsPerUnit() * 0.9f);
            heroFrame.transform.SetAsLastSibling();
        }
        image.color = Color.clear;

        UnityEngine.UI.Button button = heroImg.AddComponent <UnityEngine.UI.Button>();
        button.interactable = true;
        button.onClick.AddListener(delegate { HeroDiag(h.id); });

        // Add hero image if selected
        if (h.heroData != null)
        {
            Texture2D newTex = ContentData.FileToTexture(h.heroData.image);
            heroSprite   = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
            image.sprite = heroSprite;
        }
    }
예제 #22
0
        // Create a menu which will take up the whole screen and have options.  All items are dialog for destruction.
        public EndGameScreen()
        {
            ValkyrieDebug.Log("INFO: Show end screen");

            Game game = Game.Get();

            // Investigator picture in background full screen
            UIElement bg = new UIElement(Game.ENDGAME);
            Texture2D bgTex;

            if (game.gameType.TypeName() == "MoM")
            {
                bgTex = ContentData.FileToTexture(game.cd.images[IMG_BG_MOM].image);
            }
            else if (game.gameType.TypeName() == "D2E")
            {
                bgTex = ContentData.FileToTexture(game.cd.images[IMG_BG_DESCENT].image);
            }
            else
            {
                // TODO: support a background picture for IA
                Destroyer.MainMenu();
                return;
            }
            bg.SetImage(bgTex);
            bg.SetLocation(0, 0, UIScaler.GetWidthUnits(), UIScaler.GetHeightUnits());

            // Welcome text
            UIElement ui = new UIElement(Game.ENDGAME);

            ui.SetLocation((UIScaler.GetWidthUnits() - TitleWidth) / 2, 1, TitleWidth, 4);
            ui.SetText(STATS_WELCOME);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetSmallFont());
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);

            float offset = 5;

            // First question : player has won ?
            ui = new UIElement(Game.ENDGAME);
            ui.SetLocation(4, offset + 2, QuestionsWidth, 2);
            ui.SetText(STATS_ASK_VICTORY);
            ui.SetTextAlignment(TextAnchor.MiddleLeft);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetSmallFont());
            ui.SetBGColor(new Color(0, 0.03f, 0f, 0.2f));

            // yes button
            button_yes = new UIElement(Game.ENDGAME);
            button_yes.SetLocation((UIScaler.GetWidthUnits() / 10) * 5, offset + 2.5f, VictoryButtonWidth, 1);
            button_yes.SetText(STATS_ASK_VICTORY_YES);
            button_yes.SetFont(game.gameType.GetHeaderFont());
            button_yes.SetFontSize(UIScaler.GetSmallFont());
            button_yes.SetButton(PressVictoryYes);
            button_yes.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(button_yes);

            // no button
            button_no = new UIElement(Game.ENDGAME);
            button_no.SetLocation((UIScaler.GetWidthUnits() / 10) * 7, offset + 2.5f, VictoryButtonWidth, 1);
            button_no.SetText(STATS_ASK_VICTORY_NO);
            button_no.SetFont(game.gameType.GetHeaderFont());
            button_no.SetFontSize(UIScaler.GetSmallFont());
            button_no.SetButton(PressVictoryNo);
            button_no.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(button_no);


            offset += 4;

            // Second question : rating ?
            ui = new UIElement(Game.ENDGAME);
            ui.SetLocation(4, offset + 2, QuestionsWidth, 2);
            ui.SetText(STATS_ASK_RATING);
            ui.SetTextAlignment(TextAnchor.MiddleLeft);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetSmallFont());
            ui.SetBGColor(new Color(0, 0.03f, 0f, 0.2f));

            // rating 1 to 10
            rating_buttons = new UIElement[10];
            for (int i = 0; i <= 9; i++)
            {
                rating_buttons[i] = new UIElement(Game.ENDGAME);
                rating_buttons[i].SetLocation((UIScaler.GetWidthUnits() / 22) * (11 + i),
                                              offset + 2.5f,
                                              RatingButtonWidth,
                                              1);
                rating_buttons[i].SetText((i + 1).ToString());
                rating_buttons[i].SetFont(game.gameType.GetHeaderFont());
                rating_buttons[i].SetFontSize(UIScaler.GetSmallFont());
                rating_buttons[i].SetButtonWithParams(PressRatingButton, (i + 1).ToString());
                rating_buttons[i].SetBGColor(new Color(0, 0.03f, 0f));
                new UIElementBorder(rating_buttons[i]);
            }

            offset += 4;


            // Third question : comments ?
            ui = new UIElement(Game.ENDGAME);
            ui.SetLocation(4, offset + 2, QuestionsWidth, 2);
            ui.SetText(STATS_ASK_COMMENTS);
            ui.SetTextAlignment(TextAnchor.MiddleLeft);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetSmallFont());
            ui.SetBGColor(new Color(0, 0.03f, 0f, 0.2f));

            comments = new UIElementEditable(Game.ENDGAME);
            comments.SetLocation((UIScaler.GetWidthUnits() / 2), offset + 2, CommentsWidth, 5);
            comments.SetText(" ");
            comments.SetTextAlignment(TextAnchor.UpperLeft);
            comments.SetTextPadding(0.1f);
            comments.SetFont(game.gameType.GetFont());
            comments.SetFontSize(UIScaler.GetSmallFont());
            comments.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(comments);

            offset += 8.5f;


            // Go back to menu button
            ui = new UIElement(Game.ENDGAME);
            ui.SetLocation((UIScaler.GetWidthUnits() / 6) * 2, offset, ActionButtonWidth, 2);
            ui.SetText(STATS_MENU_BUTTON);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(MainMenu);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);

            // Publish button
            ui = new UIElement(Game.ENDGAME);
            ui.SetLocation((UIScaler.GetWidthUnits() / 6) * 3, offset, ActionButtonWidth, 2);
            ui.SetText(STATS_SEND_BUTTON);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(SendStats);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);

            offset += 3.5f;

            // Error message if any information is missing
            error_message = new UIElement(Game.ENDGAME);
            error_message.SetLocation((UIScaler.GetWidthUnits() - TitleWidth) / 2, offset, TitleWidth, 4);
            error_message.SetText(" ");
            error_message.SetFont(game.gameType.GetHeaderFont());
            error_message.SetTextAlignment(TextAnchor.MiddleCenter);
            error_message.SetFontSize(UIScaler.GetSmallFont());
            error_message.SetBGColor(Color.clear);
        }
예제 #23
0
        public SaveData(int num = 0)
        {
            Game game = Game.Get();

            if (!File.Exists(SaveFile(num)))
            {
                return;
            }
            try
            {
                if (!Directory.Exists(Path.GetTempPath() + "/Valkyrie"))
                {
                    Directory.CreateDirectory(Path.GetTempPath() + "/Valkyrie");
                }
                if (!Directory.Exists(Path.GetTempPath() + "/Valkyrie/Load"))
                {
                    Directory.CreateDirectory(Path.GetTempPath() + "/Valkyrie/Load");
                }

                Directory.Delete(Path.GetTempPath() + "/Valkyrie/Load", true);
                ZipFile zip = ZipFile.Read(SaveFile(num));
                zip.ExtractAll(Path.GetTempPath() + "/Valkyrie/Load");
                zip.Dispose();

                image = ContentData.FileToTexture(Path.GetTempPath() + "/Valkyrie/Load/image.png");

                // Check that quest in save is valid
                QuestData.Quest q = new QuestData.Quest(Path.GetTempPath() + "/Valkyrie/Load/quest");
                if (!q.valid)
                {
                    ValkyrieDebug.Log("Warning: Save " + num + " contains unsupported quest version." + System.Environment.NewLine);
                    return;
                }

                DictionaryI18n tmpDict = LocalizationRead.selectDictionary("qst");
                LocalizationRead.AddDictionary("qst", q.localizationDict);
                quest = q.name.Translate();
                LocalizationRead.AddDictionary("qst", tmpDict);

                string data = File.ReadAllText(Path.GetTempPath() + "/Valkyrie/Load/save.ini");

                IniData saveData = IniRead.ReadFromString(data);

                saveData.Get("Quest", "valkyrie");

                if (VersionNewer(game.version, saveData.Get("Quest", "valkyrie")))
                {
                    ValkyrieDebug.Log("Warning: Save " + num + " is from a future version." + System.Environment.NewLine);
                    return;
                }

                if (!VersionNewerOrEqual(minValkyieVersion, saveData.Get("Quest", "valkyrie")))
                {
                    ValkyrieDebug.Log("Warning: Save " + num + " is from an old unsupported version." + System.Environment.NewLine);
                    return;
                }

                saveTime = System.DateTime.Parse(saveData.Get("Quest", "time"));

                valid = true;
            }
            catch (System.Exception e)
            {
                ValkyrieDebug.Log("Warning: Unable to open save file: " + SaveFile(num) + " " + e.Message);
            }
        }
예제 #24
0
        public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql)
        {
            questList = ql;
            Game game = Game.Get();

            // If a dialog window is open we force it closed (this shouldn't happen)
            foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG))
            {
                Object.Destroy(go);
            }

            // Clean up downloader if present
            foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.QUESTUI))
            {
                Object.Destroy(go);
            }

            // Heading
            UIElement ui = new UIElement();

            ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3);
            ui.SetText(new StringKey("val", "SELECT", game.gameType.QuestName()));
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetLargeFont());

            UIElementScrollVertical scrollArea = new UIElementScrollVertical();

            scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f);
            new UIElementBorder(scrollArea);

            // Start here
            float offset = 0;

            // Loop through all available quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count == 0)
                {
                    string key = q.Key;
                    LocalizationRead.scenarioDict = q.Value.localizationDict;
                    string translation = q.Value.name.Translate();

                    // Frame
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.1f);
                    ui.SetBGColor(Color.white);
                    ui.SetButton(delegate { Selection(key); });
                    offset += 0.05f;

                    // Draw Image
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(1, offset, 3, 3);
                    ui.SetBGColor(Color.white);
                    ui.SetButton(delegate { Selection(key); });
                    if (q.Value.image.Length > 0)
                    {
                        ui.SetImage(ContentData.FileToTexture(Path.Combine(q.Value.path, q.Value.image)));
                    }

                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetBGColor(Color.clear);
                    ui.SetLocation(4, offset, UIScaler.GetWidthUnits() - 8, 3f);
                    ui.SetTextPadding(1.2f);
                    ui.SetText(translation, Color.black);
                    ui.SetButton(delegate { Selection(key); });
                    ui.SetTextAlignment(TextAnchor.MiddleLeft);
                    ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.3f));

                    // Duration
                    if (q.Value.lengthMax != 0)
                    {
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-11), offset, 2, 1);
                        ui.SetText(q.Value.lengthMin.ToString(), Color.black);
                        ui.SetButton(delegate { Selection(key); });
                        ui.SetBGColor(Color.clear);

                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-9), offset, 1, 1);
                        ui.SetButton(delegate { Selection(key); });
                        ui.SetText("-", Color.black);
                        ui.SetBGColor(Color.clear);

                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-8), offset, 2, 1);
                        ui.SetText(q.Value.lengthMax.ToString(), Color.black);
                        ui.SetButton(delegate { Selection(key); });
                        ui.SetBGColor(Color.clear);
                    }

                    // Difficulty
                    if (q.Value.difficulty != 0)
                    {
                        string symbol = "π"; // will
                        if (game.gameType is MoMGameType)
                        {
                            symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate();
                        }
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-12), offset + 1, 7, 2);
                        ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black);
                        ui.SetBGColor(Color.clear);
                        ui.SetFontSize(UIScaler.GetMediumFont());
                        ui.SetButton(delegate { Selection(key); });

                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-11.95f) + (q.Value.difficulty * 6.9f), offset + 1, (1 - q.Value.difficulty) * 6.9f, 2);
                        ui.SetBGColor(new Color(1, 1, 1, 0.7f));
                        ui.SetButton(delegate { Selection(key); });
                    }

                    offset += 4;
                }
            }

            // Loop through all unavailable quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count > 0)
                {
                    string key = q.Key;
                    LocalizationRead.scenarioDict = q.Value.localizationDict;
                    string translation = q.Value.name.Translate();

                    // Size is 1.2 to be clear of characters with tails
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f);
                    ui.SetText(new StringKey("val", "INDENT", translation), Color.black);
                    ui.SetTextAlignment(TextAnchor.MiddleLeft);
                    ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f));
                    offset += 1.2f;

                    foreach (string s in q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()))
                    {
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(3, offset, UIScaler.GetWidthUnits() - 9, 1.2f);
                        ui.SetText(new StringKey("val", "REQUIRES_EXPANSION", game.cd.GetContentName(s)), Color.black);
                        ui.SetTextAlignment(TextAnchor.MiddleLeft);
                        ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f));
                        offset += 1.2f;
                    }
                }
                offset += 0.8f;
            }

            scrollArea.SetScrollSize(offset);

            ui = new UIElement();
            ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(CommonStringKeys.BACK, Color.red);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(delegate { Cancel(); });
            new UIElementBorder(ui, Color.red);

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetRight(-9), UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(DOWNLOAD, Color.green);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(delegate { Download(); });
            new UIElementBorder(ui, Color.green);
        }
예제 #25
0
        public void DrawHero(float xOffset, int hero)
        {
            Game game = Game.Get();

            if (scrollOffset.Count > hero)
            {
                scrollOffset[hero] = scrollArea[hero].GetScrollPosition();
            }

            string archetype   = game.quest.heroes[hero].heroData.archetype;
            string hybridClass = game.quest.heroes[hero].hybridClass;
            float  yStart      = 7f;

            UIElement ui = null;

            if (hybridClass.Length > 0)
            {
                archetype = game.cd.classes[hybridClass].hybridArchetype;
                ui        = new UIElement(Game.HEROSELECT);
                ui.SetLocation(xOffset + 0.25f, yStart, 8.5f, 5);
                new UIElementBorder(ui);

                ui = new UIElement(Game.HEROSELECT);
                ui.SetLocation(xOffset + 1, yStart + 0.5f, 7, 4);
                ui.SetText(game.cd.classes[hybridClass].name, Color.black);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { Select(hero, hybridClass); });
                ui.SetBGColor(new Color(0, 0.7f, 0));
                new UIElementBorder(ui, Color.black);

                yStart += 5;
            }

            while (scrollArea.Count <= hero)
            {
                scrollArea.Add(null);
            }
            scrollArea[hero] = new UIElementScrollVertical(Game.HEROSELECT);
            scrollArea[hero].SetLocation(xOffset + 0.25f, yStart, 8.5f, 27 - yStart);
            new UIElementBorder(scrollArea[hero]);

            float yOffset = 1;

            foreach (ClassData cd in game.cd.classes.Values)
            {
                if (!cd.archetype.Equals(archetype))
                {
                    continue;
                }
                if (cd.hybridArchetype.Length > 0 && hybridClass.Length > 0)
                {
                    continue;
                }

                string className = cd.sectionName;
                bool   available = true;
                bool   pick      = false;

                for (int i = 0; i < game.quest.heroes.Count; i++)
                {
                    if (game.quest.heroes[i].className.Equals(className))
                    {
                        available = false;
                        if (hero == i)
                        {
                            pick = true;
                        }
                    }
                    if (game.quest.heroes[i].hybridClass.Equals(className))
                    {
                        available = false;
                    }
                }

                ui = new UIElement(Game.HEROSELECT, scrollArea[hero].GetScrollTransform());
                ui.SetLocation(0.25f, yOffset, 7, 4);
                if (available)
                {
                    ui.SetBGColor(Color.white);
                    ui.SetButton(delegate { Select(hero, className); });
                }
                else
                {
                    ui.SetBGColor(new Color(0.2f, 0.2f, 0.2f));
                    if (pick)
                    {
                        ui.SetBGColor(new Color(0, 0.7f, 0));
                    }
                }
                ui.SetText(cd.name, Color.black);
                ui.SetFontSize(UIScaler.GetMediumFont());

                yOffset += 5f;
            }

            scrollArea[hero].SetScrollSize(yOffset);
            if (scrollOffset.Count > hero)
            {
                scrollArea[hero].SetScrollPosition(scrollOffset[hero]);
            }
            else
            {
                scrollOffset.Add(0);
            }

            Texture2D heroTex    = ContentData.FileToTexture(game.quest.heroes[hero].heroData.image);
            Sprite    heroSprite = Sprite.Create(heroTex, new Rect(0, 0, heroTex.width, heroTex.height), Vector2.zero, 1);

            ui = new UIElement(Game.HEROSELECT);
            ui.SetLocation(xOffset + 2.5f, 3.5f, 4, 4);
            ui.SetImage(heroSprite);
        }
예제 #26
0
    public void Update(int hero = 0)
    {
        Destroyer.Dialog();
        Game game = Game.Get();

        DialogBox db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-15), 1),
            new Vector2(30, 6),
            StringKey.NULL);

        db.AddBorder();

        db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-17f), 7),
            new Vector2(34, 17),
            StringKey.NULL);
        db.AddBorder();

        // Add a title to the page
        db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-6), 1),
            new Vector2(12, 3),
            new StringKey("val", "SELECT_SKILLS"));
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
        db.SetFont(game.gameType.GetHeaderFont());

        // Get all heros
        int heroCount = 0;

        // Count number of selected heroes
        foreach (Quest.Hero h in game.quest.heroes)
        {
            if (h.heroData != null)
            {
                heroCount++;
            }
        }

        float xOffset = UIScaler.GetHCenter(-11);

        if (heroCount < 4)
        {
            xOffset += 3f;
        }
        if (heroCount < 3)
        {
            xOffset += 3f;
        }

        TextButton tb = null;

        int availableXP = 0;

        for (int i = 0; i < heroCount; i++)
        {
            int       tmp        = i;
            Texture2D heroTex    = ContentData.FileToTexture(game.quest.heroes[i].heroData.image);
            Sprite    heroSprite = Sprite.Create(heroTex, new Rect(0, 0, heroTex.width, heroTex.height), Vector2.zero, 1);
            tb = new TextButton(new Vector2(xOffset, 3.5f), new Vector2(4f, 4f), StringKey.NULL, delegate { Update(tmp); }, Color.clear);
            tb.background.GetComponent <UnityEngine.UI.Image>().sprite = heroSprite;
            tb.background.GetComponent <UnityEngine.UI.Image>().color  = new Color(0.3f, 0.3f, 0.3f);
            if (i == hero)
            {
                tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white;
            }
            tb.border.Destroy();

            availableXP = game.quest.heroes[i].AvailableXP();
            if (availableXP != 0)
            {
                tb = new TextButton(new Vector2(xOffset + 2, 5.5f), new Vector2(2f, 2f), availableXP, delegate { Update(tmp); }, Color.blue);
            }

            xOffset += 6f;
        }

        db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-16), 8.5f),
            new Vector2(32, 5),
            StringKey.NULL);
        db.AddBorder();

        db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-16), 8.5f),
            new Vector2(2, 5),
            1);
        db.AddBorder();
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();

        db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-16), 13.5f),
            new Vector2(32, 5),
            StringKey.NULL);
        db.AddBorder();

        db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-16), 13.5f),
            new Vector2(2, 5),
            2);
        db.AddBorder();
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();

        string hybridClass = game.quest.heroes[hero].hybridClass;

        if (hybridClass.Length > 0)
        {
            db = new DialogBox(
                new Vector2(UIScaler.GetHCenter(-16.5f), 18.5f),
                new Vector2(11, 5),
                StringKey.NULL);
            db.AddBorder();

            db = new DialogBox(
                new Vector2(UIScaler.GetHCenter(-16.5f), 18.5f),
                new Vector2(2, 5),
                1);
            db.AddBorder();
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();

            db = new DialogBox(
                new Vector2(UIScaler.GetHCenter(-5.5f), 18.5f),
                new Vector2(11, 5),
                StringKey.NULL);
            db.AddBorder();

            db = new DialogBox(
                new Vector2(UIScaler.GetHCenter(-5.5f), 18.5f),
                new Vector2(2, 5),
                2);
            db.AddBorder();
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();

            db = new DialogBox(
                new Vector2(UIScaler.GetHCenter(5.5f), 18.5f),
                new Vector2(11, 5),
                StringKey.NULL);
            db.AddBorder();

            db = new DialogBox(
                new Vector2(UIScaler.GetHCenter(5.5f), 18.5f),
                new Vector2(2, 5),
                3);
            db.AddBorder();
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
        }
        else
        {
            db = new DialogBox(
                new Vector2(UIScaler.GetHCenter(-16), 18.5f),
                new Vector2(32, 5),
                StringKey.NULL);
            db.AddBorder();

            db = new DialogBox(
                new Vector2(UIScaler.GetHCenter(-16), 18.5f),
                new Vector2(2, 5),
                3);
            db.AddBorder();
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
        }

        float[] xOffsetArray = new float[4];
        xOffsetArray[1] = UIScaler.GetHCenter(-13);
        xOffsetArray[2] = UIScaler.GetHCenter(-13);
        xOffsetArray[3] = UIScaler.GetHCenter(-8);
        float yOffset = 4;

        availableXP = game.quest.heroes[hero].AvailableXP();
        foreach (SkillData s in game.cd.skills.Values)
        {
            if (s.xp == 0)
            {
                continue;
            }
            if (game.quest.heroes[hero].className.Length == 0)
            {
                continue;
            }

            Color buttonColor = new Color(0.4f, 0.4f, 0.4f);
            if (game.quest.heroes[hero].skills.Contains(s.sectionName))
            {
                buttonColor = Color.green;
            }
            else if (s.xp <= availableXP)
            {
                buttonColor = Color.white;
            }

            string skill = s.sectionName;
            if (s.sectionName.IndexOf("Skill" + game.quest.heroes[hero].className.Substring("Class".Length)) == 0)
            {
                if (hybridClass.Length > 0 && s.xp == 3)
                {
                    continue;
                }
                tb = new TextButton(new Vector2(xOffsetArray[s.xp], yOffset + (s.xp * 5)), new Vector2(8f, 4f), s.name, delegate { SelectSkill(hero, skill); }, buttonColor);
                xOffsetArray[s.xp] += 10;
                continue;
            }

            if (hybridClass.Length == 0)
            {
                continue;
            }
            if (s.sectionName.IndexOf("Skill" + hybridClass.Substring("Class".Length)) != 0)
            {
                continue;
            }

            tb = new TextButton(new Vector2(UIScaler.GetHCenter(-25f) + (s.xp * 11f), yOffset + 15), new Vector2(8f, 4f), s.name, delegate { SelectSkill(hero, skill); }, buttonColor);
        }

        // Add a finished button to start the quest
        tb = new TextButton(
            new Vector2(UIScaler.GetHCenter(-4f), 24.5f),
            new Vector2(8, 2),
            CommonStringKeys.CLOSE,
            delegate { Destroyer.Dialog(); });
    }
예제 #27
0
    public InvestigatorItems()
    {
        Game game = Game.Get();

        // Items from heroes
        foreach (Quest.Hero h in game.quest.heroes)
        {
            if (h.heroData != null)
            {
                if (game.cd.items.ContainsKey(h.heroData.item))
                {
                    game.quest.items.Add(h.heroData.item);
                }
            }
        }

        foreach (KeyValuePair <string, QuestData.QuestComponent> kv in game.quest.qd.components)
        {
            QuestData.QItem item = kv.Value as QuestData.QItem;
            if (item != null && item.starting && game.quest.itemSelect.ContainsKey(kv.Key) &&
                item.tests != null && game.quest.vars.Test(item.tests))
            {
                game.quest.items.Add(game.quest.itemSelect[kv.Key]);
                if (item.inspect.Length > 0)
                {
                    if (game.quest.itemInspect.ContainsKey(game.quest.itemSelect[kv.Key]))
                    {
                        game.quest.itemInspect.Remove(game.quest.itemSelect[kv.Key]);
                    }
                    game.quest.itemInspect.Add(game.quest.itemSelect[kv.Key], item.inspect);
                }
            }
        }

        // If a dialog window is open we force it closed (this shouldn't happen)
        foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG))
        {
            Object.Destroy(go);
        }

        UIElement ui = new UIElement();

        ui.SetLocation(10, 0.5f, UIScaler.GetWidthUnits() - 20, 2);
        ui.SetText(STARTING_ITEMS);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetFont(Game.Get().gameType.GetHeaderFont());

        SortedList <string, SortedList <string, string> > itemSort = new SortedList <string, SortedList <string, string> >();

        foreach (string item in game.quest.items)
        {
            // Ignore "ItemX", find next capital letter
            int charIndex = 5;
            while (charIndex < item.Length - 1)
            {
                if (System.Char.IsUpper(item[charIndex++]))
                {
                    break;
                }
            }
            string typeString        = item.Substring(0, charIndex);
            string translationString = game.cd.items[item].name.Translate();

            if (!itemSort.ContainsKey(typeString))
            {
                itemSort.Add(typeString, new SortedList <string, string>());
            }

            // Duplicate names
            while (itemSort[typeString].ContainsKey(translationString))
            {
                translationString += "D";
            }

            itemSort[typeString].Add(translationString, item);
        }

        int y = 0;
        int x = 0;

        foreach (string category in itemSort.Keys)
        {
            foreach (string item in itemSort[category].Values)
            {
                Texture2D tex    = ContentData.FileToTexture(game.cd.items[item].image);
                Sprite    sprite = null;
                if (tex != null)
                {
                    sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect);
                }

                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(8f * x) - 19, 5f + (9f * y), 6, 6);
                if (sprite != null)
                {
                    ui.SetImage(sprite);
                }

                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(8f * x) - 20, 11f + (9f * y), 8, 1);
                ui.SetText(game.cd.items[item].name);

                x++;
                if (x > 4)
                {
                    x = 0;
                    y++;
                }
            }
        }
        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-6f), 27f, 12, 2);
        ui.SetText(CommonStringKeys.FINISHED);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(game.QuestStartEvent);
        new UIElementBorder(ui);
    }
예제 #28
0
    public InvestigatorItems()
    {
        Game game = Game.Get();

        // Items from heroes
        foreach (Quest.Hero h in game.quest.heroes)
        {
            if (h.heroData != null)
            {
                if (game.cd.items.ContainsKey(h.heroData.item))
                {
                    game.quest.items.Add(h.heroData.item);
                }
            }
        }

        foreach (KeyValuePair <string, QuestData.QuestComponent> kv in game.quest.qd.components)
        {
            QuestData.QItem item = kv.Value as QuestData.QItem;
            if (item != null && item.starting && game.quest.itemSelect.ContainsKey(kv.Key))
            {
                game.quest.items.Add(game.quest.itemSelect[kv.Key]);
                if (item.inspect.Length > 0)
                {
                    if (game.quest.itemInspect.ContainsKey(game.quest.itemSelect[kv.Key]))
                    {
                        game.quest.itemInspect.Remove(game.quest.itemSelect[kv.Key]);
                    }
                    game.quest.itemInspect.Add(game.quest.itemSelect[kv.Key], item.inspect);
                }
            }
        }

        // If a dialog window is open we force it closed (this shouldn't happen)
        foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG))
        {
            Object.Destroy(go);
        }

        UIElement ui = new UIElement();

        ui.SetLocation(10, 0.5f, UIScaler.GetWidthUnits() - 20, 2);
        ui.SetText(STARTING_ITEMS);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetFont(Game.Get().gameType.GetHeaderFont());

        int y = 0;
        int x = 0;

        foreach (string item in game.quest.items)
        {
            Texture2D tex    = ContentData.FileToTexture(game.cd.items[item].image);
            Sprite    sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect);

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(8f * x) - 19, 5f + (9f * y), 6, 6);
            ui.SetImage(sprite);

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(8f * x) - 20, 11f + (9f * y), 8, 1);
            ui.SetText(game.cd.items[item].name);

            x++;
            if (x > 4)
            {
                x = 0;
                y++;
            }
        }
        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-6f), 27f, 12, 2);
        ui.SetText(CommonStringKeys.FINISHED);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(game.QuestStartEvent);
        new UIElementBorder(ui);
    }
예제 #29
0
    public static void DisplayTransitionWindow(Quest.MoMPhase phase)
    {
        // do NOT delete dialog, they are hidden behing the mythos phase
        //Destroyer.Dialog();

        Game      game = Game.Get();
        UIElement text;

        // dot NOT display transition screen while we are in Editor mode
        if (game.testMode)
        {
            return;
        }

        // Background picture in full screen
        UIElement bg = new UIElement(Game.TRANSITION);
        Texture2D bgTex;

        if (phase == Quest.MoMPhase.investigator)
        {
            bgTex = ContentData.FileToTexture(game.cd.Get <ImageData>(IMG_BG_INVESTIGATORS_PHASE).image);
        }
        else
        {
            bgTex = ContentData.FileToTexture(game.cd.Get <ImageData>(IMG_BG_MYTHOS_PHASE).image);
        }
        bg.SetImage(bgTex);
        bg.SetLocation(0, 0, UIScaler.GetWidthUnits(), UIScaler.GetHeightUnits());

        // Text of phase
        text = new UIElement(Game.TRANSITION, bg.GetTransform());
        if (phase == Quest.MoMPhase.investigator)
        {
            // Silver   #C0C0C0     (192,192,192)
            text.SetText(PHASE_INVESTIGATOR, new Color32(192, 192, 192, 255));
            text.SetLocation(5, 3, 30, 3);
        }
        else
        {
            // Dark red #8B0000 (139,0,0)
            text.SetText(PHASE_MYTHOS, new Color32(139, 0, 0, 255));
            text.SetLocation(7, 3, 30, 3);
        }
        text.SetFont(game.gameType.GetHeaderFont());
        text.SetFontSize(UIScaler.GetLargeFont());
        text.SetFontStyle(FontStyle.Italic);
        text.SetTextAlignment(TextAnchor.MiddleLeft);
        text.SetBGColor(Color.clear);


        if (phase == Quest.MoMPhase.investigator)
        {
            // Draw pictures of investigators for investigator phase
            float     offset = (game.quest.GetHeroCount() - 1) * (-1 * offset_size / 2) - (offset_size / 2);
            UIElement ui     = null;
            foreach (Quest.Hero h in game.quest.heroes)
            {
                if (h.heroData != null)
                {
                    // Draw pictures
                    Texture2D newTex = ContentData.FileToTexture(h.heroData.image);

                    ui = new UIElement(Game.TRANSITION, bg.GetTransform());
                    ui.SetLocation(UIScaler.GetHCenter(offset), UIScaler.GetVCenter(), heroSize, heroSize);
                    ui.SetImage(newTex);

                    offset += offset_size;
                }
            }
        }
        else
        {
            // Don't draw anything for Mythos phase
        }

        // Launch timer to remove this window in 'transition_duration' seconds
        if (gameobject_timer == null)
        {
            gameobject_timer = new GameObject("TIMER");
            timer            = gameobject_timer.AddComponent <SimpleTimer>();
        }

        timer.Init(transition_duration, Close);
    }
예제 #30
0
        // Construct with data from the quest, pass Game for speed
        public Tile(QuestData.Tile questTile, Game gameObject) : base(gameObject)
        {
            qTile = questTile;

            // Search for tile in content
            if (game.cd.tileSides.ContainsKey(qTile.tileSideName))
            {
                cTile = game.cd.tileSides[qTile.tileSideName];
            }
            else if (game.cd.tileSides.ContainsKey("TileSide" + qTile.tileSideName))
            {
                cTile = game.cd.tileSides["TileSide" + qTile.tileSideName];
            }
            else
            {
                // Fatal if not found
                Debug.Log("Error: Failed to located TileSide: " + qTile.tileSideName + " in quest component: " + qTile.name);
                Application.Quit();
            }

            // Attempt to load image
            Texture2D newTex = ContentData.FileToTexture(game.cd.tileSides[qTile.tileSideName].image);

            if (newTex == null)
            {
                // Fatal if missing
                Debug.Log("Error: cannot open image file for TileSide: " + game.cd.tileSides[qTile.tileSideName].image);
                Application.Quit();
            }

            // Create a unity object for the tile
            unityObject     = new GameObject("Object" + qTile.name);
            unityObject.tag = "board";
            unityObject.transform.parent = game.boardCanvas.transform;

            // Add image to object
            image = unityObject.AddComponent <UnityEngine.UI.Image>();
            // Create sprite from texture
            Sprite tileSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);

            // Set image sprite
            image.sprite = tileSprite;
            // Move to get the top left square corner at 0,0
            float vPPS = game.cd.tileSides[qTile.tileSideName].pxPerSquare;
            float hPPS = vPPS;

            // manual aspect control
            // We need this for the 3x2 MoM tiles because they don't have square pixels!!
            if (game.cd.tileSides[qTile.tileSideName].aspect != 0)
            {
                hPPS = (vPPS * newTex.width / newTex.height) / game.cd.tileSides[qTile.tileSideName].aspect;
            }

            // Perform alignment move
            unityObject.transform.Translate(Vector3.right * ((newTex.width / 2) - cTile.left) / hPPS, Space.World);
            unityObject.transform.Translate(Vector3.down * ((newTex.height / 2) - cTile.top) / vPPS, Space.World);
            // Move to get the middle of the top left square at 0,0
            // We don't do this for MoM because it spaces differently
            if (game.gameType.TileOnGrid())
            {
                unityObject.transform.Translate(new Vector3(-(float)0.5, (float)0.5, 0), Space.World);
            }
            // Set the size to the image size
            image.rectTransform.sizeDelta = new Vector2((float)newTex.width / hPPS, (float)newTex.height / vPPS);

            // Rotate around 0,0 rotation amount
            unityObject.transform.RotateAround(Vector3.zero, Vector3.forward, qTile.rotation);
            // Move tile into target location (Space.World is needed because tile has been rotated)
            unityObject.transform.Translate(new Vector3(qTile.location.x, qTile.location.y, 0), Space.World);
            image.color = new Color(1, 1, 1, 0);
        }