Example #1
0
    //public void DeleteSelf()
    //{
    //    if (unit_blueprint.menu_open) return;

    //    if ((Input.GetKeyDown(KeyCode.Delete) && (be_picked || hover)) || mandatory_delete)
    //    {
    //        be_picked = false;
    //        hover = false;
    //        energy_supply = 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);
    //        }
    //        //销毁自身
    //        Destroy(gameObject);
    //    }
    //}
    void ChangeSelfOrientation()
    {
        if (unit_blueprint.menu_open)
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.C) && be_picked && symmetry)
        {
            LegPart temp_leg_part = (Instantiate(Resources.Load <GameObject>("Part/MovementPart/LegPart/" + brother_part_name))).GetComponent <LegPart>();
            temp_leg_part.enabled = true;
            temp_leg_part.Init();//手动初始化,因为Start执行顺序有问题
            temp_leg_part.CreatFromButton();
            temp_leg_part.be_creat_from_button = true;

            mandatory_delete = true;
            DeleteSelf();
        }
    }
Example #2
0
    public void ClickPartButton(PartButton click_this_button)
    {
        //计算零件出生位置:
        ////Vector3 start_pos = SetPosWhenPartCreat();

        switch ((int)click_this_button.part_type)
        {
        case 0:

            if (unit_blueprint.have_power_part)
            {
                Debug.LogError("设计平台上已经存在一个动力组件!");
                self_AS.clip = all_ACs["Error"];
                self_AS.Play();
                return;
            }

            part_prefab = Instantiate(Resources.Load <GameObject>("Part/PowerPart/" + click_this_button.part_name));
            PowerPart temp_power_part = part_prefab.GetComponent <PowerPart>();
            temp_power_part.enabled = true;
            temp_power_part.Init();    //手动初始化,因为Start执行顺序有问题
            temp_power_part.CreatFromButton();
            temp_power_part.be_creat_from_button = true;
            break;

        case 1:

            GameObject temp_go = Resources.Load <GameObject>("Part/MovementPart/LegPart/" + click_this_button.part_name);
            part_prefab = Instantiate(temp_go);
            //part_prefab.transform.position = start_pos;
            LegPart temp_leg_part = part_prefab.GetComponent <LegPart>();
            temp_leg_part.enabled = true;
            temp_leg_part.Init();    //手动初始化,因为Start执行顺序有问题
            temp_leg_part.CreatFromButton();
            temp_leg_part.be_creat_from_button = true;
            break;

        case 2:
            if (unit_blueprint.have_ctrl_part)
            {
                Debug.Log("注意:设计平台上已经存在一个控制组件!");
                //break;
            }

            part_prefab = Instantiate(Resources.Load <GameObject>("Part/ControlPart/" + click_this_button.part_name));
            ControlPart temp_control_part = part_prefab.GetComponent <ControlPart>();
            temp_control_part.enabled = true;
            temp_control_part.Init();    //手动初始化,因为Start执行顺序有问题
            temp_control_part.CreatFromButton();
            temp_control_part.be_creat_from_button = true;
            break;

        case 3:
            part_prefab = Instantiate(Resources.Load <GameObject>("Part/EquipmentPart/" + click_this_button.part_name));
            EquipmentPart temp_equip_part = part_prefab.GetComponent <EquipmentPart>();
            temp_equip_part.enabled = true;
            temp_equip_part.Init();    //手动初始化,因为Start执行顺序有问题
            temp_equip_part.CreatFromButton();
            temp_equip_part.be_creat_from_button = true;
            break;
        }

        //播放创建零件的音效:
        creat_part_audio.Play();
        //关闭悬停高亮Ui:
        click_this_button.hover_image.enabled = false;

        foreach (var lb in all_layer_button)
        {
            lb.self_image.sprite = lb.sp[0];
            lb.pressed           = false;
        }

        ToolClosePartInterface();
        unit_blueprint.menu_open = false;
    }