コード例 #1
0
ファイル: InitiativePanel.cs プロジェクト: ilfate/cardGame
    public void RenderList()
    {
        int  initiative  = this.currentInitiative;
        int  position    = 0;
        bool noSpaceLeft = false;

        while (!noSpaceLeft)
        {
            InitiativeNumber numberObj = this.numbersList [initiative].GetComponent <InitiativeNumber>();
            bool             wasActive = numberObj.WasActive();
            noSpaceLeft = !numberObj.IsVisible(position);
            if (noSpaceLeft)
            {
                break;
            }
            Vector3 numberPosition = CalculatePosition(position);
            if (!wasActive)
            {
                numberObj.SetPosition(numberObj.FindLisstEndPosition());
            }
            numberObj.Animate(numberPosition);
            if (this.list.ContainsKey(initiative))
            {
                // yes we have here items
                List <GameObject> slot = this.list [initiative];
                foreach (GameObject itemObj in slot)
                {
                    InitiativeUnit item = itemObj.GetComponent <InitiativeUnit> ();

                    Vector3 itemPosition = CalculatePosition(position);
                    item.Animate(itemPosition);

                    position++;
                }
            }
            else
            {
                position++;
            }
            initiative++;
        }
        //foreach (KeyValuePair<int, List<GameObject>> pair in this.list) {
        //Debug.Log (pair.Key.ToString() + " - " + pair.Value.ToString());
        //}
    }
コード例 #2
0
ファイル: InitiativePanel.cs プロジェクト: ilfate/cardGame
    public void AddToList(Unit unit)
    {
        int initiative         = unit.CurrentInitiative;
        List <GameObject> slot = new List <GameObject> ();

        if (this.list.ContainsKey(initiative))
        {
            slot = this.list [initiative];
            this.list.Remove(initiative);
        }

        GameObject newListItem = Instantiate(this.listItemPrefab, Vector3.zero, Quaternion.identity, this.transform);

        newListItem.name = "Initiative" + unit.name;
        InitiativeUnit item = newListItem.GetComponent <InitiativeUnit> ();

        item.unit = unit;


        slot.Add(newListItem);
        this.list.Add(initiative, slot);
        this.RenderList();
    }
コード例 #3
0
 private static int CompareByInitiative(InitiativeUnit a, InitiativeUnit b)
 {
     return a.initiative.CompareTo(b.initiative);
 }