Advertisement
Guest User

DDAA

a guest
Mar 31st, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6.  
  7. public class Run : MonoBehaviour {
  8.  
  9.     private Rigidbody2D rb2d;
  10.     public int startSpeed;
  11.     private string pressedKey;
  12.    
  13.  
  14.     // Use this for initialization
  15.     void Start () {
  16.         rb2d = GetComponent<Rigidbody2D>();
  17.     }
  18.  
  19.     void CheckSequence()
  20.     {
  21.             Debug.Log(pressedKey);
  22.         if(pressedKey.Contains("AA") || pressedKey.Contains("DD"))
  23.         {
  24.             Debug.Log("АТАС!");
  25.             pressedKey = "";
  26.         }
  27.     }
  28.  
  29.     void Update()
  30.     {
  31.         if (Input.GetKeyDown(KeyCode.D))
  32.         {
  33.             pressedKey += "D";
  34.             CheckSequence();
  35.  
  36.         }
  37.  
  38.         else if (Input.GetKeyDown(KeyCode.A))
  39.         {
  40.             pressedKey += "A";
  41.             CheckSequence();
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement