Exemplo n.º 1
0
    public static void NewGame()
    {
        if (BoltNetwork.IsRunning)
        {
            var newGame = NewGameEvent.Create();
            newGame.Send();
            return;
        }

        List <GameObject> tempGos = new List <GameObject>();

        tempGos.AddRange(GlobalReferences.FreeParts);
        tempGos.AddRange(GlobalReferences.AffectedParts);

        foreach (GameObject go in GlobalReferences.FrozenParts.Values)
        {
            tempGos.Add(go);
        }

        for (int i = tempGos.Count - 1; i >= 0; --i)
        {
            if (tempGos[i].GetComponent <Part>().ID != -1)
            {
                GlobalReferences.DeletePart((int)tempGos[i].GetComponent <Part>().ID);
            }
            else
            {
                MonoBehaviour.Destroy(tempGos[i]);
            }
        }

        GlobalReferences.FreeParts.Clear();
        GlobalReferences.FrozenParts.Clear();
        GlobalReferences.AffectedParts.Clear();
        GlobalReferences.NumOfParts = 0;
        GlobalReferences.Parts.Clear();

        GlobalReferences.PartSpawner.SpawnMultiple(PartsHolder.NumParts);
    }