コード例 #1
0
    public InfoDialog(Game.Monster m)
    {
        if (m == null)
        {
            Debug.Log("Warning: Invalid monster type requested.");
            return;
        }

        DialogBox db = new DialogBox(new Vector2(10, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 20, 12), m.monsterData.info.Replace("\\n", "\n"));

        db.AddBorder();

        if (m.unique)
        {
            db = new DialogBox(new Vector2(12, 13f), new Vector2(UIScaler.GetWidthUnits() - 24, 2), m.uniqueTitle, Color.red);
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            db.AddBorder();
            db = new DialogBox(new Vector2(10, 15f), new Vector2(UIScaler.GetWidthUnits() - 20, 8), m.uniqueText.Replace("\\n", "\n"));
            db.AddBorder(Color.red);
            new TextButton(new Vector2(UIScaler.GetWidthUnits() - 21, 23.5f), new Vector2(10, 2), "Close", delegate { onClose(); });
        }
        else
        {
            new TextButton(new Vector2(UIScaler.GetWidthUnits() - 21, 13f), new Vector2(10, 2), "Close", delegate { onClose(); });
        }
    }
コード例 #2
0
    void AddMonster(Game.Monster m, Game game)
    {
        string imagePath = @"file://" + m.monsterData.image;

        Sprite mSprite;

        WWW       www    = new WWW(imagePath);
        Texture2D newTex = new Texture2D(256, 256, TextureFormat.DXT5, false);

        www.LoadImageIntoTexture(newTex);

        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
ファイル: RoundHelper.cs プロジェクト: Liquidlogic1/valkyrie
    // Activate a monster (if any left) and return true if all monsters activated
    public static bool ActivateMonster()
    {
        Game game = Game.Get();

        List <int> notActivated = new List <int>();

        // Get the index of all monsters that haven't activated
        for (int i = 0; i < game.monsters.Count; i++)
        {
            if (!game.monsters[i].activated)
            {
                notActivated.Add(i);
            }
        }

        // If no monsters are found return true
        if (notActivated.Count == 0)
        {
            return(true);
        }

        // Find a random unactivated monster
        Game.Monster toActivate = game.monsters[notActivated[Random.Range(0, notActivated.Count)]];

        return(ActivateMonster(toActivate));
    }
コード例 #4
0
ファイル: RoundHelper.cs プロジェクト: Liquidlogic1/valkyrie
 // Finish the other half of monster activation
 public static void ParticalActivationComplete(Game.Monster m)
 {
     // Start the other half of the activation
     new ActivateDialog(m, m.minionStarted);
     m.minionStarted = true;
     m.masterStarted = true;
 }
コード例 #5
0
ファイル: RoundHelper.cs プロジェクト: Liquidlogic1/valkyrie
    public static bool ActivateMonster(Game.Monster m)
    {
        List <ActivationData> adList = new List <ActivationData>();
        Game game = Game.Get();

        // Find all possible activations
        foreach (KeyValuePair <string, ActivationData> kv in game.cd.activations)
        {
            // Is this activation for this monster type? (replace "Monster" with "MonsterActivation", ignore specific variety)
            if (kv.Key.IndexOf("MonsterActivation" + m.monsterData.sectionName.Substring("Monster".Length)) == 0)
            {
                adList.Add(kv.Value);
            }
        }
        // Search for additional common activations
        foreach (string s in m.monsterData.activations)
        {
            if (game.cd.activations.ContainsKey("MonsterActivation" + s))
            {
                adList.Add(game.cd.activations["MonsterActivation" + s]);
            }
            else
            {
                Debug.Log("Warning: Unable to find activation: " + s + " for monster type: " + m.monsterData.sectionName);
            }
        }

        // Check for no activations
        if (adList.Count == 0)
        {
            Debug.Log("Error: Unable to find any activation data for monster type: " + m.monsterData.name);
            Application.Quit();
        }

        if (m.currentActivation == null)
        {
            // Pick a random activation
            ActivationData activation = adList[Random.Range(0, adList.Count)];
            m.currentActivation = activation;
        }

        // Pick Minion or master
        m.minionStarted = Random.Range(0, 2) == 0;
        if (m.currentActivation.masterFirst)
        {
            m.minionStarted = false;
        }
        if (m.currentActivation.minionFirst)
        {
            m.minionStarted = true;
        }

        m.masterStarted = !m.minionStarted;

        // Create activation window
        new ActivateDialog(m, m.masterStarted);

        // More groups unactivated
        return(false);
    }
コード例 #6
0
    public static void TriggerEvent()
    {
        Game game = Game.Get();

        RoundHelper.CheckNewRound();

        if (game.eventList.Count == 0)
        {
            return;
        }

        QuestData.Event e = game.eventList.Pop();

        // If the flags are not set do not trigger event
        foreach (string s in e.flags)
        {
            if (!game.qd.flags.Contains(s))
            {
                return;
            }
        }

        // Add set flags
        foreach (string s in e.setFlags)
        {
            if (!game.qd.flags.Contains(s))
            {
                Debug.Log("Notice: Setting quest flag: " + s);
                game.qd.flags.Add(s);
            }
        }

        // Remove clear flags
        foreach (string s in e.clearFlags)
        {
            if (game.qd.flags.Contains(s))
            {
                Debug.Log("Notice: Clearing quest flag: " + s);
                game.qd.flags.Remove(s);
            }
        }

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


        // If this is a monster event then add the monster group
        if (e is QuestData.Monster)
        {
            QuestData.Monster qm = (QuestData.Monster)e;

            // Is this type new?
            Game.Monster oldMonster = null;
            foreach (Game.Monster m in game.monsters)
            {
                if (m.monsterData.name.Equals(qm.mData.name))
                {
                    oldMonster = m;
                }
            }
            // Add the new type
            if (oldMonster == null)
            {
                game.monsters.Add(new Game.Monster(qm));
                game.monsterCanvas.UpdateList();
            }
            else if (qm.unique)
            {
                oldMonster.unique      = true;
                oldMonster.uniqueText  = qm.uniqueText;
                oldMonster.uniqueTitle = qm.uniqueTitle;
            }

            // Display the location
            game.tokenBoard.AddMonster(qm);
        }

        if (e.highlight)
        {
            game.tokenBoard.AddHighlight(e);
        }

        new DialogWindow(e);
        foreach (string s in e.addComponents)
        {
            if (game.qd.components.ContainsKey(s))
            {
                game.qd.components[s].SetVisible(true);
            }
            else
            {
                Debug.Log("Warning: Attempting to show missing item: " + s);
            }
        }
        foreach (string s in e.removeComponents)
        {
            if (game.qd.components.ContainsKey(s))
            {
                game.qd.components[s].SetVisible(false);
            }
            else
            {
                Debug.Log("Warning: Attempting to hide missing item: " + s);
            }
        }

        if (e.locationSpecified)
        {
            CameraController.SetCamera(e.location);
        }
    }
コード例 #7
0
 // Create an activation window, if master is false then it is for minions
 public ActivateDialog(Game.Monster m, bool masterIn)
 {
     monster = m;
     master  = masterIn;
     CreateWindow();
 }
コード例 #8
0
 public MonsterDialog(Game.Monster m)
 {
     monster = m;
     CreateWindow();
 }