コード例 #1
0
ファイル: Minimap.cs プロジェクト: zeropointx/KartClone
    void Update()
    {
        /// INITIALIZE ///
        if (gm == null || !initialized)
        {
            GameObject gg = GameObject.Find("Gamemode");
            if (gg == null)
                return;
            gm = gg.GetComponent<Gamemode>();
            if (gm.currentState == Gamemode.State.RACING)
                initialized = true;
            else
                return;
            for (int i = 0; i < gm.GetPlayers().Count; i++)
            {


                tempIcon = Instantiate(defaultIcon);                                            // Create a minimap marker for a player
                tempIcon.transform.parent = transform;                                          // Set its parent to be minimap GameObject
                tempIcon.GetComponent<Image>().sprite = gm.GetPlayers()[i].gameObject.transform.Find("Kart").GetComponent<KartInformation>().miniMapIcon;   // Set the icon sprite to be sprite from KartInformation
                gm.GetPlayers()[i].gameObject.GetComponent<Placement>().miniMapObject = tempIcon;   // Set the created icon to be this players personal minimap icon
            }
        }

        /// UPDATE ///
        for (int i = 0; i < gm.GetPlayers().Count; i++)
        {
            pX = GetMapPos(gm.GetPlayers()[i].gameObject.transform.position.x - offSetX, mapWidth, sceneWidth);
            pZ = GetMapPos(gm.GetPlayers()[i].gameObject.transform.position.z - offSetZ, mapHeight, sceneHeight);
            gm.GetPlayers()[i].gameObject.GetComponent<Placement>().miniMapObject.GetComponent<RectTransform>().localPosition = new Vector3(pX, pZ, 0);
        }
    }
コード例 #2
0
ファイル: Minimap.cs プロジェクト: zeropointx/KartClone
    void Update()
    {
        /// INITIALIZE ///
        if (gm == null || !initialized)
        {
            GameObject gg = GameObject.Find("Gamemode");
            if (gg == null)
            {
                return;
            }
            gm = gg.GetComponent <Gamemode>();
            if (gm.currentState == Gamemode.State.RACING)
            {
                initialized = true;
            }
            else
            {
                return;
            }
            for (int i = 0; i < gm.GetPlayers().Count; i++)
            {
                tempIcon = Instantiate(defaultIcon);                                                                                                        // Create a minimap marker for a player
                tempIcon.transform.parent = transform;                                                                                                      // Set its parent to be minimap GameObject
                tempIcon.GetComponent <Image>().sprite = gm.GetPlayers()[i].gameObject.transform.Find("Kart").GetComponent <KartInformation>().miniMapIcon; // Set the icon sprite to be sprite from KartInformation
                gm.GetPlayers()[i].gameObject.GetComponent <Placement>().miniMapObject = tempIcon;                                                          // Set the created icon to be this players personal minimap icon
            }
        }

        /// UPDATE ///
        for (int i = 0; i < gm.GetPlayers().Count; i++)
        {
            pX = GetMapPos(gm.GetPlayers()[i].gameObject.transform.position.x - offSetX, mapWidth, sceneWidth);
            pZ = GetMapPos(gm.GetPlayers()[i].gameObject.transform.position.z - offSetZ, mapHeight, sceneHeight);
            gm.GetPlayers()[i].gameObject.GetComponent <Placement>().miniMapObject.GetComponent <RectTransform>().localPosition = new Vector3(pX, pZ, 0);
        }
    }