示例#1
0
    public MsbRegionBase Serialize(MsbRegionBase region, GameObject parent)
    {
        region.Name  = parent.name;
        region.Index = ID;

        region.PosX = parent.transform.position.x;
        region.PosY = parent.transform.position.y;
        region.PosZ = parent.transform.position.z;
        var rot = ConvertEuler(parent.transform.rotation.eulerAngles);

        //region.RotX = rot.X;
        //region.RotY = rot.Y;
        //region.RotZ = rot.Z;
        region.RotX = Rotation.x;
        region.RotY = Rotation.y;
        region.RotZ = Rotation.z;

        if (region is MsbRegionBox)
        {
            var shape = (MsbRegionBox)region;
            var col   = parent.GetComponent <BoxCollider>();
            shape.WidthX   = col.size.x;
            shape.HeightY  = col.size.y;
            shape.DepthZ   = col.size.z;
            shape.EntityID = EventEntityID;
        }
        else if (region is MsbRegionCylinder)
        {
            var shape = (MsbRegionCylinder)region;
            var col   = parent.GetComponent <CapsuleCollider>();
            shape.Radius   = col.radius;
            shape.Height   = col.height;
            shape.EntityID = EventEntityID;
        }
        else if (region is MsbRegionSphere)
        {
            var shape = (MsbRegionSphere)region;
            var col   = parent.GetComponent <SphereCollider>();
            shape.Radius   = col.radius;
            shape.EntityID = EventEntityID;
        }
        else if (region is MsbRegionPoint)
        {
            var shape = (MsbRegionPoint)region;
            shape.EntityID = EventEntityID;
        }
        return(region);
    }
示例#2
0
 public void setBaseRegion(MsbRegionBase region)
 {
     ID = region.Index;
     if (region is MsbRegionBox)
     {
         EventEntityID = ((MsbRegionBox)region).EntityID;
     }
     if (region is MsbRegionCylinder)
     {
         EventEntityID = ((MsbRegionCylinder)region).EntityID;
     }
     if (region is MsbRegionPoint)
     {
         EventEntityID = ((MsbRegionPoint)region).EntityID;
         IsPoint       = true;
     }
     if (region is MsbRegionSphere)
     {
         EventEntityID = ((MsbRegionSphere)region).EntityID;
     }
     Rotation = new UnityEngine.Vector3(region.RotX, region.RotY, region.RotZ);
 }