Guest User

Untitled

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