コード例 #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
    void OnTriggerEnter(Collider other)
    {
        /* if (other.tag.Equals("Tile"))
         * {
         *   if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION))
         *       Destroy(this.gameObject);
         * }*/

        if (other.tag.Equals("Blueprint"))
        {
            otherObject  = other.gameObject;
            followScript = otherObject.GetComponent <FollowMouse>();
            if (!followScript.snapped)
            {
                if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION))
                {
                    if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                    {
                        placementFoundationToFoundation(otherObject, followScript);
                    }
                    else if (followScript.tileType.Equals(Tile.TileType.WALL) && !followScript.getRotate())
                    {
                        Debug.Log("Wall on foundation");
                        placementWallToFoundation(otherObject, followScript, other);
                    }
                }
                else if (tileScript.tileType.Equals(Tile.TileType.WALL))
                {
                    if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                    {
                        return;
                    }
                    else if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                    {
                        placementFloorToWall(otherObject, followScript, other);
                    }
                    else if (followScript.tileType.Equals(Tile.TileType.WALL))
                    {
                        placementWallToWall(otherObject, followScript, other);
                    }
                }
                else if (tileScript.tileType.Equals(Tile.TileType.FLOOR))
                {
                    if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                    {
                        //otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent<BoxCollider>().bounds.size.x, 0, 0);
                        placementFoundationToFoundation(otherObject, followScript);
                    }
                }
            }
        }
    }
コード例 #3
0
ファイル: South.cs プロジェクト: Arnoba/ProceduralTerrain
    void OnTriggerEnter(Collider other)
    {
        /*if (other.tag.Equals("Tile"))
         * {
         *  if (tileScript.tileType.Equals(Tile.TileType.WALL) && other.GetComponent<Tile>().tileType.Equals(Tile.TileType.FOUNDATION))
         *      Destroy(this.gameObject);
         *  if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION) || tileScript.tileType.Equals(Tile.TileType.FLOOR))
         *      Destroy(this.gameObject);
         * }*/

        if (other.tag.Equals("Blueprint") && this.transform.rotation == other.transform.rotation)
        {
            otherObject  = other.gameObject;
            followScript = otherObject.GetComponent <FollowMouse>();

            if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION))
            {
                if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                {
                    placementFoundationToFoundation(otherObject, followScript);
                }
                else if (followScript.tileType.Equals(Tile.TileType.WALL) && !followScript.getRotate())
                {
                    placementWallToFoundation(otherObject, followScript, other);
                }
            }
            else if (tileScript.tileType.Equals(Tile.TileType.WALL))
            {
                if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                {
                    return;
                }
                else if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                {
                    placementFloorToWall(otherObject, followScript, other);
                }
                else if (followScript.tileType.Equals(Tile.TileType.WALL))
                {
                    placementWallToWall(otherObject, followScript, other);
                }
            }
            else if (tileScript.tileType.Equals(Tile.TileType.FLOOR))
            {
                if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                {
                    placementFoundationToFoundation(otherObject, followScript);
                }
            }
        }
    }
コード例 #4
0
    void OnTriggerEnter(Collider other)
    {
        /*Debug.Log("coliding with:" + other.gameObject.tag);
         * Debug.Log("bounds: " + other.bounds);
         * Debug.Log("Extends: " + other.bounds.extents);
         * Debug.Log("Max: " + other.bounds.max);
         * Debug.Log("Min: " + other.bounds.min);*/
        //Vector3 temp = other.transform.position;

        if (other.tag.Equals("Blueprint"))
        {
            otherObject  = other.gameObject;
            followScript = otherObject.GetComponent <FollowMouse>();
            if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION))
            {
                if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                {
                    placementFoundationToFoundation(otherObject, followScript);
                }
                else if (followScript.tileType.Equals(Tile.TileType.WALL) && followScript.getRotate())
                {
                    placementWallToFoundation(otherObject, followScript, other);
                }
            }
            else if (tileScript.tileType.Equals(Tile.TileType.WALL))
            {
                if (followScript.tileType.Equals(Tile.TileType.WALL))
                {
                    placementWalltoWall(otherObject, followScript, other);
                }
            }
            else if (tileScript.tileType.Equals(Tile.TileType.FLOOR))
            {
                Debug.Log("Floor to floor");
                if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                {
                    //otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent<BoxCollider>().bounds.size.x, 0, 0);
                    placementFoundationToFoundation(otherObject, followScript);
                }
            }
        }
    }