Example #1
0
 public void HideOther()//隐藏未选定对象,先全部隐藏,再把选定的重新显示出来就行了
 {
     foreach (TouchableObject tobj in objectsInScene)
     {
         tobj.Hide(false);
     }
     foreach (Transform obj in selectedObjects)
     {
         TouchableObject tobj = obj.GetComponent <TouchableObject>();
         if (tobj.isSpecial)
         {
             Transform tobjp = obj.parent;
             for (int i = 0; i < tobjp.childCount; i++)
             {
                 //tobjp.GetChild(i).GetComponent<TouchableObject>().Solid(false);
                 tobjp.GetChild(i).GetComponent <TouchableObject>().SuperShow(true);
             }
         }
         else
         {
             //tobj.Solid(false);
             tobj.SuperShow(true);
         }
     }
 }
Example #2
0
    /**
     * public void Init()
     * {
     *  foreach(TouchableObject tou in preObjectsAll)
     *  {
     *      if (tou.isNode && tou.state != States.Hide &&tou.isRealTouchableObject)
     *      {
     *          objectsAll.Add(tou);
     *          objectsInScene.Add(tou);
     *          objectsInSceneTemp.Add(tou);
     *      }
     *  }
     * }
     **/
    public void ControlRegion()//核心代码啊这是
    {
        List <TouchableObject> specialObjects = new List <TouchableObject>();

        //如果禁止计算区域,比如在骨单位场景就要这么做
        if (GameCamera.Inst.noControlRegion)
        {
            return;
        }
        foreach (TouchableObject obj in objectsInSceneTemp)
        {
            if (obj.CalculateDistance(core) > length)//大于这个距离,不管他本来是显示还是隐藏,都要隐藏掉
            {
                obj.SuperShow(false);
            }
            else//在距离内,也要检查他是否是hide状态,是的话,仍然不显示
            {
                if (!(obj.state == States.Hide))//如果他不是真正的隐藏状态,那么再进行下一步判断
                {
                    obj.SuperShow(true);
                    if (obj.isSpecial && !specialObjects.Contains(obj.m_transform.parent.GetComponent <TouchableObject>()))
                    {
                        //如果是特殊的,把它的父级物体先加进集合以备后用,但应该先检测下是否已经包含这个元素了
                        specialObjects.Add(obj.m_transform.parent.GetComponent <TouchableObject>());
                    }
                }
            }
        }
        foreach (TouchableObject obj in specialObjects)
        {
            for (int i = 0; i < obj.m_transform.childCount; i++)
            {
                obj.m_transform.GetChild(i).GetComponent <TouchableObject>().SuperShow(true);
            }
        }
        foreach (Transform obj in selectedObjects)
        {
            TouchableObject tobj = obj.GetComponent <TouchableObject>();
            if (tobj.isSpecial)
            {
                Transform tobjp = obj.parent;
                for (int i = 0; i < tobjp.childCount; i++)
                {
                    tobjp.GetChild(i).GetComponent <TouchableObject>().SuperShow(true);
                }
            }
            else
            {
                tobj.SuperShow(true);
            }
        }
    }