Esempio n. 1
0
    public void OnBuildOpItemSel(BuildOpItem item)
    {
        switch (item.mType)
        {
        case OpType.ItemSetting:
            mItemTab.isChecked = true;
            break;

        case OpType.NpcSetting:
            mNpcTab.isChecked = true;
            break;
        }

        if (item != mSelectedItem)
        {
            if (mSelectedItem)
            {
                mSelectedItem.SetActive(false);
            }
            mSelectedItem = item;
            mSelectedItem.SetActive(true);
            mPosX.text = mSelectedItem.transform.position.x.ToString();
            if (mPosX.text.Length > 6)
            {
                mPosX.text = mPosX.text.Substring(0, 6);
            }
            mPosY.text = mSelectedItem.transform.position.y.ToString();
            if (mPosY.text.Length > 6)
            {
                mPosY.text = mPosY.text.Substring(0, 6);
            }
            mPosZ.text = mSelectedItem.transform.position.z.ToString();
            if (mPosZ.text.Length > 6)
            {
                mPosZ.text = mPosZ.text.Substring(0, 6);
            }
            mRotX.text = mSelectedItem.transform.eulerAngles.x.ToString();
            if (mRotX.text.Length > 6)
            {
                mRotX.text = mRotX.text.Substring(0, 6);
            }
            mRotY.text = mSelectedItem.transform.eulerAngles.y.ToString();
            if (mRotX.text.Length > 6)
            {
                mRotX.text = mRotX.text.Substring(0, 6);
            }
            mRotZ.text = mSelectedItem.transform.eulerAngles.z.ToString();
            if (mRotX.text.Length > 6)
            {
                mRotX.text = mRotX.text.Substring(0, 6);
            }
        }
        else if (mSelectedItem)
        {
            mSelectedItem.SetActive(false);
            mSelectedItem = null;
        }
    }
Esempio n. 2
0
 void PutItemDown()
 {
     if (mPutOutItem)
     {
         mPutOutItem.GetComponent <Collider>().enabled = true;
     }
     mPutOutItem     = null;
     mCurrentSelItem = null;
 }
Esempio n. 3
0
 void CancelOp()
 {
     if (mSelectedItem)
     {
         mSelectedItem.SetActive(false);
     }
     mSelectedItem = null;
     mPutOutItem   = null;
     //mCurrentReq = null;
     mCurrentSelItem = null;
 }
Esempio n. 4
0
    void CreateMode(GameObject go, CreateReq req)
    {
        BoxCollider bc    = go.AddComponent <BoxCollider>();
        Bounds      bound = bc.bounds;

        Collider[] childCols = go.GetComponentsInChildren <Collider>();

        foreach (Collider col in childCols)
        {
            bound.Encapsulate(col.bounds);
            if (!req.mIsLoad)
            {
                col.enabled = false;
            }
        }

        bc.center = bound.center - go.transform.position;
        bc.size   = bound.size;

        BuildOpItem opItem = go.AddComponent <BuildOpItem>();

        switch (req.mType)
        {
        case OpType.ItemSetting:
            opItem.mType   = OpType.ItemSetting;
            opItem.mItemID = req.mItemId;
            mItemList.Add(opItem);
            break;

        case OpType.NpcSetting:
            opItem.mType = OpType.NpcSetting;
            mNpcList.Add(opItem);
            bc.center += 1f * Vector3.up;
            bc.size   += 0.5f * Vector3.up;
            break;
        }
        if (!req.mIsLoad)
        {
            mPutOutItem = opItem;
        }
    }
Esempio n. 5
0
    void Update()
    {
        switch (mOpType)
        {
        case OpType.ItemSetting:
        case OpType.NpcSetting:

            if (null != mSelectedItem && !UICamera.inputHasFocus)
            {
                if (mPosX.text == "")
                {
                    mPosX.text = "0";
                }
                if (mPosY.text == "")
                {
                    mPosY.text = "0";
                }
                if (mPosZ.text == "")
                {
                    mPosZ.text = "0";
                }
                if (mRotX.text == "")
                {
                    mRotX.text = "0";
                }
                if (mRotY.text == "")
                {
                    mRotY.text = "0";
                }
                if (mRotZ.text == "")
                {
                    mRotZ.text = "0";
                }
                mSelectedItem.transform.position = new Vector3(Convert.ToSingle(mPosX.text), Convert.ToSingle(mPosY.text), Convert.ToSingle(mPosZ.text));
                mSelectedItem.transform.rotation = Quaternion.Euler(new Vector3(Convert.ToSingle(mRotX.text), Convert.ToSingle(mRotY.text), Convert.ToSingle(mRotZ.text)));
            }

            if (null != mPutOutItem)
            {
                if (Input.GetMouseButtonUp(0))
                {
                    PutItemDown();
                }
                else
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hitInfo;
                    if (Physics.Raycast(ray, out hitInfo, 500f))
                    {
                        mPutOutItem.transform.position = hitInfo.point;
                    }
                }
            }

            if (null != mSelectedItem)
            {
                if (Input.GetKeyDown(KeyCode.Delete))
                {
                    mNpcList.Remove(mSelectedItem);
                    mItemList.Remove(mSelectedItem);
                    Destroy(mSelectedItem.gameObject);
                    mSelectedItem = null;
                }

                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    mSelectedItem.SetActive(false);
                    mSelectedItem = null;
                }
            }
            break;
        }
    }