Ejemplo n.º 1
0
    /// <summary>
    /// Stores the entity reference, updates the transform position and register to entity events
    /// </summary>
    /// <param name="entity">The entity to be linked to the gameObject</param>
    public void Init(Entity entity)
    {
        this.entity = entity;
        this.entity.OnPositionChange.AddListener(OnEntityPositionChanged);
        FaceSprite faceSprite = availableFaces.FirstOrDefault(f => f.symbol == entity.symbol);

        if (faceSprite.sprite != null) // leave the default sprite if no face sprite is found
        {
            spriteRenderer.sprite = faceSprite.sprite;
        }
        spriteRenderer.color = entity.color;
    }
Ejemplo n.º 2
0
    public int CompareTo(object obj)
    {
        if (obj == null)
        {
            return(1);
        }
        FaceSprite faceSprite = obj as FaceSprite;

        if (faceSprite != null)
        {
            return(this.randSortOrder.CompareTo(faceSprite.randSortOrder));
        }
        else
        {
            throw new System.ArgumentException("Object is not a FaceSprite");
        }
    }