Guest User

Untitled

a guest
May 20th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4.  
  5. public class MyMainObject : MonoBehaviour
  6. {
  7.    
  8.     public Vector2 position;
  9.     public Vector2 texture;
  10.     public Vector2 CollisionBoxLeftTop, CollisionBoxRightBottom;
  11.    
  12.     public Transform thisTransform;
  13.    
  14.     public int timeDisplayed;
  15.    
  16.     public OTAnimatingSprite mySprite;
  17.    
  18.    
  19.     void Start()
  20.     {
  21.         mySprite = GetComponent<OTAnimatingSprite>();
  22.         thisTransform = transform;
  23.     }
  24.  
  25.     public virtual Vector2 GetSize()
  26.     {
  27.         if (mySprite.texture != null)
  28.             return new Vector2(mySprite.texture.width, mySprite.texture.height);
  29.         else
  30.             return Vector2.zero;
  31.     }
  32.  
  33.     public virtual float GetDrawBaseHeight()
  34.     {
  35.         return thisTransform.position.y + GetSize().y;
  36.     }
  37.  
  38.     public Vector2 GetCenter() //POSITION OF TEXTURE CENTER
  39.     {
  40.         return new Vector2(thisTransform.position.x + mySprite.texture.width / 2, thisTransform.position.y + mySprite.texture.height / 2);
  41.     }
  42.  
  43.     public Vector2 GetCollisionBoxCenter()
  44.     {
  45.         return ( CollisionBoxLeftTop + CollisionBoxRightBottom ) / 2;
  46.     }
  47.  
  48.     public virtual void Update(float time)
  49.     {
  50.         timeDisplayed++;
  51.     }
  52. }
Add Comment
Please, Sign In to add comment