Пример #1
0
 void Start()
 {
     this.GetComponent <Text> ().text = "" + Game_.Adjust(displaySpeed) + "%";
     //this.GetComponent<Text>().text = ""+Game_.calcSpeed();
     Game_.debugMode = debugMode;
     timer           = timerCap;
     //PlayerPrefs.SetInt("blackMatter", 0);
     PlayerPrefs.SetInt("totalBlackMatter", (int)Game_.darkMatterTotal);
 }
Пример #2
0
    void Update()
    {
        //Debugging tool for the health bar

        if (Game_.health <= 0.5)
        {
            Game_.health = 0;
            Game_.isDead = true;
        }


        if (!Game_.isDead)
        {
            Vector3 accel = Input.acceleration;
            travelPos = new Vector3(accel.x / limit, 0, originalZ);
            newPos    = travelPos + transform.position;

            if (newPos.y > yPos || newPos.y < yPos)
            {
                transform.position = Vector3.Lerp(transform.position, new Vector3(transform.position.x, yPos, transform.position.z), Time.deltaTime * 5);
            }

            transform.rotation = Quaternion.identity;

            if (travelPos.x < 3.5 || travelPos.x > -3.5)
            {
                transform.Translate(travelPos);
            }

            //Debug.Log (transform.position.x);

            if (transform.position.x > 3 || transform.position.x < -3)
            {
                Game_.health -= edgeDamage;
                Debug.Log("offEdge");
            }

            if (Input.touchCount > 0 && Game_.fire > 0 && !hold)
            {
                count += Time.deltaTime;
                //Debug.Log(Game_.fire);
                if (slot)
                {
                    bulletPos = Fire [0].transform.position;
                }
                else
                {
                    bulletPos = Fire [1].transform.position;
                }

                bulletPos = new Vector3(bulletPos.x, bulletPos.y, 0);

                if (count > Game_.countTime)
                {
                    Game_.fire -= 2;
                    slot        = !slot;
                    GameObject clone = (GameObject)Instantiate(bullet, bulletPos, transform.rotation);
                    //clone.transform.rotation = transform.rotation;
                    clone.GetComponent <Rigidbody2D> ().AddForce(bulletSpeed * transform.forward);
                    //clone.transform.parent = GameObject.FindGameObjectsWithTag ("mainCamera");
                    count = 0;
                }
            }
            else if (Input.touchCount < 1)
            {
                if (Game_.fire < Game_.maxFire)
                {
                    Game_.fire += 1;
                }
            }
            else
            {
                //Debug.Log("On Empty");
                if (Game_.fire <= 0)
                {
                    hold = true;
                }
                if (hold)
                {
                    holdTime += Time.deltaTime;
                    if (holdTime > holdThreshold)
                    {
                        hold = false;
                    }
                }
            }
        }
        else
        {
            transform.GetComponent <Rigidbody2D> ().gravityScale = .5f;
            float calcSpeed = Game_.calcSpeed();
            if (PlayerPrefs.GetFloat("maxSpeed") < Game_.Adjust(calcSpeed - Game_.startTime))
            {
                PlayerPrefs.SetFloat("maxSpeed", Game_.Adjust(calcSpeed - Game_.startTime));
            }
            Game_.time = 0;
        }
    }
Пример #3
0
    void FixedUpdate()
    {
        if (Game_.isDead && !Game_.countDown && !trap)
        {
            this.transform.localPosition = Vector3.Lerp(this.transform.localPosition, new Vector3(0, 20, 0), rateChange * Time.deltaTime);
            //darkMatterTittle.transform.parent.transform.localPosition =
            //	Vector3.Lerp(darkMatterTittle.transform.parent.transform.localPosition, new Vector3 (20000,20000,0),rateChange*999*Time.deltaTime);
            //darkMatterTittle.text="";
            darkMatterTittle.transform.parent.gameObject.SetActive(false);

            //Debug.Log (Game_.time);
            buttonSet.transform.localPosition =
                Vector3.Lerp(buttonSet.transform.localPosition, new Vector3(0, -250, 0), rateChange * 9 * Time.deltaTime);
        }
        else if (Game_.countDown || trap)
        {
            trap = true;
            this.transform.localPosition = Vector3.Lerp(this.transform.localPosition, new Vector3(0, 500, 0), rateChange * Time.deltaTime);
            //darkMatterTittle.transform.parent.transform.localPosition =
            //	Vector3.Lerp(darkMatterTittle.transform.parent.transform.localPosition, new Vector3 (20000,20000,0),rateChange*999*Time.deltaTime);
            //darkMatterTittle.text="";
            darkMatterTittle.transform.parent.gameObject.SetActive(false);

            //Debug.Log (Game_.time);
            buttonSet.transform.localPosition =
                Vector3.Lerp(buttonSet.transform.localPosition, new Vector3(0, 500, 0), rateChange * 9 * Time.deltaTime);
        }

        if (!Game_.debugMode && !Game_.isDead)
        {
            Game_.time  += Time.deltaTime;
            timer       -= Time.deltaTime;
            displaySpeed = Game_.calcSpeed();
            //displaySpeed = 100/(1+(Mathf.Exp((float) -0.08f * (Game_.time-60))));
            Game_.starSpeed = Game_.calcSpeed();            //displaySpeed * 0.24f;
        }
        else
        {
            //Game_.time = Game_.debugTime;
            timer = -1;
        }


        if (displaySpeed > 90)
        {
            Camera.GetComponent <Camera> ().backgroundColor = Color.Lerp(Camera.GetComponent <Camera>().backgroundColor, colorTo, Time.deltaTime * .01f);
        }

        if (timer < 0)
        {
            if (displaySpeed < 100)
            {
                this.GetComponent <Text> ().text = "" + Game_.Adjust(displaySpeed - Game_.startTime) + "%";
            }
            else
            {
                this.GetComponent <Text> ().text    = "HYPERSPACE";
                subText.GetComponent <Text> ().text = "velocity has been achieved!";
            }
            timer = timerCap;
        }



        if (Game_.darkMatter >= Game_.darkMatterCapacity)
        {
            Game_.darkMatter = Game_.darkMatterCapacity;
            //PlayerPrefs.SetInt("darkMatter",Game_.darkMatter);
        }
        darkMatterTittle.text = Game_.darkMatter + " kg";
    }