Пример #1
0
 /// <summary>
 /// Sets the vehicle on fire.
 /// </summary>
 public override void setFire()
 {
     if (isServer)
     {
         if (validOwner())
         {
             RpcMessageOwner(vehicleName + " is on fire!");
         }
         fire = true;
         GameObject      fireObj   = (GameObject)Resources.Load("CarFire");       //unique fire prefab for vehicle class
         FireTransform[] fireTrans = gameObject.GetComponentsInChildren <FireTransform> ();
         if (fireTrans.Length < 1)
         {
             GameObject tmp = (GameObject)Instantiate(fireObj, new Vector3(gameObject.transform.position.x, getHighest(), gameObject.transform.position.z), fireObj.transform.rotation);
             NetworkServer.Spawn(tmp);
             Debug.LogWarning(vehicleName + " is on fire but has no transforms");
         }
         foreach (FireTransform ft in fireTrans)
         {
             GameObject tmp = (GameObject)Instantiate(fireObj, ft.transform.position, fireObj.transform.rotation);
             FireKiller fk  = tmp.GetComponent <FireKiller> ();
             ft.onFire      = true;            //Tells the fire transform that it is on fire. All fts must report back OnFire = false for advance month to consider the building not on fire!
             fk.myTransform = ft;              //sets the FireKiller's firetransform, which allows it to update the FT about the state of the fire!
             fk.setObject(gameObject.GetComponent <Vehicle> ());
             NetworkServer.Spawn(tmp);
         }
     }
 }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     fk = GetComponent <FireKiller> ();
     initialFireLife    = fk.fireLife;
     pts                = GetComponentsInChildren <ParticleSystem> ();
     modulateDownFirst  = true;
     modulateDownSecond = true;
 }
Пример #3
0
 /// <summary>
 /// Sets the building on fire.
 /// </summary>
 public virtual void setFire()
 {
     if (isServer)
     {
         fire = true;
         GameObject      fireObj   = (GameObject)Resources.Load("HouseFire");       //Must be changed for other fire prefabs in other classes
         FireTransform[] fireTrans = gameObject.GetComponentsInChildren <FireTransform>();
         if (fireTrans.Length < 1)
         {
             GameObject tmp = (GameObject)Instantiate(fireObj, new Vector3(gameObject.transform.position.x, getHighest(), gameObject.transform.position.z), fireObj.transform.rotation);
             NetworkServer.Spawn(tmp);
             Debug.LogError("Object is on fire but has no transforms");
         }
         foreach (FireTransform ft in fireTrans)
         {
             GameObject tmp = (GameObject)Instantiate(fireObj, ft.transform.position, fireObj.transform.rotation);
             FireKiller fk  = tmp.GetComponent <FireKiller> ();
             ft.onFire      = true;                               //Tells the fire transform that it is on fire. All fts must report back OnFire = false for advance month to consider the building not on fire!
             fk.myTransform = ft;                                 //sets the FireKiller's firetransform, which allows it to update the FT about the state of the fire!
             fk.setObject(gameObject.GetComponent <Building> ()); //Must be customized for sub classes if they are not buildings
             NetworkServer.Spawn(tmp);
         }
     }
 }