Exemple #1
0
    public void SetupLevel()
    {
        levelText.text = "Level: " + (level + 1);

        foreach (GameObject hoop in hoops)
        {
            Destroy(hoop);
        }
        hoops.Clear();

        if (level == 0)
        {
            GameObject     hoop       = Instantiate(hoopPrefab, new Vector3(0f, 2.5f, 1f), Quaternion.identity);
            HoopController controller = hoop.GetComponent <HoopController> ();
            controller.SetPoints(basketPoints);
            hoops.Add(hoop);
        }
        else
        {
            for (int i = 0; i < level; i++)
            {
                float          yPos       = Random.Range(2f, 2f + 2.5f * i);
                float          zPos       = 0.5f + 2.5f * i;
                GameObject     hoop       = Instantiate(hoopPrefab, new Vector3(0f, yPos, zPos), Quaternion.identity);
                HoopController controller = hoop.GetComponent <HoopController> ();
                controller.SetPoints(basketPoints + basketPoints * i);
                controller.speed = Random.Range(1f, 1f + 1.5f * i);
                controller.range = 1f + 3f * i;
                hoops.Add(hoop);
            }
        }

        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("score", GameManager.i.score);
        AnalyticsEvent.LevelStart(level, data);
    }
	// Use this for initialization
	void Start () {
		playerAugment = null;

		if (playerPrefix == "P1") {
			otherPlayerPrefix = "P2";
		} else {
			otherPlayerPrefix = "P1";
		}

		if ((Application.platform == RuntimePlatform.OSXEditor) || (Application.platform == RuntimePlatform.OSXPlayer)) {
			swapButtonAug = "SwapAugMac" + playerPrefix;
		} else if ((Application.platform == RuntimePlatform.WindowsEditor) || (Application.platform == RuntimePlatform.WindowsPlayer)) {
			swapButtonAug = "SwapAugPC" + playerPrefix;
		}

		otherPlayerStats = GameObject.Find (otherPlayerPrefix).GetComponent<StatsManager> ();
		playerAugSprite = GameObject.Find (playerPrefix + "Aug");
		otherPlayerAugSprite = GameObject.Find (otherPlayerPrefix + "Aug");
		otherPlayerHudImage = GameObject.Find(otherPlayerPrefix + "Hud").GetComponent<Image>();
		if (playerPrefix == "P1") {
			hudDefault = Resources.Load<Sprite> ("Interface/P2-slots-blank");
			hudReq = Resources.Load<Sprite> ("Interface/P2-slots-prompt");
		} else if (playerPrefix == "P2") {
			hudDefault = Resources.Load<Sprite> ("Interface/P1-slots-blank");
			hudReq = Resources.Load<Sprite> ("Interface/P1-slots-prompt");
		}

		if (roomIn != null) {
			transform.position = new Vector3(roomIn.transform.position.x, 0f, roomIn.transform.position.z);
		}

		playerShooting = GetComponent<PlayerShooting> ();
		otherPlayerShooting = GameObject.Find (otherPlayerPrefix).GetComponent<PlayerShooting> ();

		foreach (Transform child in transform) {
			if (child.tag == "Hoop") {
				hoopController = child.gameObject.GetComponent<HoopController>();
			}
		}
		//Determine shooting buttons for OS and Player
		if ((Application.platform == RuntimePlatform.OSXEditor) || (Application.platform == RuntimePlatform.OSXPlayer)) {
			pingButton = "PingMac" + playerPrefix;
		} else if ((Application.platform == RuntimePlatform.WindowsEditor) || (Application.platform == RuntimePlatform.WindowsPlayer)) {
			pingButton = "PingPC" + playerPrefix;
		}

	}
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        playerAugment = null;

        if (playerPrefix == "P1")
        {
            otherPlayerPrefix = "P2";
        }
        else
        {
            otherPlayerPrefix = "P1";
        }

        if ((Application.platform == RuntimePlatform.OSXEditor) || (Application.platform == RuntimePlatform.OSXPlayer))
        {
            swapButtonAug = "SwapAugMac" + playerPrefix;
        }
        else if ((Application.platform == RuntimePlatform.WindowsEditor) || (Application.platform == RuntimePlatform.WindowsPlayer))
        {
            swapButtonAug = "SwapAugPC" + playerPrefix;
        }

        otherPlayerStats     = GameObject.Find(otherPlayerPrefix).GetComponent <StatsManager> ();
        playerAugSprite      = GameObject.Find(playerPrefix + "Aug");
        otherPlayerAugSprite = GameObject.Find(otherPlayerPrefix + "Aug");
        otherPlayerHudImage  = GameObject.Find(otherPlayerPrefix + "Hud").GetComponent <Image>();
        if (playerPrefix == "P1")
        {
            hudDefault = Resources.Load <Sprite> ("Interface/P2-slots-blank");
            hudReq     = Resources.Load <Sprite> ("Interface/P2-slots-prompt");
        }
        else if (playerPrefix == "P2")
        {
            hudDefault = Resources.Load <Sprite> ("Interface/P1-slots-blank");
            hudReq     = Resources.Load <Sprite> ("Interface/P1-slots-prompt");
        }

        if (roomIn != null)
        {
            transform.position = new Vector3(roomIn.transform.position.x, 0f, roomIn.transform.position.z);
        }

        playerShooting      = GetComponent <PlayerShooting> ();
        otherPlayerShooting = GameObject.Find(otherPlayerPrefix).GetComponent <PlayerShooting> ();

        foreach (Transform child in transform)
        {
            if (child.tag == "Hoop")
            {
                hoopController = child.gameObject.GetComponent <HoopController>();
            }
        }
        //Determine shooting buttons for OS and Player
        if ((Application.platform == RuntimePlatform.OSXEditor) || (Application.platform == RuntimePlatform.OSXPlayer))
        {
            pingButton = "PingMac" + playerPrefix;
        }
        else if ((Application.platform == RuntimePlatform.WindowsEditor) || (Application.platform == RuntimePlatform.WindowsPlayer))
        {
            pingButton = "PingPC" + playerPrefix;
        }
    }