Example #1
0
    public virtual void DeleteSelf()
    {
        if (mandatory_delete)
        {
        }
        else if (unit_blueprint.menu_open)
        {
            return;
        }


        if ((Input.GetKeyDown(KeyCode.Delete) && (be_picked || hover)) || mandatory_delete)
        {
            be_picked = false;
            hover     = false;

            //清理蓝图的信息:
            unit_blueprint.mouse_picking_a_part = false;
            unit_blueprint.RemovePartFromUnit(this);
            //整理相关的零件的碰撞信息列表:
            foreach (Part OP in overlaped_parts)
            {
                //从所有与本零件重叠的零件的碰撞列表中移除本零件
                Debug.Log("*****" + OP.overlaped_parts.Contains(this));
                OP.overlaped_parts.Remove(this);
            }
            //重置与这个零件连接的所有节点信息、清空父级零件信息
            foreach (var MP in mount_points)
            {
                MP.UnLink2MountPoint();
            }
            //销毁自身的UI组件
            foreach (var UI in all_UI)
            {
                Destroy(UI.gameObject);
            }
            //Debug.Log("即将销毁自身");
            //销毁自身
            Destroy(gameObject);
        }
    }
Example #2
0
    void BePickedAndUnPicked()
    {
        //if (CheckGuiRaycastObjects()) return;
        if (unit_blueprint.menu_open)
        {
            return;
        }

        if (Input.GetButtonDown("Fire1") && !be_picked && hover)
        {
            RaycastHit hitwhat;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hitwhat, 2000f, 1 << 12))
            {
                if (hitwhat.transform == transform)
                {
                    Debug.Log("选中了");
                    be_picked = true;
                    unit_blueprint.mouse_picking_a_part = true;
                    //一旦一个零件被拾取,重置这个零件的所有节点信息、清空父级零件信息
                    foreach (var MP in mount_points)
                    {
                        MP.UnLink2MountPoint();
                    }
                    //////一旦一个零件被拾取,重置所有零件的 energy_supply 变量为false;
                    ////unit_blueprint.SetAllPartEnergySupplyFalse();

                    //Cursor.visible = false;
                }
            }
        }
        else if ((Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown("Fire1")) && be_picked)
        {
            Debug.Log("取消选中了");
            be_picked = false;
            unit_blueprint.mouse_picking_a_part = false;
        }
    }