Ejemplo n.º 1
0
    // nastavljanje tank indexa
    public void SetTankIndex(int _tankIndex)
    {
        // nastavimo primeren tank index
        tankIndex = _tankIndex;

        // poiščemo primeren health slider
        string sliderName = "Slider_Health_Tank_" + tankIndex.ToString();

        healthSlider = GameObject.Find(sliderName).GetComponent <Slider>();
        // nastavimo polno vrednost health sliderja
        healthSlider.value = tankStartHealth;

        if (NetworkInfo.isNetworkMatch)
        {
            GameObject[] allNetPlayers = GameObject.FindGameObjectsWithTag("NetworkPlayer");
            foreach (GameObject netPlayer in allNetPlayers)
            {
                NetworkPlayerManager netPlayerScript = netPlayer.GetComponent <NetworkPlayerManager>();
                if (netPlayerScript.playerIndex != tankIndex)
                {
                    netPlayerManagerSript = netPlayerScript;
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void Awake()
    {
        instance     = this;
        minionsCount = 0;

        scrollTexts = new Dictionary <int, ScrollCombatText>();
        hudRootGO   = GameObject.Find("HUDRoot");
    }
Ejemplo n.º 3
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }

        instance = this;
    }
 // Start is called before the first frame update
 void Awake()
 {
     if (singleton == null)
     {
         singleton = this;
     }
     else if (singleton != this)
     {
         Destroy(this);
     }
 }
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
    void CmdSetValuesOfOtherPlayers(NetworkInstanceId id)
    {
        // najprej najdemo objekt na serverju preko net id
        GameObject otherPlayer = NetworkServer.FindLocalObject(id);
        // poiščemo tole skripto
        NetworkPlayerManager otherPlayerScript = otherPlayer.GetComponent <NetworkPlayerManager>();

        // shranimo ime objekta
        string name = otherPlayer.name;
        // shranimo index objekta
        int index = otherPlayerScript.playerIndex;

        // pošljemo informacije vsem clientom
        RpcSetPlayerNameAndIndex(name, index, id);
    }
    void RpcSetPlayerNameAndIndex(string tankName, int index, NetworkInstanceId id)
    {
        // najprej poiščemo objekt preko net id
        GameObject localObject = ClientScene.FindLocalObject(id);

        // just double check, da smo res našli objekt
        if (localObject != null)
        {
            // poišči to skripto na objektu
            NetworkPlayerManager localObjectScript = localObject.GetComponent <NetworkPlayerManager>();
            // spremeni ime objekta
            localObject.name = tankName;
            // spremeni index v skripti
            localObjectScript.playerIndex = index;
            // spremeni net id value v skripti (potreben če se pridruži še kakšen igralec)
            localObjectScript.objectNetId = id;
        }
    }
 void Awake()
 {
     Instance = this;
 }