Esempio n. 1
0
    void ChangeSelfOrientation()
    {
        if (unit_blueprint.menu_open)
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.C) && be_picked && !symmetry)
        {
            //transform.Rotate(Vector3.forward, 90);

            transform.localRotation *= Quaternion.Euler(0, 0, 90);
            return;
        }
        if (Input.GetKeyDown(KeyCode.C) && be_picked && symmetry)
        {
            EquipmentPart temp_E_part = (Instantiate(Resources.Load <GameObject>("Part/EquipmentPart/" + brother_part_name))).GetComponent <EquipmentPart>();
            temp_E_part.enabled = true;
            temp_E_part.Init();//手动初始化,因为Start执行顺序有问题
            temp_E_part.CreatFromButton();
            temp_E_part.be_creat_from_button = true;

            mandatory_delete = true;
            DeleteSelf();
        }
    }
Esempio n. 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;
    }