コード例 #1
0
    /// <summary>
    /// Removes the unit from the GUI and the underlying data structure.
    /// </summary>
    /// <param name="unit">Unit.</param>
    /// <param name="turnOrder">Turn order.</param>
    public void RemoveUnit(Unit unit, TurnOrder turnOrder)
    {
        TurnOrderImage turnOrderImage = _turnOrderImageCollection.Get(unit, turnOrder);

        _turnOrderImageCollection.Remove(turnOrderImage, turnOrder);
        turnOrder.RemoveUnit(unit);
    }
コード例 #2
0
 /// <summary>
 /// Add the specified turnOrderImage and turnOrder.
 /// </summary>
 /// <param name="turnOrderImage">Turn order image.</param>
 /// <param name="turnOrder">Turn order.</param>
 public void Add(TurnOrderImage turnOrderImage, TurnOrder turnOrder)
 {
     if (!_imageDictionary.ContainsKey(turnOrder))
     {
         _imageDictionary [turnOrder] = new List <TurnOrderImage> ();
     }
     _imageDictionary[turnOrder].Add(turnOrderImage);
 }
コード例 #3
0
    /// <summary>
    /// Adds the unit to the GUI and underlying data structure.
    /// If the unit had been previously persistently highlighted, apply it when added back.
    /// </summary>
    /// <param name="unit">Unit.</param>
    /// <param name="orderIndex">Ordering Index.</param>
    public void AddUnit(Unit unit, TurnOrder turnOrder, int orderIndex = -1)
    {
        // Instantiate a new Image game object
        Image unitImage = Instantiate(imagePrefab);

        unitImage.sprite = unit.GetPortrait();
        unitImage.transform.SetParent(_panel.transform, false);

        // Associate unit with image
        TurnOrderImage turnOrderImage = unitImage.GetComponent <TurnOrderImage> ();

        turnOrderImage.Unit = unit;

        unitImage.name = string.Format("{0} - {1}", unit.GetFullName(), turnOrderImage.GetInstanceID());

        // Add image to list
        _turnOrderImageCollection.Add(turnOrderImage, turnOrder);

        // Add unit to turn order list
        if (orderIndex <= -1)
        {
            turnOrder.AddUnit(unit);
        }
        else
        {
            turnOrder.InsertUnit(unit, orderIndex);
            if (unit.HasDeferredAbility)
            {
                _turnOrderImageCollection.Get(unit, turnOrder).ActivateStatusImage(_statusImage);
            }
        }

        // Handle highlighting
        if (_highlightOnSpawn)
        {
            turnOrderImage.Highlight(false);
        }
        _highlightOnSpawn = false;
    }
コード例 #4
0
 /// <summary>
 /// Remove the specified turnOrderImage.
 /// </summary>
 /// <param name="turnOrderImage">Turn order image.</param>
 public void Remove(TurnOrderImage turnOrderImage, TurnOrder turnOrder)
 {
     _imageDictionary [turnOrder].Remove(turnOrderImage);
     turnOrderImage.transform.SetParent(null);
     Destroy(turnOrderImage.gameObject);
 }