コード例 #1
0
    /// <summary>
    /// D�sactive un enfant � l'unit�
    /// </summary>
    /// <param name="type"></param>
    /// <param name="destroy"></param>
    /// <returns></returns>
    public GameObject DesActiveChildObj(MYthsAndSteel_Enum.ChildTileType type, bool destroy = false)
    {
        GameObject child = null;

        foreach (GameObject gam in _Child)
        {
            string tag = "";
            if (gam.GetComponent <SpriteRenderer>() != null)
            {
                switch (type)
                {
                case MYthsAndSteel_Enum.ChildTileType.MoveSelect:
                    tag = "MoveSelectable";
                    break;

                case MYthsAndSteel_Enum.ChildTileType.AttackSelect:
                    tag = "AttackSelectable";
                    break;

                case MYthsAndSteel_Enum.ChildTileType.EventSelect:
                    tag = "SelectableTile";
                    break;

                case MYthsAndSteel_Enum.ChildTileType.MoveArrow:
                    tag = "DisplayArrowForMove";
                    break;
                }

                if (gam.tag == tag)
                {
                    child = gam;
                    child.GetComponent <SpriteRenderer>().enabled = false;
                    if (destroy)
                    {
                        _Child.Remove(child);
                        Destroy(child);
                        child = null;
                    }
                }
            }
        }
        return(child);
    }
コード例 #2
0
    /// <summary>
    /// Active un enfant � l'unit�
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public GameObject ActiveChildObj(MYthsAndSteel_Enum.ChildTileType type, Sprite sprite = null, float alpha = 1f)
    {
        GameObject child = null;

        foreach (GameObject gam in _Child)
        {
            string tag = "";
            if (gam.GetComponent <SpriteRenderer>() != null)
            {
                switch (type)
                {
                case MYthsAndSteel_Enum.ChildTileType.MoveSelect:
                    tag = "MoveSelectable";
                    if (gam.tag == tag)
                    {
                        child = gam;
                        child.GetComponent <SpriteRenderer>().enabled = true;
                        if (sprite != null)
                        {
                            child.GetComponent <SpriteRenderer>().sprite = sprite;
                        }
                    }
                    break;

                case MYthsAndSteel_Enum.ChildTileType.AttackSelect:
                    tag = "AttackSelectable";
                    if (gam.tag == tag)
                    {
                        child = gam;
                        child.GetComponent <SpriteRenderer>().enabled = true;
                        if (sprite != null)
                        {
                            child.GetComponent <SpriteRenderer>().sprite = sprite;
                        }
                    }
                    break;

                case MYthsAndSteel_Enum.ChildTileType.EventSelect:
                    tag = "SelectableTile";
                    if (gam.tag == tag)
                    {
                        child = gam;
                        child.GetComponent <SpriteRenderer>().enabled = true;
                        if (sprite != null)
                        {
                            child.GetComponent <SpriteRenderer>().sprite = sprite;
                        }
                    }
                    break;

                case MYthsAndSteel_Enum.ChildTileType.MoveArrow:
                    tag = "DisplayArrowForMove";
                    if (gam.tag == tag)
                    {
                        child = gam;
                        child.GetComponent <SpriteRenderer>().enabled = true;
                        if (sprite != null)
                        {
                            child.GetComponent <SpriteRenderer>().sprite = sprite;
                        }
                    }
                    break;
                }
            }
        }
        child.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha);
        return(child);
    }