示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (deadPlayers >= GlobalGameManager.NumberOfPlayers())
        {
            deadPlayers = 0;
            Application.LoadLevel(2);
        }

        if (bossNumbers <= 0)
        {
            timer += Time.deltaTime;
            if (timer >= endSceneDelay)
            {
                Application.LoadLevel(3);
            }
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (powerupTimer >= 30 * GlobalGameManager.NumberOfPlayers())
        {
            SpawnPowerup();
            powerupTimer = 0;
        }
        else
        {
            powerupTimer += Time.deltaTime;
        }
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        int playerCount = GlobalGameManager.NumberOfPlayers();

        Vector3 cp  = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, 10));
        Vector3 div = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, 10));
        float   w   = Vector3.Distance(cp, div) / (playerCount + 1);

        transform.position = new Vector3(cp.x, transform.position.y, transform.position.z);

        if (playerCount >= 1)
        {
            p1.localPosition = new Vector3(w * 1, 0, 0);
        }
        if (playerCount >= 2)
        {
            p2.localPosition = new Vector3(w * 2, 0, 0);
        }
        if (playerCount >= 3)
        {
            p3.localPosition = new Vector3(w * 3, 0, 0);
        }
        if (playerCount >= 4)
        {
            p4.localPosition = new Vector3(w * 4, 0, 0);
        }
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        instance = this;
        bossHealthBar.SetActive(false);
        int   tw = (int)Camera.main.pixelWidth;
        float bw = Camera.main.pixelWidth * 0.25f;

        tw          -= (int)(bw * GlobalGameManager.NumberOfPlayers());
        tw           = (int)(tw * 0.5f);
        bars.padding = new RectOffset(tw, tw, bars.padding.top, bars.padding.bottom);

        skull.SetActive(false);
        goldenSkull.SetActive(false);

        if ((GlobalGameManager.stage - 1) > 0)
        {
            int sw = (int)skull.transform.parent.GetComponent <RectTransform>().rect.height;
            int cw = (int)skull.transform.parent.GetComponent <RectTransform>().rect.width;

            cw -= (int)(sw * (GlobalGameManager.stage));
            cw  = (int)(cw * 0.5f);
            skull.transform.parent.GetComponent <HorizontalLayoutGroup>().padding = new RectOffset(cw, cw, 0, 0);

            for (int i = 0; i < (GlobalGameManager.stage - 1); i++)
            {
                GameObject g = (GameObject)Instantiate((i + 1) % 5 == 0?goldenSkull:skull);
                g.transform.SetParent(skull.transform.parent);
                g.SetActive(true);
            }
        }
    }