Esempio n. 1
0
    // Start is called before the first frame update
    void Start()
    {
        rb      = GetComponent <Rigidbody2D>();
        mainCam = Camera.main;

        Instance = this;
    }
 void Awake()
 {
     spaceshipAnimator            = GetComponent <Animator> ();
     spriteRendererOfTheSpaceship = GetComponent <SpriteRenderer> ();
     spaceshipMovementScript      = GetComponent <SpaceshipMovement> ();
     specialMovementScript        = GetComponent <SpecialMovement> ();
 }
Esempio n. 3
0
    void Update()
    {
        timer += Time.deltaTime;
        //horizontalAxis = Input.GetAxisRaw ("Horizontal") * -1f;
        horizontalAxis = normalMovement.HorizontalAxis();
        if (timer > cooldown || firstTimeUse)
        {
            shiftEnabled = true;
            firstTimeUse = false;
        }

        if (specialMovementActivated && timeInMovement < limitOfTimeInMovement)
        {
            normalMovement.enabled = false;
            timeInMovement        += Time.deltaTime;
            healthSystem.damage    = healthSystem.damageWhenSpecialMovementIsActive;
            SpaceshipMovement.RotateAround(objectToRotateAround.position, specialVelocity * horizontalAxis * Time.deltaTime, spaceship);
        }
        else
        {
            normalMovement.enabled = true;
            healthSystem.damage    = healthSystem.damageReceived;
        }

        bool isButtonPressed =
            (Input.GetKeyDown(KeyCode.LeftShift) || movementJoystickButton.IsButtonDown) ? true : false;

        if (shiftEnabled && isButtonPressed)
        {
            shiftEnabled             = false;
            specialMovementActivated = true;
            timer          = 0;
            timeInMovement = 0;
        }
    }
    void Start()
    {
        //Clear the list of events on Start (to avoid filling the list on restarts)
        s_orderedEventList.Clear();
        s_allEvents.Clear();

        //Train Stuff
        m_trainTrack.gameObject.SetActive(false);
        m_motivationLossDuration = Mathf.Clamp(shakeDuration + 3, 0, 25);

        //Spaceship stuff
        m_spaceshipMovement = GameObject.FindObjectOfType <SpaceshipMovement>();
        m_alienCount        = 8;

        //Radiator stuff
        radiators = FindObjectsOfType <Radiator>();

        m_eventDelayEasy   = 50;
        m_eventDelayMedium = 30;
        m_eventDelayHard   = 15;

        //Event order
        AddEventOrder();

        //Start events
        StartCoroutine(TriggerEventsInOrder(m_eventDelayEasy, m_eventDelayEasy));

        AddAllEventsToAllEventsList();

        Debug.Assert(AudioManager.instance, "No AudioManager.instance exists!!!");
    }
Esempio n. 5
0
    private void Awake()
    {
        inputDequeuer = GetComponent <SpaceshipInputDequeuer>();
        inputDequeuer.InputsDequeued += OnInputsDequeued;

        movement = GetComponent <SpaceshipMovement>();

        laserGun = GetComponentInChildren <SpaceshipLaserGun>();
    }
Esempio n. 6
0
        public MovementInitialization(Transform spaceship, SpaceshipData data, Vector3 cameraPosition)
        {
            var moveTransform = new AccelerationMove(spaceship,
                                                     data, data);
            var rotation = new RotationSpaceship(spaceship);
            var movement = new SpaceshipMovement(moveTransform, rotation, data);

            _inputMoveController = new InputMoveController(movement);
            _cameraPosition      = cameraPosition;
        }
 private void Awake()
 {
     if (myInstance == null)
     {
         myInstance = this;
     }
     else
     {
         Debug.LogWarning("Singleton: More than one SpaceshipMovement exists, removing late one.");
         Destroy(this);
     }
 }
    void OnTriggerEnter(Collider other)
    {
        if (!changeScript)
        {
            cargoMenu.SetActive(false);
            SpaceshipMovementScript         = transform.GetComponent <SpaceshipMovement>();
            SpaceshipMovementScript.forward = false;
            SpaceshipMovementScript.enabled = false;
        }

        Debug.Log("OnTriggerEnter: " + other.name);
        moveCamera = true;
    }
Esempio n. 9
0
 public InputMoveController(SpaceshipMovement movement)
 {
     _movement = movement;
 }
    void Update()
    {
        try
        {
            canvas.gameObject.SetActive(false);
            leftJoystick  = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
            rightJoystick = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);


            if (moveCamera == true)
            {
                tm.text = "                 Use Right Joystick to go to Portal Device";

                if (rightJoystick.x < 0.0f)
                {
                    CameraRig.transform.position = Vector3.MoveTowards(CameraRig.transform.position, portal.transform.position, 10 * Time.deltaTime);
                }
                else if (rightJoystick.x > 0.0f)
                {
                    CameraRig.transform.position = Vector3.MoveTowards(CameraRig.transform.position, rightController.transform.position, 10 * Time.deltaTime);
                }
                //else
                //    CameraRig.transform.position = Vector3.MoveTowards(CameraRig.transform.position, portal.transform.position, 10 * Time.deltaTime);

                if (Vector3.Distance(portal.transform.position, CameraRig.transform.position) < 20)
                {
                    moveCamera  = false;
                    cameraMoved = true;
                }
            }

            if (cameraMoved)
            {
                tm.text = "                 Press E or B to Teleport on PlanetCSE566";
                if (Input.GetKeyDown(KeyCode.E) || (OVRInput.GetDown(OVRInput.RawButton.B)))
                {
                    origPos = CameraRig.transform.position;
                    origRot = CameraRig.transform.rotation;
                    CameraRig.transform.position = teleportLocation.transform.position;
                    CameraRig.transform.rotation = teleportLocation.transform.rotation;
                    cameraMoved = false;
                    raycast     = true;
                }
            }

            if (raycast)
            {
                Raycast();
            }

            if (hit && (Input.GetKeyDown(KeyCode.X) || (OVRInput.GetDown(OVRInput.RawButton.X))))
            {
                LeftRender.positionCount     = 0;
                portal.transform.position    = new Vector3(hitleft.point.x, hitleft.point.y + 3, hitleft.point.z);
                portal.transform.rotation    = cameraRotate.transform.rotation;
                CameraRig.transform.position = new Vector3(hitleft.point.x, hitleft.point.y + 50, hitleft.point.z);
                CameraRig.transform.LookAt(cameraRotate);

                task    = true;
                hit     = false;
                raycast = false;
            }

            if (task && !teleportBack)
            {
                LeftRender.positionCount  = 2;
                RightRender.positionCount = 2;
                Tasks();
            }

            if (selectedObject && reldist != 0)
            {
                reldist += leftJoystick.y;
                selectedObject.transform.position = leftController.transform.position + (leftController.transform.forward * reldist);
            }

            if (teleportBack)
            {
                LeftRender.positionCount  = 0;
                RightRender.positionCount = 0;
                TaskMenu.SetActive(false);
                tm.text = "  Go to the Portal Device" + System.Environment.NewLine + "Use Right Joystick to Move the Player";

                if (rightJoystick.y < 0.0f)
                {
                    CameraRig.transform.position = Vector3.MoveTowards(CameraRig.transform.position, -CameraRig.transform.forward, 10 * Time.deltaTime);
                }
                else if (rightJoystick.y > 0.0f)
                {
                    CameraRig.transform.position = Vector3.MoveTowards(CameraRig.transform.position, CameraRig.transform.forward, 10 * Time.deltaTime);
                }

                if (Vector3.Distance(CameraRig.transform.position, portal.transform.position) < 37)
                {
                    tm.text = "                 Press Y to Teleport";
                    if (Input.GetKeyDown(KeyCode.Y) || (OVRInput.GetDown(OVRInput.RawButton.Y)))
                    {
                        Debug.Log("Teleport Back");


                        CameraRig.transform.position = cameraSpaceshipLocation.position;
                        CameraRig.transform.rotation = cameraSpaceshipLocation.rotation;
                        portal.transform.position    = portalSpaceshipLocation.position;
                        portal.transform.rotation    = portalSpaceshipLocation.rotation;

                        leftController.rotation  = cameraSpaceshipLocation.rotation;
                        rightController.rotation = cameraSpaceshipLocation.rotation;

                        changeScript = true;

                        SpaceshipMovementScript         = transform.GetComponent <SpaceshipMovement>();
                        SpaceshipMovementScript.enabled = true;

                        SpaceshipMovementScript.cargoMenu.GetComponent <TextMesh>().gameObject.SetActive(true);
                        SpaceshipMovementScript.cargoMenu.GetComponent <TextMesh>().text = "Use W, A, S, D or Left Joystick to Fly Spaceship";

                        teleportText.SetActive(false);

                        canvas.gameObject.SetActive(true);

                        transform.GetComponent <Teleport>().enabled = false;
                    }
                }
            }
            if (ExceptionOccured)
            {
                tm.text = "Updata(): " + ExceptionMessage;
            }
        }catch (Exception e)
        {
            ExceptionMessage = e.Message;
            ExceptionOccured = true;
        }
    }
Esempio n. 11
0
 void Awake()
 {
     spaceship      = GetComponent <Rigidbody2D> ();
     normalMovement = GetComponent <SpaceshipMovement> ();
     healthSystem   = GetComponent <Health> ();
 }