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
    // Start is called before the first frame update
    void Start()
    {
        mobileSupport = mobileSupportScript.mobileSupport;
        speedstore    = speed;
        PV            = GetComponent <PhotonView>();
        TC            = GameObject.Find("GameCanvas").transform.GetChild(0).GetComponent <TimerControler>();
        if (PV.Owner.NickName != "")
        {
            UserNameText.text = PV.Owner.NickName;
        }
        else if (PV.IsMine)
        {
            UserNameText.text = "Player " + Random.Range(0, 1000);
            PV.RPC("SetNameRPC", RpcTarget.All, UserNameText.text);
        }

        if (!PV.IsMine)
        {
            Destroy(GetComponent <Rigidbody>());
            return;
        }
        Camera = Instantiate(cam);
        Camera.GetComponent <CameraFollow>().CameraFollowObj = transform.GetChild(0).gameObject;
        rb         = GetComponent <Rigidbody>();
        controller = GetComponent <CharacterController>();
        co.Add(StartCoroutine(check()));
        //TC.addToTotal(5);
        LJ = GameObject.Find("Left Joystick").GetComponent <LeftJoystick>();
    }
 void Awake()
 {
     if (global == null)
     {
         global          = this;
         fadeHandler     = transform.Find("Fade").GetComponent <ScreenFade>();
         mapHandler      = transform.Find("Map").GetComponent <MapHandler>();
         pauseHandler    = transform.Find("Pause").gameObject;
         settingsHandler = transform.Find("Settings").GetComponent <SettingsHandler>();
         copyright       = transform.Find("Text").GetComponent <TextMeshProUGUI>();
         joystick        = transform.Find("GameButtons").Find("Left Joystick").GetComponent <LeftJoystick>();
         bgmHandler      = GetComponent <BgmHandler>();
         #if UNITY_ANDROID
         Debug.Log("Android");
         #else
         joystick.gameObject.SetActive(false);
         transform.Find("GameButtons").Find("Jump").gameObject.SetActive(false);
         #endif
         if (!isIntro)
         {
             digitalGlitch    = GameObject.FindWithTag("MainCamera").GetComponent <DigitalGlitch>();
             analogGlitch     = GameObject.FindWithTag("MainCamera").GetComponent <AnalogGlitch>();
             postProcessing   = GameObject.FindWithTag("Post Processing").GetComponent <PostProcessVolume>();
             postProcessLayer = GameObject.FindWithTag("MainCamera").GetComponent <PostProcessLayer>();
         }
         if (SceneManager.GetActiveScene().name != "title")
         {
             StartCoroutine(fadeHandler.Fade(true, 0.5f));
             if (busy)
             {
                 StartCoroutine(FadeAndUnbusy());
             }
         }
     }
 }
Ejemplo n.º 4
0
 protected override void Start()
 {
     base.Start();
     controller    = GetComponent <PlayerController>();
     gunController = GetComponent <GunController>();
     leftJoystick  = FindObjectOfType <LeftJoystick>();
     rightJoystick = FindObjectOfType <RightJoystick>();
 }
Ejemplo n.º 5
0
 public void PollInput()
 {
     LeftJoystick.Poll();
     RightJoystick.Poll();
     Button01.Poll();
     Button02.Poll();
     Button03.Poll();
     Button04.Poll();
 }
    protected override void Awake()
    {
        base.Awake();
        GameManager.instance.Player = gameObject.transform;
        _particleSystem             = GetComponentInChildren <ParticleSystem>();
        _playerAttack   = GetComponent <PlayerAttack>();
        protectedShield = GetComponent <ProtectedShield>();
        damageShield    = GetComponent <DamageShield>();
        rigidbody       = GetComponent <Rigidbody2D>();

        _joystick = GameObject.FindGameObjectWithTag("joystick").GetComponent <LeftJoystick>();
    }
Ejemplo n.º 7
0
    // Use this for initialization
    void Awake()
    {
        canMove         = true;
        myRigidBody     = GetComponent <Rigidbody2D>();
        myAnim          = GetComponent <Animator>();
        respawnPosition = transform.position;
        theLevelManager = FindObjectOfType <LevelManager>();

        if (joystick == true)
        {
            leftJoystick = FindObjectOfType <LeftJoystick>();
        }
    }
Ejemplo n.º 8
0
    protected override IMoveController CreateMoveController()
    {
        GameObject leftJoystickObj = GameObject.FindGameObjectWithTag("LeftJoystick");

        if (leftJoystickObj == null)
        {
            return(null);
        }

        LeftJoystick leftJoystick = leftJoystickObj.GetOrAddComponent <LeftJoystick> ();

        leftJoystick.joystickStaysInFixedPosition = true;

        return(new LeftJoystickMoveController(leftJoystick));
    }
    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
        }
    }
Ejemplo n.º 10
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.º 11
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.º 12
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.º 13
0
 private void Start()
 {
     if (leftJoystickBackgroundImage.GetComponent <LeftJoystick>() == null)
     {
         UnityEngine.Debug.LogError("There is no LeftJoystick script attached to the Left Joystick game object.");
     }
     else
     {
         leftJoystick = leftJoystickBackgroundImage.GetComponent <LeftJoystick>();
         leftJoystickBackgroundImage.enabled = leftJoystickAlwaysVisible;
     }
     if (leftJoystick.transform.GetChild(0).GetComponent <Image>() == null)
     {
         UnityEngine.Debug.LogError("There is no left joystick handle image attached to this script.");
     }
     else
     {
         leftJoystickHandleImage         = leftJoystick.transform.GetChild(0).GetComponent <Image>();
         leftJoystickHandleImage.enabled = leftJoystickAlwaysVisible;
     }
     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.º 14
0
    private void Start()
    {
        if (GetComponent <Image>() == null)
        {
            Debug.LogError("There is no joystick image attached to this script.");
        }

        if (transform.GetChild(0).GetComponent <Image>() == null)
        {
            Debug.LogError("There is no joystick handle image attached to this script.");
        }

        if (GetComponent <Image>() != null && transform.GetChild(0).GetComponent <Image>() != null)
        {
            bgImage           = GetComponent <Image>();                       // gets the background image of this joystick
            joystickKnobImage = transform.GetChild(0).GetComponent <Image>(); // gets the joystick "knob" imae (the handle of the joystick), the joystick knob game object must be a child of this game object and have an image component
            //bgImage.rectTransform.SetAsLastSibling(); // ensures that this joystick will always render on top of other UI elements
            bgImage.rectTransform.GetWorldCorners(fourCornersArray);          // fills the fourCornersArray with the world space positions of the four corners of the background image of this joystick

            bgImageStartPosition        = fourCornersArray[3];                // saves the world space position of the bottom right hand corner of the background image of this joystick as the image was placed on the canvas before play was pressed
            bgImage.rectTransform.pivot = new Vector2(1, 0);                  // places the bottom right corner of background image of this joystick onto the pivot (wherever it may be in the canvas)

            bgImage.rectTransform.anchorMin = new Vector2(0, 0);              // sets the min anchors to the lower left corner of the canvas
            bgImage.rectTransform.anchorMax = new Vector2(0, 0);              // sets the max anchors to the lower left corner of the canvas
            bgImage.rectTransform.position  = bgImageStartPosition;           // sets the background image of this joystick back to the same position it was on the canvas before play was pressed

            if (intance == null)
            {
                intance = this;
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }
Ejemplo n.º 15
0
    private Rigidbody rigidBody;       // rigid body component of the player character

    // Use this for initialization
    void Start()
    {
        leftJoystick = GameObject.FindGameObjectWithTag("Joystick").GetComponentsInChildren <LeftJoystick>()[0];
        rigidBody    = gameObject.GetComponentsInChildren <Rigidbody>()[0];
        //animator= gameObject.GetComponentsInChildren<Animator>()[0];
    }
 public LeftJoystickMoveController(LeftJoystick joystick)
 {
     this.joystick = joystick;
 }
    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

    void Awake()
    {
        instance = this;
    }
    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

    void Awake()
    {
        Instance = this;
    }
Ejemplo n.º 19
0
 void Start()
 {
     leftJoystick = FindObjectOfType <LeftJoystick>();
     limiteYp.y   = -30f;
     limiteYn.y   = 60f;
 }