Наследование: MonoBehaviour
Пример #1
0
 public void UnregisterRotatingObject(RotatingObject managedObject)
 {
     if (managedRotatingObjects.Contains(managedObject))
     {
         managedRotatingObjects.RemoveAt(managedRotatingObjects.FindIndex((x) => x == managedObject));
     }
 }
 private void Awake()
 {
     _eatingController    = FindObjectOfType <EatingBugsController>();
     _particlesController = FindObjectOfType <ParticlesController>();
     _rotatingModel       = FindObjectOfType <RotatingObject>();
     _turningEffect       = FindObjectOfType <TurningEffect>();
 }
Пример #3
0
 private void Awake()
 {
     _staminaSlider  = FindObjectOfType <StaminaSlider>();
     _enemyEffects   = FindObjectOfType <EnemyEffects>();
     _uiController   = FindObjectOfType <UIController>();
     _winPanel       = FindObjectOfType <WinPanelModel>();
     _rotatingObject = FindObjectOfType <RotatingObject>();
     _coinsModel     = FindObjectOfType <Coins>();
     _eatingModel    = FindObjectOfType <EatingModel>();
     _bossModel      = FindObjectOfType <Boss>();
     _staminaSlider.BasicStaminaOffMultiplyer = _staminaSlider.StaminaOffMultiplyer;
 }
Пример #4
0
    private void Start()
    {
        if (bonusType == BonusType.HURRICAN_BEER)
        {
            return;
        }

        RotatingObject rotatingObject = GetComponentInChildren <RotatingObject>();

        int id = Random.Range(0, objectiveModels.Length);

        Instantiate(objectiveModels[id], Vector3.zero, Quaternion.Euler(objectiveModelRotations[id]),
                    rotatingObject.transform).transform.localPosition = Vector3.zero;
    }
Пример #5
0
    void Start()
    {
        // prevent bad repartition of asteroïds.
        Random.InitState(seed);
        transform.rotation = Quaternion.Euler(orbitAngle);

        for (uint i = 0; i < astroidDensity; ++i)
        {
            randomRadius         = Random.Range(innerRadius, outerRadius);
            randomRotation       = Quaternion.Euler(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360));
            randomPositionOnDisk = Random.Range(0, 2 * Mathf.PI);

            // computing the asteroid's position in the world.
            localPosition.y = Random.Range(-height, height);
            localPosition.x = randomRadius * Mathf.Cos(randomPositionOnDisk);
            localPosition.z = randomRadius * Mathf.Sin(randomPositionOnDisk);
            worldPosition   = transform.rotation * localPosition + transform.position;

            GameObject asteroid = Instantiate(
                astroidPrefab,
                worldPosition,
                randomRotation
                );

            // adding a rotation script to the asteroid.
            asteroid.AddComponent <RotatingObject>();
            asteroid.AddComponent <RotatingAroundObject>();
            RotatingObject       rotatingC = asteroid.GetComponent <RotatingObject>();
            RotatingAroundObject aroundC   = asteroid.GetComponent <RotatingAroundObject>();

            // setting up components.
            rotatingC.raySize      = 0.0f;
            rotatingC.rotateSpeed  = Random.Range(minRotationSpeed, maxRotationSpeed);
            rotatingC.rotationAxis = randomRotation.eulerAngles;
            aroundC.target         = gameObject;
            aroundC.speed          = orbitSpeed;

            asteroid.transform.localScale = scale;
            asteroid.transform.parent     = gameObject.transform;
        }
    }
Пример #6
0
    // Change rotation
    private void ChangeRotation(RotatingObject rotatingObject, int?newAngle = null)
    {
        newAngle = (newAngle == null) ? Random.Range(-1, 2) : newAngle;

        switch (newAngle)
        {
        case -1:
            rotatingObject.rotationDegrees = -90;
            break;

        case 0:
            rotatingObject.rotationDegrees = 0;
            break;

        case 1:
            rotatingObject.rotationDegrees = (Random.Range(0, 9000) % 2 == 0) ? 180 : -180;
            break;

        default:
            rotatingObject.rotationDegrees = 90;
            break;
        }
    }
Пример #7
0
    public void LoadObject()
    {
        GameObject playspace = this.gameObject;
        GameObject camera    = playspace.transform.Find("Main Camera").gameObject;

        model = new GameObject(model_name);
        model.transform.parent = playspace.transform;
        model.AddComponent <MeshRenderer>();
        model.AddComponent <StepToggle>();


        Vector3 camera_pos = camera.transform.position;
        Vector3 camera_dir = camera.transform.forward;

        model.transform.position   = camera_pos + camera_dir;
        model.transform.position  += new Vector3(0.0f, -0.05f, 0.6f);
        model.transform.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);

        AssetBundle.UnloadAllAssetBundles(true);
        var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine("file:///", Application.streamingAssetsPath, model_name));

        if (myLoadedAssetBundle == null)
        {
            Debug.Log("Failed to load AssetBundle!");
            return;
        }
        var fileArray = myLoadedAssetBundle.LoadAllAssets <GameObject>();

        foreach (var obj in fileArray)
        {
            if (obj.name.Contains("step"))
            {
                GameObject step_model = Instantiate(obj);
                step_model.transform.parent = model.transform;
                //get step number to set the right order
                int step_num = int.Parse(string.Join("", obj.name.Substring(obj.name.IndexOf("step")).ToCharArray().Where(Char.IsDigit)));
                step_model.transform.SetSiblingIndex(step_num);
                //AddLines(step_model);
                step_model.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                step_model.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
                step_model.transform.GetChild(0).gameObject.AddComponent <StepHighlighter>();
            }
            else if (obj.name.Equals(model_name) || obj.name.Equals(model_name.ToLower()))
            {
                GameObject model_small = Instantiate(obj);
                model_small.transform.parent = camera.transform.GetChild(1).gameObject.transform;
                //AddLines(model_small);
                model_small.transform.localPosition = new Vector3(0f, -6.7f, -0.7f);
                model_small.transform.localRotation = new Quaternion(0.165f, -73.45901f, 31.383f, 0);
                model_small.transform.localScale    = new Vector3(0.5f, 0.5f, 0.5f);

                float canvas_width = model_small.transform.parent.GetComponent <RectTransform>().rect.width *model_small.transform.parent.GetComponent <RectTransform>().transform.localScale.x;
                float bb_width     = model_small.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().bounds.size.x * 2.25f;

                model_small.transform.localScale = new Vector3(canvas_width / bb_width, canvas_width / bb_width, canvas_width / bb_width);

                RotatingObject ro = model_small.AddComponent <RotatingObject>();
                ro.yAngle = 2;
                ro.speed  = 0.2f;
            }
            else
            {
                //bricks.Add(obj.name, obj);
            }
        }

        // make small model canvas visible
        camera.transform.Find("Canvas").gameObject.SetActive(true);
        // make model picker menu invisible
        playspace.transform.Find("Canvas").gameObject.SetActive(false);

        ConfigSpeechInputHandler();

        // add components to move and scale the model
        ManipulationHandler mh = model.AddComponent <ManipulationHandler>();

        ManipulationHandler.ReleaseBehaviorType ReleaseBehaviorType = ManipulationHandler.ReleaseBehaviorType.KeepVelocity & ManipulationHandler.ReleaseBehaviorType.KeepAngularVelocity;
        mh.ReleaseBehavior = ReleaseBehaviorType;
        model.AddComponent <BoundingBox>();
        Rigidbody modelRigidBody = model.AddComponent <Rigidbody>();

        modelRigidBody.useGravity = false;
        model.AddComponent <NearInteractionGrabbable>();
    }
Пример #8
0
 private void Awake()
 {
     _rotatingObjectModel = FindObjectOfType <RotatingObject>();
     _enemyeffects        = FindObjectOfType <EnemyEffects>();
 }
Пример #9
0
 //Player Prefs : BossesBeaten - Побито боссов(для того что бы в начале по порядку боссов пустить)
 private void Awake()
 {
     _bossModel      = FindObjectOfType <Boss>();
     _staminaSlider  = FindObjectOfType <StaminaSlider>();
     _rotatingObject = FindObjectOfType <RotatingObject>();
 }
Пример #10
0
    // Update is called once per frame
    void Update()
    {
        //If camera rotation is Enable
        if (camRotation)
        {
            //Get mouse position multiply by MouseSensitivity
            float mouseX = Input.GetAxis("Mouse X") * MouseSensitivity * Time.deltaTime;
            float mouseY = Input.GetAxis("Mouse Y") * MouseSensitivity * Time.deltaTime;

            //Rotate playerbody left/right multiply by the result of mouseX/Horizontal value
            playerBody.Rotate(Vector3.up * mouseX);

            //Rotation value
            if (!invertMouse)
            {
                xRot -= mouseY;
            }

            else if (invertMouse)
            {
                xRot += mouseY;
            }
            //Clamping the rotation value or the value of xRot to only be able to exceed only the given minimum
            //and maximum value
            xRot = Mathf.Clamp(xRot, -90f, 90f);

            //Rotate camera not inherting rotation from the parents object
            transform.localRotation = Quaternion.Euler(xRot, 0f, 0f);
        }
        //If camera doesn't rotate then rotation value return to 0
        else
        {
            xRot = 0;
        }
        //Raycast in the middle of viewport
        Ray ray;

        ray = thisCam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 5))
        {
            //If raycast hit rotateable then you can rotate object
            //Disabling movement and Camera rotation
            if (hit.collider.CompareTag("rotateable"))
            {
                rotationObj = hit.collider.GetComponent <RotatingObject>();
                if (Input.GetMouseButtonDown(0))
                {
                    playerMovement.enabled = false;
                    camRotation            = false;
                    rotationObj.enabled    = true;
                }
                //If hit telescope
                if (Input.GetMouseButtonDown(0) && hit.collider.GetComponent <telescopeScript>())
                {
                    telephone.ableToUsePhone = false;
                    pausescript.abletoPause  = false;
                    teleScript         = hit.collider.GetComponent <telescopeScript>();
                    teleScript.enabled = true;
                    teleScript.telescopeCam.enabled = true;
                    thisCam.enabled = false;
                    teleScript.telescopeImg.SetActive(true);
                }
            }

            //Lightswitch turning on and of

            if (hit.collider.CompareTag("lightswitch"))
            {
                lightSwitch = hit.collider.GetComponent <lightSwitchScript>();
                //If light is on
                if (Input.GetMouseButtonDown(0) && lightSwitch.isOn)
                {
                    lightSwitch.isOn = false;
                    SFXsource.PlayOneShot(lightSwitch.switchOff);
                }

                //If light is off
                else if (Input.GetMouseButtonDown(0) && !lightSwitch.isOn)
                {
                    lightSwitch.isOn = true;
                    SFXsource.PlayOneShot(lightSwitch.switchOn);
                }
            }
            //Checking if it has RayCastObjectName
            if (hit.collider.GetComponents <RayCastObjectName>() != null)
            {
                castobjName = hit.collider.GetComponent <RayCastObjectName>();
            }
            //If castobjName is available
            //Then active the objectText, assign it to getCastObj
            if (castobjName != null)
            {
                castobjName.objectText.SetActive(true);
                getCastObj = castobjName.objectText;
            }
            //If castobjName is not available
            else if (castobjName == null)
            {
                //getCastObj disable
                getCastObj.SetActive(false);
            }

            //Display object message on worldspace canvas
            if (hit.collider.GetComponent <RayCastBoolMsg>() != null)
            {
                boolRaycast = hit.collider.GetComponent <RayCastBoolMsg>();
                if (Input.GetMouseButtonDown(0))
                {
                    boolRaycast.cast = true;
                }
            }
        }
        //If you can rotateObject then disbale Raycastobject text GameObject
        if (rotationObj.enabled)
        {
            getCastObj.SetActive(false);
            castobjName.isCast = false;
        }

        //If object rotation is enable then pressing right mouseButton disable it
        //Allowing movement and camera movement
        if (rotationObj.enabled && Input.GetMouseButtonDown(1))
        {
            Debug.Log("He");
            playerMovement.enabled   = true;
            camRotation              = true;
            rotationObj.enabled      = false;
            rotationObj              = null;
            telephone.ableToUsePhone = true;
            pausescript.abletoPause  = true;
        }

        if (teleScript.enabled == true && Input.GetKeyDown(KeyCode.E) | Input.GetMouseButtonDown(1))
        {
            Debug.Log("He");
            rotationObj        = null;
            thisCam.enabled    = true;
            teleScript.enabled = false;
            teleScript.telescopeCam.enabled = false;
            teleScript.telescopeImg.SetActive(false);
        }
    }
Пример #11
0
 public void RegisterRotatingObject(RotatingObject managedObject)
 {
     managedRotatingObjects.Add(managedObject);
 }