コード例 #1
0
 //subscribes to a certain event from the DinoClass based on what stat the slider is listening for.
 void Start()
 {
     delegateSource = signalSource.GetComponent <GetDinoInfo> ();
     if (stat == statCode.Health)
     {
         delegateSource.sendHealth += ChangeStat;
         mySlider.value             = delegateSource.dinoStatistics [0].MaxHealth;
     }
     if (stat == statCode.Heat)
     {
         delegateSource.sendHeat += ChangeStat;
         mySlider.value           = delegateSource.dinoStatistics [0].MaxHeat;
     }
     if (stat == statCode.Speed)
     {
         delegateSource.sendSpeed += ChangeStat;
         mySlider.value            = delegateSource.dinoStatistics [0].speed;
     }
     if (stat == statCode.Damage)
     {
         delegateSource.sendDamage += ChangeStat;
         mySlider.value             = delegateSource.dinoWeapons [0].damage;
     }
     if (stat == statCode.ROF)
     {
         delegateSource.sendROF += ChangeStat;
         mySlider.value          = delegateSource.dinoWeapons [0].fireDelay;
     }
 }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     delegateSource = signalSource.GetComponent <GetDinoInfo> ();
     if (dinosaurPosition < delegateSource.numberOfDinosaurs.Count)
     {
         dinoName.text = delegateSource.numberOfDinosaurs [dinosaurPosition].name;
     }
     else
     {
         dinoName.text = delegateSource.numberOfDinosaurs [delegateSource.numberOfDinosaurs.Count - 1].name;
     }
 }
コード例 #3
0
    private GetDinoInfo delegateSource; //attaches to an instance of the GetDinoInfo script

    void Start()
    {
        delegateSource           = signalSource.GetComponent <GetDinoInfo> (); //sets delegate source to the GetDinoInfo Script of the attached object
        delegateSource.sendName += NameChange;                                 //when the player switches dinosaurs, this delegate subscription recieves the name of the new dionsaur
    }