Ejemplo n.º 1
0
    void Start()
    {
        target = GameObject.Find("TorpedoSpawn").GetComponent <Transform> ();
        offset = transform.position - target.position;

        explosion      = transform.GetChild(0).gameObject;
        explosionSound = transform.GetChild(1).gameObject.GetComponent <AudioSource> ();
        whooshSound    = transform.GetChild(2).gameObject.GetComponent <AudioSource> ();
        explosion.SetActive(false);
        rb = GetComponent <Rigidbody2D> ();

        // Joysticks
        if (GameObject.Find("LeftJoystick") != null)
        {
            leftJoystick = GameObject.Find("LeftJoystick").transform.GetChild(0)
                           .GetComponent <LeftJoystick> ();
        }
        if (GameObject.Find("RightJoystick") != null)
        {
            rightJoystick = GameObject.Find("RightJoystick").transform.GetChild(0)
                            .GetComponent <RightJoystick> ();
        }

        // Ignore collisions between Player
        Physics2D.IgnoreCollision(GetComponent <Collider2D> ()
                                  , GameObject.Find("Player").GetComponent <Collider2D> ());

        if ((GameObject.Find("LeftJoystick") != null) || (GameObject.Find("RightJoystick") != null))
        {
            moveVec = new Vector2(rightJoystick.inputVec.x, rightJoystick.inputVec.y);
        }

        StartCoroutine("Scale");
    }
Ejemplo n.º 2
0
 protected override void Start()
 {
     base.Start();
     controller    = GetComponent <PlayerController>();
     gunController = GetComponent <GunController>();
     leftJoystick  = FindObjectOfType <LeftJoystick>();
     rightJoystick = FindObjectOfType <RightJoystick>();
 }
Ejemplo n.º 3
0
 public void PollInput()
 {
     LeftJoystick.Poll();
     RightJoystick.Poll();
     Button01.Poll();
     Button02.Poll();
     Button03.Poll();
     Button04.Poll();
 }
Ejemplo n.º 4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        RightJoystick rb = collision.GetComponent <RightJoystick>();

        if (collision.gameObject.CompareTag("Player"))
        {
            audio.Play();
            rb.kecepatanTembak(0.1f);
            Destroy(gameObject, 0.1f);
        }
    }
    private int rightSideFingerID = 0;              // unique finger id for touches on the right-side half of the screen

    void Start()
    {
        if (leftJoystickBackgroundImage.GetComponent <LeftJoystick>() == null)
        {
            Debug.LogError("There is no LeftJoystick script attached to the Left Joystick game object.");
        }
        else
        {
            leftJoystick = leftJoystickBackgroundImage.GetComponent <LeftJoystick>(); // gets the left joystick script
            leftJoystickBackgroundImage.enabled = leftJoystickAlwaysVisible;          // sets left joystick background image to be always visible or not
        }

        if (leftJoystick.transform.GetChild(0).GetComponent <Image>() == null)
        {
            Debug.LogError("There is no left joystick handle image attached to this script.");
        }
        else
        {
            leftJoystickHandleImage         = leftJoystick.transform.GetChild(0).GetComponent <Image>(); // gets the handle (knob) image of the left joystick
            leftJoystickHandleImage.enabled = leftJoystickAlwaysVisible;                                 // sets left joystick handle (knob) image to be always visible or not
        }


        if (rightJoystickBackgroundImage.GetComponent <RightJoystick>() == null)
        {
            Debug.LogError("There is no RightJoystick script attached to Right Joystick game object.");
        }
        else
        {
            rightJoystick = rightJoystickBackgroundImage.GetComponent <RightJoystick>(); // gets the right joystick script
            rightJoystickBackgroundImage.enabled = rightJoystickAlwaysVisible;           // sets right joystick background image to be always visible or not
        }

        if (rightJoystick.transform.GetChild(0).GetComponent <Image>() == null)
        {
            Debug.LogError("There is no right joystick handle attached to this script.");
        }
        else
        {
            rightJoystickHandleImage         = rightJoystick.transform.GetChild(0).GetComponent <Image>(); // gets the handle (knob) image of the right joystick
            rightJoystickHandleImage.enabled = rightJoystickAlwaysVisible;                                 // sets right joystick handle (knob) image to be always visible or not
        }
    }
 private void Start()
 {
     if (rightJoystickBackgroundImage.GetComponent <RightJoystick>() == null)
     {
         UnityEngine.Debug.LogError("There is no RightJoystick script attached to Right Joystick game object.");
     }
     else
     {
         rightJoystick = rightJoystickBackgroundImage.GetComponent <RightJoystick>();
         rightJoystickBackgroundImage.enabled = rightJoyStickAlwaysVisible;
     }
     if (rightJoystick.transform.GetChild(0).GetComponent <Image>() == null)
     {
         UnityEngine.Debug.LogError("There is no right joystick handle attached to this script.");
         return;
     }
     rightJoystickHandleImage         = rightJoystick.transform.GetChild(0).GetComponent <Image>();
     rightJoystickHandleImage.enabled = rightJoyStickAlwaysVisible;
 }
Ejemplo n.º 7
0
    public void Start()
    {
        health = 100;
        System.Random r = new System.Random();

        if (controllable)
        {
            GameObject cam = GameObject.FindGameObjectWithTag("MainCamera");
            cam.transform.position = this.transform.position;
            cam.GetComponent <CameraFollow>().target = transform;
        }

        leftJoystick  = GameObject.FindGameObjectWithTag("LeftJoystick").GetComponent <LeftJoystick>();
        rightJoystick = GameObject.FindGameObjectWithTag("RightJoystick").GetComponent <RightJoystick>();

        if (items == null)
        {
            items = new Items();
        }

        SetGun(gun);

        foreach (Transform t in transform)
        {
            if (t.name == "Trigger")
            {
                d = t.GetComponent <Detector>();
            }
        }

        leftArm  = getChild(selected.transform, "Left");
        rightArm = getChild(selected.transform, "Right");

        if (controllable)
        {
            StartCoroutine("ticker");
        }
    }
Ejemplo n.º 8
0
    private void Start()
    {
        agent = GetComponent <NavMeshAgent>();
        Debug.Assert(agent != null);

        animator = GetComponentInChildren <Animator>();
        Debug.Assert(animator != null);

        mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
        Debug.Assert(mainCamera != null);

        bulletContainer = GameObject.FindGameObjectWithTag("BulletContainer");
        Debug.Assert(bulletContainer != null);

        leftJoystickController = LeftJoystick.GetComponent <LeftJoystick>();
        Debug.Assert(leftJoystickController != null);

        rightJoystickController = RightJoystick.GetComponent <RightJoystick>();
        Debug.Assert(rightJoystickController != null);

        initCameraPosition = mainCamera.transform.position;
        initPersonPosition = gameObject.transform.position;
    }
Ejemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        if (_Character.Muerto)
        {
            return;
        }

        _LeftJoystick  = GameManager.GameManagerInstance._UiManager.TouchController.leftJoystickBackgroundImage.GetComponent <LeftJoystick>();
        _RightJoystick = GameManager.GameManagerInstance._UiManager.TouchController.rightJoystickBackgroundImage.GetComponent <RightJoystick>();

        if (GameManager.GameManagerInstance.ActualNivel == GameManager.GameManagerInstance.e_Nivel01 && _Character.EnMovimiento)
        {
            MovimientoCharEnXY();

            MovimientoCrossHair2();
        }
        if (GameManager.GameManagerInstance.ActualNivel == GameManager.GameManagerInstance.e_Nivel02 && _Character.EnMovimiento)
        {
            MovimientoCharEnXYTunel();

            MovimientoCrossHair2();
        }
    }
Ejemplo n.º 10
0
 private void Start()
 {
     RJ            = GameObject.Find("Right Joystick").GetComponent <RightJoystick>();
     mobileSupport = mobileSupportScript.mobileSupport;
 }
    private Vector2 bgImageStartPosition;                // used to temporarily store the starting position of the joystick's background image (where it was placed on the canvas in the editor before play was pressed) in order to set the image back to this same position after setting the pivot to the bottom right corner of the image

    public RightJoystick()
    {
        Instance = this;
    }