コード例 #1
0
 private void placementWalltoWall(GameObject otherObject, FollowMouse followScript, Collider otherCol)
 {
     if (this.transform.rotation == otherCol.transform.rotation)
     {
         if (!followScript.getRotate())
         {
             followScript.snap();
             otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent <BoxCollider>().bounds.size.x, 0, 0);
         }
         else if (followScript.getRotate())
         {
             followScript.snap();
             otherObject.transform.position = parentObject.transform.position - new Vector3(0, 0, parentObject.transform.GetComponent <BoxCollider>().bounds.size.z);
         }
     }
     else
     {
         followScript.enableSliding();
         if (!followScript.getRotate())
         {
             followScript.snap();
             otherObject.transform.position = parentObject.transform.position - new Vector3(-(otherCol.transform.GetComponent <BoxCollider>().bounds.extents.x - otherCol.transform.GetComponent <BoxCollider>().bounds.extents.z), 0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.z);
         }
         else if (followScript.getRotate())
         {
             followScript.snap();
             otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent <BoxCollider>().bounds.extents.x, 0, otherCol.transform.GetComponent <BoxCollider>().bounds.extents.z - otherCol.transform.GetComponent <BoxCollider>().bounds.extents.x);
         }
     }
 }
コード例 #2
0
ファイル: North.cs プロジェクト: Arnoba/ProceduralTerrain
 private void placementWallToWall(GameObject otherObject, FollowMouse followScript, Collider otherCol)
 {
     if (this.transform.rotation == otherCol.transform.rotation)
     {
         followScript.snap();
         otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.size.y, 0);
     }
 }
コード例 #3
0
ファイル: North.cs プロジェクト: Arnoba/ProceduralTerrain
    private void placementFloorToWall(GameObject otherObject, FollowMouse followScript, Collider otherCol)
    {
        followScript.snap();
        //otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent<BoxCollider>().bounds.extents.y, otherObject.transform.GetComponent<BoxCollider>().bounds.extents.z - parentObject.transform.GetComponent<BoxCollider>().bounds.extents.z);
        //Debug.Log(followScript.isPlaceable());

        float   xPos      = followScript.cursorPos.x;
        float   zPos      = followScript.cursorPos.z;
        Vector3 cursorPos = followScript.cursorPos;
        Vector3 temp      = this.transform.position - cursorPos;
        Vector3 temp2     = this.GetComponent <BoxCollider>().bounds.center;
        //Debug.Log("X: " + xPos);
        //Debug.Log("Z: " + zPos);
        //Debug.Log("X: " + Mathf.Abs(xPos));
        //Debug.Log(this.transform.rotation == new Quaternion(0.0f, 0.7f, 0.0f, 0.7f));
        float angle = Quaternion.Angle(this.transform.rotation, new Quaternion(0.0f, 0.7f, 0.0f, 0.7f));

        //Debug.Log(this.transform.rotation.Equals(new Quaternion(0.0f, 0.7f, 0.0f, 0.7f)) || this.transform.rotation == new Quaternion(0.0f, 0.7f, 0.0f, 0.7f));
        if (angle < 90f)
        {
            if (xPos > temp2.x + 0.5f)
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(otherObject.transform.GetComponent <BoxCollider>().bounds.extents.x - parentObject.transform.GetComponent <BoxCollider>().bounds.extents.x, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
            }
            else if (xPos < temp2.x - 0.5f)
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(-(otherObject.transform.GetComponent <BoxCollider>().bounds.extents.x - parentObject.transform.GetComponent <BoxCollider>().bounds.extents.x), parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
            }
            else
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
            }
        }
        else
        {
            if (zPos > temp2.z + 0.5f)
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, (otherObject.transform.GetComponent <BoxCollider>().bounds.extents.z - parentObject.transform.GetComponent <BoxCollider>().bounds.extents.z));
            }
            else if (zPos < temp2.z - 0.5f)
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, -(otherObject.transform.GetComponent <BoxCollider>().bounds.extents.z - parentObject.transform.GetComponent <BoxCollider>().bounds.extents.z));
            }
            else
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
            }
        }
    }
コード例 #4
0
 private void placementWallToFoundation(GameObject otherObject, FollowMouse followScript, Collider otherCol)
 {
     followScript.snap();
     otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent <BoxCollider>().bounds.extents.x - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.x, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y + otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
 }
コード例 #5
0
 private void placementFoundationToFoundation(GameObject otherObject, FollowMouse followScript)
 {
     followScript.snap();
     otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent <BoxCollider>().bounds.size.x, 0, 0);
 }
コード例 #6
0
ファイル: South.cs プロジェクト: Arnoba/ProceduralTerrain
 private void placementFloorToWall(GameObject otherObject, FollowMouse followScript, Collider otherCol)
 {
     followScript.snap();
     otherObject.transform.position = parentObject.transform.position - new Vector3(0, 0, parentObject.transform.GetComponent <BoxCollider>().bounds.size.z);
 }