// 顯示資訊 public void ShowInfo(ISoldier Soldier) { //Debug.Log("顯示Soldier資訊"); m_Soldier = Soldier; if( m_Soldier == null || m_Soldier.IsKilled()) { Hide (); return ; } Show (); // 顯示Soldier資訊 // Icon IAssetFactory Factory = PBDFactory.GetAssetFactory(); m_Icon.sprite = Factory.LoadSprite( m_Soldier.GetIconSpriteName()); // 名稱 m_NameTxt.text = m_Soldier.GetName(); // 等級 m_LvTxt.text =string.Format("等級:{0}", m_Soldier.GetSoldierValue().GetSoldierLv()); // Atk m_AtkTxt.text = string.Format( "攻擊力:{0}",m_Soldier.GetWeapon().GetAtkValue()); // Atk距離 m_AtkRangeTxt.text = string.Format( "攻擊距離:{0}",m_Soldier.GetWeapon().GetAtkRange()); // Speed m_SpeedTxt.text = string.Format("移動速度:{0}", m_Soldier.GetSoldierValue().GetMoveSpeed());; // 更新HP資訊 RefreshHPInfo(); }
public override void VisitSoldier(ISoldier Soldier) { base.VisitSoldier( Soldier); Soldier.AddMedal(); // 遊戲事件 m_PBDGame.NotifyGameEvent( ENUM_GameEvent.SoldierUpgate, Soldier); }
// 通知Soldier單位升級 public override void SetParam( System.Object Param ) { base.SetParam( Param); m_Soldier = Param as ISoldier; m_UpgateCount++; // 通知 Notify(); }
// public EnemyCaptive( ISoldier theSoldier, Vector3 AttackPos) { m_emEnemyType = ENUM_Enemy.Catpive; m_Captive = theSoldier; // 設定成像 SetGameObject( theSoldier.GetGameObject() ); // 將Soldier數值轉成Enemy用的 EnemyAttr tempAttr = new EnemyAttr(); SetCharacterAttr( tempAttr ); // 設定武器 SetWeapon( theSoldier.GetWeapon() ); // 更改為SoldierAI m_AI = new EnemyAI( this, AttackPos ); m_AI.ChangeAIState( new IdleAIState() ); }
public static void Main() { var soldiers = new List <ISoldier>(); string inputLine; while ((inputLine = Console.ReadLine()) != "End") { var soldierInfo = inputLine.Split(); var soldierType = soldierInfo[0]; var id = int.Parse(soldierInfo[1]); var firstName = soldierInfo[2]; var lastName = soldierInfo[3]; var salary = double.Parse(soldierInfo[4]); ISoldier soldier = null; switch (soldierType) { case "Private": soldier = new Private(id, firstName, lastName, salary); break; case "LeutenantGeneral": var leutenantGeneral = new LeutenantGeneral(id, firstName, lastName, salary); foreach (var privateSoldierId in soldierInfo.Skip(5)) { var privateId = int.Parse(privateSoldierId); ISoldier privateSoldier = soldiers.FirstOrDefault(s => s.Id == privateId); leutenantGeneral.AddPrivate(privateSoldier); } soldier = leutenantGeneral; break; case "Engineer": var validEngineerCorps = Enum.TryParse(typeof(Corps), soldierInfo[5], out object engineerCorps); if (!validEngineerCorps) { continue; } var engineer = new Engineer(id, firstName, lastName, salary, (Corps)engineerCorps); for (int i = 6; i < soldierInfo.Length; i += 2) { var partName = soldierInfo[i]; var hoursWorked = int.Parse(soldierInfo[i + 1]); var repair = new Repair(partName, hoursWorked); engineer.AddRepair(repair); } soldier = engineer; break; case "Commando": var validCommandoCorps = Enum.TryParse(typeof(Corps), soldierInfo[5], out object commandoCorps); if (!validCommandoCorps) { continue; } var commando = new Commando(id, firstName, lastName, salary, (Corps)commandoCorps); for (int i = 6; i < soldierInfo.Length; i += 2) { var codeName = soldierInfo[i]; var validMissionState = Enum.TryParse(typeof(State), soldierInfo[i + 1], out object missionState); if (!validMissionState) { continue; } var mission = new Mission(codeName, (State)missionState); commando.AddMission(mission); } soldier = commando; break; case "Spy": var codeNumber = int.Parse(soldierInfo[4]); soldier = new Spy(id, firstName, lastName, codeNumber); break; } soldiers.Add(soldier); } foreach (var soldier in soldiers) { Console.WriteLine(soldier); } }
public void AddSoldier(ISoldier soldier) { mCharacterSystem.AddSoldier(soldier); }
private string Parse(List <string> input) { var soldierType = input[0]; var soldierId = int.Parse(input[1]); var firstName = input[2]; var lastName = input[3]; ISoldier soldier = null; if (soldierType == "Private") { var salary = decimal.Parse(input[4]); soldier = new Private(soldierId, firstName, lastName, salary); } else if (soldierType == "LieutenantGeneral") { var salary = decimal.Parse(input[4]); var listOfPrivates = new List <IPrivate>(); for (int i = 5; i < input.Count; i++) { IPrivate currentPrivate = (IPrivate)soldiers[int.Parse(input[i])]; listOfPrivates.Add(currentPrivate); } soldier = new LieutenantGeneral(soldierId, firstName, lastName, salary, listOfPrivates); } else if (soldierType == "Engineer") { var salary = decimal.Parse(input[4]); var isCorps = Enum.TryParse <Corps>(input[5], out Corps corps); if (!isCorps) { throw new Exception(); } var repairs = new List <IRepair>(); for (int i = 6; i < input.Count; i += 2) { var repairPart = input[i]; var repairHours = int.Parse(input[i + 1]); var repair = new Repair(repairPart, repairHours); repairs.Add(repair); } soldier = new Engineer(soldierId, firstName, lastName, salary, corps, repairs); } else if (soldierType == "Commando") { var salary = decimal.Parse(input[4]); var isCorps = Enum.TryParse <Corps>(input[5], out Corps corps); if (!isCorps) { throw new Exception(); } var missions = new List <IMission>(); for (int i = 6; i < input.Count; i += 2) { var missionName = input[i]; var state = input[i + 1]; var isState = Enum.TryParse <State>(state, out State finalState); if (!isState) { continue; } var mission = new Mission(missionName, finalState); missions.Add(mission); } soldier = new Commando(soldierId, firstName, lastName, salary, corps, missions); } else if (soldierType == "Spy") { var codeNumber = int.Parse(input[4]); soldier = new Spy(soldierId, firstName, lastName, codeNumber); } soldiers.Add(soldierId, soldier); return(soldier.ToString()); }
// 玩家单位阵亡 private void Notify_SoldierKilled(ISoldier theSoldier) { }
public void Run() { List <ISoldier> soldiers = new List <ISoldier>(); string input = string.Empty; while ((input = Console.ReadLine()) != "End") { string[] elements = input .Split(" ", StringSplitOptions.RemoveEmptyEntries) .ToArray(); string typeSoldier = elements[0]; string id = elements[1]; string firstName = elements[2]; string lastName = elements[3]; ISoldier soldier = null; if (typeSoldier == "Private") { decimal salary = decimal.Parse(elements[4]); soldier = new Private(id, firstName, lastName, salary); } else if (typeSoldier == "LieutenantGeneral") { decimal salary = decimal.Parse(elements[4]); soldier = new LieutenantGeneral(id, firstName, lastName, salary); for (int i = 5; i < elements.Length; i++) { string targetId = elements[i]; IPrivate @private = (IPrivate)soldiers .FirstOrDefault(x => x.Id == targetId); ILieutenantGeneral lieutenantGeneral = soldier as ILieutenantGeneral; lieutenantGeneral.AddPrivate(@private); } } else if (typeSoldier == "Engineer") { decimal salary = decimal.Parse(elements[4]); string targetCorp = elements[5]; bool isCorpValid = Enum.TryParse <Corp>(targetCorp, out Corp corp); if (!isCorpValid) { continue; } soldier = new Engineer(id, firstName, lastName, salary, corp); IEngineer engineer = soldier as IEngineer; for (int i = 6; i < elements.Length; i += 2) { string partName = elements[i]; int hours = int.Parse(elements[i + 1]); IRepair repair = new Repair(partName, hours); engineer.AddRepair(repair); } } else if (typeSoldier == "Commando") { decimal salary = decimal.Parse(elements[4]); string targetCorp = elements[5]; bool isCorpValid = Enum.TryParse <Corp>(targetCorp, out Corp corp); if (!isCorpValid) { continue; } soldier = new Commando(id, firstName, lastName, salary, corp); ICommando commando = soldier as ICommando; for (int i = 6; i < elements.Length; i += 2) { string codeName = elements[i]; string targetMissionState = elements[i + 1]; bool isMissionStateValid = Enum.TryParse <MissionState>(targetMissionState, out MissionState missionState); if (!isMissionStateValid) { continue; } IMission mission = new Mission(codeName, missionState); commando.AddMission(mission); } } else if (typeSoldier == "Spy") { int codeNumber = int.Parse(elements[4]); soldier = new Spy(id, firstName, lastName, codeNumber); } soldiers.Add(soldier); } foreach (ISoldier soldier in soldiers) { Console.WriteLine(soldier); } }
// 更新 public void RefreshSoldier( ISoldier Soldier ) { if( Soldier==null) { m_Soldier=null; Hide (); } if( m_Soldier != Soldier) return ; ShowInfo( Soldier ); }
public virtual void VisitSoldier(ISoldier Soldier) { VisitCharacter( Soldier ); }
static void Main(string[] args) { var soldiers = new List <ISoldier>(); string input; while ((input = Console.ReadLine()) != "End") { try { var soldierInput = input.Split(); var id = int.Parse(soldierInput[1]); var firstName = soldierInput[2]; var lastName = soldierInput[3]; var sodierType = soldierInput[0]; var salary = decimal.Parse(soldierInput[4]); ISoldier sodier = null; switch (sodierType) { case "Private": sodier = new Private(id, firstName, lastName, salary); ; break; case "Spy": sodier = new Spy(id, firstName, lastName, int.Parse(soldierInput[4])); break; case "LeutenantGeneral": var general = new LeutenantGeneral(id, firstName, lastName, salary); for (int i = 5; i < soldierInput.Length; i++) { int iid = int.Parse(soldierInput[i]); ISoldier bbSoldier = soldiers.First(x => x.Id == iid); general.AddPrivate(bbSoldier); } sodier = general; break; case "Engineer": var eng = new Engineer(id, firstName, lastName, salary, soldierInput[5]); for (int i = 6; i < soldierInput.Length; i++) { try { string partName = soldierInput[i]; int hourWorked = int.Parse(soldierInput[++i]); IRepair repeir = new Repair(partName, hourWorked); eng.AddRepiar(repeir); } catch { } } sodier = eng; break; case "Commando": var commando = new Commando(id, firstName, lastName, salary, soldierInput[5]); for (int i = 6; i < soldierInput.Length; i++) { try { string codeName = soldierInput[i]; string state = soldierInput[++i]; IMission mission = new Mission(codeName, state); commando.AddMision(mission); } catch { } } sodier = commando; break; default: throw new ArgumentException(); } soldiers.Add(sodier); } catch { } } foreach (var soldier in soldiers) { Console.WriteLine(soldier); } }
static void Main(string[] args) { var soldiers = new List <ISoldier>(); string input; while ((input = Console.ReadLine()) != "End") { var tokens = input .Split(' ', StringSplitOptions.RemoveEmptyEntries); var soldireType = tokens[0]; var id = int.Parse(tokens[1]); var firstName = tokens[2]; var lastName = tokens[3]; var sallary = double.Parse(tokens[4]); ISoldier soldier = null; try { switch (soldireType) { case "Private": soldier = new Private(id, firstName, lastName, sallary); break; case "LeutenantGeneral": var lueitenant = new LeutenantGeneral(id, firstName, lastName, sallary); for (int i = 5; i < tokens.Length; i++) { var privateId = int.Parse(tokens[i]); ISoldier @private = soldiers.FirstOrDefault(p => p.Id == privateId); lueitenant.AddPrivate(@private); } soldier = lueitenant; break; case "Engineer": var engineerCorps = tokens[5]; var engineer = new Engineer(id, firstName, lastName, sallary, engineerCorps); for (int i = 6; i < tokens.Length; i++) { var partName = tokens[i]; var hoursWorked = int.Parse(tokens[++i]); IRepair repair = new Repair(partName, hoursWorked); engineer.AddRepair(repair); } soldier = engineer; break; case "Commando": var commandoCorps = tokens[5]; var commando = new Commando(id, firstName, lastName, sallary, commandoCorps); for (int i = 6; i < tokens.Length; i++) { var codeName = tokens[i]; var missionState = tokens[++i]; try { IMission mission = new Mission(codeName, missionState); commando.AddMission(mission); } catch { } } soldier = commando; break; case "Spy": int codeNumber = (int)sallary; soldier = new Spy(id, firstName, lastName, codeNumber); break; default: throw new ArgumentException("Invalid soldier type!"); } soldiers.Add(soldier); } catch { } } foreach (var s in soldiers) { Console.WriteLine(s); } }
// 移除Soldier public void RemoveSoldier( ISoldier theSoldier) { m_Soldiers.Remove( theSoldier ); }
// 增加Soldier public void AddSoldier( ISoldier theSoldier) { m_Soldiers.Add( theSoldier ); }
public override void VisitSoldier (ISoldier Soldier) { base.VisitSoldier(Soldier); SoldierCount++; }
public void Run() { string input = Console.ReadLine(); while (input != "End") { string[] comands = input.Split(); string type = comands[0]; int id = int.Parse(comands[1]); string firstName = comands[2]; string lastName = comands[3]; if (type == "Private") { decimal salary = decimal.Parse(comands[4]); soldier = new Private(id, firstName, lastName, salary); } else if (type == "LieutenantGeneral") { decimal salary = decimal.Parse(comands[4]); soldier = GetLieutenantGeneral(id, firstName, lastName, salary, comands); } else if (type == "Engineer") { decimal salary = decimal.Parse(comands[4]); if (!Enum.TryParse(comands[5], out Corps corps)) { continue; } soldier = GetEngineer(id, firstName, lastName, salary, corps, comands); } else if (type == "Commando") { decimal salary = decimal.Parse(comands[4]); if (!Enum.TryParse(comands[5], out Corps corps)) { continue; } soldier = GetCommando(id, firstName, lastName, salary, corps, comands); } else if (type == "Spy") { int codeNumber = int.Parse(comands[4]); soldier = new Spy(id, firstName, lastName, codeNumber); } if (soldier != null) { this.soldiers.Add(soldier); } input = Console.ReadLine(); } foreach (var item in soldiers) { Console.WriteLine(item); } }
public SoldierBehaviour(ISoldier baseSoldier) { this._BaseSoldier = baseSoldier; }
// 移除Soldier public void RemoveSoldier( ISoldier theSoldier) { if( m_CharacterSystem !=null) m_CharacterSystem.RemoveSoldier( theSoldier ); }
// 加入戰士 public void AddSoldier(ISoldier NewSoldier) { }
public abstract void VisitorRookie(ISoldier soldier);
public void RemoveSoldier(ISoldier soldier) { mSoldiers.Remove(soldier); }
public abstract void VisitorSergeant(ISoldier soldier);
public void Run() { string input = Console.ReadLine(); while (input != "End") { string[] cmdArgs = input.Split(' ', StringSplitOptions.RemoveEmptyEntries); string soldierType = cmdArgs[0]; int id = int.Parse(cmdArgs[1]); string firstName = cmdArgs[2]; string lastName = cmdArgs[3]; ISoldier soldier = null; switch (soldierType) { case "Private": decimal privateSalary = decimal.Parse(cmdArgs[4]); soldier = AddPrivate(id, firstName, lastName, privateSalary); break; case "LieutenantGeneral": decimal lieutenantSalary = decimal.Parse(cmdArgs[4]); soldier = AddLieutenantGeneral(id, firstName, lastName, lieutenantSalary, cmdArgs); break; case "Engineer": decimal engineerSalary = decimal.Parse(cmdArgs[4]); string engineerCorps = cmdArgs[5]; try { IEngineer engineer = new Engineer(id, firstName, lastName, engineerSalary, engineerCorps); string[] repairArgs = cmdArgs.Skip(6).ToArray(); for (int i = 0; i < repairArgs.Length; i += 2) { string partName = repairArgs[i]; int hoursWorked = int.Parse(repairArgs[i + 1]); IRepair repair = new Repair(partName, hoursWorked); engineer.AddRepair(repair); } soldier = engineer; } catch (InvalidCorpsException) { continue; } break; case "Commando": decimal commandoSalary = decimal.Parse(cmdArgs[4]); string commandoCorps = cmdArgs[5]; try { ICommando commando = new Commando(id, firstName, lastName, commandoSalary, commandoCorps); string[] missionArgs = cmdArgs.Skip(6).ToArray(); for (int i = 0; i < missionArgs.Length; i += 2) { string missionCodeName = missionArgs[i]; string missionState = missionArgs[i + 1]; try { IMission mission = new Mission(missionCodeName, missionState); commando.AddMission(mission); } catch (Exception) { continue; } } soldier = commando; } catch (InvalidCorpsException) { continue; } break; case "Spy": int codeNumber = int.Parse(cmdArgs[4]); soldier = AddSpy(id, firstName, lastName, codeNumber); break; } if (soldier != null) { soldiers.Add(soldier); } input = Console.ReadLine(); } foreach (var soldier in soldiers) { Console.WriteLine(soldier); } }
public abstract void VisitorCaptain(ISoldier soldier);
public ChosenRangedWeapon(RangedWeapon weapon, ISoldier soldier) { ActiveWeapon = weapon; Soldier = soldier; }
public abstract void VisitorCaptive(ISoldier soldier);
// 玩家单位升級 private void Notify_SoldierUpgate(ISoldier theSoldier) { }
public abstract void VisitorEnemy(ISoldier enemy);
public void AddSoldier(ISoldier soldier) { }
public void AddPrivate(ISoldier privateToAdd) { this.privates.Add(privateToAdd); }
public void Run() { string command = Console.ReadLine(); while (command != "End") { string[] tokens = command .Split(" ") .ToArray(); string type = tokens[0]; string id = tokens[1]; string firstName = tokens[2]; string lastName = tokens[3]; decimal salary = decimal.Parse(tokens[4]); if (type == "Private") { Private soldier = new Private(id, firstName, lastName, salary); this.army.Add(soldier); } else if (type == "LieutenantGeneral") { LieutenantGeneral general = new LieutenantGeneral( id, firstName, lastName, salary); string[] privatesCommand = tokens.Skip(5).ToArray(); foreach (var pid in privatesCommand) { ISoldier soldierToAdd = this.army .First(x => x.Id == pid); general.AddPrivate(soldierToAdd); } this.army.Add(general); } else if (type == "Engineer") { try { string corps = tokens[5]; IEngineer engineer = new Engineer(id, firstName, lastName, salary, corps); string[] repearTokens = tokens.Skip(6).ToArray(); AddPepairs(engineer, repearTokens); this.army.Add(engineer); } catch (InvalidCorpsExceptions ice) { //continue; } } else if (type == "Commando") { try { string corps = tokens[5]; ICommando commando = new Commando (id, firstName, lastName, salary, corps); string[] missingTokens = tokens .Skip(6) .ToArray(); for (int i = 0; i < missingTokens.Length; i += 2) { try { string codeName = missingTokens[i]; string state = missingTokens[i + 1]; IMissions mission = new Mission(codeName, state); commando.AddMissions(mission); } catch (InvalidStateExceptions ise) { continue; } } this.army.Add(commando); } catch (InvalidCorpsExceptions ice) { } } else if (type == "Spy") { int codeNumber = (int)salary; ISpy spy = new Spy(id, firstName, lastName, codeNumber); this.army.Add(spy); } command = Console.ReadLine(); } PrintOutput(); }
public static string Stringify(this ISoldier soldier) => $"Name: {soldier.FirstName} {soldier.LastName} Id: {soldier.Id}";
// 增加Soldier public void AddSoldier( ISoldier theSoldier) { if( m_CharacterSystem !=null) m_CharacterSystem.AddSoldier( theSoldier ); }
public static void Main() { var soldiers = new List <ISoldier>(); string input; while ((input = Console.ReadLine()) != "End") { var commandArgs = input.Split(); var soldierType = commandArgs[0]; int id = int.Parse(commandArgs[1]); string firstName = commandArgs[2]; string lastName = commandArgs[3]; decimal salary = decimal.Parse(commandArgs[4]); ISoldier soldier = null; try { switch (soldierType) { case "Private": soldier = new Private(id, firstName, lastName, salary); break; case "LeutenantGeneral": var leutenant = new LeutenantGeneral(id, firstName, lastName, salary); for (int i = 5; i < commandArgs.Length; i++) { var privateId = int.Parse(commandArgs[i]); ISoldier @private = soldiers.First(p => p.Id == privateId); leutenant.AddPrivate(@private); } soldier = leutenant; break; case "Engineer": string engineerCorps = commandArgs[5]; var engineer = new Engineer(id, firstName, lastName, salary, engineerCorps); for (int i = 6; i < commandArgs.Length; i++) { string partName = commandArgs[i]; var hoursWorked = int.Parse(commandArgs[++i]); IRepair repair = new Repair(partName, hoursWorked); engineer.AddReapir(repair); } soldier = engineer; break; case "Commando": string commandoCorps = commandArgs[5]; var commando = new Commando(id, firstName, lastName, salary, commandoCorps); for (int i = 6; i < commandArgs.Length; i++) { string codeName = commandArgs[i]; string missionState = commandArgs[++i]; try { IMission mission = new Mission(codeName, missionState); commando.AddMission(mission); } catch {} } soldier = commando; break; case "Spy": int codeNumber = (int)salary; soldier = new Spy(id, firstName, lastName, codeNumber); break; default: throw new ArgumentException("Invalid soldier type!"); } soldiers.Add(soldier); } catch {} } foreach (var s in soldiers) { Console.WriteLine(s); } }
// 顯示Soldier資訊 public void ShowSoldierInfo( ISoldier Soldier ) { m_SoldierInfoUI.ShowInfo( Soldier ); m_CampInfoUI.Hide(); }
// 玩家單位升級 private void Notify_SoldierUpgate( ISoldier theSoldier) { }
public Colonel(ISoldier superior) : base(Destination.Colonel) { this.Superior = superior; }
// Hide public override void Hide () { base.Hide (); m_Soldier = null; }
public void AddSoldier(ISoldier soldier) { this.soldiers.Add(soldier); }
public void AddSoldier(ISoldier soldier) { mSoldiers.Add(soldier); }
// 玩家單位陣亡 private void Notify_SoldierKilled( ISoldier theSoldier) { }
public void AddPrivate(ISoldier soldier) { this.privates.Add(soldier); }
// 更新 public override void Update () { base.Update (); if(m_Soldier==null) return ; // 是否死亡 if(m_Soldier.IsKilled()) { m_Soldier = null; Hide (); return ; } // 更新HP資訊 RefreshHPInfo(); }
private void Awake() { _soldier = GetComponent <ISoldier>(); _tm = FindObjectOfType <DemoIaTeamManager>(); AddEffect("Cleared", true); }
public void AddPrivate(ISoldier @private) { this.privates.Add(@private); }
public abstract void VisitSoldier(ISoldier soldier);
public Captain(ISoldier superior) : base(Destination.Captain) { this.Superior = superior; }