Example #1
0
 public void SetState(eDoorState state)
 {
     CurrentState = state;
     tiledata.Map.SetTileData(tiledata.Position, TileId[(int)state].bodyTile);
     tiledata.Map.SetTileData(tiledata.Position + Vector2.up, TileId[(int)state].headTile);
     tiledata.Map.UpdateMesh();
 }
 private void setDoorClosed()
 {
     doorA.transform.position = doorAClosedPosition;
     doorB.transform.position = doorBClosedPosition;
     currentDoorState         = eDoorState.CLOSED;
     walkBlocker.GetComponent <BoxCollider>().enabled = true;
 }
Example #3
0
        public virtual void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component)
        {
            m_templateID = pos.TemplateID;
            m_component  = component;

            PositionMgr.LoadKeepItemPosition(pos, this);
            component.AbstractKeep.Doors[m_templateID] = this;

            m_oldMaxHealth     = MaxHealth;
            m_health           = MaxHealth;
            m_name             = "Keep Door";
            m_oldHealthPercent = HealthPercent;
            m_doorID           = GenerateDoorID();
            m_model            = 0xFFFF;
            m_state            = eDoorState.Closed;

            if (AddToWorld())
            {
                StartHealthRegeneration();
                DoorMgr.RegisterDoor(this);
            }
            else
            {
                log.Error("Failed to load keep door from position! DoorID=" + m_doorID + ". Component SkinID=" + component.Skin + ". KeepID=" + component.AbstractKeep.KeepID);
            }
        }
Example #4
0
        /// <summary>
        /// load the keep door object from DB object
        /// </summary>
        /// <param name="obj"></param>
        public override void LoadFromDatabase(DataObject obj)
        {
            DBDoor door = obj as DBDoor;

            if (door == null)
            {
                return;
            }
            base.LoadFromDatabase(obj);

            Zone curZone = WorldMgr.GetZone((ushort)(door.InternalID / 1000000));

            if (curZone == null)
            {
                return;
            }
            this.CurrentRegion = curZone.ZoneRegion;
            m_name             = door.Name;
            m_Heading          = (ushort)door.Heading;
            Position           = new Vector3(door.X, door.Y, door.Z);
            m_level            = 0;
            m_model            = 0xFFFF;
            m_doorID           = door.InternalID;
            m_state            = eDoorState.Closed;
            this.AddToWorld();

            m_health = MaxHealth;
            StartHealthRegeneration();
        }
Example #5
0
 // Use this for initialization
 protected override void Start()
 {
     base.Start();
     tiledata = GetComponent <TileData>();
     Assert.IsNotNull(tiledata, "A Door require a TileData component!");
     CurrentState = (eDoorState)tiledata.Tile.paramContainer.GetIntParam("state");
 }
 private void setDoorOpen()
 {
     doorA.transform.position = doorAOpenPosition;
     doorB.transform.position = doorBOpenPosition;
     currentDoorState         = eDoorState.OPEN;
     doorAutoCloseCountdown   = doorAutoCloseTime;
     walkBlocker.GetComponent <BoxCollider>().enabled = false;
 }
Example #7
0
    private void OnMoving()
    {
        DoorPivot.transform.rotation = Quaternion.Slerp(DoorPivot.transform.rotation, m_targetRotation, Time.deltaTime * Speed);

        if (DoorPivot.transform.rotation == m_targetRotation)
        {
            m_eCurrentState = m_eTargetState;
        }
    }
Example #8
0
        private void setDoorClosed()
        {
            slidingPart.transform.position = closedPosition;
            currentDoorState = eDoorState.CLOSED;

            if (playerInteractionBlocker)
            {
                playerInteractionBlocker.SetActive(false);
            }
        }
Example #9
0
        /// <summary>
        /// This function is called when door "die" to open door
        /// </summary>
        public override void Die(GameObject killer)
        {
            base.Die(killer);

            foreach (GamePlayer player in GetPlayersInRadius(WorldMgr.INFO_DISTANCE))
            {
                player.Out.SendMessage("The Keep Gate is broken!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }

            m_state = eDoorState.Open;
            BroadcastDoorStatus();
        }
Example #10
0
        private void closeTheDoor()
        {
            currentDoorState = eDoorState.CLOSING;
            playerBlocker.SetActive(true);

            if (playerInteractionBlocker)
            {
                playerInteractionBlocker.SetActive(true);
            }

            myAudio.PlayOneShot(doorClose);
            myDoorHandle.setInteractionString(openText);
        }
Example #11
0
        private void openTheDoor()
        {
            currentDoorState = eDoorState.OPENING;
            playerBlocker.SetActive(false);

            if (playerInteractionBlocker)
            {
                playerInteractionBlocker.SetActive(true);
            }

            myAudio.PlayOneShot(doorOpen);
            myDoorHandle.setInteractionString(closeText);
        }
Example #12
0
        /// <summary>
        /// load the keep door object from DB object
        /// </summary>
        /// <param name="obj"></param>
        public override void LoadFromDatabase(DataObject obj)
        {
            DBDoor door = obj as DBDoor;

            if (door == null)
            {
                return;
            }

            base.LoadFromDatabase(obj);

            Zone curZone = WorldMgr.GetZone((ushort)(door.InternalID / 1000000));

            if (curZone == null)
            {
                return;
            }

            CurrentRegion = curZone.ZoneRegion;
            m_name        = door.Name;
            m_Heading     = (ushort)door.Heading;
            X             = door.X;
            Y             = door.Y;
            Z             = door.Z;
            m_level       = 0;
            m_model       = 0xFFFF;
            m_doorID      = door.InternalID;
            m_state       = eDoorState.Closed;
            AddToWorld();

            foreach (AbstractArea area in CurrentAreas)
            {
                if (area is KeepArea)
                {
                    AbstractGameKeep keep = (area as KeepArea).Keep;
                    if (!keep.Doors.Contains(door.InternalID))
                    {
                        Component = new GameKeepComponent();
                        Component.AbstractKeep = keep;
                        keep.Doors.Add(door.InternalID, this);
                    }

                    break;
                }
            }

            m_health = MaxHealth;
            StartHealthRegeneration();
            DoorMgr.RegisterDoor(this);
        }
Example #13
0
    // Use this for initialization
    void Start()
    {
        m_eCurrentState = InitialState;

        m_cmpTimer = Opener.GetComponent <TimeBar>();

        if (TextDoor != null)
        {
            TextDoor.SetActive(false);
        }

        if (m_eCurrentState == eDoorState.eOpened)
        {
            DoorPivot.transform.Rotate(DoorPivot.transform.up, OpenningAngle);
        }
    }
Example #14
0
        /// <summary>
        /// load the keep door object from DB object
        /// </summary>
        /// <param name="obj"></param>
        public override void LoadFromDatabase(DataObject obj)
        {
            DBDoor door = obj as DBDoor;

            if (door == null)
            {
                return;
            }
            base.LoadFromDatabase(obj);

            Zone curZone = WorldMgr.GetZone((ushort)(door.InternalID / 1000000));

            if (curZone == null)
            {
                return;
            }
            this.CurrentRegion = curZone.ZoneRegion;
            m_name             = door.Name;
            m_Heading          = (ushort)door.Heading;
            Position           = new Vector3(door.X, door.Y, door.Z);
            m_level            = 0;
            m_model            = 0xFFFF;
            m_doorID           = door.InternalID;
            m_state            = eDoorState.Closed;
            this.AddToWorld();

            foreach (AbstractArea area in this.CurrentAreas)
            {
                if (area is KeepArea keepArea)
                {
                    string sKey = door.InternalID.ToString();
                    if (!keepArea.Keep.Doors.ContainsKey(sKey))
                    {
                        Component      = new GameKeepComponent();
                        Component.Keep = keepArea.Keep;
                        keepArea.Keep.Doors.Add(sKey, this);
                    }
                    break;
                }
            }

            m_health = MaxHealth;
            StartHealthRegeneration();
            DoorMgr.RegisterDoor(this);
        }
Example #15
0
        /// <summary>
        /// Call this function to open the door
        /// </summary>
        public virtual void Open(GameLiving opener = null)
        {
            if (Locked == 0)
            {
                this.State = eDoorState.Open;
            }

            if (HealthPercent > 40 || !m_openDead)
            {
                lock (m_LockObject)
                {
                    if (m_closeDoorAction == null)
                    {
                        m_closeDoorAction = new CloseDoorAction(this);
                    }
                    m_closeDoorAction.Start(CLOSE_DOOR_TIME);
                }
            }
        }
Example #16
0
    public void ToogleState()
    {
        switch (m_eCurrentState)
        {
        case eDoorState.eClosed:
            m_targetRotation = DoorPivot.transform.rotation * Quaternion.AngleAxis(OpenningAngle, Vector3.up);
            m_eTargetState   = eDoorState.eOpened;
            GlobalData.GameEventsCall.TriggerEvent(InteractuableEvents.OpenDoor);
            break;

        case eDoorState.eOpened:
            m_targetRotation = DoorPivot.transform.rotation * Quaternion.AngleAxis(-OpenningAngle, Vector3.up);
            m_eTargetState   = eDoorState.eClosed;
            GlobalData.GameEventsCall.TriggerEvent(InteractuableEvents.CloseDoor);
            break;
        }

        m_eCurrentState = eDoorState.eMoving;
    }
    // Here, we implemented the required interface function for loading a generic object. There is some custom logic to properly restore the door's locked state, animation state, timing, etc.
    public override void restoreSaveGameData(FPEGenericObjectSaveData data)
    {
        currentDoorState = (eDoorState)data.SavedInt;

        switch (currentDoorState)
        {
        case eDoorState.OPEN:
        case eDoorState.OPENING:
            setDoorOpen();
            break;

        case eDoorState.CLOSED:
        case eDoorState.CLOSING:
            setDoorClosed();
            break;
        }

        doorAutoCloseCountdown = data.SavedFloat;
        doorLocked             = data.SavedBool;
        myCardScanner.setLockLightColor(doorLocked);
    }
Example #18
0
        public void restoreSaveGameData(FPEDoorSaveData data)
        {
            currentDoorState = data.DoorState;
            myDoorHandle.setInteractionString(data.DoorHandleString);

            switch (currentDoorState)
            {
            case eDoorState.CLOSING:
            case eDoorState.CLOSED:
                setDoorClosed();
                break;

            case eDoorState.OPENING:
            case eDoorState.OPEN:
                setDoorOpen();
                break;

            default:
                Debug.LogError("FPESimpleDoor.restoreSaveGameData():: Given bad door state '" + currentDoorState + "'");
                break;
            }
        }
Example #19
0
 // Assign to Activation Failure event in the inspector
 public void doorOpenFailure()
 {
     currentDoorState = eDoorState.CLOSED;
     myAudio.PlayOneShot(doorLocked);
     myDoorHandle.setInteractionString(lockedText);
 }
Example #20
0
        /// <summary>
        /// This function is called when door "die" to open door
        /// </summary>
        public override void Die(GameObject killer)
        {
            base.Die(killer);

            foreach (GamePlayer player in this.GetPlayersInRadius(WorldMgr.INFO_DISTANCE))
                player.Out.SendMessage("The Keep Gate is broken!", eChatType.CT_System, eChatLoc.CL_SystemWindow);

            m_state = eDoorState.Open;
            BroadcastDoorStatus();
        }
Example #21
0
        public virtual void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component)
        {
            m_templateID = pos.TemplateID;
            m_component = component;

            PositionMgr.LoadKeepItemPosition(pos, this);
            component.Keep.Doors[m_templateID] = this;

            m_oldMaxHealth = MaxHealth;
            m_health = MaxHealth;
            m_name = "Keep Door";
            m_oldHealthPercent = HealthPercent;
            m_doorID = GenerateDoorID();
            this.m_model = 0xFFFF;
            m_state = eDoorState.Closed;
            this.AddToWorld();
            StartHealthRegeneration();
            DoorMgr.RegisterDoor(this);
        }
Example #22
0
        /// <summary>
        /// load the keep door object from DB object
        /// </summary>
        /// <param name="obj"></param>
        public override void LoadFromDatabase(DataObject obj)
        {
            DBDoor door = obj as DBDoor;
            if (door == null)
                return;
            base.LoadFromDatabase(obj);

            Zone curZone = WorldMgr.GetZone((ushort)(door.InternalID / 1000000));
            if (curZone == null) return;
            this.CurrentRegion = curZone.ZoneRegion;
            m_name = door.Name;
            m_Heading = (ushort)door.Heading;
            m_x = door.X;
            m_y = door.Y;
            m_z = door.Z;
            m_level = 0;
            m_model = 0xFFFF;
            m_doorID = door.InternalID;
            m_state = eDoorState.Closed;
            this.AddToWorld();

            foreach (AbstractArea area in this.CurrentAreas)
            {
                if (area is KeepArea)
                {
                    AbstractGameKeep keep = (area as KeepArea).Keep;
                    if (!keep.Doors.Contains(door.InternalID))
                    {
                        Component = new GameKeepComponent();
                        Component.Keep = keep;
                        keep.Doors.Add(door.InternalID, this);
                    }
                    break;
                }
            }

            m_health = MaxHealth;
            StartHealthRegeneration();
            DoorMgr.RegisterDoor(this);
        }
Example #23
0
		public virtual void OpenDoor()
		{
			m_state = eDoorState.Open;
			BroadcastDoorStatus();
		}
Example #24
0
        /// <summary>
        /// This method is called when door is repair or keep is reset
        /// </summary>
        public virtual void CloseDoor()
        {
            m_state = eDoorState.Closed;

            BroadcastDoorStatus();
        }
Example #25
0
 /// <summary>
 /// Make the pillar start moving down.
 /// </summary>
 public void Open(GameLiving opener = null)
 {
     State = eDoorState.Open;
 }
Example #26
0
 /// <summary>
 /// Reset pillar.
 /// </summary>
 public void Close(GameLiving closer = null)
 {
     State = eDoorState.Closed;
 }
Example #27
0
		public virtual void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component)
		{
			m_templateID = pos.TemplateID;
			m_component = component;

			PositionMgr.LoadKeepItemPosition(pos, this);
			component.AbstractKeep.Doors[m_templateID] = this;

			m_oldMaxHealth = MaxHealth;
			m_health = MaxHealth;
			m_name = "Keep Door";
			m_oldHealthPercent = HealthPercent;
			m_doorID = GenerateDoorID();
			this.m_model = 0xFFFF;
			m_state = eDoorState.Closed;

			if (AddToWorld())
			{
				StartHealthRegeneration();
				DoorMgr.RegisterDoor(this);
			}
			else
			{
				log.Error("Failed to load keep door from position! DoorID=" + m_doorID + ". Component SkinID=" + component.Skin + ". KeepID=" + component.AbstractKeep.KeepID);
			}

		}
Example #28
0
		/// <summary>
		/// Make the pillar start moving down.
		/// </summary>
		public void Open()
		{
			State = eDoorState.Open;
		}
Example #29
0
		/// <summary>
		/// Reset pillar.
		/// </summary>
		public void Close()
		{
			State = eDoorState.Closed;
		}
Example #30
0
 /// <summary>
 /// Reset pillar.
 /// </summary>
 public void Close(GameLiving closer = null)
 {
     State = eDoorState.Closed;
 }
Example #31
0
        /// <summary>
        /// Call this function to open the door
        /// </summary>
        public virtual void Open(GameLiving opener = null)
        {
            if (Locked == 0)
                this.State = eDoorState.Open;

            if (HealthPercent > 40 || !m_openDead)
            {
                lock (m_LockObject)
                {
                    if (m_closeDoorAction == null)
                    {
                        m_closeDoorAction = new CloseDoorAction(this);
                    }
                    m_closeDoorAction.Start(CLOSE_DOOR_TIME);
                }
            }
        }
Example #32
0
 /// <summary>
 /// Make the pillar start moving down.
 /// </summary>
 public void Open(GameLiving opener = null)
 {
     State = eDoorState.Open;
 }
Example #33
0
 private void setDoorOpen()
 {
     slidingPart.transform.position = openedPosition;
     currentDoorState = eDoorState.OPEN;
     playerBlocker.SetActive(false);
 }
Example #34
0
		/// <summary>
		/// load the keep door object from DB object
		/// </summary>
		/// <param name="obj"></param>
		public override void LoadFromDatabase(DataObject obj)
		{
			DBDoor door = obj as DBDoor;
			if (door == null)
				return;
			base.LoadFromDatabase(obj);

			Zone curZone = WorldMgr.GetZone((ushort)(door.InternalID / 1000000));
			if (curZone == null) return;
			this.CurrentRegion = curZone.ZoneRegion;
			m_name = door.Name;
			m_Heading = (ushort)door.Heading;
			m_x = door.X;
			m_y = door.Y;
			m_z = door.Z;
			m_level = 0;
			m_model = 0xFFFF;
			m_doorID = door.InternalID;
			m_state = eDoorState.Closed;
			this.AddToWorld();

			m_health = MaxHealth;
			StartHealthRegeneration();
		}
Example #35
0
 public virtual void OpenDoor()
 {
     m_state = eDoorState.Open;
     BroadcastDoorStatus();
 }
Example #36
0
		/// <summary>
		/// This method is called when door is repair or keep is reset
		/// </summary>
		public virtual void CloseDoor()
		{
			m_state = eDoorState.Closed;
			BroadcastDoorStatus();
		}
    void Update()
    {
        // If the player is within the automated movement zone, always move to OPENING state
        if (Vector3.Distance(transform.position, thePlayer.transform.position) < doorAutoCloseZoneRadius)
        {
            doAutoOpenClose = false;

            if (currentDoorState == eDoorState.CLOSED || currentDoorState == eDoorState.CLOSING)
            {
                if (!doorLocked)
                {
                    gameObject.GetComponent <AudioSource>().Play();
                    currentDoorState = eDoorState.OPENING;
                }
            }
        }
        else
        {
            doAutoOpenClose = true;
        }

        // State Management //
        if (currentDoorState == eDoorState.OPENING)
        {
            doorA.transform.position = Vector3.Lerp(doorA.transform.position, doorAOpenPosition, doorMovementSpeed * Time.deltaTime);
            doorB.transform.position = Vector3.Lerp(doorB.transform.position, doorBOpenPosition, doorMovementSpeed * Time.deltaTime);

            if (Vector3.Distance(doorA.transform.position, doorAOpenPosition) < 0.65f)
            {
                // we want to disable collider sooner than doors being all the way open
                walkBlocker.GetComponent <BoxCollider>().enabled = false;
            }

            if (Vector3.Distance(doorA.transform.position, doorAOpenPosition) < 0.2f)
            {
                setDoorOpen();
            }
        }
        else if (currentDoorState == eDoorState.OPEN)
        {
            // Only auto-close if it is safe to do so
            if (doAutoOpenClose)
            {
                doorAutoCloseCountdown -= Time.deltaTime;

                if (doorAutoCloseCountdown <= 0.0f)
                {
                    currentDoorState = eDoorState.CLOSING;
                    walkBlocker.GetComponent <BoxCollider>().enabled = true;
                    gameObject.GetComponent <AudioSource>().Play();
                }
            }
        }
        else if (currentDoorState == eDoorState.CLOSING)
        {
            doorA.transform.position = Vector3.Lerp(doorA.transform.position, doorAClosedPosition, doorMovementSpeed * Time.deltaTime);
            doorB.transform.position = Vector3.Lerp(doorB.transform.position, doorBClosedPosition, doorMovementSpeed * Time.deltaTime);

            if (Vector3.Distance(doorA.transform.position, doorAClosedPosition) < 0.2f)
            {
                setDoorClosed();
            }
        }
    }