Esempio n. 1
0
    void Start()
    {
        spawner = transform.parent.GetComponent <SpawnerScript>();
        spawn   = transform.position;
        timer   = Time.time;

        if (!isValid())
        {
            spawner.EndGame();
            Destroy(gameObject);
        }
    }
Esempio n. 2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (active)
        {
            if (Input.GetKeyDown(KeyCode.D))
            {
                transform.position += new Vector3(1, 0);
                if (!isValid())
                {
                    transform.position -= new Vector3(1, 0);
                }
            }
            else if (Input.GetKeyDown(KeyCode.A))
            {
                transform.position += new Vector3(-1, 0);
                if (!isValid())
                {
                    transform.position += new Vector3(1, 0);
                }
            }
            else if (Input.GetKeyDown(KeyCode.W))
            {
                //transform.RotateAround(transform.TransformPoint(rotationPoint), new Vector3(0, 0, 1), 90);

                //if (!isValid())
                //{
                //    transform.RotateAround(transform.TransformPoint(rotationPoint), new Vector3(0, 0, 1), -90);
                //}
            }
            if (Time.time - timer > (Input.GetKey(KeyCode.S) ? fallTime / 8 : fallTime))
            {
                timer = Time.time;
                transform.position += new Vector3(0, -1);
                if (!isValid())
                {
                    transform.position += new Vector3(0, 1);
                    setNotActive();
                    if (transform.position == spawn)
                    {
                        spawner.EndGame();
                    }
                }
            }
        }
    }