Ejemplo n.º 1
0
        protected override void DoSetData(PointerData data)
        {
            _doorObjId = DoorCastData.EntityId(data.IdList);

            var doorObj = _triggerObjectManager.Get(ETriggerObjectType.Door, _doorObjId);

            if (doorObj == null)
            {
                return;
            }

            _enableAction = false;

            var player = _playerContext.flagSelfEntity;
            var go     = doorObj;

            if (IsUntouchableOffGround(player, data.Position, go))
            {
                return;
            }

            //make sure player-door have a correct relative position
            var direction = player.RootGo().transform.position - go.transform.position;

            direction.y = 0;
            var dot = Vector3.Dot(direction, go.transform.forward);

            if (!dot.Equals(0))
            {
                var mapObj = MapObjectUtility.GetMapObjByRawId(_doorObjId, (int)ETriggerObjectType.Door);
                if (mapObj == null)
                {
                    Tip           = ScriptLocalization.client_actiontip.opendoor;
                    _enableAction = true;
                }
                else
                {
                    var door = mapObj as MapObjectEntity;
                    if (door == null)
                    {
                        return;
                    }
                    var state = door.doorData.State;
                    if (state == (int)DoorState.Closed)
                    {
                        Tip           = ScriptLocalization.client_actiontip.opendoor;
                        _enableAction = true;
                    }
                    else if (state == (int)DoorState.OpenMax || state == (int)DoorState.OpenMin)
                    {
                        Tip           = ScriptLocalization.client_actiontip.closedoor;
                        _enableAction = true;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override void DoSetData(PointerData data)
        {
            _doorObjId = DoorCastData.EntityId(data.IdList);

            var doorObj = _triggerObjectManager.Get(ETriggerObjectType.Door, _doorObjId);

            if (doorObj == null)
            {
                Logger.Debug("Door trigger object is null.");
                return;
            }

            _enableAction = false;

            var player = _playerContext.flagSelfEntity;
            var go     = doorObj;

            if (IsUntouchableOffGround(player, data.Position, go))
            {
                Logger.Debug("Door is untouchable to player.");
                return;
            }

            //make sure player-door have a correct relative position
            var direction = player.RootGo().transform.position - go.transform.position;

            direction.y = 0;
            var dot = Vector3.Dot(direction, go.transform.forward);

            if (!dot.Equals(0))
            {
                var mapObj = _doorContext.GetEntityWithEntityKey(new EntityKey(_doorObjId, (int)EEntityType.MapObject));
                if (mapObj == null || !mapObj.hasDoorData)
                {
                    if (DetectObstacle(go, dot < 0))
                    {
                        SetObstacleTip();
                    }
                    else
                    {
                        Tip           = ScriptLocalization.client_actiontip.opendoor;
                        _enableAction = true;
                    }
                }
                else
                {
                    var state = mapObj.doorData.State;
                    if (state == (int)DoorState.Closed)
                    {
                        if (DetectObstacle(go, dot < 0))
                        {
                            SetObstacleTip();
                        }
                        else
                        {
                            Tip           = ScriptLocalization.client_actiontip.opendoor;
                            _enableAction = true;
                        }
                    }
                    else if (state == (int)DoorState.OpenMax || state == (int)DoorState.OpenMin)
                    {
                        if ((state == (int)DoorState.OpenMax && DetectObstacle(go, true)) ||
                            (state == (int)DoorState.OpenMin && DetectObstacle(go, false)))
                        {
                            SetObstacleTip();
                        }
                        else
                        {
                            Tip           = ScriptLocalization.client_actiontip.closedoor;
                            _enableAction = true;
                        }
                    }
                    else
                    {
                        Logger.Debug("Door state is wrong.");
                    }
                }
            }
            else
            {
                Logger.Debug("Door operation angle failed.");
            }
        }