예제 #1
0
        private void HandleTouch()
        {
            if (Input.touchCount != 1)
            {
                return;
            }

            var touch = Input.touches[0];

            if (touch.phase == TouchPhase.Began)
            {
                DragStartPosition = touch.position;

                transform.position = DragStartPosition;
            }
            else if (touch.phase == TouchPhase.Moved)
            {
                Hook.transform.position = touch.position;
            }
            else if (touch.phase == TouchPhase.Ended)
            {
                Vector2 delta = touch.position - DragStartPosition;
                SlingShootValue.Value = new Vector2(
                    x: delta.x,
                    y: delta.y
                    );
                OnSlingShootEvent.Invoke();

                transform.position      = InitialZonePosition;
                Hook.transform.position = InitialHookPosition;

                AvailableTime = Time.time + SlingShootDelay.Value;
            }
        }
예제 #2
0
        protected override void Init()
        {
            var slingShootUnityEvent = new UnityEvent();

            slingShootUnityEvent.AddListener(new UnityAction(OnSlingShoot));
            SlingShootEvent.AddListener(slingShootUnityEvent);

            var energyDepletedUnityEvent = new UnityEvent();

            energyDepletedUnityEvent.AddListener(new UnityAction(OnEnergyDepleted));
            EnergyDepletedEvent.AddListener(energyDepletedUnityEvent);

            var winUnitytEvent = new UnityEvent();

            winUnitytEvent.AddListener(new UnityAction(OnWin));
            WinEvent.AddListener(winUnitytEvent);

            OnInfectiousChange += new System.Action <bool>((isInfected) =>
            {
                if (isInfected)
                {
                    InfectedEvent.Invoke();
                }
                else
                {
                    DeinfectedEvent.Invoke();
                }
            });
        }
예제 #3
0
파일: Serial.cs 프로젝트: etigui/led_matrix
 /// <summary>
 /// Check is the serial port changed => check every 2 sec
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 public void SerialPortPinChanged(object source, ElapsedEventArgs e)
 {
     string[] sp = GetSerialPort();
     if (!sp.SequenceEqual(_serialPort))
     {
         _serialPort = sp;
         SerialEvent?.Invoke(this, new EventArgs());
         Console.WriteLine("changed");
     }
 }
예제 #4
0
        public void OnCollide(ICollidable collidable, Vector2 delta)
        {
            PlayerPawn player = collidable as PlayerPawn;

            if (player == null)
            {
                return;
            }

            WinEvent.Invoke();
            gameObject.SetActive(false);
        }
예제 #5
0
파일: Serial.cs 프로젝트: etigui/led_matrix
        public Serial()
        {
            // Init serial port
            _serial = new SerialPort();
            SerialEvent?.Invoke(this, new EventArgs());

            // Init timer to handle serial port change
            _timerEvent          = new Timer();
            _serialPort          = GetSerialPort();
            _timerEvent.Elapsed += new ElapsedEventHandler(SerialPortPinChanged);
            _timerEvent.Interval = 2000;
            _timerEvent.Start();
        }
예제 #6
0
        public IEnumerator UpdateEnergyValue()
        {
            while (true)
            {
                yield return(new WaitForSeconds(1.0f));

                Energy.Value -= (IsInfected ? 2.0f : 1.0f) / GameTimeInSeconds;
                if (Energy.Value <= 0)
                {
                    break;
                }
            }

            EnergyDepleted.Invoke();
        }