Exemple #1
0
    public void TurnEnded()
    {
        overviewCam.SetActive(true);
        if (CheckIfWon())
        {
            return;
        }
        deathObject.Play("Death");
        gameState = currentState.Picking;
        Instantiate(powerups[Random.Range(0, powerups.Length)], spawnlocations[Random.Range(0, spawnlocations.Length)]);
        switch (currentPlayer)
        {
        case playerTurn.RedTeam:
            currentPlayer      = playerTurn.BlueTeam;
            whoseTurnText.text = "Blue Player Turn";
            break;

        case playerTurn.BlueTeam:
            currentPlayer      = playerTurn.RedTeam;
            whoseTurnText.text = "Red Player Turn";
            break;

        default:
            break;
        }
    }
Exemple #2
0
 void UnitSelect()
 {
     if (Input.GetMouseButton(0))
     {
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, roofIgnore) && currentPlayer == playerTurn.BlueTeam)
         {
             if (hit.collider.tag == "Blue Team")
             {
                 UnitController ut = hit.collider.GetComponent <UnitController>();
                 overviewCam.SetActive(false);
                 gameState = currentState.Playing;
                 ut.GainControl();
             }
         }
         if (Physics.Raycast(ray, out hit, roofIgnore) && currentPlayer == playerTurn.RedTeam)
         {
             if (hit.collider.tag == "Red Team")
             {
                 UnitController ut = hit.collider.GetComponent <UnitController>();
                 overviewCam.SetActive(false);
                 gameState = currentState.Playing;
                 ut.GainControl();
             }
         }
     }
 }
Exemple #3
0
    void Attack()
    {
        if (currentAtAnTime > 0)
        {
            currentAtAnTime -= Time.deltaTime;
        }
        else
        {
            lastAttackANM = "";
        }

        if (Input.GetButtonDown("Attack") && currentAtAnTime < 0.7f)
        {

            if (lastAttackANM == "" || lastAttackANM == attackAnimations[attackAnimations.Length-1]&& currentAtAnTime < myBody.animation[attackAnimations[0]].length * 0.1f)
            {
                myBody.animation.Stop();
                currentAtAnTime = myBody.animation[attackAnimations[0]].length * 1.25f;
                lastAttackANM = attackAnimations[0];
                myBody.animation.CrossFade(attackAnimations[0]);
                audio.Play();
            }
            else if ( lastAttackANM == attackAnimations[0] && currentAtAnTime > 0 && currentAtAnTime < myBody.animation[attackAnimations[0]].length * 0.7f)
            {
                myBody.animation.Stop();
                currentAtAnTime = myBody.animation[attackAnimations[1]].length * 1.25f;
                lastAttackANM = attackAnimations[1];
                myBody.animation.CrossFade(attackAnimations[1]);
                audio.Play();
            }
            State = currentState.Attack;
        }
    }
Exemple #4
0
    private void Update()
    {
        switch (state)
        {
        case currentState.IDLE:
            // Idle state

            break;

        case currentState.GETRESOLUTION:

            if (retry)
            {
                GetResolution();
                StartCoroutine(WaitForResponse());
                if (resX != 0)
                {
                    state = currentState.INIT;
                }
                if (stop)
                {
                    state = currentState.IDLE;
                }
            }
            break;

        case currentState.INIT:

            if (retry)
            {
                startFPV();

                StartCoroutine(WaitForResponse());
                if (start)
                {
                    state = currentState.STARTED;
                }
                if (stop)
                {
                    state = currentState.IDLE;
                }
            }
            break;

        case currentState.STARTED:
            putTexture();

            if (stop)
            {
                state = currentState.IDLE;
            }
            break;

        default:
            Application.Quit();
            break;
        }
        ;
    }
Exemple #5
0
    // Start is called before the first frame update
    void Start()
    {
        bool begin = true;

        print("in start");
        state = currentState.BUY;
        // SceneManager.LoadScene(0);
    }
    // Use this for initialization
    void Start()
    {
        listSize = currentNeeds.Count;
        this.GetComponentInChildren <NeedsUIScript>().addToList();
        oldPosition = gameObject.transform.position;

        //default state
        state = currentState.none;
    }
Exemple #7
0
 void stopFPV()
 {
     if (clientUnity != null && clientUnity.client != null && clientUnity.client.isConnected)
     {
         UnityEngine.Debug.Log("Stopped FPV");
         clientUnity.client.SendCommand((byte)Modules.FPV_MODULE, (byte)FPVCommandType.FPV_STOP_STREAMING);
         state = currentState.IDLE;
         //UnityEngine.Debug.Log("Version Get: " + AtreyuManager.majorV + "." + AtreyuManager.minorV + "." + AtreyuManager.patchV);
     }
 }
Exemple #8
0
 void States() //checks states
 {
     if (actual == currentState.isJumping)
     {
     }
     else if (Mathf.Abs(player.velocity.x) < .1f)
     {
         actual = currentState.isStill;
     }
 }
Exemple #9
0
 void startFPV()
 {
     if (clientUnity != null && clientUnity.client != null && clientUnity.client.isConnected)
     {
         UnityEngine.Debug.Log("Starting FPV");
         clientUnity.client.SendCommand((byte)Modules.FPV_MODULE, (byte)CommandType.START);
         state = currentState.STARTED;
         //UnityEngine.Debug.Log("Version Get: " + AtreyuManager.majorV + "." + AtreyuManager.minorV + "." + AtreyuManager.patchV);
     }
 }
Exemple #10
0
 public void CloseQuitMenu()
 {
     quitMenuStuff.SetActive(false);
     if (homeMenuStuff.activeInHierarchy)
     {
         state = currentState.HOMEMENU;
     }
     else
     {
         state = currentState.NOMENU;
     }
 }
Exemple #11
0
        public void CountSearchWords(
            System.ComponentModel.BackgroundWorker worker,
            System.ComponentModel.DoWorkEventArgs e)
        {
            // Initialize the variables.
            currentState state              = new currentState();
            string       line               = "";
            int          elapsedTime        = 20;
            DateTime     lastReportDateTime = DateTime.Now;

            if (search_String == null ||
                search_String == System.String.Empty)
            {
                throw new Exception("Search String not specified.");
            }

            FileInfo fi = new FileInfo(source_file);

            file_size          = fi.Length;
            SearchWord_counter = 0;
            lines_processed    = 0;
            using (System.IO.StreamReader myStream = new System.IO.StreamReader(source_file))
            {
                // Process lines while there are lines remaining in the file.
                while (!myStream.EndOfStream)
                {
                    size = size + System.Text.ASCIIEncoding.ASCII.GetByteCount(line);
                    if (worker.CancellationPending)
                    {
                        e.Cancel = true;
                        break;
                    }
                    else
                    {
                        line = myStream.ReadLine();
                        //SearchWord_counter += CountInString(line, search_String);
                        lines_processed = lines_processed + 1;

                        if (line.IndexOf(search_String, 0, StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            state.match       = "1";
                            state.matchedline = line;
                            state.line_index  = lines_processed;
                            state.work_done   = (size * 100) / file_size;
                            worker.ReportProgress(0, state);
                        }
                    }
                    // Uncomment for testing.
                    System.Threading.Thread.Sleep(5);
                }
                myStream.ReadToEnd();
            }
        }
Exemple #12
0
    public void ToggleCamera()
    {
        //activates and deactivates the camera
        if (cameraOpen)
        {
            if (clientUnity != null && clientUnity.client != null && clientUnity.client.isConnected)
            {
                start = false;
                clientUnity.client.SendCommand((byte)Modules.FPV_MODULE, (byte)FPVCommandType.FPV_STOP_STREAMING);
                //UnityEngine.Debug.Log("Version Get: " + AtreyuManager.majorV + "." + AtreyuManager.minorV + "." + AtreyuManager.patchV);

                if (airtBackground != null)
                {
                    //If there is a background, we hide it and put the fpv texture. Recording is the only one that doesn't have one
                    //airtBackground.sprite = opaqueBackground;
                    airtBackground.gameObject.SetActive(true);
                }
                fpvRender.gameObject.SetActive(false);
                //toggleFPV.interactable = true;
                //closeFPV.interactable = false;
                toggleFPV.gameObject.GetComponent <Image>().sprite = openFPVImage;
                cameraOpen = false;
                //We are never in mapping anymore here
                if (GeneralSceneManager.sceneState == GeneralSceneManager.SceneState.Mapping)
                {
                    GameObject.Find("Scan").GetComponent <Button>().interactable = true;
                    GameObject.Find("Scan").transform.GetChild(0).GetComponent <Text>().color = new Vector4(1, 1, 1, 1);
                }
            }
        }
        else
        {
            stop  = false;
            state = currentState.INIT;
            if (airtBackground != null)
            {
                //airtBackground.sprite = alphaBackground;
                airtBackground.gameObject.SetActive(false);
            }
            fpvRender.gameObject.SetActive(true);
            //openFPV.interactable = false;
            //closeFPV.interactable = true;
            toggleFPV.gameObject.GetComponent <Image>().sprite = closeFPVImage;
            cameraOpen = true;

            if (GeneralSceneManager.sceneState == GeneralSceneManager.SceneState.Mapping)
            {
                GameObject.Find("Scan").GetComponent <Button>().interactable = false;
                GameObject.Find("Scan").transform.GetChild(0).GetComponent <Text>().color = new Vector4(1, 1, 1, 0.4f);
            }
        }
    }
Exemple #13
0
 //These 2 functions were substituted for the one above
 public void StartReceiving()
 {
     stop  = false;
     state = currentState.INIT;
     if (airtBackground != null)
     {
         //airtBackground.sprite = alphaBackground;
         airtBackground.gameObject.SetActive(false);
     }
     fpvRender.gameObject.SetActive(true);
     //toggleFPV.interactable = false;
     //closeFPV.interactable = true;
 }
    V_GameManager gm;           // For accessing non-static variables in game manager

    // Use this for initialization
    void Start()
    {
        // DontDestroyOnLoad(gameObject); //its always here

        // }
        //if broken revert to an awake function. MAKE SURE TO CALL!!
        //public void EnterGame(){
        // References:
        p  = FindObjectOfType <V_PlayerHandler>();
        gm = FindObjectOfType <V_GameManager> ();
        // Set the player's starting life and energy:
        V_PlayerHandler.health = startingHealth;
        V_PlayerHandler.energy = startingEnergy;
        V_AI.health            = startingHealth;
        V_AI.energy            = startingEnergy;

        sEnergy = startingEnergy;
        iEnergy = increasingEnergy;
        //need to add handlers for multiple new zones
        battleZone    = battleZoneHandler;
        spellZone     = spellZoneHandler;
        handZone      = handZoneHandler;
        gameArea      = gameAreaHandler;
        graveZone     = graveZoneHandler;
        aiBattleZone  = aiBattleZoneHandler;
        aiSpellZone   = aiSpellZoneHandler;
        aiAvatarZone  = aiAvatarHandler;
        aigraveZone   = aigraveZoneHandler;
        avatarZone    = avatarHandler;
        sdamageEffect = damageEffect;
        shealEffect   = healEffect;

        if (drawCostText != null)
        {
            drawCostText.text = drawCost.ToString();
        }

        // Draw the first hand cards:
        playerTurn    = playerTypes.Player;
        p.gm          = this;
        CardGameState = currentState.draw;
        //this is what we need to use to set the health to the size of the deck. we can disable it for now.
        // V_PlayerHandler.health = p.myDeck.Length;
        //p.StartDraw ();//we can disable this for now. if we have effects that only trigger in starting hand we can readd.
        for (int i = 0; i < startinghand; i++)
        {
            p.DrawOneCard();
        }
    }
    // This is called when a player hits the "End Turn" button:
    public void ChangeTurn(playerTypes type)
    {
        //modify this to create the stages of a turn. this is the recharge step. players can draw up to 2 cards and their energy becomes 5. now its talking about the players turn. we will edit this first.
        warentered = false;
        if (type == playerTypes.AI)
        {
            CardGameState         = currentState.begin;
            allowIncreasingEnergy = true;
            playerTurn            = playerTypes.Player;
            gm.endTurnBTN.SetActive(true);
            gm.DrawBTN.SetActive(true);
            RefreshField();

            //check for begin turn effects here

            CardGameState = currentState.recharge;

            if (allowIncreasingEnergy)
            {
                V_PlayerHandler.energy = refreshedEnergy;
                //V_PlayerHandler.AddEnergy (iEnergy);
            }
            if (handZone.transform.childCount > 7)
            {
                //make players discard down to 7 cards.
            }
            V_GameManager.CardGameState = V_GameManager.currentState.draw;
            //////////////////////////////////////
            //now its talking about the AI turn. lets ignore this for now.
        }
        else if (type == playerTypes.Player)
        {
            CardGameState = currentState.begin;
            CardGameState = currentState.recharge;
            if (allowIncreasingEnergy)
            {
                V_AI.energy = 5;//EffectAddEnergy (iEnergy);
            }
            allowIncreasingEnergy       = true;
            playerTurn                  = playerTypes.AI;
            V_GameManager.CardGameState = V_GameManager.currentState.draw;
            RefreshField();
            //         GameObject[] obj = GameObject.FindGameObjectsWithTag ("AIOwned");
            //foreach (GameObject o in obj) {
            //	o.GetComponent<V_CardActions> ().isUsed = false;
            //}
            V_GameManager.CardGameState = V_GameManager.currentState.action;
        }
    }
Exemple #16
0
    // Use this for initialization
    void Start()
    {
        //set the game manager
        nodeManager = GameObject.Find("GameManager").GetComponent <NodeManager>();
        if (!nodeManager)
        {
            Debug.LogError("cannot locate node manager");
        }

        //set the knowledge base
        knowledgeBase = gameObject.GetComponent <NodeKnowledgeBase>();
        if (!knowledgeBase)
        {
            Debug.LogError("no knowledge base attached to " + gameObject.name);
        }

        listSize = needList.Count;

        for (int i = 0; i < needList.Count; i++)
        {
            if (!needList[i].Init())
            {
                Debug.Log("Error on element : " + i + " On object : " + gameObject.name);
            }
            else
            {
                Debug.Log(i + " : No errors");
            }
        }


        //add needs to the UI script (if there is one attached)

        if (gameObject.GetComponentInChildren <NeedsUIScript>())
        {
            gameObject.GetComponentInChildren <NeedsUIScript>().addToList();
        }

        if (gameObject.GetComponentInChildren <WeightUIScript>())
        {
            gameObject.GetComponentInChildren <WeightUIScript>().addToList();
        }

        oldPosition = gameObject.transform.position;

        //default state
        state = currentState.none;
    }
Exemple #17
0
        //! Constructor
        public Form1()
        {
            InitializeComponent();

            gmh = new GlobalMouseHandler();
            Application.AddMessageFilter(gmh);

            // Resize the array to its initial size
            ResizeLetters(13, 15);

            theLetters.cursorMovesHorizontal = true;

            myCurrentState = currentState.MODE_BLACKEN_SQUARES;

            fileName = String.Empty;
        }
Exemple #18
0
        /// <summary>
        ///
        /// </summary>
        public void DriveLeft()
        {
            List <byte> bytes = new List <byte>();

            foreach (byte b in integerToBytes(_velocity))
            {
                bytes.Add(b);
            }
            foreach (byte b in integerToBytes(_radius))
            {
                bytes.Add(b);
            }

            _interface.execute(OpCode.Drive, bytes);
            updateTracker();
            _lastUpdate = DateTime.Now;
            _state      = currentState.ArcLeft;
        }
Exemple #19
0
        public void DriveStop()
        {
            List <byte> bytes = new List <byte>();

            foreach (byte b in integerToBytes(0))
            {
                bytes.Add(b);
            }
            foreach (byte b in integerToBytes(0))
            {
                bytes.Add(b);
            }

            _interface.execute(OpCode.DriveDirect, bytes);
            updateTracker();
            _lastUpdate = DateTime.Now;
            _state      = currentState.Stop;
        }
Exemple #20
0
    void FillNeedCleanup()
    {
        //CLEANUP

        //Clear the tag of the need
        needTag = string.Empty;

        //Clear the target node that was used
        needNodeObject = null;

        //reset the init
        fillNeedStateInit = false;

        //reset the focus node's drains
        needList[focusNeed].resetDrain();

        //head back to the weight evaluation
        state = currentState.none;
    }
Exemple #21
0
 public bool CheckIfWon()
 {
     if (teamBlue < 1)
     {
         whoseTurnText.text = "Team Red WON";
         gameState          = currentState.Won;
         return(true);
     }
     else if (teamRed < 1)
     {
         whoseTurnText.text = "Team Blue WON";
         gameState          = currentState.Won;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #22
0
    void calculateDamage(int winner)
    {
        //Determine whether the object at index 0 is a player or enemy
        if (winner == 1)
        {
            print("enemy HP: " + enemyHP);
            enemyHP -= 10;
            destroyPlayers();
        }
        else
        {
            playerHP -= 10;
            print("Player HP: " + playerHP);
            destroyEnemy();
        }

        turnOffCombat();
        state = currentState.BUY;
    }
        static private int AppInCurrentStateCount(IAppBundleWeb appBundle, currentState state, bool logStates = false)
        {
            int count = 0;

            for (int appIndex = 0; appIndex < appBundle.length; ++appIndex)
            {
                var currState = (ICurrentState)appBundle[appIndex].currentState;

                if (logStates)
                {
                    ToLog(new[] { ((currentState)currState.stateValue).ToString() });
                }

                if (currState.stateValue == (int)state)
                {
                    ++count;
                }
            }
            return(count);
        }
Exemple #24
0
    void Click()
    {
        if (Input.GetMouseButtonDown(0) && curState != currentState.Controlling)
        {
            RaycastHit hit;
            Debug.Log("click");
            curState = currentState.None;
            curUnit  = null;
            Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                Debug.Log(hit.collider.name);
                curUnit = hit.collider.GetComponent <Unit>();

                if (curUnit != null)
                {
                    target   = hit.collider.transform;
                    curState = currentState.Selected;
                }
            }
        }
    }
Exemple #25
0
    void ControlState()
    {
        switch (curState)
        {
        case currentState.None:
            yaw    = 0;
            pitch  = 0;
            target = null;
            TopDownCamera();
            Debug.Log(curState);
            break;

        case currentState.Selected:
            ThirdPersonCamera();
            if (Input.GetKeyDown(KeyCode.Space) == true)
            {
                curState = currentState.Controlling;
            }
            Debug.Log(curState);
            break;

        case currentState.Controlling:
            ThirdPersonCamera();
            curUnit.Move(mainCamera);
            timeLeft -= 1.0f * Time.deltaTime;
            Debug.Log(timeLeft);
            if (timeLeft < 0)
            {
                curState = currentState.None;
                timeLeft = 10.0f;
            }

            break;

        default:
            break;
        }
    }
Exemple #26
0
    void Update()
    {
        if (Input.GetKey(KeyCode.A))                                       //left movement
        {
            player.velocity      = new Vector2(-speed, player.velocity.y); //vector of movement
            transform.localScale = new Vector2(-1, 1);                     //sets sprite direction
            if (Mathf.Abs(player.velocity.y) < 0.1)                        //checks for left velocity for run animation
            {
                actual = currentState.isRunning;                           //sets to isrunning
            }
        }
        else if (Input.GetKey(KeyCode.D))                                 //Right movement
        {
            player.velocity      = new Vector2(speed, player.velocity.y); //vector of movement
            transform.localScale = new Vector2(1, 1);                     //sets sprite direction
            if (Mathf.Abs(player.velocity.y) < 0.1)                       //checks for left velocity for run animation
            {
                actual = currentState.isRunning;                          //sets to isrunning
            }
        }

        if (Time.time > nextJump)                                     //jump timer check
        {
            if (Input.GetKeyDown(KeyCode.Space))                      //jump movement
            {
                player.velocity = new Vector2(player.velocity.x, 7f); //vector of movement
                actual          = currentState.isJumping;             //sets state to isJumping
                nextJump        = Time.time + jumpCool;               //starts cooldown
            }
        }
        if (Input.GetKey(KeyCode.S))                               //downward movement
        {
            player.velocity = new Vector2(player.velocity.x, -5f); //downwards velocity vector
        }
        States();                                                  //runs states function

        animate.SetInteger("State", (int)actual);                  //sets animate to the integer of the enum
    }
Exemple #27
0
    IEnumerator checkState()
    {
        while (!IsDead)
        {
            yield return(new WaitForSeconds(0.2f));

            float Dist = Vector3.Distance(Playertransform.position, transform.position);
            if (Dist <= AttackDist)
            {
                curstate = currentState.Attack;
                Debug.Log("Attack");
            }
            else if (Dist >= AttackDist)
            {
                curstate = currentState.Trace;
                Debug.Log("trace");
                //nvagent.Warp(newPos);
            }
            else
            {
                curstate = currentState.Idle;
            }
        }
    }
Exemple #28
0
    public void Attack()
    {
        if (curstate == currentState.Attack)
        {
            if (attacktimer > attackdelay)
            {
                transform.LookAt(Playertransform.position);
                ani.SetBool("Attack", true);

                attacktimer = 0f;
            }

            else
            {
                curstate = currentState.Idle;
                ani.SetBool("Attack", false);
            }
            attacktimer += Time.deltaTime;
        }
        else
        {
            curstate = currentState.Trace;
        }
    }
 void GoToMainMenuButton_Click(object sender, RoutedEventArgs e)
 {
     stopButton.Click += stopButton_Click;
     reportStopButton.Click += reportStopButton_Click;
     logStopButton.Click += logStopButton_Click;
     if (parent.rulesAnalyzer.interruption)
     {
         parent.rulesAnalyzer.makeLog();
     }
     myCanvas.Children.Remove(interruptFeedback);
     interruptFeedback = null;
     reportFeedback = null;
     myState = currentState.play;
     parent.freeStyleMode_reportStopButton_Click(null, null);
 }
Exemple #30
0
 void CheckCurrentState()
 {
     if (!myBody.animation.IsPlaying("Attack1") &&
         !myBody.animation.IsPlaying("Attack2"))
     {
         if (MoveDirection.z != 0 && MoveDirection.y == -1)
         {
             State = currentState.Moving;
         }
         else if (MoveDirection.y > 0)
         {
             State = currentState.Jumping;
         }
         else if (MoveDirection.y < -1)
         {
             if (!Helper.Grounded(gameObject,1, Vector3.zero) &&
             !Helper.Grounded(gameObject,1, new Vector3(0,0,-0.75f)) &&
             !Helper.Grounded(gameObject,1, new Vector3(0,0,0.75f)))
             {
             State = currentState.Falling;
             }
             else
             {
                 State = currentState.Landing;
             }
         }
         else if (MoveDirection.z == 0 && MoveDirection.y == -1)
         {
             State = currentState.Idle;
         }
     }
 }
Exemple #31
0
 public void SetTurning(currentState cs)
 {
     m_rigidbody.angularVelocity *= .9f;
     m_curState = cs;
 }
Exemple #32
0
 public Robot(string comport)
 {
     _interface  = new RobotInterface(comport);
     _state      = currentState.Stop;
     _lastUpdate = DateTime.Now;
 }
Exemple #33
0
 public Robot(IRobotInterface rint)
 {
     _interface  = rint;
     _state      = currentState.Stop;
     _lastUpdate = DateTime.Now;
 }
 public void loadInterruption(PresentationAction[] x)
 {
     myState = currentState.stop;
     interruptFeedback = new InterruptFeedback();
     interruptFeedback.mistakes = x;
     myCanvas.Children.Add(interruptFeedback);
     Canvas.SetLeft(interruptFeedback, 20);
     Canvas.SetTop(interruptFeedback, 20);
     interruptFeedback.GoBackButton.Click += OrdinaryReturn_Click;
     interruptFeedback.GoToExercises.Click += GoToExercises_Click;
    // interruptFeedback.GoToMainMenuButton.
     //interruptFeedback.GoBackButton.Click += GoBackButton_Click;
    // interruptFeedback.GoToMainMenuButton.Click += GoToMainMenuButton_Click;
     stopButton.Click -= stopButton_Click;
     reportStopButton.Click -= reportStopButton_Click;
     logStopButton.Click -= logStopButton_Click;
 }
 void countdown_countdownFinished(object sender)
 {
     myState = currentState.play;
 }
Exemple #36
0
    private void Update()
    {
        switch (state)
        {
        case currentState.IDLE:
            // Idle state

            break;

        case currentState.GETRESOLUTION:
            //No one is getting the reolution right now. It goes from idle to init
            if (retry)
            {
                GetResolution();
                StartCoroutine(WaitForResponse());
                if (resX != 0)
                {
                    state = currentState.INIT;
                }
                if (stop)
                {
                    state = currentState.IDLE;
                }
            }
            break;

        case currentState.INIT:

            if (retry)
            {
                //The fpv is started, and if the drone receives the message, the texture begins to be displayed
                startFPV();

                StartCoroutine(WaitForResponse());
                if (start)
                {
                    state = currentState.STARTED;
                }
                if (stop)
                {
                    state = currentState.IDLE;
                }
            }
            break;

        case currentState.STARTED:
            if (FPVPeriod)
            {
                FPVPeriod.text = FPVModule.period.ToString();
            }

            putTexture();

            if (stop)
            {
                state = currentState.IDLE;
            }
            break;

        default:
            Application.Quit();
            break;
        }
        ;
    }
 public void loadReport()
 {
     myState = currentState.stop;
     reportFeedback = new ReportFeedback();
     myCanvas.Children.Add(reportFeedback);
     Canvas.SetLeft(reportFeedback, 300);
     Canvas.SetTop(reportFeedback, 20);
     reportFeedback.ContinueButton.Click += ContinueButton_Click;
     reportFeedback.GoToMainMenuButton.Click += GoToMainMenuButton_Click;
     stopButton.Click -= stopButton_Click;
     reportStopButton.Click -= reportStopButton_Click;
     logStopButton.Click -= logStopButton_Click;
 }
        //shows 3 second countdown for pausing
        void countdownPause_countdownFinished(object sender)
        {
            myState = currentState.stop;
            pauseControl = new PauseControl();
            myCanvas.Children.Add(pauseControl);
            Canvas.SetLeft(pauseControl, 20);
            Canvas.SetTop(pauseControl, 20);
            pauseControl.GoBackButton.Click+=GoBackButtonPause_Click;
            pauseControl.GoMainMenu.Click+=GoMainMenu_Click;            

        }
        void GoBackButton_Click(object sender, RoutedEventArgs e)
        {
            interruptFeedback.GoBackButton.Click -= GoBackButton_Click;
            stopButton.Click += stopButton_Click;
            reportStopButton.Click += reportStopButton_Click;
            logStopButton.Click += logStopButton_Click;
            myCanvas.Children.Remove(interruptFeedback);
            interruptFeedback = null;
            myState = currentState.play;
            if (parent.rulesAnalyzer.interruption)
            {
                parent.rulesAnalyzer.interrupted = false;
                //parent.rulesAnalyzer.reset();
                parent.rulesAnalyzer.resetForMistake((Mistake)parent.rulesAnalyzer.feedBackList[parent.rulesAnalyzer.feedBackList.Count - 1]);
            }

        }
 void ContinueButton_Click(object sender, RoutedEventArgs e)
 {
     reportFeedback.ContinueButton.Click -= ContinueButton_Click;
     stopButton.Click += stopButton_Click;
     reportStopButton.Click += reportStopButton_Click;
     logStopButton.Click += logStopButton_Click;
     myCanvas.Children.Remove(reportFeedback);
     reportFeedback = null;
     myState = currentState.play;
     if (parent.rulesAnalyzer.interruption)
     {
         parent.rulesAnalyzer.interrupted = false;
         //parent.rulesAnalyzer.reset();
     }
 }
Exemple #41
0
 //! Helper function to set the current state
 private void setMode(currentState mode)
 {
     myCurrentState = mode;
 }
        //initialization after freestylemode window is loaded.
        public void loaded()
        {
            backgroundImg.Width = parent.ActualWidth;
            backgroundImg.Height = parent.ActualHeight;
            Canvas.SetLeft(backgroundImg, 0);
            Canvas.SetTop(backgroundImg, 0);
            myBody.initialize(parent);
            myAudio.initialize(parent);
            mySkeleton.initialize(parent);
            parent.rulesAnalyzer.hmmmEvent += rulesAnalyzer_hmmmEvent;
            parent.rulesAnalyzer.tooLoudEvent += rulesAnalyzer_tooLoudEvent;
            parent.rulesAnalyzer.badPostureEvent += rulesAnalyzer_badPostureEvent;
            parent.rulesAnalyzer.noMistakeEvent += rulesAnalyzer_noMistakeEvent;
            parent.rulesAnalyzer.periodicMovementsEvent += rulesAnalyzer_periodicMovementsEvent;
            parent.rulesAnalyzer.moveMoreEvent += rulesAnalyzer_moveMoreEvent;
            parent.rulesAnalyzer.feedBackEvent += rulesAnalyzer_feedBackEvent;

            loadGhosts();

            //parent.rulesAnalyzerFIFO.feedBackEvent += rulesAnalyzerFIFO_feedBackEvent;
            //parent.rulesAnalyzerFIFO.correctionEvent += rulesAnalyzerFIFO_correctionEvent;
            //parent.rulesAnalyzerFIFO.myInterruptionEvent += rulesAnalyzerFIFO_myInterruptionEvent;

            parent.rulesAnalyzerImproved.feedBackEvent += rulesAnalyzerImproved_feedBackEvent;
            parent.rulesAnalyzerImproved.correctionEvent += rulesAnalyzerImproved_correctionEvent;
            parent.rulesAnalyzerImproved.myInterruptionEvent += rulesAnalyzerImproved_myInterruptionEvent;


            myState = currentState.stop;

            coinSound.MediaEnded += coinSound_MediaEnded;
            countdown.startAnimation();
            countdown.countdownFinished += countdown_countdownFinished;

            countdownPause.countdownFinished += countdownPause_countdownFinished;

        }