Exemplo n.º 1
0
    public void OnEnterThisPage()
    {
        transform.Find("Panel (2)").gameObject.SetActive(false);
        Dictionary <int, Dictionary <int, Vector3> > dic = AvoidVacancyHelper.avoidmap;

        foreach (KeyValuePair <int, Dictionary <int, Vector3> > item in dic)
        {
            Vector3 pos    = Vector3.zero;
            Vector3 scaler = Vector3.zero;
            foreach (KeyValuePair <int, Vector3> it in item.Value)
            {
                if (it.Key == 0)
                {
                    pos = it.Value;
                }
                if (it.Key == 1)
                {
                    scaler = it.Value;
                }
            }
            Spawn(pos, scaler);
        }
        Enums.AvoidvacancyControll ac = Enums.AvoidvacancyControll.ActiveAll;
        MSGCenter.Execute(ac.ToString());

        MSGCenter.Execute(Enums.LeftMouseButtonControl.AddAvoidGizmo.ToString(), "True");
    }
Exemplo n.º 2
0
    public void OnLeveThisPage()
    {
        Replay("");
        transform.Find("Panel (2)").gameObject.SetActive(false);
        Enums.AvoidvacancyControll ac = Enums.AvoidvacancyControll.InactiveAll;
        MSGCenter.Execute(ac.ToString());

        MSGCenter.Execute(Enums.LeftMouseButtonControl.AddAvoidGizmo.ToString(), "False");
    }
Exemplo n.º 3
0
    void Spawn(Vector3 pos, Vector3 scaler)
    {
        GameObject prefab = transform.Find("Panel/Scroll View/Viewport/Content/AvoidvacancyItem").gameObject;
        Transform  parent = prefab.transform.parent;

        GameObject go    = SpawnChildren(prefab);
        int        index = go.transform.parent.childCount - 2;

        //添加
        childmap.Add(index, go);
        string message = MSGCenter.FormatMessage(index.ToString(), pos.ToString(), scaler.ToString());

        MSGCenter.Execute(Enums.AvoidvacancyControll.Add.ToString(), message);
        go.GetComponentInChildren <Text>().text = "第" + (index + 1) + "个避空位";
        //删除
        go.transform.Find("Button").GetComponent <Button>().onClick.AddListener(() =>
        {
            Destroy(go);
            childmap.Remove(index);
            MSGCenter.Execute(Enums.AvoidvacancyControll.Remove.ToString(), index.ToString());
        });
        //编辑
        go.transform.Find("Button (1)").GetComponent <Button>().onClick.AddListener(() =>
        {
            transform.Find("Panel (2)").gameObject.SetActive(true);
            MSGCenter.Execute(Enums.AvoidvacancyControll.Edit.ToString(), index.ToString());
            if (lastchoise == index)
            {
                return;
            }
            go.GetComponent <Image>().color = Color.green;
            if (childmap.ContainsKey(lastchoise))
            {
                childmap[lastchoise].GetComponent <Image>().color = Color.gray;
            }
            lastchoise = index;
        });
        //显示/隐藏
        go.transform.Find("Toggle").GetComponent <Toggle>().onValueChanged.AddListener((iSon) =>
        {
            Enums.AvoidvacancyControll ac = Enums.AvoidvacancyControll.Active;
            if (!iSon)
            {
                ac = Enums.AvoidvacancyControll.Inactive;
            }
            MSGCenter.Execute(ac.ToString(), index.ToString());
        });
    }
Exemplo n.º 4
0
    void Start()
    {
        MSGCenter.Register(Enums.MainProcess.MainProcess_RePlay.ToString(), Replay);
        GameObject prefab   = transform.Find("Panel/Scroll View/Viewport/Content/AvoidvacancyItem").gameObject;
        Transform  parent   = prefab.transform.parent;
        Button     addaboid = transform.Find("Panel/AddButton").GetComponent <Button>();

        addaboid.onClick.AddListener(() => { Spawn(Vector3.zero, Vector3.zero); });

        //隐藏/显示全部
        transform.Find("Panel/AllToggle").GetComponent <Toggle>().onValueChanged.AddListener((iSon) =>
        {
            Enums.AvoidvacancyControll ac = Enums.AvoidvacancyControll.ActiveAll;
            if (!iSon)
            {
                ac = Enums.AvoidvacancyControll.InactiveAll;
            }
            MSGCenter.Execute(ac.ToString());
        });


        //保存
        transform.Find("Panel (2)/Button").GetComponent <Button>().onClick.AddListener(() =>
        {
            transform.Find("Panel (2)").gameObject.SetActive(false);
            MSGCenter.Execute(Enums.AvoidvacancyControll.SaveAvoid.ToString());
        });
        //取消
        transform.Find("Panel (2)/Button (1)").GetComponent <Button>().onClick.AddListener(() =>
        {
            transform.Find("Panel (2)").gameObject.SetActive(false);
            MSGCenter.Execute(Enums.AvoidvacancyControll.Remove.ToString());
        });
        //重置
        transform.Find("Panel (2)/Button (2)").GetComponent <Button>().onClick.AddListener(() =>
        {
            transform.Find("Panel (2)").gameObject.SetActive(false);
            MSGCenter.Execute(Enums.AvoidvacancyControll.Reset.ToString());
        });
    }
Exemplo n.º 5
0
    void AliveAddAvoidvacancy(string message)
    {
        Dictionary <int, string> map = MSGCenter.UnFormatMessage(message);
        int     index  = currenteditvacancy;
        Vector3 pos    = Vector3.zero;
        Vector3 scaler = Vector3.zero;

        if (map.ContainsKey(1))
        {
            index = int.Parse(map[1]);
        }
        if (map.ContainsKey(2))
        {
            pos = MSGCenter.ParseToVector(map[2]);
        }
        if (map.ContainsKey(3))
        {
            scaler = MSGCenter.ParseToVector(map[3]);
        }
        GameObject voidva = null;


        if (!avoidvacancymap.ContainsKey(index))
        {
            voidva = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            voidva.transform.SetParent(userimport.transform);
            voidva.transform.localScale    = scaler;
            voidva.transform.localPosition = pos;
            voidva.AddComponent <AvoidVacancyController>();
            voidva.GetComponent <MeshRenderer>().material.color = Color.blue;
            Destroy(voidva.GetComponent <Collider>());
            avoidvacancymap[index] = voidva;
        }
        voidva = avoidvacancymap[index];

        Enums.AvoidvacancyControll ac = Enums.ParseEnums <Enums.AvoidvacancyControll>(map[0]);
        switch (ac)
        {
        case Enums.AvoidvacancyControll.Add:

            break;

        case Enums.AvoidvacancyControll.Edit:
            canaddAvoidvacancy = true;
            break;

        case Enums.AvoidvacancyControll.Remove:
            Destroy(voidva);
            avoidvacancymap.Remove(index);
            if (AvoidVacancyHelper.avoidmap.ContainsKey(index))
            {
                AvoidVacancyHelper.avoidmap.Remove(index);
            }
            index--;
            canaddAvoidvacancy = false;
            break;

        case Enums.AvoidvacancyControll.Inactive:
            voidva.SetActive(false);
            canaddAvoidvacancy = false;
            break;

        case Enums.AvoidvacancyControll.Active:
            voidva.SetActive(true);
            canaddAvoidvacancy = true;
            break;

        case Enums.AvoidvacancyControll.SaveAvoid:
            canaddAvoidvacancy = false;
            if (!AvoidVacancyHelper.avoidmap.ContainsKey(index))
            {
                AvoidVacancyHelper.avoidmap.Add(index, new Dictionary <int, Vector3>());
                AvoidVacancyHelper.avoidmap[index].Add(0, voidva.transform.localPosition);
                AvoidVacancyHelper.avoidmap[index].Add(1, voidva.transform.localScale);
            }
            else
            {
                AvoidVacancyHelper.avoidmap[index][0] = voidva.transform.localPosition;
                AvoidVacancyHelper.avoidmap[index][1] = voidva.transform.localScale;
            }

            break;

        case Enums.AvoidvacancyControll.InactiveAll:
            foreach (KeyValuePair <int, GameObject> item in avoidvacancymap)
            {
                if (avoidvacancymap.ContainsKey(item.Key))
                {
                    avoidvacancymap[item.Key].SetActive(false);
                }
            }
            break;

        case Enums.AvoidvacancyControll.ActiveAll:
            foreach (KeyValuePair <int, GameObject> item in avoidvacancymap)
            {
                if (avoidvacancymap.ContainsKey(item.Key))
                {
                    avoidvacancymap[item.Key].SetActive(true);
                }
            }
            break;

        case Enums.AvoidvacancyControll.Reset:
        default:
            break;
        }
        currenteditvacancy = index;
        PointHelper.GetInstance().currenteditvacancyindex = currenteditvacancy;
    }