コード例 #1
0
    void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Cube")
        {
            m_toRotAround      = col.gameObject;
            m_center           = m_toRotAround.transform;
            transform.position = (transform.position - m_center.position).normalized * m_radius + m_center.position;

            if (m_toRotAround.GetComponent <OrbStats>().beenVisited == false)
            {
                m_toRotAround.GetComponent <OrbStats>().beenVisited = true;
                m_chainCount++;
            }

            if (transform.position.x < m_center.position.x)
            {
                state           = curState.LEFT;
                m_rotationSpeed = -m_rotationSpeed;
            }
            else if (transform.position.x > m_center.position.x)
            {
                state           = curState.RIGHT;
                m_rotationSpeed = -m_rotationSpeed;
            }
        }
        if (col.tag == "Destroyer")
        {
            if (m_toRotAround == null)
            {
                GameObject.Find("GameManager").GetComponent <GameManager>().m_isDead = true;
            }
        }
        if (col.tag == "Blackhole")
        {
        }
    }
コード例 #2
0
 public void leve2()
 {
     state = curState.tl;
     Reset();
 }
コード例 #3
0
 public void emer()
 {
     state = curState.em;
     Reset();
 }
コード例 #4
0
 public void scal()
 {
     state = curState.sc;
     Reset();
 }
コード例 #5
0
    void Update()
    {
#if UNITY_STANDALONE || UNITY_WEBPLAYER
        if (!m_nameSet)
        {
            //GameObject.Find("GameManager").GetComponent<GameManager>().inputField.SetActive(true);

            GameObject.Find("GameManager").GetComponent <GameManager>().m_gamesPlayedTxt.gameObject.SetActive(true);
            GameObject.Find("GameManager").GetComponent <GameManager>().m_localHighScoreTxt.gameObject.SetActive(true);


            for (int i = 0; i < GameObject.Find("GameManager").GetComponent <GameManager>().menuObjs.Length; i++)
            {
                GameObject.Find("GameManager").GetComponent <GameManager>().menuObjs[i].SetActive(true);
            }

            //if (GameObject.Find("GameManager").GetComponent<GameManager>().menuObjs[0].GetComponent<InputField>().text != "")
            //{
            //    if (Input.GetMouseButtonUp(0))
            //    {
            //        m_nameSet = true;
            //        PlayerPrefs.SetString("playerName", GameObject.Find("GameManager").GetComponent<GameManager>().menuObjs[0].GetComponent<InputField>().text);
            //        GameObject.Find("GameManager").GetComponent<GameManager>().m_nameOfPlayer = GameObject.Find("GameManager").GetComponent<GameManager>().menuObjs[0].GetComponent<InputField>().text;
            //    }
            //}
        }

        if (m_nameSet)
        {
            //GameObject.Find("GameManager").GetComponent<GameManager>().inputField.SetActive(false);
            if (Camera.main.gameObject.GetComponent <VignetteAndChromaticAberration>().blurSpread > 0)
            {
                Camera.main.gameObject.GetComponent <VignetteAndChromaticAberration>().blurSpread -= Time.deltaTime;
            }
            else
            {
                Camera.main.gameObject.GetComponent <VignetteAndChromaticAberration>().blurSpread = 0;
            }

            if (Camera.main.gameObject.GetComponent <VignetteAndChromaticAberration>().blur > 0)
            {
                Camera.main.gameObject.GetComponent <VignetteAndChromaticAberration>().blur -= Time.deltaTime;
            }
            else
            {
                Camera.main.gameObject.GetComponent <VignetteAndChromaticAberration>().blur = 0;
            }

            if (Camera.main.gameObject.GetComponent <VignetteAndChromaticAberration>().chromaticAberration > 0)
            {
                Camera.main.gameObject.GetComponent <VignetteAndChromaticAberration>().chromaticAberration -= Time.deltaTime * 10;
            }
            else
            {
                Camera.main.gameObject.GetComponent <VignetteAndChromaticAberration>().chromaticAberration = 0;
            }

            GameObject.Find("GameManager").GetComponent <GameManager>().m_gamesPlayedTxt.gameObject.SetActive(false);
            GameObject.Find("GameManager").GetComponent <GameManager>().m_localHighScoreTxt.gameObject.SetActive(false);

            for (int i = 0; i < GameObject.Find("GameManager").GetComponent <GameManager>().menuObjs.Length; i++)
            {
                GameObject.Find("GameManager").GetComponent <GameManager>().menuObjs[i].SetActive(false);
            }

            if (Input.GetMouseButtonDown(0) && m_toRotAround != null)
            {
                m_toRotAround = null;
            }
            else if (Input.GetMouseButtonDown(0) && m_toRotAround == null)
            {
            }
#elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_IPHONE
        //Check if Input has registered more than zero touches
        if (Input.touchCount > 0)
        {
            //Store the first touch detected.
            Touch myTouch = Input.touches[0];

            //Check if the phase of that touch equals Began
            if (myTouch.phase == TouchPhase.Ended)
            {
                m_toRotAround = null;
            }
        }
#endif
            // if your 'chain' is greater than one, hence if you are actually in a chain
            if (m_chainCount > 1)
            {
                GameObject.Find("GameManager").GetComponent <GameManager>().m_chainTxt.gameObject.SetActive(true);
                GameObject.Find("GameManager").GetComponent <GameManager>().m_chainTxt.text = "Chain x" + m_chainCount + "!";
            }
            else
            {
                GameObject.Find("GameManager").GetComponent <GameManager>().m_chainTxt.gameObject.SetActive(false);
            }

            // Checks for any chain achievements
            CheckForChainAchievement();

            // If you are currently orbitting an atom or have just go into orbit of an atom
            if (m_toRotAround != null)
            {
                // set the timeInAir to equal nothing
                m_timeInAir = 0.0f;

                // ----------------------------------------------------------------------------------------------------------------
                transform.RotateAround(m_center.position, m_axis, m_rotationSpeed * Time.deltaTime);                             //-       This chunk of code put simply
                m_desiredPosition  = (transform.position - m_center.position).normalized * m_radius + m_center.position;         //-       rotates you around an object
                transform.position = Vector3.MoveTowards(transform.position, m_desiredPosition, Time.deltaTime * m_radiusSpeed); //-
                // ----------------------------------------------------------------------------------------------------------------

                // forces you to always be looking at the object you are orbitting
                transform.LookAt(m_center);

                // resets your rotation if you enter the orbit on a weird orientation, it will correct itself
                transform.rotation = new Quaternion(0, 0, transform.rotation.z, 1);

                // Sets the 'state' of your player, depending on the side of the orbit zone you are on.
                if (transform.position.x < m_center.position.x)
                {
                    state = curState.LEFT;
                }
                else if (transform.position.x > m_center.position.x)
                {
                    state = curState.RIGHT;
                }
            }
            // else if, you are not rotating around an object, hence, in space
            else if (m_toRotAround == null)
            {
                // increase your time in air value.
                m_timeInAir += Time.deltaTime;

                // Checks your state, and moves you accordingly
                if (state == curState.LEFT)
                {
                    transform.Translate(-Vector3.up * Time.deltaTime * (m_rotationSpeed / 30), Space.Self);
                }
                else if (state == curState.RIGHT)
                {
                    transform.Translate(Vector3.up * Time.deltaTime * (m_rotationSpeed / 30), Space.Self);
                }
            }
        }
    }
コード例 #6
0
ファイル: PlayerControls.cs プロジェクト: lessuknow/RPGEngine
 public void Awake()
 {
     cS = curState._Null;
 }
コード例 #7
0
ファイル: PlayerControls.cs プロジェクト: lessuknow/RPGEngine
 //Sets the charater's current state to "In shop". This is the only thing that sets cS to Shop.
 public void CharInShop()
 {
     cS = curState._Shop;
 }