Пример #1
0
    void CmdInteractionItem()
    {
        if (itemHolder.childCount > 0)
        {
            RpcThrowItem();
            return;
        }

        RaycastHit hit;

        if (Physics.Raycast(fpsCamera.transform.position,
                            fpsCamera.transform.forward,
                            out hit,
                            4f,
                            1 << LayerMask.NameToLayer("Floor")))
        {
            print(hit.transform.name);
            DoorButton door = hit.transform.gameObject.GetComponent <DoorButton>();
            if (door != null)
            {
                door.ToggleDoor();
            }
            Item item = hit.transform.gameObject.GetComponent <Item>();
            if (item != null)
            {
                RpcPickup(hit.transform.GetComponentInParent <NetworkIdentity>().netId);
            }
        }
    }
Пример #2
0
    public void InteractableInitialize()
    {
        //In case I forget...
        gameObject.layer = LayerMask.NameToLayer("Interactable");

        if (GetComponent <PowerCube>() != null)
        {
            pc = GetComponent <PowerCube>();
            it = InteractableType.PowerCube;
        }
        else if (GetComponent <PowerStation>() != null)
        {
            ps = GetComponent <PowerStation>();
            it = InteractableType.PowerStation;
        }
        else if (GetComponent <DoorButton>() != null)
        {
            db = GetComponent <DoorButton>();
            it = InteractableType.DoorButton;
        }
        else if (GetComponent <TimedDoorButton>() != null)
        {
            timd = GetComponent <TimedDoorButton>();
            it   = InteractableType.TimedDoorButton;
        }
        else
        {
            it = InteractableType.None;
        }

        //If universal functionality is needed, that will go here
    }
Пример #3
0
    public override void Exit()
    {
        base.Exit();
        if (_coroutine != null)
        {
            _controller.StopCoroutine(_coroutine);
        }

        _doorButton = null;
        _time       = Time.time;
    }
Пример #4
0
    public override void Enter()
    {
        _controller.navMeshAgent.velocity  = Vector3.zero;
        _controller.navMeshAgent.isStopped = true;
        _doorButton = GetDoorButton();

        if (_doorButton)
        {
            _basicAudio = _doorButton.GetBasicAudio();
            _coroutine  = _controller.StartCoroutine(PoundOnDoor());
        }
    }
Пример #5
0
    public override void OnTriggered()
    {
        switch (currEvent)
        {
        case CONSOLE_EVENT.DOOR_REQUEST:
            if (savedObject != null)
            {
                if (hasConsoleTextChanged == 0)     // if all the text has displayed, then allow touch to open door
                {
                    // Open the door, then
                    DoorButton buttonScript = GetScript <DoorButton>(savedObject);
                    if (buttonScript != null)
                    {
                        buttonScript.AllowUnlockDoor();
                    }

                    EndOfDoorButtonEvent();
                }
                else     // If still typing out, first click immediately shows all the text
                {
                    UpdateAllTextImmediately();
                }
            }
            break;

        case CONSOLE_EVENT.DOOR_MINIGAME_TURN:
            if (savedObject != null)
            {
                // Open the door, then
                DoorUnlockSequence doorUnlockSeq = GetScript <DoorUnlockSequence>(savedObject);
                if (doorUnlockSeq != null)
                {
                    doorUnlockSeq.CenterPull(0);
                }
            }
            break;

        case CONSOLE_EVENT.MINIGAME_FOUR_PLAYERS:
            if (savedObject != null && eventState != -1 && eventState2 != -1)     // If one of the buttons is active
            {
                MiniGameFourPlayersButtonController minigameScript = GetScript <MiniGameFourPlayersButtonController>(savedObject);
                if (minigameScript != null)
                {
                    minigameScript.TriggeredButton(eventState, false);     // Click on screen to perform action on game
                }
            }
            break;
        }
    }
Пример #6
0
    private DoorButton GetDoorButton()
    {
        DoorButton doorButton = null;

        Collider[] colls = Physics.OverlapBox(_transform.position, new Vector3(5f, 5f, 5f), _transform.rotation, _interactableLayer);
        foreach (Collider coll in colls)
        {
            doorButton = coll.GetComponent <DoorButton>();
            if (doorButton)
            {
                break;
            }
        }

        if (!doorButton)
        {
            TransitionToPrevious();
            return(null);
        }

        return(doorButton.GetMaster());
    }
Пример #7
0
    public void PoweredInteractableInitialize()
    {
        if (GetComponent <DoorButton>() != null)
        {
            pdb = GetComponent <DoorButton>();
            pt  = PoweredType.DoorButton;
        }
        else if (GetComponent <TimedDoorButton>() != null)
        {
            tim = GetComponent <TimedDoorButton>();
            pt  = PoweredType.TimedDoorButton;
        }
        else if (GetComponent <HeavyDoor>() != null)
        {
            hd = GetComponent <HeavyDoor>();
            pt = PoweredType.HeavyDoor;
        }
        else if (GetComponent <PoweredLight>() != null)
        {
            pl = GetComponent <PoweredLight>();
            pt = PoweredType.PoweredLight;
        }
        else if (GetComponent <PoweredDialogueActivator>() != null)
        {
            pda = GetComponent <PoweredDialogueActivator>();
            pt  = PoweredType.PoweredDialogueActivator;
        }
        else
        {
            pt = PoweredType.None;
        }

        //Start() will only run on the "lowest-level" class
        //If Class A that derives from Class B does not implement Start(),
        //Class B Start() will be used.
        //If Class A & Class B both have Start(), Start() will be called on Class A because it is "lower"
        InteractableInitialize();
    }
Пример #8
0
 void Awake()
 {
     button = GameObject.FindGameObjectWithTag (Tags.button).GetComponent<DoorButton>();
     door = GameObject.FindGameObjectWithTag (Tags.door).GetComponent<ExitDoor>();
 }
Пример #9
0
    // Use this for initialization
    void Start()
    {
        alert = GameObject.Find("Alert System").GetComponent<AlertManager>();

        roomX = 0;
        roomZ = 0;

        dButton = GameObject.Find("Door Button").GetComponent<DoorButton>();

        playerObject = GameObject.FindGameObjectWithTag("Player");
        level = GameObject.Find("Level").GetComponent<Level>();

        nextRoomInformation = GameObject.Find("NextRoomInfo").GetComponent<NextRoomInfo>();

        currentRoom = transform.parent.parent.parent.GetComponent<Room>();
        if(currentRoom){
            roomX = currentRoom.xIndex;
            roomZ = currentRoom.zIndex;
        }

        leftDoor 	= transform.Find("LeftDoor");
        rightDoor 	= transform.Find("RightDoor");

        closedScale = leftDoor.localScale;
        openScale = new Vector3(leftDoor.localScale.x * 0.1f, leftDoor.localScale.y, leftDoor.localScale.z);;
        targetScale = closedScale;

        leftDoorClosedPosition 	= leftDoor.transform.position;
        leftDoorOpenPosition 	= leftDoor.transform.position + (-transform.right * 0.3f);
        targetLeftDoorPosition 	= leftDoorClosedPosition;

        rightDoorClosedPosition 	= rightDoor.transform.position;
        rightDoorOpenPosition 		= rightDoor.transform.position + (transform.right * 0.3f);
        targetRightDoorPosition		= rightDoorClosedPosition;

        canvasObject = GameObject.Find("Canvas");
        sFade = GameObject.Find("Screen Fade").GetComponent<ScreenFade>();
    }
Пример #10
0
        public bool MakeCorridor(int x, int y, int length, Direction direction)
        {
            // define the dimensions of the corridor (er.. only the width and height..)
            int        len   = Helper.GetRandom() % 5 + 2;
            const Tile Floor = Tile.Corridor;

            int xtemp;
            int ytemp = 0;

            DoorButton Button;
            DoorButton Button2;
            Door       Door;

            switch (direction)
            {
            case Direction.North:
                // north
                // check if there's enough space for the corridor
                // start with checking it's not out of the boundaries
                if (x < 0 || x > this._xsize)
                {
                    return(false);
                }
                xtemp = x;

                // same thing here, to make sure it's not out of the boundaries
                for (ytemp = y; ytemp > (y - len); ytemp--)
                {
                    if (ytemp < 0 || ytemp > this._ysize)
                    {
                        return(false);                                     // oh boho, it was!
                    }
                    if (GetCellType(xtemp, ytemp) != Tile.Unused)
                    {
                        return(false);
                    }
                }

                // if we're still here, let's start building
                Corridors++;
                for (ytemp = y; ytemp > (y - len); ytemp--)
                {
                    this.SetCell(xtemp, ytemp, Floor);
                }

                if (GetCellType(x - 1, y + 2) == Tile.Corridor || GetCellType(x - 1, y + 2) == Tile.DirtFloor)
                {
                    Button = new DoorButton(new Rectangle((x - 1) * 64 + 32, (y + 2) * 64 + 8, 16, 16), Chunk.map);
                }
                else if (GetCellType(x + 1, y + 2) == Tile.Corridor || GetCellType(x + 1, y + 2) == Tile.DirtFloor)
                {
                    Button = new DoorButton(new Rectangle((x + 1) * 64 + 32, (y + 2) * 64 + 8, 16, 16), Chunk.map);
                }
                else
                {
                    break;
                }

                if (GetCellType(x, y + 1) == Tile.Corridor || GetCellType(x, y + 1) == Tile.DirtFloor)
                {
                    Button2 = new DoorButton(new Rectangle(x * 64 + 8, (y + 1) * 64, 16, 16), Chunk.map);
                }
                else
                {
                    Chunk.map.Entities.Remove(Button);
                    Button = null;
                    break;
                }

                Door = new Door(new Rectangle(x * 64 + 32, (y + 1) * 64 + 32, 64, 64), Chunk.map);

                Door.DoorButton = Button;
                Button.Doors    = Door;
                Button2.Doors   = Door;

                Button2.Fixture.Body.Rotation = 1.5f * (float)Math.PI;

                break;

            case Direction.East:
                // east
                if (y < 0 || y > this._ysize)
                {
                    return(false);
                }
                ytemp = y;

                for (xtemp = x; xtemp < (x + len); xtemp++)
                {
                    if (xtemp < 0 || xtemp > this._xsize)
                    {
                        return(false);
                    }
                    if (GetCellType(xtemp, ytemp) != Tile.Unused)
                    {
                        return(false);
                    }
                }

                Corridors++;
                for (xtemp = x; xtemp < (x + len); xtemp++)
                {
                    this.SetCell(xtemp, ytemp, Floor);
                }

                if (GetCellType(x - 2, y - 1) == Tile.Corridor || GetCellType(x - 2, y - 1) == Tile.DirtFloor)
                {
                    Button = new DoorButton(new Rectangle((x - 2) * 64 + 56, (y - 1) * 64 + 32, 16, 16), Chunk.map);
                }
                else if (GetCellType(x - 2, y + 1) == Tile.Corridor || GetCellType(x - 2, y + 1) == Tile.DirtFloor)
                {
                    Button = new DoorButton(new Rectangle((x - 2) * 64 + 56, (y + 1) * 64 + 32, 16, 16), Chunk.map);
                }
                else
                {
                    break;
                }

                if (GetCellType(x, y) == Tile.Corridor || GetCellType(x, y) == Tile.DirtFloor)
                {
                    Button2 = new DoorButton(new Rectangle(x * 64, y * 64 + 56, 16, 16), Chunk.map);
                }
                else
                {
                    Chunk.map.Entities.Remove(Button);
                    Button = null;
                    break;
                }

                Door = new Door(new Rectangle((x - 1) * 64 + 32, (y) * 64 + 32, 64, 64), Chunk.map);

                Door.Fixture.Body.Rotation    = (float)Math.PI / 2f;
                Button.Fixture.Body.Rotation  = (float)Math.PI / 2f;
                Button2.Fixture.Body.Rotation = (float)Math.PI;

                Door.DoorButton = Button;
                Button.Doors    = Door;
                Button2.Doors   = Door;

                break;

            case Direction.South:
                // south
                if (x < 0 || x > this._xsize)
                {
                    return(false);
                }
                xtemp = x;

                for (ytemp = y; ytemp < (y + len); ytemp++)
                {
                    if (ytemp < 0 || ytemp > this._ysize)
                    {
                        return(false);
                    }
                    if (GetCellType(xtemp, ytemp) != Tile.Unused)
                    {
                        return(false);
                    }
                }

                Corridors++;
                for (ytemp = y; ytemp < (y + len); ytemp++)
                {
                    this.SetCell(xtemp, ytemp, Floor);
                }

                if (GetCellType(x - 1, y - 2) == Tile.Corridor || GetCellType(x - 1, y - 2) == Tile.DirtFloor)
                {
                    Button = new DoorButton(new Rectangle((x - 1) * 64 + 32, (y - 2) * 64 + 56, 16, 16), Chunk.map);
                }
                else if (GetCellType(x + 1, y - 2) == Tile.Corridor || GetCellType(x + 1, y - 2) == Tile.DirtFloor)
                {
                    Button = new DoorButton(new Rectangle((x + 1) * 64 + 32, (y - 2) * 64 + 56, 16, 16), Chunk.map);
                }
                else
                {
                    break;
                }

                if (GetCellType(x, y) == Tile.Corridor || GetCellType(x, y) == Tile.DirtFloor)
                {
                    Button2 = new DoorButton(new Rectangle(x * 64 + 8, y * 64, 16, 16), Chunk.map);
                }
                else
                {
                    Chunk.map.Entities.Remove(Button);
                    Button = null;
                    break;
                }

                Door = new Door(new Rectangle(x * 64 + 32, (y - 1) * 64 + 32, 64, 64), Chunk.map);

                Door.DoorButton = Button;
                Button.Doors    = Door;
                Button2.Doors   = Door;

                Button.Fixture.Body.Rotation  = (float)Math.PI;
                Button2.Fixture.Body.Rotation = (float)Math.PI * 1.5f;
                break;

            case Direction.West:
                // west
                if (ytemp < 0 || ytemp > this._ysize)
                {
                    return(false);
                }
                ytemp = y;

                for (xtemp = x; xtemp > (x - len); xtemp--)
                {
                    if (xtemp < 0 || xtemp > this._xsize)
                    {
                        return(false);
                    }
                    if (GetCellType(xtemp, ytemp) != Tile.Unused)
                    {
                        return(false);
                    }
                }

                Corridors++;
                for (xtemp = x; xtemp > (x - len); xtemp--)
                {
                    this.SetCell(xtemp, ytemp, Floor);
                }

                if (GetCellType(x + 2, y - 1) == Tile.Corridor || GetCellType(x + 2, y - 1) == Tile.DirtFloor)
                {
                    Button = new DoorButton(new Rectangle((x + 2) * 64 + 8, (y - 1) * 64 + 32, 16, 16), Chunk.map);
                }
                else if (GetCellType(x + 2, y + 1) == Tile.Corridor || GetCellType(x + 2, y + 1) == Tile.DirtFloor)
                {
                    Button = new DoorButton(new Rectangle((x + 2) * 64 + 8, (y + 1) * 64 + 32, 16, 16), Chunk.map);
                }
                else
                {
                    break;
                }

                if (GetCellType(x, y) == Tile.Corridor || GetCellType(x, y) == Tile.DirtFloor)
                {
                    Button2 = new DoorButton(new Rectangle((x + 1) * 64, y * 64 + 56, 16, 16), Chunk.map);
                }
                else
                {
                    Chunk.map.Entities.Remove(Button);
                    Button = null;
                    break;
                }

                Door = new Door(new Rectangle((x + 1) * 64 + 32, (y) * 64 + 32, 64, 64), Chunk.map);

                Door.Fixture.Body.Rotation    = (float)-Math.PI / 2f;
                Button.Fixture.Body.Rotation  = (float)-Math.PI / 2f;
                Button2.Fixture.Body.Rotation = (float)Math.PI;

                Door.DoorButton = Button;
                Button.Doors    = Door;
                Button2.Doors   = Door;

                break;
            }
            // woot, we're still here! let's tell the other guys we're done!!
            return(true);
        }
Пример #11
0
 public void Submit(DoorButton slave)
 {
     _slaves.Add(slave);
 }