Example #1
0
    public void deleteButtonProcess(GameObject parentReference, GameObject toDelete, string tagName) //toDelete은 조건 동그라미, parentReerence 는
    {
        //여기서 toDelete가 DPSMT같은 아이. X버튼 지우려면 따로 child 타서 들어가야됌
        print("DeleteButtonProcess Starts from Here");
        if (toDelete.GetComponent <DragDropCondition>().connectedOnes.Count != 0)
        {
            deleteButtonProcess(toDelete, toDelete.GetComponent <DragDropCondition>().connectedOnes[0], "Condition");
        }
        DragDropCondition conditionScript = toDelete.GetComponent <DragDropCondition>();

        toDelete.transform.GetChild(0).tag = "Condition";
        Destroy(toDelete.transform.GetChild(2).gameObject);
        toDelete.transform.SetParent(conditionScript.originalParent.transform);
        conditionScript.moveToOriginal();
        conditionScript.alreadyLinked = 0;
        conditionScript.startPos      = new Vector2(0, 0);
        conditionScript.endPos        = new Vector2(0, 0);
        conditionScript.onScreen      = false;
        conditionManager = GameObject.Find("UIManager").GetComponent <Conditions>();
        conditionManager.conditionList[int.Parse(toDelete.transform.GetChild(1).name) - 1001].conditionPositionX = 0;
        conditionManager.conditionList[int.Parse(toDelete.transform.GetChild(1).name) - 1001].conditionPositionY = 0;
        conditionManager.conditionList[int.Parse(toDelete.transform.GetChild(1).name) - 1001].conditionParent    = 0;
        conditionManager.conditionList[int.Parse(toDelete.transform.GetChild(1).name) - 1001].usingCharID        = -1;
        string condName      = toDelete.transform.GetChild(1).name + conditionManager.conditionList[int.Parse(toDelete.transform.GetChild(1).name) - 1001].conditionName;
        int    tempParentNum = conditionManager.conditionList[int.Parse(toDelete.transform.GetChild(1).name) - 1001].conditionID / 100;

        if (tempParentNum == 1)    //hp
        {
            conditionScript.modifySelected(ref conditionManager.hpOnList, ref conditionManager.hpOffList, condName);
        }
        else if (tempParentNum == 2)    //state
        {
            conditionScript.modifySelected(ref conditionManager.stateOnList, ref conditionManager.stateOffList, condName);
        }
        else if (tempParentNum == 3)    //radius
        {
            conditionScript.modifySelected(ref conditionManager.radiusOnList, ref conditionManager.radiusOffList, condName);
        }
        if (int.Parse(parentReference.transform.GetChild(1).name) > 1000)
        {
            parentReference.GetComponent <DragDropCondition>().connectedOnes = new List <GameObject>();
        }
        else
        {
            parentReference.GetComponent <DragDropAction>().connectedOnes.Remove(toDelete);
        }
    }
Example #2
0
    public void deleteButton()
    {
        print("delete button pressed");
        //변경사항 발동
        somethingChanged = true;
        //변경사항 발동
        GameObject toDestroy       = EventSystem.current.currentSelectedGameObject; //X버튼
        GameObject parentToDestroy = toDestroy.transform.parent.gameObject;         //동그란 버튼

        print(parentToDestroy.name);

        DragDropAction    actionScript    = parentToDestroy.GetComponent <DragDropAction>();
        DragDropCondition conditionScript = parentToDestroy.GetComponent <DragDropCondition>();

        GameObject[] referenceIDList = GameObject.FindGameObjectsWithTag("ReferenceID");
        if (conditionScript == null && actionScript.connectedOnes.Count > 0) //Action이면서 줄줄이 달려있을 경우
        {
            print("Action이면서 줄줄이 달려있을 경우");
            while (actionScript.connectedOnes.Count > 0)
            {
                deleteButtonProcess(parentToDestroy, actionScript.connectedOnes[0], "Condition"); //무조건 0 밖에 없을거임 Condition은 한개밖에 안달리기 때문에
            }
            parentToDestroy.transform.GetChild(0).tag = "Action";
            Destroy(toDestroy);
            parentToDestroy.transform.SetParent(actionScript.originalParent.transform);
            actionScript.moveToOriginal();
            actionScript.startPos = new Vector2(0, 0);
            actionScript.endPos   = new Vector2(0, 0);
            actionScript.onScreen = false;

            actionManager = GameObject.Find("UIManager").GetComponent <Actions>();
            actionManager.actionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1].actionPositionX = 0f;
            actionManager.actionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1].actionPositionY = 0f;
            actionManager.actionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1].actionUsed      = 2;

            int tempParentNum = actionManager.actionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1].actionParent;
            if (tempParentNum == 1) //movement
            {
                actionScript.modifySelected(ref actionManager.movementOnList, ref actionManager.movementOffList, parentToDestroy.transform.GetChild(1).name);
            }
            else if (tempParentNum == 2) //Attack
            {
                actionScript.modifySelected(ref actionManager.attackOnList, ref actionManager.attackOffList, parentToDestroy.transform.GetChild(1).name);
            }
            else if (tempParentNum == 3) //Item
            {
                actionScript.modifySelected(ref actionManager.itemOnList, ref actionManager.itemOffList, parentToDestroy.transform.GetChild(1).name);
            }
        }
        else if (actionScript == null && conditionScript.connectedOnes.Count > 0)                //Condition이면서 줄줄이 달려있을 경우
        {
            deleteButtonProcess(parentToDestroy, conditionScript.connectedOnes[0], "Condition"); //무조건 0 밖에 없을거임 Condition은 한개밖에 안달리기 때문에
            parentToDestroy.transform.GetChild(0).tag = "Condition";
            Destroy(toDestroy);
            parentToDestroy.transform.SetParent(conditionScript.originalParent.transform);
            string tempText = (parentToDestroy.transform.GetChild(1).GetComponent <Text>().text);
            if (int.Parse(tempText) > 1000)
            {
                GameObject.Find(tempText).transform.parent.gameObject.GetComponent <DragDropCondition>().connectedOnes = new List <GameObject>();
            }
            else
            {
                GameObject.Find(tempText).transform.parent.GetComponent <DragDropAction>().connectedOnes.Remove(parentToDestroy);
            }
            conditionScript.moveToOriginal();
            conditionScript.alreadyLinked = 0;
            conditionScript.startPos      = new Vector2(0, 0);
            conditionScript.endPos        = new Vector2(0, 0);
            conditionScript.onScreen      = false;

            conditionManager = GameObject.Find("UIManager").GetComponent <Conditions>();
            conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionPositionX = 0;
            conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionPositionY = 0;
            conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionParent    = 0;
            string condName      = parentToDestroy.transform.GetChild(1).name + conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionName;
            int    tempParentNum = conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionID / 100;
            if (tempParentNum == 1) //hp
            {
                conditionScript.modifySelected(ref conditionManager.hpOnList, ref conditionManager.hpOffList, condName);
            }
            else if (tempParentNum == 2) //state
            {
                conditionScript.modifySelected(ref conditionManager.stateOnList, ref conditionManager.stateOffList, condName);
            }
            else if (tempParentNum == 3) //radius
            {
                conditionScript.modifySelected(ref conditionManager.radiusOnList, ref conditionManager.radiusOffList, condName);
            }
        }
        else if (conditionScript == null && actionScript.connectedOnes.Count == 0) //Action이면서 달려있는 애들이 없는 경우
        {
            parentToDestroy.transform.GetChild(0).tag = "Action";
            Destroy(toDestroy);
            parentToDestroy.transform.SetParent(actionScript.originalParent.transform); //put it inside the content prefab
            actionScript.moveToOriginal();
            actionScript.startPos = new Vector2(0, 0);
            actionScript.endPos   = new Vector2(0, 0);
            actionScript.onScreen = false;
            Actions actionManager = GameObject.Find("UIManager").GetComponent <Actions>();
            actionManager.actionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1].actionPositionX = 0f;
            actionManager.actionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1].actionPositionY = 0f;
            actionManager.actionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1].actionUsed      = 2;

            int tempParentNum = actionManager.actionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1].actionParent;
            if (tempParentNum == 1) //movement
            {
                actionScript.modifySelected(ref actionManager.movementOnList, ref actionManager.movementOffList, parentToDestroy.transform.GetChild(1).name);
            }
            else if (tempParentNum == 2) //Attack
            {
                actionScript.modifySelected(ref actionManager.attackOnList, ref actionManager.attackOffList, parentToDestroy.transform.GetChild(1).name);
            }
            else if (tempParentNum == 3) //Item
            {
                actionScript.modifySelected(ref actionManager.itemOnList, ref actionManager.itemOffList, parentToDestroy.transform.GetChild(1).name);
            }
        }
        else //Condition이면서 달려있는 애들이 없을 경우
        {
            parentToDestroy.transform.GetChild(0).tag = "Condition";
            Destroy(toDestroy);
            parentToDestroy.transform.SetParent(conditionScript.originalParent.transform);
            string tempText = (parentToDestroy.transform.GetChild(1).GetComponent <Text>().text);
            if (int.Parse(tempText) > 1000)
            {
                GameObject.Find(tempText).transform.parent.gameObject.GetComponent <DragDropCondition>().connectedOnes = new List <GameObject>();
            }
            else
            {
                GameObject.Find(tempText).transform.parent.GetComponent <DragDropAction>().connectedOnes.Remove(parentToDestroy);
            }
            conditionScript.moveToOriginal();
            conditionScript.alreadyLinked = 0;
            conditionScript.startPos      = new Vector2(0, 0);
            conditionScript.endPos        = new Vector2(0, 0);
            conditionScript.onScreen      = false;
            conditionManager = GameObject.Find("UIManager").GetComponent <Conditions>();
            conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionPositionX = 0;
            conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionPositionY = 0;
            conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionParent    = 0;
            string condName = parentToDestroy.transform.GetChild(1).name + conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionName;
            print("condName = " + condName);
            int tempParentNum = conditionManager.conditionList[int.Parse(parentToDestroy.transform.GetChild(1).name) - 1001].conditionID / 100;
            if (tempParentNum == 1) //hp
            {
                conditionScript.modifySelected(ref conditionManager.hpOnList, ref conditionManager.hpOffList, condName);
            }
            else if (tempParentNum == 2) //state
            {
                conditionScript.modifySelected(ref conditionManager.stateOnList, ref conditionManager.stateOffList, condName);
            }
            else if (tempParentNum == 3) //radius
            {
                conditionScript.modifySelected(ref conditionManager.radiusOnList, ref conditionManager.radiusOffList, condName);
            }
        }
    }