Exemple #1
0
    // Start is called before the first frame update


    void Start()
    {
        PrefabKey variable = GetComponent <PrefabKey>();

        nombrecomparar = variable.nombre;
        Debug.Log(nombrecomparar);
    }
Exemple #2
0
    public AllyData(GameObject ally)
    {
        // Try to pull a PrefabKey script off the ally (it should have one)
        PrefabKey prefabKeyScriptRef = ally.GetComponent <PrefabKey>();

        if (prefabKeyScriptRef != null)
        {
            _prefKey = prefabKeyScriptRef.GetPrefabKey();
        }
        else
        {
            Debug.LogError("No PrefabKey script was attached to " + ally.name);
        }

        // Try to pull an AllyStats script off the ally (it should have one)
        AllyStats allyStatsScriptRef = ally.GetComponent <AllyStats>();

        if (allyStatsScriptRef != null)
        {
            _experience            = allyStatsScriptRef.GetExperience();
            _oneLvlExperience      = allyStatsScriptRef.GetOneLevelExperience();
            _level                 = allyStatsScriptRef.GetLevel();
            _nextLvlThreshold      = allyStatsScriptRef.GetNextLevelThreshold();
            _oneLvlThreshold       = allyStatsScriptRef.GetOneLevelNextLevelThreshold();
            _amountStatIncreases   = allyStatsScriptRef.AmountStatIncreases;
            _strength              = allyStatsScriptRef.GetStrength();
            _magic                 = allyStatsScriptRef.GetMagic();
            _speed                 = allyStatsScriptRef.GetSpeed();
            _vitality              = allyStatsScriptRef.GetVitality();
            _strengthBubblesFilled = allyStatsScriptRef.StrBubblesFilled;
            _magicBubblesFilled    = allyStatsScriptRef.MagicBubblesFilled;
            _speedBubblesFilled    = allyStatsScriptRef.SpeedBubblesFilled;
            _vitalityBubblesFilled = allyStatsScriptRef.VitalityBubblesFilled;
        }
        else
        {
            Debug.LogError("There was no AllyStats script attached to " + ally.name);
        }

        // Try to pull an AllyHealth script off the ally (it should have one)
        AllyHealth allyHealthScriptRef = ally.GetComponent <AllyHealth>();

        if (allyHealthScriptRef != null)
        {
            _maxHP = allyHealthScriptRef.MaxHP;
            _curHP = allyHealthScriptRef.CurHP;
        }
        else
        {
            Debug.LogError("There was no AllyHealth script attached to " + ally.name);
        }

        // Transform components
        _position    = new float[3];
        _position[0] = ally.transform.position.x;
        _position[1] = ally.transform.position.y;
        _position[2] = ally.transform.position.z;
    }
    public InteractableData(Interactable interact)
    {
        // Try to pull prefab key off
        PrefabKey prefabKeyScriptRef = interact.GetComponent <PrefabKey>();

        if (prefabKeyScriptRef != null)
        {
            _prefKey = prefabKeyScriptRef.GetPrefabKey();
        }
        else
        {
            Debug.LogError("No PrefabKey attached to " + interact.name);
        }

        _canInteractWith = interact.GetCanInteractWith();

        _position    = new float[3];
        _position[0] = interact.transform.position.x;
        _position[1] = interact.transform.position.y;
        _position[2] = interact.transform.position.z;
    }
    /// <summary>
    /// Create the hashtable for looking up the prefab
    /// </summary>
    /// <param name="allPrefabs">The prefabs that we are setting the hashtable to contain<param>
    /// <returns>Hashtable. Built hashtable that has assigned keys to the prefabs</returns>
    public static Hashtable BuildHashtable(GameObject[] allPrefabs)
    {
        Hashtable prefHash = new Hashtable(allPrefabs.Length);

        // Put each prefab into the hashtables based on their key
        foreach (GameObject singlePref in allPrefabs)
        {
            // Try to pull a PrefabKey script off the prefab (it should have one)
            PrefabKey prefKeyScriptRef = singlePref.GetComponent <PrefabKey>();
            if (prefKeyScriptRef != null)
            {
                int currentKey = prefKeyScriptRef.GetPrefabKey();
                prefHash.Add(currentKey, singlePref);
            }
            else
            {
                Debug.LogError("No Interactable script was attached to " + singlePref.name);
            }
        }

        return(prefHash);
    }
Exemple #5
0
    public EnemyData(GameObject enemy)
    {
        // Try to pull a PrefabKey script off the enemy (it should have one)
        PrefabKey prefabKeyScriptRef = enemy.GetComponent <PrefabKey>();

        if (prefabKeyScriptRef != null)
        {
            _prefKey = prefabKeyScriptRef.GetPrefabKey();
        }
        else
        {
            Debug.LogError("No PrefabKey script was attached to " + enemy.name);
        }

        // Try to pull an EnemyStats script off the enemy (it should have one)
        EnemyStats enemyStatsScriptRef = enemy.GetComponent <EnemyStats>();

        if (enemyStatsScriptRef != null)
        {
            _strength     = enemyStatsScriptRef.GetStrength();
            _magic        = enemyStatsScriptRef.GetMagic();
            _speed        = enemyStatsScriptRef.GetSpeed();
            _vitality     = enemyStatsScriptRef.GetVitality();
            _baseXpToGive = enemyStatsScriptRef.GetBaseXpToGive();
            _difficulty   = enemyStatsScriptRef.GetDifficulty();
        }
        else
        {
            Debug.LogError("No EnemyStats script was attached to " + enemy.name);
        }

        // Try to pull an EnemyHealth script off the enemy (it should have one)
        EnemyHealth enemyHealthScriptRef = enemy.GetComponent <EnemyHealth>();

        if (enemyHealthScriptRef != null)
        {
            _curHP = enemyHealthScriptRef.CurHP;
            _maxHP = enemyHealthScriptRef.MaxHP;
        }
        else
        {
            Debug.LogError("No EnemyHealth script was attached to " + enemy.name);
        }

        // Try to pull a Rainbow script off the enemy (does not necessarily have one)
        Rainbow rainbowScriptRef = enemy.GetComponent <Rainbow>();

        if (rainbowScriptRef != null)
        {
            _isRainbow = true;
        }
        else
        {
            _isRainbow = false;
        }

        // Position off transform
        _position    = new float[3];
        _position[0] = enemy.transform.position.x;
        _position[1] = enemy.transform.position.y;
        _position[2] = enemy.transform.position.z;
    }