Beispiel #1
0
    void Start()
    {
        List <Magic> MagicsConvert = new List <Magic>();

        MagicsConvert.Add(new MagicSnow());


        MagicsConvert.ForEach(key =>
        {
            magics.Add(key.getID(), key);
        });

        Magic magic = null;

        magics.TryGetValue(0, out magic);

        if (magic.getID() == 0)
        {
            MagicSnow snow = (MagicSnow)magic;

            snow.getDamageMultiplier();
        }

        if (magic is MagicFire)
        {
            MagicFire damaged = (MagicFire)magic;
            damaged.getDamageMultiply();
        }
    }
    // Pool
    void PoolStart()
    {
        _objectQueue = new Queue <GameObject>();

        for (int i = 0; i < _size; i++)
        {
            GameObject obj = Instantiate(_magicFirePrefab, transform);

            MagicFire magicFire = obj.GetComponent <MagicFire>();
            magicFire.OwnerTransform = transform;

            obj.SetActive(false);
            _objectQueue.Enqueue(obj);
        }
    }