示例#1
0
 /// <summary>
 /// Overriden method for when scripts starts
 /// </summary>
 protected override void Start()
 {
     base.Start();
     action           = GetComponentInChildren <WheelAction>();
     toggle           = GetComponentInChildren <LightToggle>();
     outAnglePrevious = action.outAngle;
     audioSource      = GetComponent <AudioSource>();
 }
示例#2
0
 /// <summary>
 /// Method for when scripts starts
 /// </summary>
 protected void Start()
 {
     action = GetComponentInChildren <WheelAction>();
     toggle = GetComponentInChildren <LightToggle>();
     //Tests if game needs to start automatically
     if (autoStart)
     {
         StartGameSequence();
     }
 }
示例#3
0
 /// <summary>
 /// Overrriden method for when scripts starts
 /// </summary>
 protected override void Start()
 {
     base.Start();
     selectedLightColor = possibleColors[Random.Range(0, possibleColors.Count)];
     possibleColors.Remove(selectedLightColor);
     lastLightColour = selectedLightColor;
     indentifer.GetComponent <MeshRenderer>().material       = new Material(indentifer.GetComponent <MeshRenderer>().material.shader);
     indentifer.GetComponent <MeshRenderer>().material.color = selectedLightColor;
     lightCount  = possibleColors.Count;
     toggle      = GetComponentInChildren <LightToggle>();
     audioSource = GetComponent <AudioSource>();
 }
示例#4
0
    /// <summary>
    /// Method for when scripts starts
    /// </summary>
    protected void Start()
    {
        if (isRandom)
        {
            possibleColors.Remove(selectedLightColor);
        }

        selectedLightColor = possibleColors[startingColour];
        lastLightColour    = selectedLightColor;
        indentifer.GetComponent <MeshRenderer>().material       = new Material(indentifer.GetComponent <MeshRenderer>().material.shader);
        indentifer.GetComponent <MeshRenderer>().material.color = selectedLightColor;
        toggle = GetComponentInChildren <LightToggle>();

        //Tests if game needs to auto start
        if (autoStart)
        {
            StartGameSequence();
        }
    }
 void Start()
 {
     flashLight = GameObject.Find("FlashLight Light");
     battery    = flashLight.GetComponent <LightToggle> ();
 }
示例#6
0
    void OnTriggerStay(Collider other)
    {
        if (other.gameObject == player)
        {
            //playerInSight = false;
            //Debug.Log(playerInSight);
            Vector3 direction = other.transform.position - transform.position;
            float   angle     = Vector3.Angle(direction, transform.forward);
            // Debug.Log(angle);
            //Check front cone of view
            if (angle < fieldOfViewAngle * 0.5f)
            {
                RaycastHit hit;
                if (Physics.Raycast(transform.position + transform.up, direction.normalized, out hit, col.radius))
                {
                    if (hit.collider.gameObject == player)
                    {
                        playerInSight    = true;
                        previousSighting = playerPos;
                    }
                }
            }
            else
            {
                // small radius check around the cyclops so to agro player.

                if (Vector3.Distance(transform.position, playerPos) < 50)
                {
                    playerInSight    = true;
                    previousSighting = playerPos;
                }
                else
                {
                    playerInSight = false;
                }
            }
        }

        else if (other.gameObject.tag == "Lamps")
        {
            Light       current  = other.gameObject.GetComponentInChildren <Light>();
            LightToggle LTscript = current.GetComponent <LightToggle>();

            //Debug.Log(current.enabled);
            if (current.enabled)
            {
                nav.destination = current.transform.position;

                float dist = Vector3.Distance(transform.position, current.transform.position);
                if (dist < 20)
                {
                    current.enabled = false;
                    //cyclopsAI.state = CyclopsAI.State.PATROLLING;
                }
            }
        }
        else if (other.gameObject.tag == "Projectile")
        {
            //cyclopsAI.state = CyclopsAI.State.CHASING;
            playerInSight   = true;
            nav.destination = playerPos;
        }
    }
示例#7
0
    // Update is called once per frame
    void Update()
    {
        CharacterController controller = GetComponent <CharacterController>();

        //Camera controlls
        transform.Rotate(0, Input.GetAxis("Mouse X") * rotateSpeed, 0);                 //Moving the mouse left and right turns the whole object
        Camera.main.transform.Rotate(-1 * Input.GetAxis("Mouse Y"), 0, 0);              //Moving the mouse up and down only tilts the camera

        //Movement
        Vector3 forward         = transform.TransformDirection(Vector3.forward);        //Used to set movement relative to current orientation
        Vector3 right           = transform.TransformDirection(Vector3.right);          //Used to set movement relative to current orientation
        Vector3 up              = transform.TransformDirection(Vector3.up);
        float   verticalSpeed   = Input.GetAxis("Vertical") * speed;
        float   horizontalSpeed = Input.GetAxis("Horizontal") * speed;

        isSprinting = false;
        float finalSpeed = speed;

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
        }


        //Crouching
        if (Input.GetButtonUp("Crouch"))                                                                                //If Q is pressed the player will crouch
        {
            if (isCrouching)                                                                                            //and if it is pressed again the player will uncrouch
            {
                isCrouching = false;
                this.transform.localScale = this.transform.localScale * 2;                      //If uncrouched set Player scale back to normal
            }
            else
            {
                isCrouching = true;
                this.transform.localScale = this.transform.localScale / 2;                      //If crouched set Player scale to be half it's normal size
            }
        }

        if (isCrouching)                                                                                                                //If crouching movement is half it's normal speed
        {
            horizontalSpeed = horizontalSpeed / 2;
            verticalSpeed   = verticalSpeed / 2;
            finalSpeed      = speed / 2;
        }


        //Sprinting															            //If left shift is held down
        if (Input.GetButton("Sprint") && !isCrouching && stamina > 0 && !refilling)             //and the player is not crouching, they will move twice
        {
            verticalSpeed   = verticalSpeed * 2;                                                //their normal speed and isSprinting = true
            horizontalSpeed = horizontalSpeed * 2;                                              //otherwise isSprinting = false
            isSprinting     = true;
            finalSpeed      = speed * 2;
        }

        if (controller.isGrounded)
        {
            moveDirection  = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
            moveDirection  = transform.TransformDirection(moveDirection);
            moveDirection *= finalSpeed;
            if (Input.GetButton("Jump"))
            {
                moveDirection.y = jumpSpeed;
            }
        }
        moveDirection.y -= gravity * Time.deltaTime;
        controller.Move(moveDirection * Time.deltaTime);

        //Applying movement to the player controller
        //controller.SimpleMove (forward * verticalSpeed);					//Foward and backward movement
        //controller.SimpleMove (right * horizontalSpeed);					//Side to side movement

        //Fire Projectiles
        if (fireRate > 0.0)
        {
            fireRate -= Time.deltaTime;
        }

        if (Input.GetButtonDown("Fire1") && fireRate <= 0.0)
        {
            //creates an instance of GameObject projectile based on the location and rotation of GameObject projectileLocation
            Instantiate(projectile, projectileLocation.transform.position, projectileLocation.transform.rotation);
            fireRate = fireRateConst;
        }

        //Stamina
        if (stamina <= 0 && !Input.GetButton("Sprint") || refilling)
        {
            refilling = true;
            RefillWait();
        }

        if (isSprinting)
        {
            DepleteStamina();
        }
        else if (!isSprinting && !Input.GetButton("Sprint") && !refilling)
        {
            RefillStamina();
        }

        //Visibility
        float tempVisAmount = 0.0f;

        //visibilityAmount = 0.0f;
        foreach (GameObject obj in lights)
        {
            LightToggle light = obj.GetComponent <LightToggle>();
            if (light.playerInLight)
            {
                if (isCrouching)
                {
                    tempVisAmount += (light.currentLight.intensity * 1 / (light.distance + 0.0000001f)) / 2.0f;
                }
                else
                {
                    tempVisAmount += light.currentLight.intensity * 1 / (light.distance + 0.0000001f);
                }
            }
        }

        visibilityAmount = tempVisAmount;

        /*
         * if(visibilityAmount >= visibilityThreshold)
         * {
         *  isVisible = true;
         * }
         * else
         * {
         *  isVisible = false;
         * }
         */

        if (distVisibility >= visibilityThreshold)
        {
            isVisible = true;
        }
        else
        {
            isVisible = false;
        }
    }
 // Use this for initialization
 void Start()
 {
     flashLight   = GameObject.Find("FlashLight Light");
     lightToggle  = flashLight.GetComponent <LightToggle> ();
     batteryValue = GetComponent <Text> ();
 }