Example #1
0
    public override void Initialize(int ownerUniqueID)
    {
        this.ownerUniqueID = ownerUniqueID;
        identifier         = PStrings.door;

        animation    = DoorMode.Null;
        modelA       = null;
        localOpenedA = Vector3.zero;
        modelB       = null;
        localOpenedB = Vector3.zero;

        ObstacleData obstacleData = (ObstacleData)GridData.GetExtensible(ownerUniqueID);

        if (obstacleData.instructionSetID == PStrings.doorSingleSmall || obstacleData.instructionSetID == PStrings.doorSingleLarge)
        {
            animation = DoorMode.Single;

            modelA       = obstacleData.gameObject.transform.GetChild(0).GetChild(1);
            localOpenedA = obstacleData.gameObject.transform.GetChild(0).GetChild(0).localPosition;
        }
        else if (obstacleData.instructionSetID == PStrings.doorDoubleSmall || obstacleData.instructionSetID == PStrings.doorDoubleLarge)
        {
            animation = DoorMode.Double;

            modelA       = obstacleData.gameObject.transform.GetChild(0).GetChild(1);
            localOpenedA = obstacleData.gameObject.transform.GetChild(0).GetChild(0).localPosition;

            modelB       = obstacleData.gameObject.transform.GetChild(1).GetChild(1);
            localOpenedB = obstacleData.gameObject.transform.GetChild(1).GetChild(0).localPosition;
        }

        halfExtents = new Vector3(obstacleData.orientedWidth, Metrics.wallHeight - Metrics.trimHeight, obstacleData.orientedLength) * 0.5f;
        center      = obstacleData.gameObject.transform.position - (Vector3.right * 0.5f) - (Vector3.forward * 0.5f);
        if (obstacleData.orientation == Direction.S || obstacleData.orientation == Direction.E)
        {
            center = new Vector3(center.x + halfExtents.x, center.y + halfExtents.y, center.z + halfExtents.z);
        }
        else
        {
            center = new Vector3((center.x - halfExtents.x) + 1, center.y + halfExtents.y, (center.z - halfExtents.z) + 1);
        }

        halfExtents.x = (obstacleData.orientation == Direction.N || obstacleData.orientation == Direction.S) ? halfExtents.x + (trgDstThreshold * 0.5f) : halfExtents.x + trgDstThreshold;
        halfExtents.z = (obstacleData.orientation == Direction.N || obstacleData.orientation == Direction.S) ? halfExtents.z + trgDstThreshold : halfExtents.z + (trgDstThreshold * 0.5f);

        collisions = null;

        sqrDstA       = 0;
        sqrDstB       = 0;
        timeTriggered = 0;
        nextCycleTime = -1;

        state = DoorState.Closed;

        Activation = DoorActivation.Null;
        key        = DoorKey.Null;
        closeSpeed = 10f;
        openSpeed  = 10f;
        openTime   = -1f;
    }
Example #2
0
    public override void ReadXml(XmlReader reader)
    {
        activation = (DoorActivation)int.Parse(reader.GetAttribute("Activation"));
        key        = (DoorKey)int.Parse(reader.GetAttribute("Key"));

        closeSpeed = float.Parse(reader.GetAttribute("CloseSpeed"));
        openSpeed  = float.Parse(reader.GetAttribute("OpenSpeed"));
        openTime   = float.Parse(reader.GetAttribute("OpenTime"));
    }