示例#1
0
    void setMySkill(GameObject o)
    {
        //If the dragged item comes from another position of the bar, swap!
        MySkillButton mySkill = this.GetComponentInChildren <MySkillButton>();

        if (mySkill != null)
        {
            SkillbarPanel panel = o.GetComponent <MySkillButton>().myParent;
            if (panel != null)
            {
                mySkill.putInBar(panel);
            }
        }

        destroyAllMyChildren();         //Whenever we drag a new skill, we destroy the previous one

        //Just in case
        MySkillButton skill = o.GetComponent <MySkillButton>();

        if (skill == null)
        {
            return;
        }

        //We make a copy of the skill and attach it here
        skill.putInBar(this);
    }
示例#2
0
 public void copyMyself()      //We instantiate this object, set it to 'dragged', and attach it to movedSkills
 {
     draggedItem = Instantiate(this.gameObject, this.transform.position, Quaternion.identity) as GameObject;
     draggedItem.transform.SetParent(movedSkills.transform);
     myParent = this.GetComponentInParent <SkillbarPanel>();
     draggedItem.GetComponent <MySkillButton>().setParameters(dragged, myParent);
     draggedItem.name = this.gameObject.name;         //To avoid the extra '(copy)' in its name.
 }
示例#3
0
    public void putInBar(SkillbarPanel panel) //We instantiate the object and put it as a child of the panel
    {
        eliminateOtherSkills();               //We eliminate all other skills in the bar with the same skillNumber
        GameObject newChildren = Instantiate(this.gameObject, panel.transform.position, Quaternion.identity) as GameObject;

        newChildren.transform.SetParent(panel.transform);
        newChildren.GetComponent <MySkillButton>().setParameters(inSkillBar, null);
        newChildren.name = this.gameObject.name;
    }
示例#4
0
    public void setParameters(int state, SkillbarPanel panel)      //set myState to state (+ consequences)
    {
        myState  = state;
        myParent = panel;
        if (myState == dragged)
        {
            //aesthetics
            myImage       = this.GetComponent <Image>();
            myImage.color = defaultColor;

            //We don't want this object to bother our raycasts if we are dragging it
            GetComponent <CanvasGroup>().blocksRaycasts = false;
        }
        else
        {
            GetComponent <CanvasGroup>().blocksRaycasts = true;
        }
    }