Exemplo n.º 1
0
    public void SpawnVersion(RepairState newState)
    {
        currentState = newState;
        if (spawnedVersion != null)
        {
            HilightMaterialSwitcher     hmatSwitcher    = spawnedVersion.GetComponentInChildren <HilightMaterialSwitcher>();
            HilightAllMaterialsSwitcher hmatAllSwitcher = spawnedVersion.GetComponentInChildren <HilightAllMaterialsSwitcher>();
            if (hmatSwitcher != null)
            {
                GetComponent <Interactable>().hilightChangedDelegate -= hmatSwitcher.OnHilightChanged;
            }
            if (hmatAllSwitcher != null)
            {
                GetComponent <Interactable>().hilightChangedDelegate -= hmatAllSwitcher.OnHilightChanged;
            }
            Destroy(spawnedVersion.gameObject);
        }
        switch (newState)
        {
        case RepairState.Repaired:
            spawnedVersion = Instantiate(repairedPrefab, transform);
            break;

        case RepairState.Twisted:
            spawnedVersion = Instantiate(twistedPrefab, transform);
            break;

        case RepairState.Unpainted:
            spawnedVersion = Instantiate(unpaintedPrefab, transform);
            break;

        case RepairState.Damaged:
            spawnedVersion = Instantiate(damagedPrefab, transform);
            break;
        }
        {
            HilightMaterialSwitcher     hmatSwitcher    = spawnedVersion.GetComponentInChildren <HilightMaterialSwitcher>();
            HilightAllMaterialsSwitcher hmatAllSwitcher = spawnedVersion.GetComponentInChildren <HilightAllMaterialsSwitcher>();
            if (hmatSwitcher != null)
            {
                GetComponent <Interactable>().hilightChangedDelegate += hmatSwitcher.OnHilightChanged;
            }
            if (hmatAllSwitcher != null)
            {
                GetComponent <Interactable>().hilightChangedDelegate += hmatAllSwitcher.OnHilightChanged;
            }
        }
    }
Exemplo n.º 2
0
 public void OnDestroy()
 {
     if (spawnedVersion != null)
     {
         HilightMaterialSwitcher     hmatSwitcher    = spawnedVersion.GetComponentInChildren <HilightMaterialSwitcher>();
         HilightAllMaterialsSwitcher hmatAllSwitcher = spawnedVersion.GetComponentInChildren <HilightAllMaterialsSwitcher>();
         if (hmatSwitcher != null)
         {
             GetComponent <Interactable>().hilightChangedDelegate += hmatSwitcher.OnHilightChanged;
         }
         if (hmatAllSwitcher != null)
         {
             GetComponent <Interactable>().hilightChangedDelegate += hmatAllSwitcher.OnHilightChanged;
         }
     }
 }