Inheritance: MonoBehaviour
        public void GetShouldReturnAllDoors()
        {
            //Arrange
            var _doorrepo = new Mock <IEntityBaseRepository <Door> >();

            _doorrepo.Setup(x => x.GetAll()).Returns(doors.AsQueryable());

            var _errorrepo = new Mock <IEntityBaseRepository <Error> >();
            var _uow       = new Mock <IUnitOfWork>();

            var AutoMapperMock = new Mock <IMapper>();

            var config    = new HttpConfiguration();
            var request   = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/door");
            var route     = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");
            var routeData = new HttpRouteData(route, new HttpRouteValueDictionary {
                { "controller", "door" }
            });

            var controller = new DoorController(_doorrepo.Object, _errorrepo.Object, _uow.Object);

            controller.ControllerContext = new HttpControllerContext(config, routeData, request);
            controller.Request           = request;
            controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;

            //Act
            var _response = controller.Get(request);

            // Assert
            var responseResult = JsonConvert.DeserializeObject <List <DoorDTO> >(_response.Content.ReadAsStringAsync().Result).ToArray();

            Assert.AreEqual(_response.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(responseResult.Any(), true);
            Assert.AreEqual(responseResult.Length, 2);
        }
        public void PutShouldInsertItemAndReturnCorrectStatus()
        {
            //Arrange
            var _doorrepo = new Mock <IEntityBaseRepository <Door> >();

            _doorrepo.Setup(x => x.GetAll()).Returns(doors.AsQueryable());

            var _errorrepo = new Mock <IEntityBaseRepository <Error> >();
            var _uow       = new Mock <IUnitOfWork>();

            var AutoMapperMock = new Mock <IMapper>();

            var config    = new HttpConfiguration();
            var request   = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/door/");
            var route     = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");
            var routeData = new HttpRouteData(route, new HttpRouteValueDictionary {
                { "controller", "door" }
            });

            var controller = new DoorController(_doorrepo.Object, _errorrepo.Object, _uow.Object);

            controller.ControllerContext = new HttpControllerContext(config, routeData, request);
            controller.Request           = request;
            controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;

            DoorDTO newDoor = new DoorDTO {
                Id = 2, Make = "NewDoor"
            };

            //Act
            var _response = controller.Put(request, newDoor);

            // Assert
            Assert.AreEqual(_response.StatusCode, HttpStatusCode.Created);
        }
Exemplo n.º 3
0
        private void InteractDoor(Vector3 currentPosition, Vector3 direction)
        {
            // Make sure there is a door controller
            Vector3Int position = Vector3Int.RoundToInt(currentPosition + direction);

            DoorController doorController = matrix.GetFirst <DoorController>(position);

            if (!doorController)
            {
                doorController = matrix.GetFirst <DoorController>(Vector3Int.RoundToInt(currentPosition));

                if (doorController)
                {
                    RegisterDoor registerDoor = doorController.GetComponent <RegisterDoor>();
                    if (registerDoor.IsPassable(position))
                    {
                        doorController = null;
                    }
                }
            }

            // Attempt to open door
            if (doorController != null && allowInput)
            {
                pna.CmdCheckDoorPermissions(doorController.gameObject, gameObject);

                allowInput = false;
                StartCoroutine(DoorInputCoolDown());
            }
        }
Exemplo n.º 4
0
 public void Setup()
 {
     _door       = Substitute.For <IDoor>();
     _entry      = Substitute.For <IEntryNotification>();
     _validation = Substitute.For <IUserValidation>();
     _uut        = new DoorController(_door, _validation, _entry);
 }
Exemplo n.º 5
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Door" && !hasDoorBeenTriggered)
        {
            // Stores a cached reference to the door that we are interacting with
            doorInteractingWith = other.GetComponent <DoorController>();

            // Sets a bool so that we know that the agent is already interacting with a door
            hasDoorBeenTriggered = true;

            // Takes user input control away
            hasControl = false;

            // Saves the final destination position that the agent is trying to reach
            targetPosition = myNavmeshAgent.destination;

            // Gets the position the player should move to while waiting for the door to open
            Vector3 waitPosition = doorInteractingWith.GetWaitPosition(transform.position);

            // Gets the length of the door open animation so we know how long to wait
            doorOpenDelay = doorInteractingWith.animationDuration;

            // Tell the agent to move to the position where he should wait for the door open animation
            SetDestination(waitPosition);

            // Starts the coroutine that will carry out the sequence of waiting and opening the door
            StartCoroutine(DelayCoroutine());
        }
    }
Exemplo n.º 6
0
 void MakeInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 7
0
 public void RemoveDoor(DoorController cont)
 {
     if (currentDoors.Contains(cont))
     {
         currentDoors.Remove(cont);
     }
 }
Exemplo n.º 8
0
    private void GenerateDoorsAndWalls()
    {
        m_spawnedDoors = new List <DoorController>();
        m_spawnedWalls = new List <GameObject>();
        List <int> proccessedConnectors = new List <int>();

        foreach (RoomModule module in m_spawnedModules)
        {
            foreach (ModuleConnector connector in module.GetConnectors())
            {
                if (connector.linkedModule == null)
                {
                    //  Spawn wall
                    GameObject wall = Instantiate(wallPrefab, connector.transformPoint.position, connector.transformPoint.rotation, module.transform);
                    proccessedConnectors.Add(connector.UniqueId);
                    m_spawnedWalls.Add(wall);
                }
                else
                {
                    if (proccessedConnectors.Contains(connector.LinkedUniqueId) == false)
                    {
                        //  Spawn door
                        if (Random.Range(0f, 1f) >= 0.5f)
                        {
                            DoorController cont = Instantiate(doorPrefab, connector.transformPoint.position, connector.transformPoint.rotation, module.transform).GetComponent <DoorController>();
                            m_spawnedDoors.Add(cont);
                        }
                        proccessedConnectors.Add(connector.UniqueId);
                        proccessedConnectors.Add(connector.LinkedUniqueId);
                    }
                }
            }
        }
    }
Exemplo n.º 9
0
 public void Attach(GameplayController gameplayController, CardController cardController, DoorController doorController, Camera mainCamera)
 {
     this.gameplayController = gameplayController;
     this.cardController     = cardController;
     this.doorController     = doorController;
     this.mainCamera         = mainCamera;
 }
Exemplo n.º 10
0
    // code that is executed when something collides with lock
    void OnTriggerEnter2D(Collider2D collider)
    {
        // ignore any collision with non-player game objects
        if (collider.CompareTag("Player") == false)
        {
            return;
        }

        // get the player's script who entered the square
        PlayerController p = collider.gameObject.GetComponent <PlayerController>();
        DoorController   d = (DoorController)door.GetComponent(typeof(DoorController));

        // set unlock to true if player has keys and matches color
        if (p.checkKey() && p.colorPower.Contains(color))
        {
            // play sound effect once so it doesn't play on exit
            if (sound)
            {
                keyUnlock.Play();
                sound = false;
            }

            // set variable and check door
            unlock = true;
            d.CheckDoor();
        }
    }
 // Esta funcao e chamada a cada frame
 void Update()
 {
     if (alive)
     {
         if (curHealth <= 0)
         {
             // O boss morreu
             movementScript.canMove = false; // O boss nao pode mais se mexer
             attackScript.canAttack = false; // O boss nao pode mais atacar
             animator.SetTrigger("Died");    // Avisa ao Animator que ele morreu
             oldCollider.enabled = false;
             newCollider.enabled = true;
             if (healthBar != null)
             {
                 Destroy(healthBar.gameObject, 0.5f); // Desativa sua barra de vida apos um certo tempo
             }
             Destroy(gameObject, 4f);                 // Destroi ele apos um certo tempo
             // Abre todas as portas para o jogador
             foreach (GameObject obj in doors)
             {
                 DoorController contr = obj.GetComponent <DoorController>();
                 contr.CanBeOpened(true);
             }
             alive = false;
             attackScript.IsAlive(false);
         }
         // Atualiza a barra de vida
         healthBar.SetValueWithoutNotify(curHealth / health);
     }
 }
Exemplo n.º 12
0
    DoorController findBestDoorAux(List <DoorController> lista_door, int playerLvl, int old_lvl)
    {
        bool           flag_aux = true;
        DoorController best_door = new DoorController();
        int            max, max_aux = 100;

        //print(lista_door.Count);
        foreach (DoorController door in lista_door)
        {
            if (door.nextLevel != old_lvl)
            {
                if (flag_aux)
                {
                    max_aux  = Mathf.Abs(playerLvl - door.nextLevel); // door.nextlevel mais proximo do playerlvl;
                    flag_aux = false;
                }
                max = Mathf.Abs(playerLvl - door.nextLevel);

                if (Mathf.Abs(playerLvl - door.nextLevel) <= max_aux)
                {
                    max_aux   = max;
                    best_door = door;
                    // Debug.Log("in");
                }
            }
        }
        //Debug.Break();

        return(best_door);
    }
Exemplo n.º 13
0
        /// Cross-matrix now! uses world positions
        private void InteractDoor(Vector3Int currentPos, Vector3Int targetPos)
        {
            // Make sure there is a door controller
            DoorController doorController = MatrixManager.Instance.GetFirst <DoorController>(targetPos);

            if (!doorController)
            {
                doorController = MatrixManager.Instance.GetFirst <DoorController>(Vector3Int.RoundToInt(currentPos));

                if (doorController)
                {
                    RegisterDoor registerDoor = doorController.GetComponent <RegisterDoor>();

                    Vector3Int localPos = MatrixManager.Instance.WorldToLocalInt(targetPos, matrix);
                    if (registerDoor.IsPassable(localPos))
                    {
                        doorController = null;
                    }
                }
            }

            // Attempt to open door
            if (doorController != null && allowInput)
            {
                pna.CmdCheckDoorPermissions(doorController.gameObject, gameObject);

                allowInput = false;
                StartCoroutine(DoorInputCoolDown());
            }
        }
Exemplo n.º 14
0
    Vector3 ChooseDoor()
    {
        DoorController closestDoor = null;
        float          maxDistance = 100;

        foreach (DoorController door in currentRoom.doors)
        {
            if (currentRoom.doors.Count > 1)
            {
                if (door.locked)
                {
                    float newDistance = Vector3.Distance(transform.position, door.transform.position);
                    if (newDistance < maxDistance)
                    {
                        maxDistance = newDistance;
                        closestDoor = door;
                    }
                }
            }
            else
            {
                closestDoor = door;
            }
        }
        targetDoor = closestDoor;
        return(closestDoor.transform.position);
    }
Exemplo n.º 15
0
    public static int RegisterDoor( DoorController doorController )
    {
        if( instance )
            return instance.internalRegisterDoor( doorController );

        return -1;
    }
Exemplo n.º 16
0
        protected void InitializeControllers()
        {
            _doorController             = new DoorController(_doorServo, _openEndStopSwitch, _closeEndStopSwitch);
            _doorController.DoorOpened += (s, e) => {
                Debug.Print("Door opened.");
                _menu.UpdateItemValue("toggle", "Close");
            };
            _doorController.DoorClosed += (s, e) => {
                Debug.Print("Door closed.");
                _menu.UpdateItemValue("toggle", "Open");
            };
            _tempController = new TemperatureController(_heatLampRelay, _tempSensor);

            switch (_doorController.State)
            {
            case DoorStateType.Closed:
                _menu.UpdateItemValue("toggle", "Open");
                break;

            case DoorStateType.Open:
                _menu.UpdateItemValue("toggle", "Close");
                break;
            }

            Debug.Print("Controllers initialized.");
        }
Exemplo n.º 17
0
    void OnLoadCallback(Scene scene, LoadSceneMode scenemode)
    {
        //if we have changed scenes from a room then move our player to the door they came from
        if (PreviousSceneName != null && PreviousSceneName != "Menu" && !"Menu".Equals(scene.name))
        {
            //finds all of our doors. we will use this to set the player position
            DoorController[] doors  = FindObjectsOfType <DoorController>();
            PlayerController player = FindObjectOfType <PlayerController>();
            //start by finding the door that leads to the other level that we came from, this is the transform we want
            DoorController fromDoor = Array.Find(doors, door => PreviousSceneName.Equals(door.transitionToLabel));
            //modify the player transform, by combining the door transform and the transform modifiers
            Transform newPos = fromDoor.gameObject.transform;

            player.gameObject.transform.position = new Vector3(
                newPos.position.x + fromDoor.xSpawn,
                newPos.position.y + fromDoor.ySpawn,
                -1//fix the player position to not spawn at 0 on the axis
                );
            player.Spawn(new Vector2(
                             newPos.position.x + fromDoor.xSpawn,
                             newPos.position.y + fromDoor.ySpawn
                             ), fromDoor.xSpawn, fromDoor.ySpawn);
        }
        //set the previous scene to be this scene (should always happen)
        PreviousSceneName = scene.name;
    }
Exemplo n.º 18
0
        protected void Move(Vector3Int dirToMove)
        {
            var dest = mobTile.LocalPositionServer + dirToMove;

            if (mobTile.customNetTransform.Push(dirToMove.To2Int(), context: gameObject) == false)
            {
                //New doors
                DoorMasterController tryGetDoorMaster = mobTile.Matrix.GetFirst <DoorMasterController>(dest, true);
                if (tryGetDoorMaster)
                {
                    tryGetDoorMaster.Bump(gameObject);
                }

                //Old doors
                DoorController tryGetDoor = mobTile.Matrix.GetFirst <DoorController>(dest, true);
                if (tryGetDoor)
                {
                    tryGetDoor.MobTryOpen(gameObject);
                }
            }

            if (rotatable != null)
            {
                rotatable.SetFaceDirectionLocalVictor(dirToMove.To2Int());
            }
        }
Exemplo n.º 19
0
        //move in direction input
        public void MoveInDirection(Vector2 direction)
        {
            nextTile.x = (int)(Mathf.Round(transform.position.x) + direction.x);
            nextTile.y = (int)(Mathf.Round(transform.position.y) + direction.y);

            if (Matrix.Matrix.At(nextTile.x, nextTile.y).IsPassable())
            {
                lerpA         = false;
                moveDirection = direction;
                isMoving      = true;

                if (direction == Vector2.right || direction == Vector2.left)
                {
                    clampPos = Mathf.Round(transform.position.y);
                }

                if (direction == Vector2.down || direction == Vector2.up)
                {
                    clampPos = Mathf.Round(transform.position.x);
                }
            }
            else
            {
                //Check why it is not passable (doors etc)
                DoorController getDoor = Matrix.Matrix.At(nextTile.x, nextTile.y).GetDoor();
                if (getDoor != null && !tryOpenDoor)
                {
                    tryOpenDoor = true;
                    StartCoroutine("OpenCoolDown");
//					getDoor.CmdTryOpen();
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        gameController               = GameObject.Find("Controller").GetComponent("GameController") as GameController;
        introFlowController          = this.GetComponent("IntroFlowController") as IntroFlowController;
        introFlowController.enabled  = false;
        level1FlowController         = this.GetComponent("Level1FlowController") as Level1FlowController;
        level1FlowController.enabled = false;
        level2FlowController         = this.GetComponent("Level2FlowController") as Level2FlowController;
        level2FlowController.enabled = false;
        EndController  = GetComponent("GameEndsController") as GameEndsController;
        doorController = GameObject.Find("Door2").GetComponent("DoorController") as DoorController;

        introFlowController.FinishedEvent  += introFlowControllerListener;
        level1FlowController.FinishedEvent += level1FlowControllerListener;
        level2FlowController.FinishedEvent += level2FlowControllerListener;

        if (!gameController.isCheating())
        {
            if (gameController.startingLevel() == 0)
            {
                startStory();
            }
            else if (gameController.startingLevel() == 1)
            {
                introFlowControllerListener(null);
            }
            else if (gameController.startingLevel() == 2)
            {
                level1FlowControllerListener(null);
            }
        }
    }
Exemplo n.º 21
0
 private void Awake()
 {
     _switches     = GameObject.FindObjectsOfType <SwitchController>();
     _door         = GameObject.FindObjectOfType <DoorController>();
     _camera       = GameObject.FindObjectOfType <CameraController>();
     _enemyManager = GameObject.FindObjectOfType <EnemyManager>();
 }
Exemplo n.º 22
0
 private void Awake()
 {
     _particleSystem = GetComponent <ParticleSystem>();
     _renderer       = GetComponent <MeshRenderer>();
     _doorController = FindObjectOfType <DoorController>();
     _particleSystem.Stop();
 }
Exemplo n.º 23
0
    bool IsNearDoor()
    {
        Vector3 pos = Snap(m_Transform.position);

        if (Vector3.Distance(pos, m_Transform.position) > senseRadius)
        {
            return(false);
        }

        Vector2[] options = { Vector2.up, Vector2.down, Vector2.left, Vector2.right };
        foreach (var option in options)
        {
            var hit = Physics2D.Raycast(pos, option, 1.0f);
            if (hit.collider == null)
            {
                continue;
            }
            door = hit.collider.GetComponent <DoorController>();
            if (door == null)
            {
                continue;
            }

            // Hit door
            m_CircleCollider.enabled = false;
            m_Transform.position     = pos;
            return(true);
        }

        return(false);
    }
Exemplo n.º 24
0
        private void CheckDoorAccess(IDCard cardID, DoorController doorController)
        {
            if (cardID.accessSyncList.Contains((int)doorController.restriction))
            {
                // has access
                allowInput = false;
                //Server only here but it is a cmd for the input trigger (opening with mouse click from client)
                if (CustomNetworkManager.Instance._isServer)
                {
                    doorController.CmdTryOpen(gameObject);
                }

                StartCoroutine(DoorInputCoolDown());
            }
            else
            {
                // does not have access
                allowInput = false;
                StartCoroutine(DoorInputCoolDown());
                //Server only here but it is a cmd for the input trigger (opening with mouse click from client)
                if (CustomNetworkManager.Instance._isServer)
                {
                    doorController.CmdTryDenied();
                }
            }
        }
Exemplo n.º 25
0
    // Use this for initialization
    void Start()
    {
        gameController = GameObject.Find("Controller").GetComponent("GameController") as GameController;
        introFlowController = this.GetComponent("IntroFlowController") as IntroFlowController;
        introFlowController.enabled = false;
        level1FlowController = this.GetComponent("Level1FlowController") as Level1FlowController;
        level1FlowController.enabled = false;
        level2FlowController = this.GetComponent("Level2FlowController") as Level2FlowController;
        level2FlowController.enabled = false;
        EndController = GetComponent("GameEndsController") as GameEndsController;
        doorController = GameObject.Find("Door2").GetComponent("DoorController") as DoorController;

        introFlowController.FinishedEvent += introFlowControllerListener;
        level1FlowController.FinishedEvent += level1FlowControllerListener;
        level2FlowController.FinishedEvent += level2FlowControllerListener;

        if( !gameController.isCheating() ){
            if( gameController.startingLevel() == 0){
                startStory();
            } else if( gameController.startingLevel() == 1){
                introFlowControllerListener(null);
            } else if( gameController.startingLevel() == 2){
                level1FlowControllerListener(null);
            }
        }
    }
Exemplo n.º 26
0
 private void OnTriggerExit2D(Collider2D other)
 {
     if (other.GetComponent <DoorController>() != null)
     {
         door = null;
     }
 }
Exemplo n.º 27
0
    private void HandleDoorAreaInteraction(Collider2D doorInteractiveArea)
    {
        DoorController doorController = doorInteractiveArea.gameObject.GetComponentInParent <DoorController>();

        if (doorController.openWithKeyName != "")
        {
            PickUp requiredKey = FindInInventory(PickUpConstants.TYPE_KEY, doorController.openWithKeyName);

            if (requiredKey != null)
            {
                doorController.ToggleState();
                bool result = RemoveFromInventory(requiredKey);

                if (!result)
                {
                    Debug.Log("There was an error trying to remove the required key from inventory.");
                }
            }
            else
            {
                Debug.Log("Doesn't have the right key!");
            }
        }
        else
        {
            Debug.Log("The door doesn't use a key!");
        }
    }
Exemplo n.º 28
0
    void atDoor(DoorController dc)
    {
        if (doorUpdate[0] == null)
        {
            doorUpdate[0] = dc;
            doorUpdate[0].activateRooms(true);
            return;
        }

        if (doorUpdate[1] == null)
        {
            if (doorUpdate[0] == dc)
            {
                return;
            }
            else
            {
                doorUpdate[1] = dc;
                doorUpdate[0].activateRooms(false);
                doorUpdate[1].activateRooms(true);
            }
        }

        if (doorUpdate[1] == dc)
        {
            return;
        }
        else
        {
            doorUpdate[0] = doorUpdate[1];
            doorUpdate[1] = dc;
            doorUpdate[0].activateRooms(false);
            doorUpdate[1].activateRooms(true);
        }
    }
Exemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        score             = LevelManager.instance.scoreInOneScene;
        scoreText.text    = "Score:" + score;
        gameLife          = LevelManager.instance.playerHealth;
        heartCount_Player = LevelManager.instance.heartCount_Player;
        heartCount_Dof    = LevelManager.instance.heartCount_Dof;
        levelText.text    = "Màn chơi cuối";

        ////Display the player's life
        //for (int i = heartCount_Player - 1; i < gameLife - 1; i++)
        //{
        //    heart_Player[i + 1].gameObject.SetActive(false);
        //}

        for (int i = 0; i < heartCount_Player; i++)
        {
            heart_Player[i].gameObject.SetActive(true);
        }
        for (int i = heartCount_Dof - 1; i < 2; i++)
        {
            heart_Dof[i + 1].gameObject.SetActive(false);
        }


        doorController = LevelManager.instance.doors[LevelManager.instance.indexDoor];
        //Debug.Log(LevelManager.indexDoor);
        //Debug.Log(doorController.QASetList[0].question);
        FinalMCManager.instance.BeginConversation(doorController);
    }
Exemplo n.º 30
0
    public int AddDoor(DoorController cont, out DoorController.DoorType newOrientation)
    {
        newOrientation = cont.DoorLocation;
        if (newOrientation == DoorController.DoorType.East ||
            newOrientation == DoorController.DoorType.West)
        {
            if (cont.gameObject.transform.position.x - transform.position.x > 0)
            {
                newOrientation = DoorController.DoorType.East;
            }
            else
            {
                newOrientation = DoorController.DoorType.West;
            }
        }

        else if (newOrientation == DoorController.DoorType.North ||
                 newOrientation == DoorController.DoorType.South)
        {
            if (cont.gameObject.transform.position.x - transform.position.x > 0)
            {
                newOrientation = DoorController.DoorType.South;
            }
            else
            {
                newOrientation = DoorController.DoorType.North;
            }
        }

        currentDoors.Add(cont);
        return(currentDoors.Count);
    }
 public void DecreaseMonsterCountAtRoom(int col, int row)
 {
     sessionArray[row, col].movingEnemyCount--;
     if (sessionArray[row, col].movingEnemyCount <= 0)
     {
         if (sessionArray[row, col].roomType == RoomType.boss)
         {
             HeroController.S.isClearSession = true;
         }
         else
         {
             sessionArray[row, col].movingEnemyCount = 0;
             sessionArray[row, col].monsterList.Clear();
             DoorController tempDoorController = null;
             foreach (var door in sessionArray[row, col].doorsInRoomDic)
             {
                 tempDoorController = door.Value.transform.Find("Door").GetComponent <DoorController>();
                 if (tempDoorController != null)
                 {
                     tempDoorController.DoorOpen();
                 }
             }
         }
     }
 }
Exemplo n.º 32
0
 void Start()
 {
     intObj.interactMethod        = UseKeypad;
     uiKeypadInput                = uiKeypad.GetComponent <TMP_InputField>();
     uiKeypadInput.characterLimit = characterLimit;
     connectedDoorController      = connectedDoor.GetComponent <DoorController>();
 }
Exemplo n.º 33
0
    void Start()
    {
        this.cameraControler = this.gameObject.AddComponent<CameraControler> ();
        this.doorController = this.gameObject.AddComponent<DoorController> ();
        this.inventory = this.gameObject.AddComponent<Inventory> ();
        this.lightManager = this.gameObject.AddComponent<LightManager> ();
        this.playerController = this.gameObject.AddComponent<PlayerController> ();

        this.cameraControler.lightManager = this.lightManager;
        this.gameObject.name = "Player";
    }
Exemplo n.º 34
0
    //This script unlocks a door when called by an NPC...
    void OnEnable()
    {
        if(!alreadyEnabledOnce){
            alreadyEnabledOnce = true;
            doorController = GetComponent<DoorController> ();
            doorController.UnlockDoor ();

            //if there is a chained action...
            if(targetGO){
                (targetGO.GetComponent(scriptNameToEnable) as MonoBehaviour).enabled = true;
            }
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == Tags.player) {
            if(!targetEnabled && targetGO != null){
                doorController = targetGO.GetComponent<DoorController>();
                doorController.LockDoor();

                (targetGO.GetComponent(scriptNameToEnable) as MonoBehaviour).enabled = true;
                targetEnabled = true;
                if(destroyGO){
                    Destroy (gameObject);
                }

            }
        }
    }
Exemplo n.º 36
0
 public void Close()
 {
     _opener = null;
     ActionState = DoorState.Idle;
 }
Exemplo n.º 37
0
 public void WalkThrough(DoorController opener)
 {
     _opener = opener;
     ActionState = DoorState.Ghost;
 }
Exemplo n.º 38
0
    // Initialization
    void Start()
    {
        // If the player is the seeker, tag their player object as "Hunter" and
        // send a message to all clients that this object is the Hunter object
        if (isServer && isLocalPlayer) {
            this.tag = "Hunter";
            SendPropMessageTag ();
        }

        // Setup camera based on player role
        string whichCamera;
        if (isServer) {
            whichCamera = "FirstPerson";
            UIText = firstPersonText;
        } else {
            whichCamera = "ThirdPerson";
            UIText = thirdPersonText;
        }

        // hide and lock the cursor
        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;

        // Get Audio Source
        playerAudio = GetComponent<AudioSource>();

        // get necessary references
        graphics = transform.Find("Graphics").gameObject;
        playerModel = graphics.transform.Find("Player Model").gameObject;
        cam = transform.Find(whichCamera).gameObject;
        myCamera = cam.GetComponent<Camera>();
        rigidBody = GetComponent<Rigidbody>();
        doorController = GetComponent<DoorController>();
        timer = GameObject.Find("Timer").GetComponent<Timer>();

        // life status
        health = MaxHealth;
        dead = false;

        // record the spawn place, used to respawn
        spawnPosition = transform.position;
        spawnRotation = transform.rotation;

        // disable UI for other players
        if (!isLocalPlayer) {
            cam.transform.Find("Canvas").gameObject.SetActive(false);
        }

        // ignore local player model to avoid clipping with first person camera
        if (isLocalPlayer && isServer) {
            playerModel.GetComponent<MeshRenderer>().enabled = false;
        }

        // setup handlers for messages
        if (isServer) {
            NetworkServer.RegisterHandler(PropMessage.TypeId, OnPropMessageServer);
        }
        if (isLocalPlayer) {
            NetworkClient.allClients[0].RegisterHandler(PropMessage.TypeId, OnPropMessageClient);
        }

        // TEMPORARY SOLUTION: the server is the hunter permanantly
        if (isServer) {
            if (isLocalPlayer) {
                isActive = false;
            }
            else {
                isActive = true;
            }
        }
    }
Exemplo n.º 39
0
 public void Open(DoorController opener)
 {
     _opener = opener;
     ActionState = DoorState.Open;
 }
Exemplo n.º 40
0
 // Use this for initialization
 void Start()
 {
     doorController = GameObject.Find(whichDoor).GetComponent("DoorController") as DoorController;
 }
Exemplo n.º 41
0
 void Awake()
 {
     nearestDoor = FindObjectOfType<DoorController>();
     //nearestDoor.AddToTargetList(gameObject);
 }
Exemplo n.º 42
0
    // Use this for initialization
    void Start()
    {
        // If the player is the host and the object in the scene is the localplayer's character, initialize the Steam controller
        if (isServer && isLocalPlayer) {
            rightTrackedObject = this.transform.Find("[CameraRig]").Find("Controller (right)").GetComponent<SteamVR_TrackedObject>();
        }

        // Determining the camera based on if the person is a seeker or hider
        string whichCamera;
        if (isServer && isLocalPlayer) {
            whichCamera = "FirstPerson";
            UIText = firstPersonText;
        } else {
            whichCamera = "ThirdPerson";
            UIText = thirdPersonText;
        }
        myCamera = transform.Find(whichCamera).GetComponent<Camera>();
        doorController = GetComponent<DoorController>();
        timer = GameObject.Find("Timer").GetComponent<Timer>();

        // record the spawn place, used to respawn
        spawnPosition = transform.position;
        spawnRotation = transform.rotation;
        rigidBody = GetComponent<Rigidbody>();

        // TEMPORARY solution: the server is the hunter
        if (isServer) {
            if (isLocalPlayer) {
                isActive = true;
                this.transform.Find ("[CameraRig]").gameObject.SetActive (true);
            }
            else {
                isActive = false;
            }
        }

        // wait at the beginning of the game
        if (isActive) {
            waiting = true;
            GetComponent<myViveController>().enabled = false;
        }
    }
Exemplo n.º 43
0
    private int internalRegisterDoor( DoorController doorController )
    {
        if( doorController.getUniqueID() == -1 )
        {
            int uniqueID = IDIndex;
            IDIndex++;

            doorsById.Add( uniqueID, doorController );

            return uniqueID;
        }

        return doorController.getUniqueID();
    }
Exemplo n.º 44
0
 // Use this for initialization
 void Start()
 {
     doorAnim = door.GetComponent<Animator> ();
     doorScript = door.GetComponent<DoorController> ();
     anim = gameObject.GetComponent<Animator> ();
 }
Exemplo n.º 45
0
 void Awake()
 {
     doorController = GetComponentInParent<DoorController> ();
 }