Advertisement
Guest User

Lava Floor Mod

a guest
Jul 16th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. using UnityEngine;
  8.  
  9. namespace meta
  10. {
  11.     public class TriggerCode : MonoBehaviour {
  12.        
  13.         void OnTriggerStay(Collider other) {
  14.             try {
  15.                 if (other.attachedRigidbody) {
  16.                     other.attachedRigidbody.AddForce (Vector3.up * 10);
  17.  
  18.                 }
  19.                 other.attachedRigidbody.GetComponentInChildren<FireTag> ().Ignite ();
  20.             } catch {
  21.  
  22.             }
  23.             /**
  24.             try {
  25.                
  26.                 other.GetComponent<FireTag>().Ignite();
  27.  
  28.             } catch {
  29.                
  30.             }**/
  31.  
  32.         }/**
  33.         void OnTriggerEnter(Collider other) {
  34.             if (other.attachedRigidbody) {
  35.                 other.attachedRigidbody.AddForce (Vector3.up * 10);
  36.             }
  37.  
  38.             try {
  39.  
  40.                 other.GetComponent<FireTag>().Ignite();
  41.  
  42.  
  43.  
  44.  
  45.  
  46.             } catch {
  47.  
  48.             }
  49.  
  50.         }**/
  51.     }
  52.  
  53.     public class Mod : MonoBehaviour
  54.     {
  55.         public Mod() {
  56.  
  57.         }
  58.  
  59.         public void Start ()
  60.         {
  61.            
  62.         }
  63.  
  64.         public bool LavaUp = false;
  65.         GameObject Lava;
  66.         bool LavaState = false;
  67.         public Color LavaColor = Color.red;
  68.         float TempColorLerpThing;
  69.  
  70.         public void Update () {
  71.             if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.M) && LavaState == true) {
  72.  
  73.                 GameObject.Destroy (GameObject.Find ("Lava"));
  74.                 Lava = null;
  75.                 TempColorLerpThing = 0;
  76.                 LavaColor = Color.red;
  77.                 LavaUp = false;
  78.                 LavaState = false;
  79.  
  80.             } else if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.M) && LavaState == false) {
  81.                 Lava = GameObject.CreatePrimitive (PrimitiveType.Cube);
  82.                 Lava.renderer.material.color = LavaColor;
  83.                 Lava.name = "Lava";
  84.                 Lava.transform.position = new Vector3 (0, 0.5f, 0);
  85.                 Lava.transform.localScale = new Vector3 (1000, 1, 1000);
  86.                 Lava.collider.enabled = true;
  87.                 Lava.collider.isTrigger = true;
  88.                 Lava.AddComponent<TriggerCode> ();
  89.                 //Lava.AddComponent<FireTag> ();
  90.                 //Lava.GetComponent<FireTag> ().Start ();
  91.                 //Lava.GetComponent<FireTag> ().Ignite ();
  92.                 LavaState=true;
  93.             }
  94.  
  95.             if (GameObject.Find ("Lava") != null) {
  96.                 Lava.renderer.material.color = LavaColor;
  97.                 if (GameObject.Find ("Lava").transform.position.y < 0) {
  98.                     LavaUp = true;
  99.                     TempColorLerpThing = 0;
  100.                 }
  101.                 if (GameObject.Find ("Lava").transform.position.y > 0.5f) {
  102.                     LavaUp = false;
  103.                     TempColorLerpThing = 1;
  104.                 }
  105.  
  106.                 if (LavaUp == true) {
  107.                     Lava.transform.position = new Vector3 (0, Lava.transform.position.y + 0.01f, 0);
  108.                     TempColorLerpThing += 0.002f;
  109.                     LavaColor = Color.Lerp (Color.red, Color.yellow, TempColorLerpThing);
  110.                 }
  111.  
  112.                 if (LavaUp == false) {
  113.                     Lava.transform.position = new Vector3 (0, Lava.transform.position.y - 0.01f, 0);
  114.                     TempColorLerpThing -= 0.002f;
  115.                     LavaColor = Color.Lerp (Color.yellow, Color.red, TempColorLerpThing);
  116.                 }
  117.             }
  118.         }
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement