Advertisement
AnthonyGraceffa

QK Scaleform HUD Manager

Mar 7th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.46 KB | None | 0 0
  1. /*---------------------------------*/
  2. /*do not access these public functions to change HUD Info, call the ones in HUDCam instead */
  3. /*---------------------------------*/
  4.  
  5. using System;
  6. using System.Collections;
  7. using UnityEngine;
  8. using Scaleform;
  9.  
  10.  
  11.  
  12. public class gameHUD : Movie
  13. {
  14.  
  15.     protected Value swfMovie = null;
  16.     //private SWFCamera parent = null;
  17.     public bool liveBattTest = true;
  18.  
  19.  
  20.     public gameHUD(HUDCam parent, SFManager sfmgr, SFMovieCreationParams cp) :
  21.     base(sfmgr, cp){
  22.         //this.parent = parent;
  23.         SFMgr = sfmgr;
  24.         this.SetFocus(true);
  25.     }
  26.    
  27.     public void OnRegisterSWFCallback(Value swfRef){
  28.         swfMovie = swfRef;
  29.         //Debug.Log ("SWF Callback!");
  30.     }
  31.  
  32.     //used for testing all updates with default values
  33.     public void testUpdates () {
  34.         updateObjective ("Goal: Fix the SVN");
  35.         updateBattery (78f);
  36.         setCompassP1 (250f);
  37.     }
  38.  
  39.     //call this to update battery display
  40.     public void updateBattery (float battLevel) {
  41.         Value bBar = swfMovie.GetMember ("bBar");
  42.         if (bBar != null) {
  43.             SFDisplayInfo dInfo = bBar.GetDisplayInfo();
  44.  
  45.             if(dInfo == null) return;
  46.  
  47.             //this sets the scale on the x axis(the width) of the battery bar,the max width is 78, adjust math acoordingly
  48.             dInfo.XScale = (double)battLevel;
  49.             bBar.SetDisplayInfo(dInfo);
  50.  
  51.         }
  52.     }
  53.  
  54.     //hard sets x of ability bar
  55.     public void slideAbility (bool right, float newX) {
  56.         Value bBar = swfMovie.GetMember ("abilityBar");
  57.         if (bBar != null) {
  58.             SFDisplayInfo dInfo = bBar.GetDisplayInfo();
  59.            
  60.             if(dInfo == null) return;
  61.            
  62.             if(right){
  63.                 dInfo.X  += 45;
  64.             }
  65.             else{
  66.                 dInfo.X  -= 45;
  67.             }
  68.             bBar.SetDisplayInfo(dInfo);
  69.            
  70.         }
  71.     }
  72.  
  73.     //for lerping ability bar x
  74.     public void slideAbilitySmooth (float newX) {
  75.         Value bBar = swfMovie.GetMember ("abilityBar");
  76.         if (bBar != null) {
  77.             SFDisplayInfo dInfo = bBar.GetDisplayInfo();
  78.            
  79.             if(dInfo == null) return;
  80.            
  81.             dInfo.X = newX;
  82.             bBar.SetDisplayInfo(dInfo);
  83.            
  84.         }
  85.     }
  86.  
  87.     //call this to move minimap
  88.     public void updateMap (float mapX, float mapY) {
  89.         Value miniMap = swfMovie.GetMember ("miniMap");
  90.         if (miniMap != null) {
  91.             SFDisplayInfo dInfo = miniMap.GetDisplayInfo();
  92.            
  93.             if(dInfo == null) return;
  94.            
  95.             //this sets the x and y position of the minimap
  96.             dInfo.X = (double)mapX;
  97.             dInfo.Y = (double)mapY;
  98.             miniMap.SetDisplayInfo(dInfo);
  99.            
  100.         }
  101.     }
  102.  
  103.     //call this to update objective display text at top of the HUD, the passed string becomes the new objective
  104.     public void updateObjective (string objective) {
  105.         swfMovie.Invoke ("updateObjective", objective);
  106.     }
  107.  
  108.     //when this is called the little charge "bloop" plays around the charge gauge indicating the level has changed
  109.     public void chargeGraphic () {
  110.         swfMovie.Invoke ("chargePulse");
  111.     }
  112.  
  113.     //set compass objective indicator 1
  114.     public void setCompassP1 (float x) {
  115.         Value p1 = swfMovie.GetMember ("P1");
  116.         float y = 59;
  117.  
  118.         if (p1 != null) {
  119.             SFDisplayInfo dInfo = p1.GetDisplayInfo();
  120.            
  121.             if(dInfo == null) return;
  122.            
  123.             //this sets x value of the position of compass point 1, 150 is the farthest left it should go and 400 is the farthest right
  124.             //float xBegin = 150f;
  125.             //float xEnd = 400f;
  126.             float curX = 0;
  127.             if(x < 250f){
  128.                 curX = 250 - x;
  129.                 curX = curX/125;
  130.                 y = 41 + 18*curX;
  131.  
  132.  
  133.             }
  134.             if(x >= 250f){
  135.                 curX = x - 250;
  136.                 curX = curX/125;
  137.                 y = 41 + 18*curX;
  138.             }
  139.             dInfo.X = (double)x;
  140.             dInfo.Y = (double)y;
  141.             p1.SetDisplayInfo(dInfo);
  142.            
  143.         }
  144.     }
  145.  
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement