// 加入Elf單位 public IEnemy AddElf(ENUM_Weapon emWeapon) { // 產生物件 EnemyElf theEnmey = new EnemyElf(); // 設定模型 GameObject tmpGameObject = CreateGameObject("ElfGameObjectName"); tmpGameObject.gameObject.name = "EnemyElf"; theEnmey.SetGameObject(tmpGameObject); // 加入武器 IWeapon Weapon = CreateWeapon(emWeapon); theEnmey.SetWeapon(Weapon); // 取得Soldier的數值,設定給角色 EnemyAttr theEnemyAttr = CreateEnemyAttr(1); theEnmey.SetCharacterAttr(theEnemyAttr); // 加入AI EnemyAI theAI = CreateEnemyAI(); theEnmey.SetAI(theAI); // 加入管理器 //PBaseDefenseGame.Instance.AddEnemy( theEnmey as IEnemy ); return(theEnmey as IEnemy); }
public static void Idle(EnemyElf handle) { // stay handle.PlayBornedAnim(); handle.transform.localEulerAngles = Vector3.zero; handle.Entity.localScale = Vector3.one * 5; }
// 建立Enemy public override IEnemy CreateEnemy(ENUM_Enemy emEnemy, ENUM_Weapon emWeapon, Vector3 SpawnPosition, Vector3 AttackPosition) { // 產生對應的Character ICharacter theEnemy = null; switch (emEnemy) { case ENUM_Enemy.Elf: theEnemy = new EnemyElf(); break; case ENUM_Enemy.Troll: theEnemy = new EnemyTroll(); break; case ENUM_Enemy.Ogre: theEnemy = new EnemyOgre(); break; default: Debug.LogWarning("無法建立[" + emEnemy + "]"); return(null); } // 增加角色功能 AddCharacterFuncs(theEnemy, emWeapon, 0); // 加入管理器 //PBaseDefenseGame.Instance.AddEnemy( theEnemy as IEnemy); return(theEnemy as IEnemy); }
public static void MoveDestination(EnemyElf handle) { if (handle.Target == null) { return; } Vector3 targetDirection = handle.Target.transform.position - handle.transform.position; float singleStep = handle.RotateSpeed * Time.deltaTime; Vector3 newDirection = Vector3.RotateTowards(-handle.transform.forward, targetDirection, singleStep, 0.0f); handle.transform.rotation = Quaternion.LookRotation(newDirection); handle.transform.Translate(handle.transform.forward * handle.MoveSpeed * Time.deltaTime); }
public ICharacter CreateCharacter(string characterName) { IEnemy enemy = null; string assetName = ""; switch (characterName) { case "Elf": assetName = "Elf"; break; case "Ogre": assetName = "Ogre"; break; case "Troll": assetName = "Troll"; break; } IAssetsFactory resoureLoadFactory = new ResouresLoadFactory(); GameObject GO = resoureLoadFactory.LoadSoldier(assetName); switch (characterName) { case "Elf": enemy = new EnemyElf(); break; case "Ogre": enemy = new EnemyOgre(); break; case "Troll": enemy = new EnemyTroll(); break; } return(enemy); }
public virtual void VisitEnemyElf(EnemyElf Elf) { VisitEnemy(Elf); }
public static void Dead(EnemyElf handle) { handle.PlayDead(); }
public static void Attack(EnemyElf handle) { handle.PlayAttack(); }
public static void FindEnemy(EnemyElf handle) { }
public static void MoveStraight(EnemyElf handle) { handle.transform.Translate(Vector3.back * handle.MoveSpeed * Time.deltaTime); }
public virtual void VisitEnemyElf(EnemyElf Elf) { VisitEnemy( Elf ); }
public override void VisitEnemyElf(EnemyElf Elf) { base.VisitEnemyElf(Elf); EnemyElfCount++; }
public override void VisitEnemyElf (EnemyElf Elf) { base.VisitEnemyElf(Elf); EnemyElfCount++; }
// 加入Elf單位 public IEnemy AddElf(ENUM_Weapon emWeapon) { // 產生物件 EnemyElf theEnmey = new EnemyElf(); // 設定模型 GameObject tmpGameObject = CreateGameObject("ElfGameObjectName"); tmpGameObject.gameObject.name = "EnemyElf"; theEnmey.SetGameObject( tmpGameObject ); // 加入武器 IWeapon Weapon = CreateWeapon(emWeapon); theEnmey.SetWeapon( Weapon ); // 取得Soldier的數值,設定給角色 EnemyAttr theEnemyAttr = CreateEnemyAttr(1); theEnmey.SetCharacterAttr(theEnemyAttr); // 加入AI EnemyAI theAI = CreateEnemyAI(); theEnmey.SetAI( theAI ); // 加入管理器 //PBaseDefenseGame.Instance.AddEnemy( theEnmey as IEnemy ); return theEnmey as IEnemy; }
// 建立Enemy public override IEnemy CreateEnemy( ENUM_Enemy emEnemy, ENUM_Weapon emWeapon, Vector3 SpawnPosition, Vector3 AttackPosition) { // 產生對應的Character ICharacter theEnemy =null; switch( emEnemy) { case ENUM_Enemy.Elf: theEnemy = new EnemyElf(); break; case ENUM_Enemy.Troll: theEnemy = new EnemyTroll(); break; case ENUM_Enemy.Ogre: theEnemy = new EnemyOgre(); break; default: Debug.LogWarning("無法建立["+emEnemy+"]"); return null; } // 增加角色功能 AddCharacterFuncs( theEnemy, emWeapon, 0); // 加入管理器 //PBaseDefenseGame.Instance.AddEnemy( theEnemy as IEnemy); return theEnemy as IEnemy; }
public void Init(EnemyElf manager) { this.manager = manager; }