Beispiel #1
0
    void Awake()
    {
        applyTestStats = false;

        init   = GetComponent <InitAbilities>();
        stats  = GetComponent <StatBlock>();
        inv    = GetComponent <EquipmentUser>();
        pClass = GetComponent <PlayerClass>();

        buffs        = new List <TimedBuff>();
        buffsToAdd   = new List <TimedBuff>();
        oldHpPrecent = -10000f;
    }
    private void Awake()
    {
        // NOTE: This Component's TakenPerks field gets its value from the
        // takenPerks field. That field must be loaded (the Load method must
        // have been called on it) before its Perks property will have a
        // non-null value in it. Therefore, the Load method of that PerkList is
        // called right here. This will work so long as no other Component in
        // the same scene as this Component requires the same PerkList to be
        // loaded for its Awake method. Normally, this PerkList would be
        // loaded in a GameState's Enter method but because a GameState's
        // Enter method is only guaranteed to run before any Component's Start
        // method, we must load it here. If any other Component's Awake method
        // in the same scene as this Component required this PerkList to be
        // loaded, it must have its Load method called on it in the GameState
        // just before the GameState that all those Components exist in. For
        // example, it would probably be loaded in HubGameState's Enter method.
        // If this logic (besides the takenPerks.Load() which could go in a
        // GameState's Enter method) was moved to Start, it may possibly work
        // but I don't know enough about the other Components that may rely on
        // PlayerClass's Awake method doing some set up that they need for
        // their own Start methods.
        // - Wesley
        takenPerks.Load();

        // If takenPerks is empty, it means that we're either looking at the
        // null perk list or a new player perk list that is empy.
        if (takenPerks.Perks.Count <= 0)
        {
            // We have to make an entirely new list otherwise the null perk
            // list's list would be overwritten.
            TakenPerks = new List <PerkPrototype>();
        }
        else
        {
            // Not a null perk list
            TakenPerks = takenPerks.Perks;
        }

        stats = GetComponent <ControlStatBlock>();
        init  = GetComponent <InitAbilities>();
    }