コード例 #1
0
    IEnumerator startanim()
    {
        yield return(new WaitForSeconds(2.75f));

        myFields.changeState(Multi_Fields.States.ROUND_STARTS, true);
        myFields.changeState(Multi_Fields.States.ATTACK_ANI_READY, true);
        yield return(new WaitForSeconds(0.25f));

        Destroy(gameObject);
    }
コード例 #2
0
    IEnumerator startanim()
    {
        gameObject.audio.Play();
        float ReadyYPos = Ready.transform.position.y;

        for (float i = 0; i <= 1; i += 0.1f)
        {
            Ready.renderer.material.color = new Vector4(Ready.renderer.material.color.r, Ready.renderer.material.color.g, Ready.renderer.material.color.b, i);
            Ready.transform.position      = new Vector3(Ready.transform.position.x, ReadyYPos - (1 - i), Ready.transform.position.z);

            yield return(new WaitForSeconds(0.01f));
        }
        yield return(new WaitForSeconds(1.5f));

        for (float i = 0; i <= 1; i += 0.05f)
        {
            Ready.renderer.material.color = new Vector4(Ready.renderer.material.color.r, Ready.renderer.material.color.g, Ready.renderer.material.color.b, 1 - i);
            Ready.transform.position      = new Vector3(Ready.transform.position.x, ReadyYPos + i, Ready.transform.position.z);

            Go.renderer.material.color = new Vector4(Go.renderer.material.color.r, Go.renderer.material.color.g, Go.renderer.material.color.b, i);
            Go.transform.position      = new Vector3(Go.transform.position.x, ReadyYPos - (1 - i), Go.transform.position.z);

            yield return(new WaitForSeconds(0.01f));
        }
        Ready.GetComponent <SpriteRenderer> ().sprite = null;
        yield return(new WaitForSeconds(1.5f));

        for (float i = 0; i <= 1; i += 0.05f)
        {
            Go.renderer.material.color = new Vector4(Go.renderer.material.color.r, Go.renderer.material.color.g, Go.renderer.material.color.b, 1 - i);
            Go.transform.position      = new Vector3(Go.transform.position.x, ReadyYPos + i, Go.transform.position.z);

            yield return(new WaitForSeconds(0.01f));
        }
        Go.GetComponent <SpriteRenderer> ().sprite = null;


        //myFields.syncState(Multi_Fields.States.ROUND_STARTS,true);
        myFields.changeState(Multi_Fields.States.ROUND_STARTS, true);
        myFields.changeState(Multi_Fields.States.ATTACK_ROUND, true);

        Debug.Log(" " + myFields.QTEmode);
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        //&& !myFields.stateInfo [(int)Multi_Fields.States.ATTACK_ANI_READY]
        if (myFields.stateInfo [(int)Multi_Fields.States.ROUND_STARTS] && !myFields.stateInfo [(int)Multi_Fields.States.ATTACK_ANI_READY])
        {
            Debug.Log("Attrd: " + myFields.stateInfo [(int)Multi_Fields.States.ATTACK_ROUND]);
            Debug.Log("Defenrd: " + myFields.stateInfo [(int)Multi_Fields.States.DEFENSE_ROUND]);
            myFields.changeState(Multi_Fields.States.ROUND_STARTS, false);
            if (roundStarterInstance == null &&
                myFields.stateInfo [(int)Multi_Fields.States.ATTACK_ROUND] &&
                !myFields.stateInfo [(int)Multi_Fields.States.DEFENSE_ROUND])
            {
                roundStarterInstance = Instantiate(attackRound, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            }
            else if (roundStarterInstance == null &&
                     !myFields.stateInfo [(int)Multi_Fields.States.ATTACK_ROUND] &&
                     myFields.stateInfo [(int)Multi_Fields.States.DEFENSE_ROUND])
            {
                roundStarterInstance = Instantiate(defenseRound, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            }


            if (Network.isServer)
            {
                float myRan = Random.Range(0, 5);
                myFields.syncQTEMode(Mathf.FloorToInt(myRan));
            }
        }


        //start a qte round
        if (!myFields.stateInfo [(int)Multi_Fields.States.ROUND_IN_PROGRESS] &&
            myFields.stateInfo [(int)Multi_Fields.States.SERVER_READY_TO_START_ROUND] &&
            myFields.stateInfo [(int)Multi_Fields.States.CLIENT_READY_TO_START_ROUND])
        {
            myFields.changeState(Multi_Fields.States.CLIENT_READY_TO_START_ROUND, false);
            myFields.changeState(Multi_Fields.States.SERVER_READY_TO_START_ROUND, false);
            myFields.changeState(Multi_Fields.States.ROUND_IN_PROGRESS, true);

            if (QTEChildren == null)
            {
                switch (myFields.QTEmode)
                {
                case 0:
                    QTEChildren = Instantiate(QTETouch, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                    break;

                case 1:
                    QTEChildren = Instantiate(QTESwipe, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                    break;

                case 2:
                    QTEChildren = Instantiate(QTESlide, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                    break;

                case 3:
                    QTEChildren = Instantiate(QTETriangle, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                    break;

                case 4:
                    QTEChildren = Instantiate(QTEUpDown, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                    break;
                }

                int currentSeconds = int.Parse(System.DateTime.Now.ToString("ss"));
                int currentMinutes = int.Parse(System.DateTime.Now.ToString("mm"));
                int currentHours   = int.Parse(System.DateTime.Now.ToString("hh"));
                startingSecond = currentHours * 3600 + currentMinutes * 60 + currentSeconds;
            }
        }

        //Round end
        if (myFields.stateInfo [(int)Multi_Fields.States.ROUND_IN_PROGRESS] &&
            myFields.stateInfo [(int)Multi_Fields.States.SERVER_FINISH] &&
            myFields.stateInfo [(int)Multi_Fields.States.CLIENT_FINISH])
        {
            if (long.Parse(myFields.ServerFinishTime) < long.Parse(myFields.ClientFinishTime))
            {
                result = "Server";
                myFields.changeState(Multi_Fields.States.SERVER_SUCCESS, true);
                if (Network.isServer)
                {
                    myFields.incrementWonQTE(true);
                }
            }
            else if (long.Parse(myFields.ServerFinishTime) > long.Parse(myFields.ClientFinishTime))
            {
                result = "Client";
                myFields.changeState(Multi_Fields.States.SERVER_SUCCESS, false);
                if (Network.isServer)
                {
                    myFields.incrementWonQTE(false);
                }
            }
            else
            {
                result = "Fair";
            }

            sSumSecond += myFields.ServerFinishTimeHelper - startingSecond;
            cSumSecond += myFields.ClientFinishTimeHelper - startingSecond;

            myFields.changeState(Multi_Fields.States.ROUND_IN_PROGRESS, false);
            myFields.changeState(Multi_Fields.States.SERVER_FINISH, false);
            myFields.changeState(Multi_Fields.States.CLIENT_FINISH, false);

            Instantiate(resultBanner, new Vector3(0, 0, 0), Quaternion.identity);

            myFields.ServerFinishTime = null;
            myFields.ClientFinishTime = null;


            //Attack round
            if (myFields.stateInfo [(int)Multi_Fields.States.ATTACK_ROUND] &&
                !myFields.stateInfo [(int)Multi_Fields.States.DEFENSE_ROUND])
            {
                if (myFields.stateInfo [(int)Multi_Fields.States.SERVER_SUCCESS])
                {
                    myFields.changeState(Multi_Fields.States.SERVER_ATTACKING, true);
                }
                else
                {
                    myFields.changeState(Multi_Fields.States.SERVER_ATTACKING, false);
                }

                /*myFields.changeState (Multi_Fields.States.ATTACK_ANI_READY, false);*/
                //change back to defense round
                myFields.changeState(Multi_Fields.States.ATTACK_ROUND, false);
                myFields.changeState(Multi_Fields.States.DEFENSE_ROUND, true);

                //Defense round and its action
            }
            else if (!myFields.stateInfo [(int)Multi_Fields.States.ATTACK_ROUND] &&
                     myFields.stateInfo [(int)Multi_Fields.States.DEFENSE_ROUND])
            {
                //check defense operation success or not
                if (myFields.stateInfo [(int)Multi_Fields.States.SERVER_SUCCESS])
                {
                    if (myFields.stateInfo [(int)Multi_Fields.States.SERVER_ATTACKING])
                    {
                        myFields.changeState(Multi_Fields.States.DEFENSE_SUCCESS, false);
                    }
                    else
                    {
                        myFields.changeState(Multi_Fields.States.DEFENSE_SUCCESS, true);
                    }
                }
                else
                {
                    if (myFields.stateInfo [(int)Multi_Fields.States.SERVER_ATTACKING])
                    {
                        myFields.changeState(Multi_Fields.States.DEFENSE_SUCCESS, true);
                    }
                    else
                    {
                        myFields.changeState(Multi_Fields.States.DEFENSE_SUCCESS, false);
                    }
                }

                /*myFields.changeState (Multi_Fields.States.ATTACK_ANI_READY, false);*/
                //change back to attack round
                myFields.changeState(Multi_Fields.States.ATTACK_ROUND, true);
                myFields.changeState(Multi_Fields.States.DEFENSE_ROUND, false);
            }
        }
        if (myFields.stateInfo [(int)Multi_Fields.States.ATTACK_ANI_READY])
        {
            if (myFields.stateInfo [(int)Multi_Fields.States.ATTACK_ROUND] &&
                !myFields.stateInfo [(int)Multi_Fields.States.DEFENSE_ROUND])
            {
                if (Network.isServer)
                {
                    if (!myFields.stateInfo [(int)Multi_Fields.States.SERVER_ATTACKING])
                    {
                        GameObject.Find("Enemy").GetComponent <Multi_dembeater1> ().startFlag = true;
                        //while(GameObject.Find ("Enemy").GetComponent<Multi_dembeater1> ().startFlag);
                    }
                }
                else
                {
                    if (myFields.stateInfo [(int)Multi_Fields.States.SERVER_ATTACKING])
                    {
                        GameObject.Find("Enemy").GetComponent <Multi_dembeater2> ().startFlag = true;
                        //while(GameObject.Find ("Enemy").GetComponent<Multi_dembeater2> ().startFlag);
                    }
                }

                //issue damage

                if (myFields.stateInfo [(int)Multi_Fields.States.SERVER_ATTACKING])
                {
                    if (myFields.stateInfo [(int)Multi_Fields.States.DEFENSE_SUCCESS])
                    {
                        myFields.ClientHP -= reducedDamage;
                        //myFields.syncHP (reducedDamage, false);
                    }
                    else
                    {
                        myFields.ClientHP -= originalDamage;
                        //myFields.syncHP (originalDamage, false);
                    }
                    if (myFields.ClientHP < 0)
                    {
                        myFields.ClientHP = 0;
                    }
                }
                else
                {
                    if (myFields.stateInfo [(int)Multi_Fields.States.DEFENSE_SUCCESS])
                    {
                        myFields.ServerHP -= reducedDamage;
                        //myFields.syncHP (reducedDamage, true);
                    }
                    else
                    {
                        myFields.ServerHP -= originalDamage;
                        //myFields.syncHP (originalDamage, true);
                    }
                    if (myFields.ServerHP < 0)
                    {
                        myFields.ServerHP = 0;
                    }
                }


                if (myFields.ServerHP == 0 || myFields.ClientHP == 0)
                {
                    myFields.ServerFinishTimeHelper = sSumSecond / (myFields.SWonQTE + myFields.CWonQTE);
                    myFields.ClientFinishTimeHelper = cSumSecond / (myFields.SWonQTE + myFields.CWonQTE);
                    Destroy(gameObject);
                }
            }
            myFields.changeState(Multi_Fields.States.ATTACK_ANI_READY, false);
        }
    }