Guest User

Get how many coins target has in inventory

a guest
May 31st, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. #if UNITY_EDITOR
  6. using UnityEditor;
  7. #endif
  8. namespace RPGSystem{
  9. public class Coins : Float {
  10.  
  11.     public CrossSceneReference target;
  12.     public override float GetResult()
  13.     {
  14.         MovementController c=null;
  15.         if(target!=null)
  16.         {
  17.             if(target.obj!=null){
  18.                 c= target.obj.GetComponent<MovementController>();
  19.             }
  20.         }else{
  21.             c= parent.controller;
  22.         }
  23.         if(c!=null)
  24.         {
  25.             return c.inv.coins;
  26.         }
  27.         return 0;
  28.     }
  29. #if UNITY_EDITOR
  30.     protected override void DrawAdditionalFields()
  31.     {
  32.             target = (CrossSceneReference)EditorGUILayout.ObjectField("Target", target, typeof(CrossSceneReference), true);
  33.     }
  34. #endif
  35.     public override string Type()
  36.     {
  37.         return "Coins";
  38.     }
  39.     public override void CopyTo(Node other)
  40.     {
  41.         Coins temp = other as Coins;
  42.         temp.target = target;
  43.         base.CopyTo(other);
  44.     }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment