Ejemplo n.º 1
0
    /// <summary>
    /// 选中
    /// </summary>
    private void SelectSelf(bool isNew = false)
    {
        if (MapUtil.m_SelectId != 0 &&
            !MapUtil.m_SelectOK)
        {
            if (MapUtil.m_SelectNew)
            {
                JerryEventMgr.DispatchEvent(Enum_Event.SetFurn2Package.ToString(), new object[] { MapUtil.m_SelectId });
            }
            else
            {
                JerryEventMgr.DispatchEvent(Enum_Event.CancelSetFurn.ToString(), new object[] { MapUtil.m_SelectId });
            }
        }

        if (isNew)
        {
            RayClickPos fp = MapUtil.GetFirstPos(m_Config.setType);
            //Debug.LogWarning(fp.pos + " x " + fp.wallType + " " + m_Config.setType);
            SelectChange2Wall(Enum_Wall.Wall, fp.wallType, fp.pos);
        }
        else if (m_InitData.m_CurWall != Enum_Wall.None)
        {
            //先浮起来,再记录,保持回退时一致性
            this.transform.position = MapUtil.GetMap(m_InitData.m_CurWall).AdjustFurn2Wall(m_Config.size, true, this.transform.position);

            m_InitData.m_LastPos  = this.transform.position;
            m_InitData.m_LastWall = m_InitData.m_CurWall;

            MapUtil.GetMap(m_InitData.m_CurWall).CleanOne(this.transform.position, m_Config.size);
        }

        //Debug.LogWarning("xxx " + m_InitData.isNew + " " + m_InitData.m_CurWall);

        MapUtil.m_SelectId   = m_Id;
        MapUtil.m_SelectOK   = false;
        MapUtil.m_SelectNew  = isNew;
        MapUtil.m_SelectFurn = this;

        this.gameObject.layer = LayerMask.NameToLayer(Enum_Layer.ActiveFurniture.ToString());
        m_Selected            = true;
        m_InitData.isSeted    = false;

        bool canSet = MapUtil.GetMap(m_InitData.m_CurWall).JudgeSet(this.transform.position, m_Config.size);

        //GridMgr.Inst.ShowGrid(m_Config.setType, m_Config.size.y);
        MeshDraw.Inst.ShowGrid(m_Config.setType, m_Config.size.y);

        SetOutLineVisible(true);
        SetOutLineColor(canSet ? Color.green : Color.red);
        FurnitureShadow.Inst.SetSize(m_Config.size.ToVector3(), m_InitData.m_CurWall);
        FurnitureShadow.Inst.SetVisible(true);
        FurnitureShadow.Inst.SetPosColor(MapUtil.GetMap(m_InitData.m_CurWall).Adjust2Wall(this.transform.position), canSet ? Color.green : Color.red);
        UI_Ctr.Inst.ShowCtr();
    }