public T CreateCharacter <T>(WeaponType _weaponType, Vector3 _pos, int _lv = 1) where T : AbsCharacter, new() { AbsCharacter character = new T(); AbsCharacterBuilder builder = new SoldierBuilder(character, typeof(T), _weaponType, _pos, _lv); return(CharacterBuilderDirector.Construct(builder) as T); }
public ICharacter CreateCharacter <T>(WeaponType weaponType, Vector3 spawnPosition, int lv = 1) { IEnemy enemy = new IEnemy(); ICharacterBuilder builder = new EnemyBuilder(enemy, typeof(T), weaponType, spawnPosition, lv); return(CharacterBuilderDirector.Construct(builder)); }
public ICharacter CreateCharacter <T>(WeaponType weaponType, Vector3 spawnPosition, int lv = 1) where T : ICharacter, new() { ICharacter character = new T(); //string name = ""; //int maxHP = 0; //float moveSpeed = 0; //string iconSprite = ""; //string prefabName = ""; //System.Type t = typeof(T); //if (t == typeof(SoldierCaptain)) //{ // name = "上尉军官"; // maxHP = 100; // moveSpeed = 3; // iconSprite = "CaptainIcon"; // prefabName = "Soldier1"; //} //else if (t == typeof(SoldierSergeant)) //{ // name = "中士士兵"; // maxHP = 90; // moveSpeed = 3; // iconSprite = "SergeantIcon"; // prefabName = "Soldier3"; //} //else if (t == typeof(SoldierRookie)) //{ // name = "新手士兵"; // maxHP = 80; // moveSpeed = 2.5f; // iconSprite = "RookieIcon"; // prefabName = "Soldier2"; //} //else //{ // Debug.LogError("类型" + t + "不属于ISoldier,无法创建战士"); // return null; //} //ICharacterAttr attr = new ICharacterAttr(new SoldierAtrrStrategy(), lv, name, maxHP, moveSpeed, iconSprite, prefabName); //character.attr = attr; ////创建角色的游戏物体 ////1.加载 2.实例化 //GameObject characterGO = FactoryManager.assetFactory.LoadSoldier(prefabName); //characterGO.transform.position = spawnPosition; //character.gameobject = characterGO; ////添加武器 //IWeapon weapon = FactoryManager.weaponFactory.CreateWeapon(weaponType); //character.weapon = weapon; ICharacterBuilder builder = new SoldierBuilder(character, typeof(T), weaponType, spawnPosition, lv); character = CharacterBuilderDirector.Construct(builder); return(character); }
public ICharacter CreateCharacter <T>(WeaponType weaponType, Vector3 spawnPosition, int lv = 1) where T : ICharacter, new() { ICharacter soldier = new T(); ICharacterBuilder builder = new SoldierBuilder(soldier, typeof(T), weaponType, spawnPosition, lv); return(CharacterBuilderDirector.Constructer(builder)); }
public ICharacter CreateCharacter <T>(int characterID, CharacterRefreshPO characterRefreshPO) where T : ICharacter, new() { ICharacter character = new T(); ICharacterBuilder builder = new FireMonsterBuilder(character, characterID, characterRefreshPO); return(CharacterBuilderDirector.Construct(builder)); }
public ICharacter CreateCharacter <T>(WeaponType weaponType, Vector3 pos, int lv = 1) where T : ICharacter, new() { ICharacter character = new T(); ICharacterBuilder builder = new SoldierBuilder(character, typeof(T), weaponType, pos, lv); return(CharacterBuilderDirector.Construct(builder)); }
public ICharacter CreatCharacter <T>(WeaponType weaponType, IWeapon weapon, Vector3 spawnPosition, int lv = 1) where T : ICharacter, new() { ICharacter character = new T(); ICharacterBuilder enemyBuilder = new EnemyBuilder(typeof(T), character, weaponType, weapon, spawnPosition, lv); return(CharacterBuilderDirector.Construct(enemyBuilder)); }
public ICharacter CreateCharacter <T>(WeaponType weaponType, Vector3 spawnPosition, int lv = 1) where T : ICharacter, new() { ICharacter character = new T(); // 创建建造者 ICharacterBuilder builder = new EnemyBuilder(character, typeof(T), weaponType, spawnPosition, lv); return(CharacterBuilderDirector.Construct(builder)); }
public ICharacter CreatCharacter <T>(Vector3 spawnPosition, Transform startParent, RoadType roadType, CampType campType, Transform[] towers, int lv = 1) where T : ICharacter, new() { ICharacter soldier = new T(); // 创建角色 添加状态机 CharacterBuilderDirector director = new CharacterBuilderDirector(); // 创建指导者 SoldierBuilder builder = new SoldierBuilder(startParent, soldier, typeof(T), spawnPosition, roadType, campType, towers); // 创建Soldier建造者 return(director.Construct(builder)); // 建造Soldier并返回 }
public ICharacter CreateCharacter <T>(WeaponType weaponType, Vector3 spawnPosition, int lv = 1) where T : ICharacter, new() { ICharacter character = new T(); //string name = ""; //int maxHP = 0; //float moveSpeed = 0; //string iconSprite = ""; //string prefabName = ""; ////System.Type t = typeof(T); //System.Type t = character.GetType(); //if (t == typeof(EnemyElf)) //{ // name = "小精灵"; // maxHP = 100; // moveSpeed = 3; // iconSprite = "ElfIcon"; // prefabName = "Enemy1"; //} //else if (t == typeof(EnemyOgre)) //{ // name = "怪物"; // maxHP = 120; // moveSpeed = 4; // iconSprite = "OgreIcon"; // prefabName = "Enemy2"; //} //else if (t == typeof(EnemyTroll)) //{ // name = "巨魔"; // maxHP = 200; // moveSpeed = 1f; // iconSprite = "TrollIcon"; // prefabName = "Enemy3"; //} //else //{ // Debug.LogError("类型" + t + "不属于IEnemy,无法创建战士"); // return null; //} //ICharacterAttr attr = new ICharacterAttr(new SoldierAtrrStrategy(), lv, name, maxHP, moveSpeed, iconSprite, prefabName); //character.attr = attr; ////创建角色的游戏物体 ////1.加载 2.实例化 //GameObject characterGO = FactoryManager.assetFactory.LoadEnemy(prefabName); //characterGO.transform.position = spawnPosition; //character.gameobject = characterGO; ////添加武器 //IWeapon weapon = FactoryManager.weaponFactory.CreateWeapon(weaponType); //character.weapon = weapon; ICharacterBuilder builder = new EnemyBuilder(character, typeof(T), weaponType, spawnPosition, lv); character = CharacterBuilderDirector.Construct(builder); return(character); }