public IWeapon CreateWeapon(WeaponType weaponType) { IWeapon weapon = null; WeaponBaseAttr baseAttr = FactoryManager.AttrFactory.getWeaponBaseAttr(weaponType); GameObject weaponGO = FactoryManager.AssetFactory.LoadWeapon(baseAttr.AssetName); switch (weaponType) { case WeaponType.Gun: weapon = new WeaponGun(baseAttr, weaponGO); break; case WeaponType.Rifle: weapon = new WeaponRifle(baseAttr, weaponGO); break; case WeaponType.Rocket: weapon = new WeaponRocket(baseAttr, weaponGO); break; default: break; } return(weapon); }
public override void Execute() { IEnemy enemy = null; IWeapon weapon = null; switch (mWeaponType) { case WeaponType.Gun: weapon = new WeaponGun(); break; case WeaponType.Rifle: weapon = new WeaponRifle(); break; case WeaponType.Rocket: weapon = new WeaponRocket(); break; default: Debug.LogError("无法创建武器类型:" + mWeaponType); break; } switch (mEnemyType) { case EnemyType.Elf: enemy = FactoryManager.GetEnemyFactory.CreatCharacter <EnemyElf>(mWeaponType, weapon, mSpawnPostion) as IEnemy; break; case EnemyType.Ogre: enemy = FactoryManager.GetEnemyFactory.CreatCharacter <EnemyOgre>(mWeaponType, weapon, mSpawnPostion) as IEnemy; break; case EnemyType.Troll: enemy = FactoryManager.GetEnemyFactory.CreatCharacter <EnemyTroll>(mWeaponType, weapon, mSpawnPostion) as IEnemy; break; default: Debug.LogError("无法创建敌人类型:" + mEnemyType); break; } GameFacade.Instance.RemoveEnemy(enemy); //从敌人阵营里移除 SoldierCaptive captive = new SoldierCaptive(enemy); //适配为俘兵 GameFacade.Instance.AddSoldier(captive); //加入战士阵营 }
public IWeapon CreateWeapon(WeaponType weaponType) { IWeapon weapon = null; //string assetName = ""; //switch (weaponType) //{ // case WeaponType.Gun: // assetName = "WeaponGun"; // break; // case WeaponType.Rifle: // assetName = "WeaponRifle"; // break; // case WeaponType.Rocket: // assetName = "WeaponRocket"; // break; //} WeaponBaseAttr baseAttr = FactoryManager.attrFactory.GetWeaponBaseAttr(weaponType); //GameObject weaponGO = FactoryManager.assetFactory.LoadWeapon(assetName); GameObject weaponGO = FactoryManager.assetFactory.LoadWeapon(baseAttr.assetName); switch (weaponType) { case WeaponType.Gun: //weapon = new WeaponGun(20,5,weaponGO); weapon = new WeaponGun(FactoryManager.attrFactory.GetWeaponBaseAttr(WeaponType.Gun), weaponGO); break; case WeaponType.Rifle: //weapon = new WeaponRifle(30, 7, weaponGO); weapon = new WeaponRifle(FactoryManager.attrFactory.GetWeaponBaseAttr(WeaponType.Rifle), weaponGO); break; case WeaponType.Rocket: //weapon = new WeaponRocket(40, 8, weaponGO); weapon = new WeaponRocket(FactoryManager.attrFactory.GetWeaponBaseAttr(WeaponType.Rocket), weaponGO); break; } return(weapon); }
// 建立武器 public override IWeapon CreateWeapon(ENUM_Weapon emWeapon) { IWeapon pWeapon = null; string AssetName = ""; // Unity模型名称 int AttrID = 0; // 武器的能力值 // 依武器 switch (emWeapon) { case ENUM_Weapon.Gun: pWeapon = new WeaponGun(); AssetName = "WeaponGun"; AttrID = 1; break; case ENUM_Weapon.Rifle: pWeapon = new WeaponRifle(); AssetName = "WeaponRifle"; AttrID = 2; break; case ENUM_Weapon.Rocket: pWeapon = new WeaponRocket(); AssetName = "WeaponRocket"; AttrID = 3; break; default: Debug.LogWarning("CreateWeapon:无法建立[" + emWeapon + "]"); return(null); } // 产生Asset IAssetFactory AssetFactory = PBDFactory.GetAssetFactory(); GameObject WeaponGameObjet = AssetFactory.LoadWeapon(AssetName); pWeapon.SetGameObject(WeaponGameObjet); // 取得武器的威力 IAttrFactory theAttrFactory = PBDFactory.GetAttrFactory(); WeaponAttr theWeaponAttr = theAttrFactory.GetWeaponAttr(AttrID); // 设定武器的威力 pWeapon.SetWeaponAttr(theWeaponAttr); return(pWeapon); }
// 建立武器 public override IWeapon CreateWeapon(ENUM_Weapon enumWeapon) { IWeapon weapon = null; string AssetName = ""; // Unity模型名称 int AttrID = 0; // 武器能力值 switch (enumWeapon) { case ENUM_Weapon.Gun: weapon = new WeaponGun(); AssetName = "WeaponGun"; AttrID = 1; break; case ENUM_Weapon.Rifle: weapon = new WeaponRifle(); AssetName = "WeaponRifle"; AttrID = 2; break; case ENUM_Weapon.Rocket: weapon = new WeaponRocket(); AssetName = "WeaponRocket"; AttrID = 3; break; default: Debug.LogWarning("CreateWeapon无法建立[" + enumWeapon + "]"); return(null); } // 产生Asset IAssetFactory AssetFactory = RTSFactory.GetAssetFactory(); GameObject WeaponGameObject = AssetFactory.LoadWeapon(AssetName); weapon.SetGameObject(WeaponGameObject); // 获取武器威力 IAttrFactory AttrFactory = RTSFactory.GetAttrFactory(); WeaponAttr theWeaponAttr = AttrFactory.GetWeaponAttr(AttrID); // 设置属性 weapon.SetWeaponAttr(theWeaponAttr); return(weapon); }
// 建立武器 public override IWeapon CreateWeapon( ENUM_Weapon emWeapon) { IWeapon pWeapon = null; string AssetName = ""; // Unity模型名稱 int AttrID = 0; // 武器的能力值 // 依武器 switch( emWeapon ) { case ENUM_Weapon.Gun: pWeapon = new WeaponGun(); AssetName = "WeaponGun"; AttrID = 1; break; case ENUM_Weapon.Rifle: pWeapon = new WeaponRifle(); AssetName = "WeaponRifle"; AttrID = 2; break; case ENUM_Weapon.Rocket: pWeapon = new WeaponRocket(); AssetName = "WeaponRocket"; AttrID = 3; break; default: Debug.LogWarning("CreateWeapon:無法建立["+emWeapon+"]"); return null; } // 產生Asset IAssetFactory AssetFactory = PBDFactory.GetAssetFactory(); GameObject WeaponGameObjet = AssetFactory.LoadWeapon( AssetName ); pWeapon.SetGameObject( WeaponGameObjet ); // 取得武器的威力 IAttrFactory theAttrFactory = PBDFactory.GetAttrFactory(); WeaponAttr theWeaponAttr = theAttrFactory.GetWeaponAttr( AttrID ); // 設定武器的威力 pWeapon.SetWeaponAttr( theWeaponAttr ); return pWeapon; }
public override void Execute() { IWeapon weapon = null; switch (mWeaponType) { case WeaponType.Gun: weapon = new WeaponGun(); break; case WeaponType.Rifle: weapon = new WeaponRifle(); break; case WeaponType.Rocket: weapon = new WeaponRocket(); break; default: Debug.LogError("武器类型不存在:" + mWeaponType); break; } switch (mSoldierType) { case SoldierType.Rookie: FactoryManager.GetSoldierFactory.CreatCharacter <SoldierRookie>(mWeaponType, weapon, mSpawnPostion, mLv); break; case SoldierType.Sergeant: FactoryManager.GetSoldierFactory.CreatCharacter <SoldierSergeant>(mWeaponType, weapon, mSpawnPostion, mLv); break; case SoldierType.Captain: FactoryManager.GetSoldierFactory.CreatCharacter <SoldierCaptain>(mWeaponType, weapon, mSpawnPostion, mLv); break; default: Debug.LogError("无法根据SoldierType:" + mSoldierType + "创建角色"); break; } }
/// <summary> /// 产生敌人 /// </summary> private void SpawnEnemy() { mCountSpawn++; IWeapon weapon = null; switch (mWeaponType) { case WeaponType.Gun: weapon = new WeaponGun(); break; case WeaponType.Rifle: weapon = new WeaponRifle(); break; case WeaponType.Rocket: weapon = new WeaponRocket(); break; default: Debug.LogError("无法创建武器类型:" + mWeaponType); break; } switch (mEnemyType) { case EnemyType.Elf: FactoryManager.GetEnemyFactory.CreatCharacter <EnemyElf>(mWeaponType, weapon, mPosition); break; case EnemyType.Ogre: FactoryManager.GetEnemyFactory.CreatCharacter <EnemyOgre>(mWeaponType, weapon, mPosition); break; case EnemyType.Troll: FactoryManager.GetEnemyFactory.CreatCharacter <EnemyTroll>(mWeaponType, weapon, mPosition); break; default: Debug.LogError("无法创建敌人类型:" + mEnemyType); break; } }
public IWeapon CreateWeapon(WeaponType type) { IWeapon weapon = null; string assetName = ""; switch (type) { case WeaponType.Gun: assetName = "Gun"; break; case WeaponType.Rifle: assetName = "Rifle"; break; case WeaponType.Rocket: assetName = "Rocket"; break; } IAssetsFactory resoureLoadFactory = new ResouresLoadFactory(); GameObject GO = resoureLoadFactory.LoadWeapon(assetName); switch (type) { case WeaponType.Gun: weapon = new WeaponGun(30, 4, GO); break; case WeaponType.Rifle: weapon = new WeaponRifle(40, 6, GO); break; case WeaponType.Rocket: weapon = new WeaponRocket(60, 8, GO); break; } return(weapon); }
public IWeapon CreateWeapon(WeaponType weaponType) { IWeapon weapon = null; WeaponBaseAttr baseAttr = FactoryManager.attrFactory.GetWeaponBaseAttr(weaponType); //通过资源工厂创建枪的游戏物体 GameObject weaponGo = FactoryManager.assetFactory.LoadWeapon(baseAttr.assetName); switch (weaponType) { case WeaponType.Gun: weapon = new WeaponGun(baseAttr, weaponGo); break; case WeaponType.Rifle: weapon = new WeaponRifle(baseAttr, weaponGo); break; case WeaponType.Rocket: weapon = new WeaponRocket(baseAttr, weaponGo); break; } return(weapon); }
public IWeapon CreateWeapon(WeaponType weaponType) { IWeapon weapon = null; WeaponBaseAttr baseAttr = FactoryManager.AttrFactory.GetWeaponBaseAttr(weaponType); //Debug.Log("WeaponFactory::baseAttr.AssetName = " + baseAttr.AssetName); GameObject weaponGO = FactoryManager.AssetFactory.LoadWeapon(baseAttr.AssetName); //aSong:文档加载方式解决.将士兵和敌人动态的数据统一放在文件中.加载进来后用Dic来保存Struct //将这个工厂改为泛型工厂,然后通过Dic保存 weaponType和对应指定类型的泛型工厂来实例化 switch (weaponType) { case WeaponType.Gun: weapon = new WeaponGun(baseAttr, weaponGO); break; case WeaponType.Rifle: weapon = new WeaponRifle(baseAttr, weaponGO); break; case WeaponType.Rocket: weapon = new WeaponRocket(baseAttr, weaponGO); break; } return(weapon); /* * string assetName = ""; * switch (weaponType) * { * case WeaponType.Gun: * assetName = "WeaponGun"; * break; * case WeaponType.Rifle: * * assetName = "WeaponRifle"; * break; * case WeaponType.Rocket: * assetName = "WeaponRocket"; * break; * } * GameObject weaponGO = FactoryManager.AssetFactory.LoadWeapon(assetName); * * * switch (weaponType) * { * case WeaponType.Gun: * weapon = new WeaponGun(20, 5, weaponGO); * break; * case WeaponType.Rifle: * * weapon = new WeaponRifle(30, 7, weaponGO); * * break; * case WeaponType.Rocket: * weapon = new WeaponRocket(40, 8, weaponGO); * * break; * default: * break; * } * return weapon; */ }