Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class JoysticManager : MonoBehaviour {
- public int walkID ;
- public int attackID ;
- public bool isWalking;
- public bool isAttacking;
- Touch[] touches;
- private void Start()
- {
- isAttacking = false;
- isWalking = false;
- walkID = -1;
- attackID = -1;
- }
- private void Update()
- {
- for(int i = 0; i < Input.touchCount; i++)
- {
- Touch touch = Input.GetTouch(i);
- if(touch.phase == TouchPhase.Began)
- {
- if (isWalking == true)
- {
- walkID = i;
- //инверт для другого
- if (isAttacking != true)
- {
- attackID = 1 - i;
- }
- //Debug.Log("new i:" + i.ToString());
- continue;
- }
- if (isAttacking == true)
- {
- attackID = i;
- //инверт для другого
- if (isWalking != true)
- {
- walkID = 1 - i;
- }
- // Debug.Log("new i:" + i.ToString());
- }
- }
- }
- }
- public void Attack()
- {
- isAttacking = true;
- }
- public void StartMove()
- {
- isWalking = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement