Ejemplo n.º 1
0
    void Start()
    {
        EchoScript         = GameObject.Find("Main Camera").GetComponent <Echo>();
        recordingSituation = new Echo.Situation();

        allCombos = new List <Combo>();
        listining = true;
        Debug.Log(Input.GetJoystickNames()[0]);
        //Move tempMove = new Move();
        //	Move tempMove2 = new Move();
        //Combo newCombo = new Combo();


        //	newCombo.Moves.Add(tempMove);
        //	newCombo.Moves.Add(tempMove2);

        /*	newCombo.addMove(tempMove);
         *      newCombo.addMove(tempMove2);
         *      allCombos.Add(newCombo);
         *      saveToFile(allCombos);
         *      loadAllMoves();*/
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            //	 saveToFile(allCombos);
            saveToFile(everyCombo);
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            loadAllMoves();
            EchoScript.EchoRank = loadAllRanks();
        }

        //Debug.Log(Input.GetAxis("L2")+" vs "+Input.GetAxis("R2"));

        blockL = Input.GetAxis("L2");
        blockR = Input.GetAxis("R2");

        float valueXL = Input.GetAxis("Horizontal");
        float valueYL = Input.GetAxis("Vertical");

        float valueXR = Input.GetAxis("Horizontal2");
        float valueYR = Input.GetAxis("Vertical2");

        //Debug.Log(Input.GetAxis ("Horizontal2")+" vs "+Input.GetAxis ("Vertical2"));

        if (listining)
        {
            clickedAction = pressedAction();

            if (speedChangeNewXL != valueXL)
            {
                speedChangeLastXL = speedChangeNewXL;
                speedChangeNewXL  = valueXL;
            }
            if (speedChangeNewYL != valueYL)
            {
                speedChangeLastYL = speedChangeNewYL;
                speedChangeNewYL  = valueYL;
            }
            diffXL = speedChangeNewXL - speedChangeLastXL;
            diffYL = speedChangeNewYL - speedChangeLastYL;
            if (speedChangeNewXR != valueXR)
            {
                speedChangeLastXR = speedChangeNewXR;
                speedChangeNewXR  = valueXR;
            }
            if (speedChangeNewYR != valueYR)
            {
                speedChangeLastYR = speedChangeNewYR;
                speedChangeNewYR  = valueYR;
            }
            diffXR = speedChangeNewXR - speedChangeLastXR;
            diffYR = speedChangeNewYR - speedChangeLastYR;
            //Debug.Log(wasChangeFast(diffX, diffY));
            //Debug.Log(speedChangeNewX - speedChangeLastX);
            if (valueXL != 0 || valueYL != 0 || valueXR != 0 || valueYR != 0 || clickedAction >= 0)
            {
                StopCoroutine("switchCombo");


                if (changeState == 0)
                {
                    //if(recordingCombo.Moves.Count>0) {
                    //		Debug.Log("added");
                    //	allCombos.Add(recordingCombo);
                    //}
                    //Debug.Log("lalalalala"+clickedAction);
                    recordingCombo     = null;
                    recordingCombo     = new Combo();
                    recordingSituation = EchoScript.checkSituation();
                }                        // else {
                currentStateL = defineState(valueXL, valueYL);
                currentStateR = defineState(valueXR, valueYR);

                currentBlock = blockL + "." + blockR;

                if (recordingCombo.numberOfMoves == 0 || (recordingCombo.numberOfMoves > 0 && (currentBlock != recordingCombo.Moves[recordingCombo.numberOfMoves - 1].blockState ||
                                                                                               currentStateL != recordingCombo.Moves[recordingCombo.numberOfMoves - 1].analogStateL ||
                                                                                               currentStateR != recordingCombo.Moves[recordingCombo.numberOfMoves - 1].analogStateR)))
                {
                    if (recordingCombo.numberOfMoves > 0)
                    {
                        recordingCombo.Moves[recordingCombo.numberOfMoves - 1].duration = Time.time - calculatedMoveTime;
                        if (currentStateL != lastStateL)
                        {
                            recordingCombo.Moves[recordingCombo.numberOfMoves - 1].style = wasChangeFast(diffXL, diffYL);
                        }
                        else if (currentStateR != lastStateR)
                        {
                            recordingCombo.Moves[recordingCombo.numberOfMoves - 1].style = wasChangeFast(diffXR, diffYR);
                        }
                    }
                    Move newMove = new Move(currentStateL, currentStateR, currentBlock);
                    Debug.Log(newMove.analogStateL + " vs " + newMove.analogStateR);
                    if (clickedAction >= 0)
                    {
                        //	newMove.actions= new List<int>();
                        //	Debug.Log(newMove.actions);
                        newMove.actions.Add(clickedAction);
                    }
                    recordingCombo.addMove(newMove);

                    if (currentStateL != lastStateL)
                    {
                        currentStateL = lastStateL;
                    }
                    else if (currentStateR != lastStateR)
                    {
                        currentStateR = lastStateR;
                    }
                    calculatedMoveTime = Time.time;
                }
                else if (clickedAction >= 0)
                {
                    recordingCombo.Moves[recordingCombo.numberOfMoves - 1].actions.Add(clickedAction);
                }
                //	}
                changeState = 1;
                //	Debug.Log(valueXL+" vs "+valueYL+" vs "+defineState(valueXL, valueYL));
            }
            else
            {
                if (changeState == 1)
                {
                    changeState = 2;
                    StopCoroutine("switchCombo");
                    StartCoroutine("switchCombo");
                    Debug.Log("just stated " + Time.deltaTime + " " + gameObject.transform.name);
                }
            }
        }
    }