Beispiel #1
0
    private void Awake()
    {
        if (m_stats == null)
        {
            m_stats = new DiceStats();
        }

        if (m_renderer == null)
        {
            if (!this.GetComponentInChildrenChecked <Shape>(ref m_renderer))
            {
                Debug.LogError("The dice prefab has no shape renderer assigned!");
            }
        }

        if (m_text == null)
        {
            if (!this.GetComponentChecked <Text>(ref m_text))
            {
                m_text = gameObject.AddComponent <Text>();
            }
        }

        transform.position += new Vector3(0, 0, 1);

        Button button = GetComponent <Button>();

        if (button != null)
        {
            button.onClick.AddListener(delegate { MenuSelector.GetInstance().OpenDiceMenu(this); });
        }
    }
    public void LoadDice(DiceStats stats)
    {
        RemoveAllDice();

        Transform dice = Instantiate(m_dicePrefab, new Vector3(0, 0, 0), Quaternion.identity);

        dice.GetComponent <Dice>().LoadStats(stats);
    }
 public DiceStats(DiceStats dice)
 {
     this.m_power     = dice.m_power;
     this.m_sides     = dice.m_sides;
     this.m_goalSides = dice.m_goalSides;
     this.m_magic     = dice.m_magic;
     this.m_usedMagic = dice.m_usedMagic;
 }
Beispiel #4
0
 private static void GatherDice()
 {
     _save._savedDice = new List <DiceStats>();
     for (int i = 0; i < DiceManager.GetInstance().GetDiceList().Count; i++)
     {
         DiceStats temp = new DiceStats(DiceManager.GetInstance().GetDiceList()[i].GetStats());
         _save._savedDice.Add(temp);
     }
 }
    public void DiceTestSides()
    {
        DiceStats stats = new DiceStats();

        stats.TestConstructor(3, 6);
        const int expectedSides = 4;

        for (int i = 0; i < 100; i++)
        {
            stats.AddSide();
        }

        Assert.AreEqual(expectedSides, stats.GetSides(), 0);
    }
 // Start is called before the first frame update
 void Start()
 {
     diceStats = gameObject.GetComponent <DiceStats>();
 }
Beispiel #7
0
 public void LoadStats(DiceStats stats)
 {
     m_stats = stats;
     m_stats.m_powerAdded += SetLineRenderer;
     SetLineRenderer(m_stats.GetSides());
 }