Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class JoysticManager : MonoBehaviour {
  5.  
  6.     public int walkID ;
  7.     public int attackID ;
  8.     public bool isWalking;
  9.     public bool isAttacking;
  10.     Touch[] touches;
  11.     private void Start()
  12.     {
  13.         isAttacking = false;
  14.         isWalking = false;
  15.         walkID = -1;
  16.         attackID = -1;
  17.     }
  18.  
  19.     private void Update()
  20.     {
  21.  
  22.         for(int i = 0; i < Input.touchCount; i++)
  23.         {
  24.             Touch touch = Input.GetTouch(i);
  25.  
  26.             if(touch.phase ==  TouchPhase.Began)
  27.                 {
  28.                     if (isWalking == true)
  29.                     {
  30.                         walkID = i;
  31.                     //инверт для другого
  32.                         if (isAttacking != true)
  33.                         {
  34.                             attackID = 1 - i;
  35.                         }
  36.                     //Debug.Log("new i:" + i.ToString());
  37.                         continue;
  38.                     }
  39.                
  40.                     if (isAttacking == true)
  41.                     {
  42.                         attackID = i;
  43.                     //инверт для другого
  44.                         if (isWalking != true)
  45.                         {
  46.                             walkID = 1 - i;
  47.                         }
  48.                     // Debug.Log("new i:" + i.ToString());
  49.                     }
  50.                 }
  51.  
  52.         }
  53.     }
  54.  
  55.     public void Attack()
  56.     {
  57.         isAttacking = true;
  58.     }
  59.  
  60.     public void StartMove()
  61.     {
  62.         isWalking = true;
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement