コード例 #1
0
    public HeroSelection(Game.Hero h)
    {
        Game game = Game.Get();

        DialogBox db = new DialogBox(new Vector2(8, 1), new Vector2(UIScaler.GetWidthUnits() - 16, 3), "Select Heros");

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

        float x = 8;
        float y = 5;

        HeroSelectButton(new Vector2(x, y), null, h.id);
        foreach (KeyValuePair <string, HeroData> hd in game.cd.heros)
        {
            x += 6;
            if (x > UIScaler.GetRight(-13))
            {
                x  = 8;
                y += 6;
            }

            bool disabled = false;
            foreach (Game.Hero hIt in game.heros)
            {
                if ((hIt.heroData == hd.Value) && (hIt.id != h.id))
                {
                    disabled = true;
                }
            }
            HeroSelectButton(new Vector2(x, y), hd.Value, h.id, disabled);
        }
    }
コード例 #2
0
ファイル: HeroCanvas.cs プロジェクト: Liquidlogic1/valkyrie
    void HeroDiag(int id)
    {
        Game game = Game.Get();

        Game.Hero target = null;

        foreach (Game.Hero h in game.heros)
        {
            if (h.id == id)
            {
                target = h;
            }
        }

        // If there are any other dialogs
        if (GameObject.FindGameObjectWithTag("dialog") != null)
        {
            if (game.eventList.Count > 0 && game.eventList.Peek().maxHeroes != 0)
            {
                target.selected = !target.selected;
                UpdateStatus();
            }
            return;
        }

        if (game.heroesSelected && target.heroData != null)
        {
            new HeroDialog(target);
        }
        if (!game.heroesSelected)
        {
            icons[id].color = new Color((float)0.3, (float)0.3, (float)0.3);
            new HeroSelection(target);
        }
    }
コード例 #3
0
ファイル: HeroCanvas.cs プロジェクト: Liquidlogic1/valkyrie
    void AddHero(Game.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)
        {
            string imagePath = @"file://" + h.heroData.image;
            WWW    www       = new WWW(imagePath);
            newTex = new Texture2D(256, 256, TextureFormat.DXT5, false);
            www.LoadImageIntoTexture(newTex);
            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); });
    }
コード例 #4
0
ファイル: HeroDialog.cs プロジェクト: Liquidlogic1/valkyrie
 public HeroDialog(Game.Hero h)
 {
     hero = h;
     CreateWindow();
 }