Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TrapBox : Bolt.EntityBehaviour<ITrapBox> {
  6.  
  7.     // Use this for initialization
  8.     void Start () {
  9.        
  10.     }
  11.    
  12.     public override void Attached()
  13.     {
  14.         state.SetTransforms(state.Transform, transform);
  15.         state.AddCallback("isAlive", StateChange);
  16.         state.isAlive = true;
  17.     }
  18.  
  19.     private void StateChange()
  20.     {
  21.         Debug.Log("IsAlive Change");
  22.         GetComponent<MeshRenderer>().enabled = state.isAlive;
  23.     }
  24.  
  25.     private void OnTriggerEnter(Collider other)
  26.     {
  27.         if (entity.isOwner)
  28.         {
  29.             Debug.Log("Trigger");
  30.             if (other.CompareTag("Player"))
  31.             {
  32.                 other.GetComponent<PlayerBoltLinker>().state.HP -= 10;
  33.                 state.isAlive = false;
  34.             }
  35.         }
  36.     }
  37.  
  38.     private void FixedUpdate()
  39.     {
  40.         if (entity.isOwner)
  41.         {
  42.             transform.Rotate(20 * BoltNetwork.FrameDeltaTime, 20 * BoltNetwork.FrameDeltaTime,
  43.                 20 * BoltNetwork.FrameDeltaTime);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement