Наследование: MonoBehaviour
Пример #1
0
        private void Start()
        {
            tag   = "Player";
            trans = transform;
            StageManager sManager = StageManager.Instance;

            if (sManager)
            {
                sManager.PlayerTracker.Target = trans;
                sManager.BgPlacer.Target      = trans;
                swipe = sManager.Swipe;
                if (swipe)
                {
                    swipe.OnSwiping.RemoveListener(OnSwiping);
                    swipe.OnSwiping.AddListener(OnSwiping);
                    swipe.OnStartedSwipe.RemoveListener(OnStartedSwipe);
                    swipe.OnStartedSwipe.AddListener(OnStartedSwipe);
                    swipe.OnEndedSwipe.RemoveListener(OnEndedSwipe);
                    swipe.OnEndedSwipe.AddListener(OnEndedSwipe);
                }
                flick = sManager.Flick;
                if (flick)
                {
                    flick.OnFlick.RemoveListener(OnFlick);
                    flick.OnFlick.AddListener(OnFlick);
                }
            }
        }
Пример #2
0
    void Awake()
    {
        //Set up UI
        canvas        = FindObjectOfType <Canvas>();
        controllersUI = canvas.GetComponent <ControllersUI>();
        gameUI        = canvas.GetComponent <GameUI>();

        //Find map, player, and equip weapon
        mapGen = FindObjectOfType <MapGenerator>().GetComponent <MapGenerator>();
        Map map = mapGen.map;

        currentPlayer       = (Player)Instantiate(startPlayer, mapGen.CoordToPosition(map.mapSize.x / 2, 2), Quaternion.identity);
        weaponManager       = currentPlayer.transform.GetComponent <WeaponManager>();
        playerCurrentWeapon = weaponManager.EquipWeapon(weaponManager.startingWeaponIndex);
        //playerCurrentWeapon = weaponManager.allWeapons[weaponManager.startingWeaponIndex];

        //Setup audio
        Transform audioManager = FindObjectOfType <AudioManager>().transform;

        audioManager.position = currentPlayer.transform.position;
        audioManager.rotation = currentPlayer.transform.rotation;
        audioManager.parent   = currentPlayer.transform;

        //Set up controllers
        SwipeDetector swipeDetect = currentPlayer.GetComponent <SwipeDetector>();

        swipeDetect.aimJoystickArea          = controllersUI.AimJoystickArea;
        swipeDetect.aimJoystickRect          = controllersUI.AimJoystickRect;
        swipeDetect.attackJoystickRect       = controllersUI.AttackJoystickRect;
        swipeDetect.changeWeaponJoystickRect = controllersUI.ChangeWeaponRect;
        //Camera.main.GetComponent<CameraController>().SetTarget(currentPlayer.transform);
        Camera.main.GetComponent <CameraFollow>().SetTarget(currentPlayer.transform);
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        stateMachine = new StateMachine(false);
        BoardManager.Instance.Init();

        stateMachine.AddState(STATE_PRE_GAME, new List <int>()
        {
            STATE_IDLE
        }, preGameEnterHandler, preGameUpdateHandler, preGameExitHandler);
        stateMachine.AddState(STATE_INIT_BOARD, new List <int>()
        {
            STATE_PRE_GAME
        }, initBoardEnterHandler, initBoardUpdateHandler, initBoardExitHandler);
        stateMachine.AddState(STATE_IDLE, new List <int>()
        {
            STATE_INIT_BOARD, STATE_SPAWN_TILES
        }, idleEnterHandler, idleUpdateHandler, idleExitHandler);
        stateMachine.AddState(STATE_SPAWN_TILES, new List <int>()
        {
            STATE_IDLE, STATE_MOVE_TILES
        }, spawnTilesEnterHandler, spawnTilesUpdateHandler, spawnTilesExitHandler);
        stateMachine.AddState(STATE_MOVE_TILES, new List <int>()
        {
            STATE_IDLE
        }, moveTilesEnterHandler, moveTilesUpdateHandler, moveTilesExitHandler);

        stateMachine.SetInitialState(STATE_PRE_GAME);

        //deterministic (if needed) random number generator
        Random.seed = (int)System.DateTime.Now.Ticks;

        transform.position = new Vector3(-BoardManager.Instance.NumColumns * TileBehaviour.DISTANCE_BETWEEN_TILES_X / 2.0f + TileBehaviour.DISTANCE_BETWEEN_TILES_X * 0.5f, -BoardManager.Instance.NumRows * TileBehaviour.DISTANCE_BETWEEN_TILES_Y / 2.0f + TileBehaviour.DISTANCE_BETWEEN_TILES_Y * 0.5f);

        swipeDetector = GetComponent <SwipeDetector>();
    }
Пример #4
0
 private void Awake()
 {
     _endPoint      = gameObject.transform.position;
     Global.IsAlive = true;
     KeyMap.Load();
     swipeDetector = GameManager.instance.swipeDetector;
     swipeDetector.onSwipeDetected += OnSwipeDetected;
 }
Пример #5
0
 private void Awake()
 {
     swipeDetector = GetComponent<SwipeDetector> ();
     swipeDetector.onSwipeContinued = OnSwipeContinued;
     swipeDetector.useDelta = true;
     if (invertX) sensitivity.x *= -1.0f;
     if (invertY) sensitivity.y *= -1.0f;
 }
Пример #6
0
 private void Awake()
 {
     if (SwipeDetector.instance != null)
     {
         Destroy(gameObject);
         return;
     }
     SwipeDetector.instance = this;
 }
Пример #7
0
 // Use this for initialization
 void Start()
 {
     WorldGestion = GameObject.Find ("WorldGestion");
     WorldController = (World)WorldGestion.GetComponent(typeof(World));
     TouchDetector = GameObject.Find ("TouchDetector");
     SwipeScript = (SwipeDetector)TouchDetector.GetComponent(typeof(SwipeDetector));
     Player = GameObject.Find ("player");
     playerScript = (playerController)Player.GetComponent(typeof(playerController));
 }
Пример #8
0
 override protected void Start()
 {
     base.Start();
     controller    = GetComponent <PlayerController>();
     gunController = GetComponent <GunController>();
     swipeControl  = GetComponent <SwipeDetector>();
     animator      = GetComponent <Animator>();
     viewCamera    = Camera.main;
 }
Пример #9
0
    public void Init()
    {
        _swipeDetector          = new SwipeDetector();
        _swipeDetector.OnSwipe += SwipeDetector_OnSwipe;

        _swipeAction = new SwipeAction();

        //TODO: Remove this. Input should be enabled from game controller.
        EnableInput();
    }
Пример #10
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Пример #11
0
        public void RestartGame()
        {
            SwipeDetector.ClearOnSwipeListeners();
            ScoreManager.ResetCurrentScore();
            GameplayManager.StartNewGame();

            UIManager.ShowPanel(PanelType.InGame);
            UIManager.HidePanel(PanelType.GameOver);

            Time.timeScale = gameplayTimeScale;
        }
Пример #12
0
    override protected void Start()
    {
        base.Start();
        controller    = GetComponent <PlayerController>();
        weaponManager = GetComponent <WeaponManager>();
        swipeControl  = GetComponent <SwipeDetector>();
        anim          = GetComponentInChildren <Animator>();
        viewCamera    = Camera.main;
        spawnRect.SetOwner(transform);

        anim.SetInteger("weaponNum", weaponManager.EquipWeapon(weaponManager.startingWeaponIndex).weaponNum);
    }
Пример #13
0
    private void MovementWithChangeDirection()
    {
        var movementDirectionFromInput = SwipeDetector.GetDirectionFromSwipes();

        if (movementDirectionFromInput != Vector3.zero)
        {
            if (MovementDirection != Vector3.zero)
            {
                transform.position = new Vector3(Mathf.Round(transform.position.x), Mathf.Round(transform.position.y), Mathf.Round(transform.position.z));
            }
            MovementDirection = movementDirectionFromInput;
        }


        if (MovementDirection == Vector3.zero)
        {
            return;
        }

        if (animationSequence.Any())
        {
            animationSequence.ForEach(a => a.Kill());
            animationSequence.Clear();

            transform.localScale = Vector3.one;
            transform.position   = new Vector3(Mathf.Round(transform.position.x), Mathf.Round(transform.position.y), Mathf.Round(transform.position.z));
        }

        var newPositionInfo = MovementUtils.GetPosition(transform, MovementDirection, PlayerSpeed, positionOnPreviousFrame);

        transform.position = newPositionInfo.newPosition;
        if (newPositionInfo.nextTile?.TileType == TileType.Wall)
        {
            if (MovementUtils.CheckSpikesCollision(newPositionInfo.nextTile, MovementDirection))
            {
                //var camera = GamePlayPrefabsSettings.Prefabs.MainCamera;
                //camera.transform.SetParent(null);
                GameplaySettings.MainCamera.transform.SetParent(null);
                Destroy(transform.gameObject);
            }
            else
            {
                animationSequence = MovementUtils.DoWallCollisionAnimation(MovementDirection, transform, wallCollisionAnimationSpeed);
                animationSequence[0].AppendCallback(() => animationSequence.Clear());

                MovementDirection = Vector3.zero;
                WallCollisionEvent(gameObject);
            }
        }

        positionOnPreviousFrame = transform.position;
    }
Пример #14
0
    // Start is called before the first frame update
    void Start()
    {
        detector = new ClassicSwipeDetector();

        swipeRight = delegate {
            Debug.Log("swipe right");
            transform.position += Vector3.right / 20;
        };
        swipeLeft = delegate {
            Debug.Log("swipe left");
            transform.position += Vector3.left / 20;
        };
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (isLocalPlayer && character != null)
        {
            int i = character.x;
            int j = character.y;

            if (SwipeDetector.GetSwipeUp())
            {
                if (j + 1 < y && g.areConnected(matrix[i, j], matrix[i, j + 1]))
                {
                    player.transform.position = player.transform.position + transform.up * gap;
                    character.y = character.y + 1;
                }
                SwipeDetector.GestureCompleted();
            }

            if (SwipeDetector.GetSwipeDown())
            {
                if (j - 1 >= 0 && g.areConnected(matrix[i, j], matrix[i, j - 1]))
                {
                    player.transform.position = player.transform.position + transform.up * -gap;
                    character.y = character.y - 1;
                }
                SwipeDetector.GestureCompleted();
            }
            if (SwipeDetector.GetSwipeRight())
            {
                if (i + 1 < x && g.areConnected(matrix[i, j], matrix[i + 1, j]))
                {
                    player.transform.position = player.transform.position + transform.right * gap;
                    character.x = character.x + 1;
                }
                SwipeDetector.GestureCompleted();
            }
            if (SwipeDetector.GetSwipeLeft())
            {
                if (i - 1 >= 0 && g.areConnected(matrix[i, j], matrix[i - 1, j]))
                {
                    player.transform.position = player.transform.position + transform.right * -gap;
                    character.x = character.x - 1;
                }
                SwipeDetector.GestureCompleted();
            }
        }
    }
Пример #16
0
 private void Awake()
 {
     swipeDetector = GetComponent <SwipeDetector> ();
     swipeDetector.onSwipeContinued = OnSwipeContinued;
     swipeDetector.useDelta         = true;
     if (invertX)
     {
         sensitivity.x *= -1.0f;
     }
     if (invertY)
     {
         sensitivity.y *= -1.0f;
     }
 }
Пример #17
0
    // Use this for initialization
    void Start()
    {
        //PrefabSpawner.onScrumhalfSpawned += ScrumHalfSpawned;
        //PrefabSpawner.onScrumhalfDestroyed += ScrumHalfDestroyed;

        CatchBall_Test.onKickBallSpawned += KickBallSpawned;

        if (catchBallObject != null)
        {
            CatchBall   = GameObject.FindWithTag(catchBallObject);
            catchScript = CatchBall.GetComponent <CatchBall_Test> ();
        }

        swipeScript = gameObject.GetComponent <SwipeDetector> ();
        hasKicked   = false;
    }
Пример #18
0
    // Funkcje wykrywajace kolizje znajduja sie w skryptach: Taker i Destroyer

    // OnCollisionExit2D (wykrywajacy koniec kolizji) nie dziala w przypadku gdy obiekt kolidujacy
    // zostaje zniszczony, a OnCollisionStay2D(gdy kolizja trwa) nie zostaje wywolany bo nie ma juz obiektu kolidujacego
    // wiec w ramach zastepstwa: to daje 'efekt' wyjscia z kolizji, ktorej już nie ma.
    private void EndCollision(string collider)
    {
        SwipeDetector swipedObject = gameObject.GetComponent <SwipeDetector>();

        if (collider == "Taker")
        {
            GameObject.Find(collider).GetComponent <Transform>().localScale = new Vector2(1.0f, 1.0f);
            swipedObject.colliding     = false;
            swipedObject.whichCollider = "none";
        }
        else if (collider == "Destroyer")
        {
            GameObject.Find(collider).GetComponent <Transform>().localScale = new Vector2(1.0f, 1.0f);
            swipedObject.colliding     = false;
            swipedObject.whichCollider = "none";
        }
    }
Пример #19
0
        /// <summary>
        /// Setup builds an XN Context, Session Manager and all the detectors.
        /// It also adds the callbacks for the SessionManager and adds the listeners on the Broadcaster.
        /// </summary>
        private void Setup()
        {
            //build the context
            Context = new Context(CONFIG);
            //build session manager
            SeshManager = new SessionManager(Context, "RaiseHand", "RaiseHand");
            SeshManager.SetQuickRefocusTimeout(15000);

            //build the detectors
            Pushy = new PushDetector();
            Swipy = new SwipeDetector();
            //setup all the callbacks
            SetupCallbacks();
            SeshManager.SessionStart += SessionStarted;
            //add the flow router to the session
            SeshManager.AddListener(Pushy);
            SeshManager.AddListener(Swipy);
        }
Пример #20
0
    public void InitSimpleButton(string title, SwipeDetector.directions direction)
    {
        if (direction == SwipeDetector.directions.NONE || direction == SwipeDetector.directions.LEFT)
            button.gameObject.SetActive(true);
        else button.gameObject.SetActive(false);

        this.direction = direction;
        simpleButton.SetActive(true);
        simpleButtonTitle.text = title;
        Time.timeScale = 0;

        print("direction" + direction);

        if (direction == SwipeDetector.directions.UP)
        {
            hand.gameObject.SetActive(true);
            hand.updateMode = AnimatorUpdateMode.UnscaledTime;
            hand.Play("swipeUp",0,0);

        }
        else if (direction == SwipeDetector.directions.DOWN)
        {
            hand.gameObject.SetActive(true);
            hand.updateMode = AnimatorUpdateMode.UnscaledTime;
            hand.Play("swipeDown", 0, 0);
        }
        else if (direction == SwipeDetector.directions.RIGHT)
        {
            hand.gameObject.SetActive(true);
            hand.updateMode = AnimatorUpdateMode.UnscaledTime;
            hand.Play("tap", 0, 0);
        }
        else if (direction == SwipeDetector.directions.LEFT)
        {
            hand.gameObject.SetActive(true);
            hand.updateMode = AnimatorUpdateMode.UnscaledTime;
            hand.Play("fuckyou", 0, 0);
            buttonField.text = "F**K YOU!";
        }
        else
        {
            hand.gameObject.SetActive(false);
        }
    }
Пример #21
0
    // Use this for initialization
    void Start()
    {
        moveCounter   = GameObject.Find("MoveCounter").GetComponent <MoveCounter>();
        swipeDetector = new GameObject().AddComponent <SwipeDetector>();
        menuManager   = GameObject.Find("Menu Manager").GetComponent <MenuManager>();
        colorModel    = GameObject.Find("RGB Diagram").GetComponent <ColorModel> ();

        closeIngameUI();
        //Get instance of GameData created on start screen
        data = GameObject.Find("GameData").GetComponent <GameData>();
        data.deserialize();


        //Initialize AudioSource
        audioSource   = gameObject.AddComponent <AudioSource>();
        deathSound    = Resources.Load("Audio/death", typeof(AudioClip)) as AudioClip;
        endLevelSound = Resources.Load <AudioClip>("Audio/Home2");
        restartSound  = Resources.Load <AudioClip>("Audio/restart");
        audioSettings = GameObject.Find("Audio").GetComponent <AudioControl>();
    }
Пример #22
0
        public HandData()
            : base()
        {
            Console.WriteLine("Constructing MyCanvas");
            pushDetector = new PushDetector();
            swipeDetector = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push += new EventHandler<VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new EventHandler<DirectionVelocityAngleEventArgs>(swipeDetector_GeneralSwipe);

            PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(MyCanvas_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler<IdEventArgs>(MyCanvas_PrimaryPointDestroy);
            PrimaryPointUpdate += new EventHandler<HandEventArgs>(MyCanvas_PrimaryPointUpdate);
            OnUpdate += new EventHandler<UpdateMessageEventArgs>(MyCanvas_OnUpdate);
        }
Пример #23
0
        private void CreateAndRun()
        {
            m_context        = new Context(@"data\openNI.xml");
            m_imageGenerator = new ImageGenerator(m_context);
            m_depthGenerator = new DepthGenerator(m_context);

            SessionManager sessionManager = new SessionManager(m_context, "Wave", "RaiseHand");

            // update the state
            Dispatcher.BeginInvoke(() => { State = SessionState.Idle; });

            sessionManager.SessionStart += SessionManager_SessionStart;
            sessionManager.SessionEnd   += SessionManager_SessionEnd;

            PointControl pointControl = new PointControl();

            pointControl.PrimaryPointCreate  += PointControl_PrimaryPointCreate;
            pointControl.PrimaryPointDestroy += PointControl_PrimaryPointDestroy;
            pointControl.PrimaryPointUpdate  += PointControl_PrimaryPointUpdate;

            SwipeDetector swipeDetector = new SwipeDetector();

            swipeDetector.UseSteady   = true;
            swipeDetector.SwipeLeft  += SwipeDetector_SwipeLeft;
            swipeDetector.SwipeRight += SwipeDetector_SwipeRight;

            PointDenoiser denoiser = new PointDenoiser();

            denoiser.AddListener(pointControl);
            denoiser.AddListener(swipeDetector);
            sessionManager.AddListener(denoiser);

            while (m_running)
            {
                m_context.WaitAndUpdateAll();
                sessionManager.Update(m_context);
            }
        }
Пример #24
0
        public MyBox(System.Windows.Forms.Panel box, string name) :
            base()
        {
            this.name = name;
            this.box  = box;

            pushDetector   = new PushDetector();
            swipeDetector  = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter     = new FlowRouter();
            broadcaster    = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push          += new PushDetector.PushHandler(pushDetector_Push);
            steadyDetector.Steady      += new SteadyDetector.SteadyHandler(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new SwipeDetector.GeneralSwipeHandler(swipeDetector_GeneralSwipe);

            PrimaryPointCreate  += new PrimaryPointCreateHandler(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new PrimaryPointDestroyHandler(MyBox_PrimaryPointDestroy);
            OnUpdate            += new UpdateHandler(MyBox_OnUpdate);
        }
Пример #25
0
    void OnSwipe(SwipeDetector.directions direction)
    {
        if (Game.Instance.gameManager.state == GameManager.states.TUTORIAL) return;
        if ( Game.Instance.state != Game.states.PLAYING ) return;

        switch (direction)
        {
            case SwipeDetector.directions.UP:
                if (character.hero.state == Hero.states.SORETE) return;
                if (!character.CantMoveUp && lanes.TryToChangeLane(true))
                    character.MoveUP();
                break;
            case SwipeDetector.directions.DOWN:
                if (character.hero.state == Hero.states.SORETE) return;
                if (!character.CantMoveDown && lanes.TryToChangeLane(false))
                    character.MoveDown();
               break;
            case SwipeDetector.directions.RIGHT:
               if (character.hero.state == Hero.states.SORETE) return;
               character.Dash();
               break;
        }
    }
Пример #26
0
        public MyBox(System.Windows.Forms.Panel box, string name) :
            base()
        {
            this.name = name;
            this.box = box;

            pushDetector = new PushDetector();
            swipeDetector = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push +=new EventHandler<VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new EventHandler<DirectionVelocityAngleEventArgs>(swipeDetector_GeneralSwipe);

            PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler<IdEventArgs>(MyBox_PrimaryPointDestroy);
            OnUpdate += new EventHandler<UpdateMessageEventArgs>(MyBox_OnUpdate);
        }
Пример #27
0
        public MyBox(System.Windows.Forms.Panel box, string name) :
            base()
        {
            this.name = name;
            this.box  = box;

            pushDetector   = new PushDetector();
            swipeDetector  = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter     = new FlowRouter();
            broadcaster    = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push          += new EventHandler <VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady      += new EventHandler <SteadyEventArgs>(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new EventHandler <DirectionVelocityAngleEventArgs>(swipeDetector_GeneralSwipe);

            PrimaryPointCreate  += new EventHandler <HandFocusEventArgs>(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler <IdEventArgs>(MyBox_PrimaryPointDestroy);
            OnUpdate            += new EventHandler <UpdateMessageEventArgs>(MyBox_OnUpdate);
        }
Пример #28
0
    // Update is called once per frame
    void Update()
    {
        instance = this;
        if (Input.GetKeyDown(KeyCode.Space))
        {
            OnSwipeDown();
        }

        foreach (Touch touch in Input.touches)
        {
            if (touch.phase == TouchPhase.Began)
            {
                fingerUp   = touch.position;
                fingerDown = touch.position;
            }

            //Detects Swipe while finger is still moving
            if (touch.phase == TouchPhase.Moved)
            {
                if (!detectSwipeOnlyAfterRelease)
                {
                    fingerDown = touch.position;
                }
            }

            //Detects swipe after finger is released
            if (touch.phase == TouchPhase.Ended)
            {
                fingerDown = touch.position;
                checkSwipe();
            }
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            OnSwipeDown();
        }
    }
Пример #29
0
    //private static bool showDefaultFlag=false;

    void Awake()
    {
        instance = (SwipeDetector)target;
    }
Пример #30
0
	void Start ()
	{
		sd = this.GetComponent<SwipeDetector>();
	}
Пример #31
0
        private void CreateAndRun()
        {
            m_context = new Context(@"data\openNI.xml");
            m_imageGenerator = new ImageGenerator(m_context);
            m_depthGenerator = new DepthGenerator(m_context);

            SessionManager sessionManager = new SessionManager(m_context, "Wave", "RaiseHand");

            // update the state
            Dispatcher.BeginInvoke(() => { State = SessionState.Idle; });

            sessionManager.SessionStart += SessionManager_SessionStart;
            sessionManager.SessionEnd += SessionManager_SessionEnd;

            PointControl pointControl = new PointControl();
            pointControl.PrimaryPointCreate += PointControl_PrimaryPointCreate;
            pointControl.PrimaryPointDestroy += PointControl_PrimaryPointDestroy;
            pointControl.PrimaryPointUpdate += PointControl_PrimaryPointUpdate;

            SwipeDetector swipeDetector = new SwipeDetector();
            swipeDetector.UseSteady = true;
            swipeDetector.SwipeLeft += SwipeDetector_SwipeLeft;
            swipeDetector.SwipeRight += SwipeDetector_SwipeRight;

            PointDenoiser denoiser = new PointDenoiser();
            denoiser.AddListener(pointControl);
            denoiser.AddListener(swipeDetector);
            sessionManager.AddListener(denoiser);

            while (m_running)
            {
                m_context.WaitAndUpdateAll();
                sessionManager.Update(m_context);
            }
        }
Пример #32
0
        /// <summary>
        /// Setup builds an XN Context, Session Manager and all the detectors. 
        /// It also adds the callbacks for the SessionManager and adds the listeners on the Broadcaster. 
        /// </summary>
        private void Setup()
        {
            //build the context
            Context = new Context(CONFIG);
            //build session manager
            SeshManager = new SessionManager(Context,"RaiseHand","RaiseHand");
            SeshManager.SetQuickRefocusTimeout(15000);

            //build the detectors
            Pushy = new PushDetector();
            Swipy = new SwipeDetector();
            //setup all the callbacks
            SetupCallbacks();
            SeshManager.SessionStart += SessionStarted;
            //add the flow router to the session
            SeshManager.AddListener(Pushy);
            SeshManager.AddListener(Swipy);
        }
Пример #33
0
    void Start()
    {
        InitializeCharacter ();
        context = new Context (XML_SETUP_FILE);
        sessionManager = new SessionManager(context, "Wave", "RaiseHand");
        depthGenerator = context.FindExistingNode(NodeType.Depth) as DepthGenerator;
        handsGenerator = context.FindExistingNode(NodeType.Hands) as HandsGenerator;

        //image = context.FindExistingNode(NodeType.Image) as ImageGenerator;
        //gesture = context.FindExistingNode(NodeType.Gesture) as GestureGenerator;
        if (depthGenerator == null) throw new Exception("Viewer must have a depth node!");
        //if (gesture == null) throw new Exception("Viewer must have a gesture node!");
        //if (image == null) throw new Exception("Viewer must have a image node!");

        userGenerator = new UserGenerator (context);
        skeletonCapability = userGenerator.SkeletonCapability;
        poseDetectionCapability = userGenerator.PoseDetectionCapability;
        calibPose = skeletonCapability.CalibrationPose;
        //gestureGenerator = new GestureGenerator(context);

        foreach (String s in poseDetectionCapability.GetAllAvailablePoses())
            Debug.LogWarning("available pose found: " +s);

        //foreach (String s in gestureGenerator.EnumerateAllGestures())
        //	Debug.LogWarning("available gesture found: " + s);

        //gestureGenerator.GestureRecognized += HandleGestureGestureRecognized;
        //gesture.AddGesture("Click");
        //gestureGenerator.AddGesture("RaiseHand"); //seems buggy
        //gestureGenerator.AddGesture("Wave");

        swipeDetector = new SwipeDetector();
        //steadyDetector = new SteadyDetector();//(3, 1f);

        //swipeDetector.SwipeLeft += HandleSwipeDetectorSwipeLeft;

        //Session Managment
        sessionManager.SessionStart += HandleSessionManagerSessionStart;
        sessionManager.SessionEnd += HandleSessionManagerSessionEnd;

        //User Generator
        userGenerator.NewUser += HandleUserGeneratorNewUser;
        userGenerator.LostUser += HandleUserGeneratorLostUser;
        poseDetectionCapability.PoseDetected += HandlePoseDetectionCapabilityPoseDetected;
        skeletonCapability.CalibrationEnd += HandleSkeletonCapabilityCalibrationEnd;

        skeletonCapability.SetSkeletonProfile (SkeletonProfile.All);
        skeletonCapability.SetSmoothing(.5f); // give us some smooothing

        //Start generating
        userGenerator.StartGenerating();
        //handsGenerator.MirrorCapability.SetMirror(true); // TODO: should this be true?
        handsGenerator.StartGenerating();
        //gestureGenerator.StartGenerating();

        //slider selector
        //selectableSlider2D = new SelectableSlider2D(Screen.width, Screen.height);
        //selectableSlider2D.ValueChange += HandleSelectableSlider2DValueChange;
        //selectableSlider2D.ItemHover += HandleSelectableSlider2DItemHover;
        //selectableSlider2D.ItemSelect += HandleSelectableSlider2DItemSelect;

        pointDenoiser = new PointDenoiser();
        pointDenoiser.AddListener(swipeDetector);
        //pointDenoiser.AddListener(steadyDetector);
        //pointDenoiser.AddListener(selectableSlider2D);

        //flowRouter = new FlowRouter();
        //flowRouter.ActiveListener = pointDenoiser;

        sessionManager.AddListener(pointDenoiser);

        MapOutputMode mapMode = depthGenerator.MapOutputMode;

        // Init depth & label map related stuff
        usersMapSize = mapMode.XRes * mapMode.YRes;
        //usersLabelTexture = new Texture2D(mapMode.XRes, mapMode.YRes); //nonPOT slow
        usersLabelTexture = new Texture2D(1024,512);
        //speed up by using power of two and then setpixel() with blockwidth (640) and blockheight (480)
        usersMapColors = new Color[usersMapSize];
        usersMapRect = new Rect(Screen.width - usersLabelTexture.width / 2, Screen.height - usersLabelTexture.height / 2, usersLabelTexture.width / 2, usersLabelTexture.height / 2);
        usersLabelMap = new short[usersMapSize];
        usersDepthMap = new short[usersMapSize];
        usersHistogramMap = new float[5000];

        this.shouldRun = true;

        if (NiteInitializingEvent != null) //notify others that we're done initializing
            NiteInitializingEvent(this, EventArgs.Empty);
    }
Пример #34
0
 void OnSwipe(SwipeDetector.directions dir)
 {
     Lanes lanes = Game.Instance.GetComponent<LevelsManager>().lanes;
     if (dir.ToString() == direction.ToString())
     {
         if (dir == SwipeDetector.directions.UP)
         {
             lanes.TryToChangeLane(true);
             character.MoveUP();
             hand.gameObject.SetActive(false);
         }
         else if (dir == SwipeDetector.directions.DOWN)
         {
             lanes.TryToChangeLane(false);
             character.MoveDown();
             hand.gameObject.SetActive(false);
         }
         else if (dir == SwipeDetector.directions.RIGHT)
         {
             character.Dash();
             hand.gameObject.SetActive(false);
         }
         SimpleButtonOk();
     }
 }
Пример #35
0
 private void Awake()
 {
     swipeDetector = FindObjectOfType <SwipeDetector>();
 }
Пример #36
0
 void SwipeHappened(SwipeDetector.SwipeType type)
 {
     if(!InputPressed && !SwitchingLanes) {
         if(type == SwipeDetector.SwipeType.Left) {
             SwitchLanes(-1);
         } else if(type == SwipeDetector.SwipeType.LeftLong) {
             SwitchLanes(-2);
         }else if(type == SwipeDetector.SwipeType.Right) {
             SwitchLanes(1);
         } else if(type == SwipeDetector.SwipeType.RightLong) {
             SwitchLanes(2);
         }
     }
 }
Пример #37
0
 void Awake()
 {
     instance = this;
 }
 private void Awake()
 {
     swipeDetector         = GetComponent <SwipeDetector>();
     swipeDetector.enabled = false;
 }
 //private static bool showDefaultFlag=false;
 void Awake()
 {
     instance = (SwipeDetector)target;
 }
Пример #40
0
 void Start()
 {
     swipeDetector     = GetComponent <SwipeDetector>();
     arromKeysDetector = GetComponent <ArrowKeysDetector>();
 }
Пример #41
0
 public void OnCollisionEnter2D(Collision2D col)
 {
     scale.localScale = new Vector2(1.2f, 1.2f);
     swipeSeed        = col.gameObject.GetComponent <SwipeDetector>();
 }
Пример #42
0
 // Use this for initialization
 void Awake()
 {
     this.basicDetector = this.GetComponent<BasicDetector>();
     this.swipeDetector = this.GetComponent<SwipeDetector>();
     this.Disable();
 }
Пример #43
0
        public MyBox(System.Windows.Forms.Panel box, string name)
            : base()
        {
            this.name = name;
            this.box = box;

            pushDetector = new PushDetector();
            swipeDetector = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push += new PushDetector.PushHandler(pushDetector_Push);
            steadyDetector.Steady += new SteadyDetector.SteadyHandler(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new SwipeDetector.GeneralSwipeHandler(swipeDetector_GeneralSwipe);

            PrimaryPointCreate += new PrimaryPointCreateHandler(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new PrimaryPointDestroyHandler(MyBox_PrimaryPointDestroy);
            OnUpdate += new UpdateHandler(MyBox_OnUpdate);
        }
Пример #44
0
 private void Awake()
 {
     swipeDetector = GetComponent <SwipeDetector>();
 }
Пример #45
0
 void Start()
 {
     swipeDetecor       = FindObjectOfType <SwipeDetector>();
     transform.position = new Vector3(transform.position.x, transform.position.y, 10f);
     SetPlateState();
 }
Пример #46
0
 void OnCollisionEnter2D(Collision2D col)                              // wykrywam kolizje
 {
     scale.localScale = new Vector2(1.2f, 1.2f);                       // powiekszam sie
     swipeSeed        = col.gameObject.GetComponent <SwipeDetector>(); // biore swipe detectora by wyslac mu wiadomosc o aktualnym stanie kolizji.
 }                                                                     // na podstawie wyslanych mu informacji sprawdzam gdzie zostal dropniety seed.