Ejemplo n.º 1
0
    public Bullet CreateBullet(Bullet.BulletTypes bType)
    {
        Bullet bullet = bulletFactory.CreateBullet(bType);

        BulletInstances.Add(bullet);

        return(bullet);
    }
Ejemplo n.º 2
0
 public WeaponPartSchematic(string name, float _reloadTime, int energyUsage, WeaponTier _tier, Bullet.BulletTypes _bulletType, Dictionary <string, object> bulletInfos) : base(name, PartType.Weapon)
 {
     Name            = name;
     BulletInfos     = bulletInfos;
     ReloadTimeInSec = _reloadTime;
     EnergyUsage     = energyUsage;
     Tier            = _tier;
     BulletType      = _bulletType;
 }
Ejemplo n.º 3
0
    public Bullet CreateBullet(Bullet.BulletTypes bType)
    {
        Bullet prefab = typeToBulletDict[bType];

        Bullet bullet = GameObject.Instantiate(prefab);

        bullet.transform.SetParent(bulletsRoot, false);
        return(bullet);
    }
Ejemplo n.º 4
0
    public Bullet GetBullet(Bullet.BulletTypes type)
    {
        Bullet b;

        switch (type)
        {
        case Bullet.BulletTypes.Enemy:
            if (enemyBulletCache.Count == 0)
            {
                b = Instantiate(enemyBulletPrefab);
            }
            else
            {
                b = enemyBulletCache.Dequeue();
            }
            break;

        case Bullet.BulletTypes.Diagonal:
            if (playerBulletCache.Count == 0)
            {
                b = Instantiate(playerBulletPrefab);     //todo diagonal shot not implemented yet
            }
            else
            {
                b = playerBulletCache.Dequeue();
            }
            break;

        case Bullet.BulletTypes.Horizontal:
        default:
            if (playerBulletCache.Count == 0)
            {
                b = Instantiate(playerBulletPrefab);     //todo diagonal shot not implemented yet
            }
            else
            {
                b = playerBulletCache.Dequeue();
            }
            break;
        }
        b.gameObject.SetActive(true);
        return(b);
    }
Ejemplo n.º 5
0
    private void loadWeaponParts()
    {
        Dictionary <string, PartSchematic> schematics = new Dictionary <string, PartSchematic>();

        TextAsset jsonText = Resources.Load("WeaponPartList") as TextAsset;

        JObject root = JObject.Parse(jsonText.text);

        foreach (var partInfo in root)
        {
            string name = partInfo.Key;

            JObject info = (JObject)partInfo.Value;

            float  reloadTime             = info.Value <float>("reload_time");
            int    energyUsage            = info.Value <int>("energy_usage");
            string tierStr                = info.Value <string>("tier");
            PartSchematic.WeaponTier tier = PartSchematic.WeaponTier.Light;
            if (tierStr.Equals("L"))
            {
                tier = PartSchematic.WeaponTier.Light;
            }
            else if (tierStr.Equals("M"))
            {
                tier = PartSchematic.WeaponTier.Medium;
            }
            else if (tierStr.Equals("H"))
            {
                tier = PartSchematic.WeaponTier.Heavy;
            }

            Bullet.BulletTypes bType = (Bullet.BulletTypes)Enum.Parse(typeof(Bullet.BulletTypes), info.Value <string>("bullet_type"));

            Dictionary <string, object> bulletInfoDict = parseBulletInfoJson(bType, info.Value <JObject>("bullet_info"));

            WeaponPartSchematic part = TankParSchematictFactory.CreateWeaponPartSchematic(name, reloadTime, energyUsage, tier, bType, bulletInfoDict);

            schematics.Add(part.Name, part);
        }

        partSchematicDics.Add(PartSchematic.PartType.Weapon, schematics);
    }
Ejemplo n.º 6
0
    private Dictionary <string, object> parseBulletInfoJson(Bullet.BulletTypes bType, JObject info)
    {
        Dictionary <string, object> bulletInfos = new Dictionary <string, object>();

        bulletInfos.Add("shoot_impulse", info.Value <float>("shoot_impulse"));
        bulletInfos.Add("recoil_impulse", info.Value <float>("shoot_recoil_impulse"));
        bulletInfos.Add("hit_impulse", info.Value <float>("hit_impulse"));
        bulletInfos.Add("damage", info.Value <int>("damage"));
        bulletInfos.Add("range", info.Value <float>("range"));

        if (bType == Bullet.BulletTypes.MissileCluster)
        {
            bulletInfos.Add("num_missiles", info.Value <int>("num_missiles"));
            bulletInfos.Add("missile_range", info.Value <float>("missile_range"));
            bulletInfos.Add("missile_shoot_time", info.Value <float>("missile_shoot_time"));
            bulletInfos.Add("missile_init_impulse", info.Value <float>("missile_init_impulse"));
            bulletInfos.Add("missile_fire_impulse", info.Value <float>("missile_fire_impulse"));
            bulletInfos.Add("missile_trigger_time", info.Value <float>("missile_trigger_time"));
        }

        return(bulletInfos);
    }
Ejemplo n.º 7
0
 public static WeaponPartSchematic CreateWeaponPartSchematic(string name, float reloadTime, int energyUsage, PartSchematic.WeaponTier weaponTier, Bullet.BulletTypes bulletType, Dictionary <string, object> bulletInfos)
 {
     return(new WeaponPartSchematic(name, reloadTime, energyUsage, weaponTier, bulletType, bulletInfos));
 }