상속: MonoBehaviour, IDragHandler, IPointerUpHandler, IPointerDownHandler
예제 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.GetComponent <Player>())
        {
            if (collision.GetComponent <Player>() != null)
            {
                //Enable the button
                DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_door");
                if (!d.active)
                {
                    VirtualJoystick.EnableDynamicButton(d);
                    d.button.onClick.AddListener(() =>
                    {
                        OpenDoor();
                        VirtualJoystick.DisableDynamicButton(d);
                    });
                }
            }
        }

        if (collision.gameObject.GetComponent <ItemBase>() != null)
        {
            if (collision.gameObject.GetComponent <ItemBase>().thrown&& !collision.gameObject.GetComponent <ItemBase>().isFromEnemy)
            {
                OpenDoor();
            }
        }
    }
예제 #2
0
 void IObservable <VirtualJoystickArgs> .Notify(VirtualJoystickArgs eventArgs)
 {
     if (VirtualJoystick != null)
     {
         VirtualJoystick.Invoke(this, eventArgs);
     }
 }
예제 #3
0
    void AbsorbCharacter()
    {
        //Enable the virtual joystick button by checking the target's status
        Enemy e = DetectCharacter();

        if (e != null)
        {
            if (e.IsStunned())
            {
                //Enable Absorb Button
                if (absorbButton == null && !absorbing && !player.userInputs.absorbPressed)
                {
                    EnableAbsorbButton();
                }

                if (player.userInputs.absorbPressed)
                {
                    InitiateAbsorb(e, 3.0f);
                }
            }
            else if (absorbButton != null && !absorbing)
            {
                Debug.Log("Character is not stunned");
                VirtualJoystick.DisableDynamicButton(absorbButton);
                absorbButton = null;
            }
        }
        else if (absorbButton != null && !absorbing)
        {
            Debug.Log("character is null");
            VirtualJoystick.DisableDynamicButton(absorbButton);
            absorbButton = null;
        }
    }
예제 #4
0
 private void FixedUpdate()
 {
     this.joystick = UnityEngine.Object.FindObjectOfType <VirtualJoystick>();
     this.dir      = new Vector2(this.joystick.Horizontal(), this.joystick.Vertical());
     this.Rotate();
     this.Shoot();
 }
예제 #5
0
 void Start()
 {
     rbody   = GetComponent <Rigidbody2D> ();
     anim    = GetComponent <Animator> ();
     canMove = true;
     vJoy    = GetComponent <VirtualJoystick>();
 }
예제 #6
0
    // Use this for initialization
    void Start()
    {
        Top   = GameObject.Find("Top").transform;        // eles estao sendo encotrados pelo find pq o player n fica na cena
        Down  = GameObject.Find("Down").transform;
        Left  = GameObject.Find("Left").transform;
        Rigth = GameObject.Find("Rigth").transform;

        joystick    = FindObjectOfType(typeof(VirtualJoystick)) as VirtualJoystick;
        script_GC   = FindObjectOfType(typeof(_GC)) as _GC;
        scriptAudio = FindObjectOfType(typeof(Audio)) as Audio;
        scriptArma  = FindObjectOfType(typeof(armaNave)) as armaNave;

        playerRb       = GetComponent <Rigidbody2D> ();
        animatorPlayer = GetComponent <Animator> ();
        playerSR       = GetComponent <SpriteRenderer> ();
        animatorEscudo.SetBool("escudoAtivado", true);

        barraVida            = GameObject.Find("barra_Vida").transform; // para encontrar a barra via script
        barraVida.localScale = new Vector3(1, 1, 1);                    // atualiza a barra quando morre

        HPatual  = HpMax;
        Hpescudo = HPmaximoEscudo;

        armasExtras [poewrUpColetados].SetActive(true);

        //inicia com o jogador invuneravel e depois chama a funcao para tornar vuneravel de novo
        this.gameObject.layer = 10;
        this.gameObject.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0.5f);
        StartCoroutine("vuneravel");

        //deixa o icone visivel
        //iconeItemEspecial.GetComponent<SpriteRenderer> ().enabled = true;
    }
예제 #7
0
        public override void onAddedToEntity()
        {
            _player = entity as Player;

            // Keyboard player
            if (_gp == null)
            {
                // Virtual mouse joystick
                _mouseJoystick = new VirtualMouseJoystick(_player.position);

                // Virtual joysticks
                _leftStick  = new VirtualJoystick(false);
                _rightStick = new VirtualJoystick(true);

                // Buttons
                _fireButton         = new VirtualButton();
                _reloadButton       = new VirtualButton();
                _dropGunButton      = new VirtualButton();
                _debugButton        = new VirtualButton();
                _interactButton     = new VirtualButton();
                _switchWeaponButton = new VirtualButton();
                _sprintButton       = new VirtualButton();

                _leftStick.addKeyboardKeys(VirtualInput.OverlapBehavior.CancelOut, Keys.A, Keys.D, Keys.S, Keys.W);
                _rightStick.nodes.Add(_mouseJoystick);
                _fireButton.addMouseLeftButton();
                _reloadButton.addKeyboardKey(Keys.R);
                _interactButton.addKeyboardKey(Keys.E);
                _dropGunButton.addKeyboardKey(Keys.G);
                _debugButton.addKeyboardKey(Keys.F2);
                _switchWeaponButton.addKeyboardKey(Keys.Q);
                _sprintButton.addKeyboardKey(Keys.LeftShift);
            }
        }
예제 #8
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.gameObject.GetComponent <Player>())
     {
         VirtualJoystick.DisableDynamicButton("tag_door");
     }
 }
예제 #9
0
    void OnTriggerStay2D(Collider2D collider)
    {
        if (gameObject.tag == "tag_ladder")
        {
            Player p = collider.GetComponent <Player>();
            if (p != null)
            {
                //Debug.Log("Player detected");
                playerOnFocus = p;
                if (p.State.Equals(typeof(IdleState)))
                {
                    //Enable the button
                    DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_ladder");
                    if (!d.active)
                    {
                        VirtualJoystick.EnableDynamicButton(d);
                        d.button.onClick.AddListener(() =>
                        {
                            p.userInputs.climbPressed = true;

                            if (p.State.Equals(typeof(ClimbingState)))
                            {
                                //Disable the button
                                VirtualJoystick.DisableDynamicButton(d);
                            }
                        });
                    }
                }
            }
        }
    }
예제 #10
0
    private void OnTriggerExit2D(Collider2D collider)
    {
        if (playerOnFocus != null)
        {
            if (collider.gameObject == playerOnFocus.gameObject)
            {
                playerOnFocus = null;

                //Disable the button
                VirtualJoystick.DisableDynamicButton("tag_item");
            }
        }

        //if(collider.tag == "tag_player")
        //{
        //
        //    promptPickUp = false;
        //    //Set the player to null only of the object is not picked up
        //    if (!pickedUp && collider.gameObject.GetComponent<PlayerMechanics>().itemPickedUp == null)
        //    {
        //        VirtualJoystick.pickUpButton.SetActive(false);
        //        playerMechanics = null;
        //    }
        //}
    }
    void Start()
    {
        r   = GetComponent <Rigidbody> ();
        cam = Camera.main;

        r.maxAngularVelocity       = 8;
        r.maxDepenetrationVelocity = 8;

        if (isLocalPlayer)
        {
            Renderer rend = transform.GetChild(0).GetChild(0).GetComponent <Renderer>();
            rend.material = bichoMulti;
            rend          = transform.GetChild(0).GetChild(1).GetComponent <Renderer>();
            rend.material = bichoMulti;
        }

        sonidos = GameObject.FindGameObjectWithTag("reproductor").GetComponent <ReproductorSonidos>();
        sonidos.ReproducirSonidoSpawn();

        planeta = GameObject.Find("planeta").transform;

                #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WEBGL
        joystickMovimiento = GameObject.Find("FondoJoystickMovimiento").GetComponent <VirtualJoystick>();
                #endif
    }
예제 #12
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        Player p = collider.GetComponent <Player>();

        if (p != null)
        {
            playerOnFocus = p;

            //Enable the button
            DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_item");
            if (!d.active)
            {
                VirtualJoystick.EnableDynamicButton(d);
                d.button.onClick.AddListener(() =>
                {
                    //p.userInputs.doorOpenPressed = true;

                    //Disable the button
                    VirtualJoystick.DisableDynamicButton(d);
                });
            }
        }

        //if(collider.tag == "tag_player")
        //{
        //    promptPickUp = true;
        //    playerMechanics = collider.gameObject.GetComponent<PlayerMechanics>();
        //
        //    //Enable the button on the controls canvas
        //    VirtualJoystick.pickUpButton.SetActive(true);
        //    //Set the sprite to pick up sprite
        //    if(playerMechanics.itemPickedUp == null)
        //        VirtualJoystick.pickUpButton.GetComponent<UnityEngine.UI.Image>().sprite = VirtualJoystick.pickUpButton.GetComponent<PickUpButton>().pickupSprite;
        //}
    }
예제 #13
0
        public static void Begin(Level self)
        {
            if (Settings.Enabled)
            {
                PlayerTwoDash = new VirtualButton();
                PlayerTwoDash.Nodes.Add(new VirtualButton.KeyboardKey(Keys.J));
                PlayerTwoJump = new VirtualButton();
                PlayerTwoJump.Nodes.Add(new VirtualButton.KeyboardKey(Keys.K));
                PlayerTwoGrab = new VirtualButton();
                PlayerTwoGrab.Nodes.Add(new VirtualButton.KeyboardKey(Keys.H));
                PlayerTwoMoveX = new VirtualIntegerAxis();
                PlayerTwoMoveX.Nodes.Add(new VirtualAxis.KeyboardKeys(VirtualInput.OverlapBehaviors.TakeNewer, Keys.NumPad4, Keys.NumPad6));
                PlayerTwoMoveY = new VirtualIntegerAxis();
                PlayerTwoMoveY.Nodes.Add(new VirtualAxis.KeyboardKeys(VirtualInput.OverlapBehaviors.TakeNewer, Keys.NumPad8, Keys.NumPad5));
                PlayerTwoAim = new VirtualJoystick(true);
                PlayerTwoAim.Nodes.Add(new VirtualJoystick.KeyboardKeys(VirtualInput.OverlapBehaviors.TakeNewer, Keys.NumPad4, Keys.NumPad6, Keys.NumPad8, Keys.NumPad5));

                Player    P1        = Celeste.Scene.Entities.FindFirst <Player>();
                PlayerTwo Madeline2 = new PlayerTwo(P1.Position, PlayerSpriteMode.MadelineNoBackpack)
                {
                    IntroType = PlayerTwo.IntroTypes.None
                };
                Celeste.Scene.Entities.Add(Madeline2);
            }

            orig_Begin(self);
        }
예제 #14
0
    public override void OnStartLocalPlayer()
    {
        GetComponent <MeshRenderer> ().material.color = Color.green;
        Camera.main.GetComponent <PlayerCamera> ().setTarget(gameObject.transform);
        this.joystick    = GameObject.FindGameObjectWithTag("Joystick");
        joystickBehavior = (VirtualJoystick)joystick.GetComponent(typeof(VirtualJoystick));

        arrowButton = (Button)GameObject.FindGameObjectWithTag("ArrowButton").GetComponent <Button> ();
        arrowButton.interactable = true;
        arrowButton.onClick.AddListener(Shoot);
        arrowGlow = (Image)GameObject.FindGameObjectWithTag("ArrowGlow").GetComponent(typeof(Image));


        taichiButton = (Button)GameObject.FindGameObjectWithTag("TaichiButton").GetComponent <Button> ();
        taichiButton.onClick.AddListener(Taichi);
        taichiGlow = (Image)GameObject.FindGameObjectWithTag("TaichiGlow").GetComponent(typeof(Image));

        healthImages[0] = (Image)GameObject.FindGameObjectWithTag("Life").GetComponent(typeof(Image));
        healthImages[1] = (Image)GameObject.FindGameObjectWithTag("Life2").GetComponent(typeof(Image));
        healthImages[2] = (Image)GameObject.FindGameObjectWithTag("Life3").GetComponent(typeof(Image));
        healthImages[3] = (Image)GameObject.FindGameObjectWithTag("Life4").GetComponent(typeof(Image));
        healthImages[4] = (Image)GameObject.FindGameObjectWithTag("Life5").GetComponent(typeof(Image));

        //gameOverOverlay = GameObject.FindGameObjectWithTag("GameOverOverlay");
        //gameOverOverlay.SetActive (false);
    }
예제 #15
0
    /// <summary>
    /// Update component
    /// </summary>
    public void Update(VirtualJoystick joystick, int id = 0)
    {
        // Determine whether the joystick is using a controller
        isUsingController = joystick.isUsingController;

        // Reset the axis position
        direction = Vector2.zero;

        // Update each axis
        xAxis.Update(joystick, id);
        yAxis.Update(joystick, id);

        // Update the button
        button.Update(joystick, id);

        // Set the position of the axis
        direction = new Vector2(xAxis, yAxis).normalized;

        if (isUsingController)
        {
            float h = Input.GetAxis("Controller " + (id + 1) + " " + controllerAnalog.ToString() + "X");
            float v = Input.GetAxis("Controller " + (id + 1) + " " + controllerAnalog.ToString() + "Y");
            direction = Vector2.ClampMagnitude(new Vector2(h, v), 1);
        }
    }
예제 #16
0
 void Awake()
 {
     DontDestroyOnLoad(this);
     joystick     = GameObject.FindGameObjectWithTag("GameController").GetComponent <VirtualJoystick> ();
     mouseControl = GameObject.FindGameObjectWithTag("MouseArea").GetComponent <MouseController> ();
     fire         = GameObject.FindGameObjectWithTag("FireButton").GetComponent <UIbuttons> ();
     reload       = GameManagers.Instance.ReloadButton;
 }
예제 #17
0
 void Start()
 {
     this.lifeManager = GameObject.FindObjectOfType <LifeManager>();
     joystick         = GameObject.FindObjectOfType <VirtualJoystick>();
     audioSource      = GetComponent <AudioSource>();
     timeCounter      = GameObject.FindObjectOfType <TimeCounter>();
     timeCounter.resetTime();
 }
예제 #18
0
    // Use this for initialization
    void Start()
    {
        //Get the Rigidbody component
        rb = GetComponent <Rigidbody>();

        //Get the VirtualJoystick component from the joystickBackground gameObject
        joystick = joystickBackground.GetComponent <VirtualJoystick>();
    }
예제 #19
0
 private void Update()
 {
     moveJoystick = GameObject.Find("VirtualJoystickContainer").GetComponent <VirtualJoystick>();
     if (Input.GetKeyDown("space"))
     {
         StartCoroutine(ShieldTimer());
     }
 }
예제 #20
0
 void Awake()
 {
     VJ        = FindObjectOfType <VirtualJoystick>();
     forward   = Camera.main.transform.forward;
     forward.y = 0;
     forward   = Vector3.Normalize(forward);
     right     = Quaternion.Euler(new Vector3(0, 90, 0)) * forward;
 }
예제 #21
0
 // Use this for initialization
 void Start()
 {
     joystick = GameObject.Find("Joystick").GetComponent <VirtualJoystick> ();
     GM       = GameObject.Find("Game Manager").GetComponent <GameManager>();
     SM       = GameObject.Find("Game Manager").GetComponent <ScoreManager>();
     GUINav   = GameObject.Find("UI Manager").GetComponent <GameGUINavigation>();
     _dest    = transform.position;
 }
예제 #22
0
 // Use this for initialization
 void Start()
 {
     col      = GetComponent <CircleCollider2D>();
     anim     = GetComponent <Animator>();
     instance = this;
     camSpeed = Camera.main.GetComponent <CameraController>().camSpeed;
     joystick = FindObjectOfType <VirtualJoystick>();
 }
    void SetupPlayerJoyStick()
    {
        GameObject canvas = GameObject.FindWithTag("MainCanvas");

        moveJoystick = Instantiate(moveJoystick_Prefab, Vector3.zero, Quaternion.identity) as VirtualJoystick;
        moveJoystick.transform.SetParent(canvas.transform);
        moveJoystick.transform.localScale = new Vector3(1, 1, 1);
        moveJoystick.GetComponent <RectTransform>().anchoredPosition = new Vector2(100, 100);
    }
예제 #24
0
 // Use this for initialization
 void Start()
 {
     velocidadeBase = velocidade;
     audio          = GetComponent <AudioSource> ();
     GameController = FindObjectOfType(typeof(_GC)) as _GC;
     playerRb       = GetComponent <Rigidbody2D> ();
     playerAnimator = GetComponent <Animator> ();
     joystick       = FindObjectOfType(typeof(VirtualJoystick)) as VirtualJoystick;
 }
예제 #25
0
            public Device(PPJoyPlugin plugin, VirtualJoystick joystick)
            {
                LowerRange = -1000;
                UpperRange = 1000;

                this.plugin        = plugin;
                Joystick           = joystick;
                setPressedStrategy = new SetPressedStrategy(OnPress, OnRelease);
            }
예제 #26
0
    void Start()
    {
        _rigidBody    = GetComponent <Rigidbody>();
        _playerHealth = GetComponent <PlayerHealth>();
        _mesh         = transform.FindChild("Model");
        _weapon       = GetComponentInChildren <Weapon>();

        _virtualJoystick = FindObjectOfType <VirtualJoystick>();
    }
예제 #27
0
    private void OnTriggerExit2D(Collider2D collider)
    {
        if (playerOnFocus != null && collider.gameObject == playerOnFocus.gameObject)
        {
            playerOnFocus = null;

            //Disable the button
            VirtualJoystick.DisableDynamicButton("tag_door");
        }
    }
예제 #28
0
파일: Player.cs 프로젝트: nBiped/DigOut
    //Cosas de Albert ;)


    void Start()
    {
        myRigidbody2D = this.GetComponent <Rigidbody2D>();

        myRigidbody2D.freezeRotation = true;
        myRigidbody2D.gravityScale   = 0;

        moveJoystick = GameObject.Find("VirtualJoystickContainer").GetComponent <VirtualJoystick>();
        drillButton  = GameObject.Find("VirtualDrillButton").GetComponent <VirtualDigButton>();
    }
예제 #29
0
        void SetupInput()
        {
            _thrustInput = new VirtualButton();
            _thrustInput.nodes.Add(new VirtualButton.KeyboardKey(Keys.Z));
            _thrustInput.nodes.Add(new VirtualButton.GamePadButton(0, Buttons.A));

            _leftStick = new VirtualJoystick(true);
            _leftStick.nodes.Add(new VirtualJoystick.PadLeftStick());
            _leftStick.nodes.Add(new VirtualJoystick.KeyboardKeys(VirtualInput.OverlapBehavior.TakeNewer, Keys.Left, Keys.Right, Keys.Up, Keys.Down));
        }
 void Start()
 {
     health   = 100;
     sound    = Sound.Instance;
     canMove  = true;
     block    = BlockButton.Instance;
     player   = Player.Instance;
     switcher = PlayerModelSwitcher.Instance;
     joystick = VirtualJoystick.Instance;
 }
예제 #31
0
    //================================================================================
    public override void OnInspectorGUI()
    {
        virtualJoystickScript = target as VirtualJoystick;

        EditorGUILayout.BeginHorizontal();
        {
            EditorGUILayout.PrefixLabel (" ");
            AddJoystick ();
            ToggleHelp ();
        }
        EditorGUILayout.EndHorizontal();

        ShowHelp ();

        int i = 0;
        bool removeItem = false;
        int itemToRemove = -1;
        bool moveItem = false;
        int itemToMove = -1;
        int itemMoveDirection = 0;
        foreach (VirtualJoystick.Joystick joystick in virtualJoystickScript.virtualJoysticks)
        {
            if (!joystick.isActive)
            {
                joystick.centerBackground = joystick.centerDefault;
                joystick.centerBackgroundNew = joystick.centerDefault;
                joystick.centerButton = joystick.centerDefault;
                joystick.centerButtonNew = joystick.centerDefault;
                joystick.sensitivityCurve = new AnimationCurve(new Keyframe(-1f, 1f), new Keyframe(0f, joystick.sensitivity), new Keyframe(1f, 1f));
                joystick.touchID = -1;
            }

            EditorGUILayout.BeginHorizontal();
            {
                joystick.showSettingsInInspector = EditorGUILayout.Foldout (joystick.showSettingsInInspector, "[" + (i+1) + "] " + joystick.name);
                joystick.enabled = EditorGUILayout.Toggle(" " ,joystick.enabled);
                if (GUILayout.Button("<"))
                {
                    moveItem = true;
                    itemToMove = i;
                    itemMoveDirection = -1;
                }
                if (GUILayout.Button(">"))
                {
                    moveItem = true;
                    itemToMove = i;
                    itemMoveDirection = 1;
                }
                EditorGUILayout.LabelField (" ", GUILayout.Width (8));
                if (GUILayout.Button("-"))
                {
                    removeItem = true;
                    itemToRemove = i;
                }
            }
            EditorGUILayout.EndHorizontal();

            if (joystick.showSettingsInInspector)
            {
                joystick.name = EditorGUILayout.TextField ("Name", joystick.name);
                EditorGUILayout.BeginHorizontal ();
                {
                    EditorGUILayout.PrefixLabel ("Background Texture");
                    joystick.backgroundTexture = EditorGUILayout.ObjectField(joystick.backgroundTexture,typeof(Texture),false) as Texture;
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal ();
                {
                    EditorGUILayout.PrefixLabel ("Button Texture");
                    joystick.buttonTexture = EditorGUILayout.ObjectField(joystick.buttonTexture,typeof(Texture),false) as Texture;
                }
                EditorGUILayout.EndHorizontal();

                if (joystick.backgroundTexture || joystick.buttonTexture)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Joystick size");
                        joystick.backgroundSize = EditorGUILayout.Slider(joystick.backgroundSize,0f,1f);
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Button size");
                        joystick.buttonSize = EditorGUILayout.Slider(joystick.buttonSize,0f,1f);
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        joystick.centerDefault = EditorGUILayout.Vector2Field("Center", joystick.centerDefault);
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Center X");
                        joystick.centerDefault.x = EditorGUILayout.Slider(joystick.centerDefault.x,0f,1f);
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Center Y");
                        joystick.centerDefault.y = EditorGUILayout.Slider(joystick.centerDefault.y,0f,1f);
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        joystick.axisMultiplier = EditorGUILayout.Vector2Field("Axis Multiplier", joystick.axisMultiplier);
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Sensitivity");
                        joystick.sensitivity = EditorGUILayout.Slider(joystick.sensitivity,0f,1f);
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Smoothing Time");
                        joystick.smoothingTime = EditorGUILayout.Slider(joystick.smoothingTime,0f,1f);
                    }
                    EditorGUILayout.EndHorizontal();

                    joystick.alwaysVisible = EditorGUILayout.Toggle("Always Visible",joystick.alwaysVisible);

                    joystick.autoUpdateEnabled = EditorGUILayout.Toggle("Auto Update",joystick.autoUpdateEnabled);
                    if (joystick.autoUpdateEnabled)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.PrefixLabel(" ");
                            joystick.autoUpdateGyroAccelScript = EditorGUILayout.ToggleLeft(" GyroAccelScript",joystick.autoUpdateGyroAccelScript);
                        }
                        EditorGUILayout.EndHorizontal();

                        // SendMessage: Axis

                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.PrefixLabel(" ");
                            if (GUILayout.Button ("+"))
                            {
                                joystick.autoUpdateAxisMessageReceivers.Add(new VirtualJoystick.SendMessageReceiver());
                                int last = joystick.autoUpdateAxisMessageReceivers.Count-1;
                                joystick.autoUpdateAxisMessageReceivers[last].messageReceiver = null;
                                joystick.autoUpdateAxisMessageReceivers[last].functionName = "Function to call";
                            }
                            EditorGUILayout.LabelField ("SendMessage: Axis");
                        }
                        EditorGUILayout.EndHorizontal();

                        int j = 0;
                        bool removeReceiver = false;
                        int receiverToRemove = -1;
                        foreach (VirtualJoystick.SendMessageReceiver receiver in joystick.autoUpdateAxisMessageReceivers)
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.PrefixLabel(" ");
                                if (GUILayout.Button("-"))
                                {
                                    removeReceiver = true;
                                    receiverToRemove = j;
                                }
                                receiver.messageReceiver = EditorGUILayout.ObjectField(receiver.messageReceiver,typeof(GameObject),true) as GameObject;
                            }
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.PrefixLabel(" ");
                                EditorGUILayout.LabelField ("",GUILayout.Width(20));
                                receiver.functionName = EditorGUILayout.TextField ("", receiver.functionName);
                            }
                            EditorGUILayout.EndHorizontal();
                            j++;
                        }
                        if (removeReceiver)
                        {
                            joystick.autoUpdateAxisMessageReceivers.RemoveAt(receiverToRemove);
                        }

                        // SendMessage: DoubleTap

                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.PrefixLabel(" ");
                            if (GUILayout.Button ("+"))
                            {
                                joystick.autoUpdateDoubleTapMessageReceivers.Add(new VirtualJoystick.SendMessageReceiver());
                                int last = joystick.autoUpdateDoubleTapMessageReceivers.Count-1;
                                joystick.autoUpdateDoubleTapMessageReceivers[last].messageReceiver = null;
                                joystick.autoUpdateDoubleTapMessageReceivers[last].functionName = "Function to call";
                            }
                            EditorGUILayout.LabelField ("SendMessage: DoubleTap");
                        }
                        EditorGUILayout.EndHorizontal();

                        j = 0;
                        removeReceiver = false;
                        receiverToRemove = -1;
                        foreach (VirtualJoystick.SendMessageReceiver receiver in joystick.autoUpdateDoubleTapMessageReceivers)
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.PrefixLabel(" ");
                                if (GUILayout.Button("-"))
                                {
                                    removeReceiver = true;
                                    receiverToRemove = j;
                                }
                                receiver.messageReceiver = EditorGUILayout.ObjectField(receiver.messageReceiver,typeof(GameObject),true) as GameObject;
                            }
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.PrefixLabel(" ");
                                EditorGUILayout.LabelField ("",GUILayout.Width(20));
                                receiver.functionName = EditorGUILayout.TextField ("", receiver.functionName);
                            }
                            EditorGUILayout.EndHorizontal();
                            j++;
                        }
                        if (removeReceiver)
                        {
                            joystick.autoUpdateDoubleTapMessageReceivers.RemoveAt(receiverToRemove);
                        }

                        // SendMessage: DoubleTapHold

                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.PrefixLabel(" ");
                            if (GUILayout.Button ("+"))
                            {
                                joystick.autoUpdateDoubleTapHoldMessageReceivers.Add(new VirtualJoystick.SendMessageReceiver());
                                int last = joystick.autoUpdateDoubleTapHoldMessageReceivers.Count-1;
                                joystick.autoUpdateDoubleTapHoldMessageReceivers[last].messageReceiver = null;
                                joystick.autoUpdateDoubleTapHoldMessageReceivers[last].functionName = "Function to call";
                            }
                            EditorGUILayout.LabelField ("SendMessage: DoubleTapHold");
                        }
                        EditorGUILayout.EndHorizontal();

                        j = 0;
                        removeReceiver = false;
                        receiverToRemove = -1;
                        foreach (VirtualJoystick.SendMessageReceiver receiver in joystick.autoUpdateDoubleTapHoldMessageReceivers)
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.PrefixLabel(" ");
                                if (GUILayout.Button("-"))
                                {
                                    removeReceiver = true;
                                    receiverToRemove = j;
                                }
                                receiver.messageReceiver = EditorGUILayout.ObjectField(receiver.messageReceiver,typeof(GameObject),true) as GameObject;
                            }
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.PrefixLabel(" ");
                                EditorGUILayout.LabelField ("",GUILayout.Width(20));
                                receiver.functionName = EditorGUILayout.TextField ("", receiver.functionName);
                            }
                            EditorGUILayout.EndHorizontal();
                            j++;
                        }
                        if (removeReceiver)
                        {
                            joystick.autoUpdateDoubleTapHoldMessageReceivers.RemoveAt(receiverToRemove);
                        }

                    }
                }
                //
                if (Application.isPlaying)
                {
                    EditorGUILayout.BeginHorizontal ();
                    {
                        EditorGUILayout.PrefixLabel ("Debug Info");
                        EditorGUILayout.LabelField ("axis = " + joystick.axis);
                    }
                    EditorGUILayout.EndHorizontal ();
                    EditorGUILayout.BeginHorizontal ();
                    {
                        EditorGUILayout.PrefixLabel (" ");
                        EditorGUILayout.LabelField ("angle = " + joystick.angle);
                    }
                    EditorGUILayout.EndHorizontal ();
                    EditorGUILayout.BeginHorizontal ();
                    {
                        EditorGUILayout.PrefixLabel (" ");
                        EditorGUILayout.LabelField ("magnitude = " + joystick.magnitude);
                    }
                    EditorGUILayout.EndHorizontal ();
                } // if (joystick.showDebugInfoInInspector)
            } // if (joystick.showSettingsInInspector)
            EditorGUILayout.Space();
            i++;
        } // foreach (VirtualJoystick.Joystick joystick in virtualJoystickScript.virtualJoysticks)

        if (removeItem)
        {
            virtualJoystickScript.virtualJoysticks.RemoveAt(itemToRemove);
        }
        if (moveItem)
        {
            int itemToSwap = Mathf.Clamp (itemToMove + itemMoveDirection, 0, i - 1);
            VirtualJoystick.Joystick tmpItem = virtualJoystickScript.virtualJoysticks[itemToSwap];
            virtualJoystickScript.virtualJoysticks[itemToSwap] =  virtualJoystickScript.virtualJoysticks[itemToMove];
            virtualJoystickScript.virtualJoysticks[itemToMove] =  tmpItem;
        }

        EditorGUILayout.Space ();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(virtualJoystickScript);
        }

        if (!Application.isPlaying) {
            foreach (VirtualJoystick.Joystick joystick in virtualJoystickScript.virtualJoysticks)
            {
                float sw = (float)Screen.width;
                float sh = (float)Screen.height;
                joystick.backgroundRect.width = (int)(joystick.backgroundSize * sw);
                joystick.backgroundRect.height = joystick.backgroundRect.width;
                joystick.backgroundRect.center = new Vector2 ((int)(sw * joystick.centerBackground.x), (int)(sh * (1f - joystick.centerBackground.y)));

                joystick.buttonRect.width = (int)(joystick.backgroundSize * joystick.buttonSize * sw);
                joystick.buttonRect.height = joystick.buttonRect.width;
                joystick.buttonRect.center = new Vector2 ((int)(sw * joystick.centerButton.x), (int)(sh * (1f - joystick.centerButton.y)));

                joystick.centerBackground = joystick.centerDefault;
                joystick.centerBackgroundNew = joystick.centerDefault;
                joystick.centerButton = joystick.centerDefault;
                joystick.centerButtonNew = joystick.centerDefault;
                joystick.sensitivityCurve = new AnimationCurve(new Keyframe(-1f, 1f), new Keyframe(0f, joystick.sensitivity), new Keyframe(1f, 1f));
                joystick.touchID = -1;
            }
        }
    }
예제 #32
0
파일: Walk.cs 프로젝트: albertus88/demo
 public void Init(float velocity,Transform player)
 {
     _velocity = velocity;
     _player = player;
     _vJ = GameObject.FindGameObjectWithTag ("Joystick").GetComponent<VirtualJoystick> ();
 }
예제 #33
0
            public Device(PPJoyPlugin plugin,  VirtualJoystick joystick)
            {
                LowerRange = -1000;
                UpperRange = 1000;

                this.plugin = plugin;
                Joystick = joystick;
                setPressedStrategy = new SetPressedStrategy(OnPress, OnRelease);
            }
예제 #34
0
	// The player's number gets added to the end of the button name. Check
	// Project Settings -> Input to see how they are layed out.
	public void SetupInputNames(bool aiOn, int difPlayNumber = 0)
	{
		// Button names are setup, now if this is AI, disable this script.
		// I just make sure I setup the button names first for safe keeping.
		if(aiOn || !Manager_Game.usingMobile)
			this.enabled = false;
        if(_charStatus.PlayerNumber <= Manager_Mobile.instance.virtualJoysticks.Count)
            _myVirtJoystick = Manager_Mobile.instance.virtualJoysticks[_charStatus.PlayerNumber - 1];
    }
예제 #35
0
 public void Start()
 {
     _movementJoystick = GetComponent<VirtualJoystick>();
     _character = GetComponent<CharacterController> ();
 }
 private void Awake()
 {
     currentJS = this;
 }