public void ApplyStateLate(SavedState state)
    {
        if (state.IsLoaded)
        {
            Player initialPlayer = currentVirus.Value;

            List <SystemElement> _elementList = elementList.Value;
            int elementCount = _elementList.Count;
            SystemElementInfo[] elementInfoArray = state.SystemElementInfoArray;
            Player[]            playersArray     = players.Array;

            for (int i = 0; i < elementCount; i++)
            {
                var systemElement = _elementList[i];
                var elementInfo   = elementInfoArray[i];

                if (elementInfo.IsHacked)
                {
                    Player hacker = playersArray[elementInfo.OwnerVirus];
                    systemElement.OwnerVirus = hacker;
                    systemElement.IsHacked   = true;

                    currentVirus.Value = hacker;
                    componentController.HackElement(systemElement.Controller);
                }
                else if (elementInfo.IsDestroyed)
                {
                    Player destroyer = playersArray[elementInfo.OwnerVirus];
                    systemElement.OwnerVirus  = destroyer;
                    systemElement.IsDestroyed = true;

                    currentVirus.Value = destroyer;
                    componentController.DestroyElement(systemElement.Controller);
                }
            }

            currentVirus.Value = initialPlayer;
        }
    }
Exemplo n.º 2
0
 private void Destroy()
 {
     componentController.DestroyElement(elementController);
     Hide();
 }