Esempio n. 1
0
    private void Break()
    {
        Hazard.Type[] possibleHazards = new Hazard.Type[0];
        foreach (var moduleType in moduleHazardList.modules)
        {
            if (moduleType.enumID == this.type)
            {
                possibleHazards = moduleType.GetPossibleHazards();
                break;
            }
        }
        if (possibleHazards.Length > 0)
        {
            Hazard.Type selectedHazardType = possibleHazards[Random.Range(0, possibleHazards.Length)];

            Vector3 hazardPosition = transform.position;
            Hazard  hazardPrefab   = hazardsInfos.GetPrefab(selectedHazardType);
            currentHazard = GameObject.Instantiate(hazardPrefab, hazardPosition, Quaternion.identity);

            currentHazard.onFix += this.Fix;
            this.OnBreak();
            isBroken = true;
            status.status[status.modules.IndexOf(type)] = selectedHazardType;
            this.GetComponent <AudioSource>().Play();
        }
    }
Esempio n. 2
0
 public Hazard GetPrefab(Hazard.Type type)
 {
     foreach (var hazardInfos in hazardsInfos)
     {
         if (hazardInfos.type == type)
         {
             return(hazardInfos.prefab);
         }
     }
     return(null);
 }