void Start() { armor = GetComponent <ArmorSystem>(); initialLife = totalLife; unitsPerLife = GameManager.singleton.unitsPerLife; lifeBarMaterial = GameManager.singleton.lifeBarMaterial; if (armor != null) { hasArmor = true; } CreateBar(); if (hasArmor) { armor.CreateArmorBar(); armor.UpdateArmorBar(); } }
public PlayerModel(SignalBus signalBus, PlayerData data, ArmorSystem armorSystem) { _signalBus = signalBus; PlayerData = data; _armorSystem = armorSystem; _carModel = new CarModel(PlayerData.CarData); _weaponModel = new WeaponModel(PlayerData.CarData.WeaponData); _signalBus.Subscribe <InputSignal.LeftArrowUp>(m => CheckPlayerAction(m, _carModel.StopStearLeft)); _signalBus.Subscribe <InputSignal.LeftArrowDown>(m => CheckPlayerAction(m, _carModel.StartStearLeft)); _signalBus.Subscribe <InputSignal.RightArrowUp>(m => CheckPlayerAction(m, _carModel.StopStearRight)); _signalBus.Subscribe <InputSignal.RightArrowDown>(m => CheckPlayerAction(m, _carModel.StartStearRight)); _signalBus.Subscribe <InputSignal.ForwardArrowDown>(m => CheckPlayerAction(m, _carModel.StartAccelerate)); _signalBus.Subscribe <InputSignal.ForwardArrowUp>(m => CheckPlayerAction(m, _carModel.StopAccelerate)); _signalBus.Subscribe <InputSignal.DownArrowDown>(m => CheckPlayerAction(m, _carModel.StartBreak)); _signalBus.Subscribe <InputSignal.DownArrowUp>(m => CheckPlayerAction(m, _carModel.StopBreak)); _signalBus.Subscribe <InputSignal.UpgradeArmor>(m => CheckPlayerAction(m, HandleUpgradeArmor)); _signalBus.Subscribe <InputSignal.FireDown>(m => CheckPlayerAction(m, _weaponModel.Fire)); _signalBus.Subscribe <GameSignals.ChangeResourceSignal>(m => CheckPlayerAction(m, HandleResourceChange)); }
protected void Initialize() { //컴포넌트 SetupComponent(); GetUiInfo(); //스크립트 if (playerUi != null) { inventory = new Inventory(playerUi.inventoryUi); } if (inventory != null) { inventory.SetInventorySize(0, 0); } if (armorSystem == null) { armorSystem = new ArmorSystem(playerUi.inventoryUi, playerUi, playerUi.hpUi.SetArmor); //임시 SetArmor(0); } }
public void TestCloning() { // GameEngine uses a "cheat" and routes its clone method through a serialize/deserialize operation: GameState ge = new GameState() { Id = 99, Exchange = 99, Volley = 99, Turn = 99 }; GameState newGE = GameStateStreamUtilities.CloneGameState(ge); newGE.Id = 0; newGE.Volley = 0; Assert.AreNotEqual(newGE.Id, ge.Id); Assert.AreNotEqual(newGE.Volley, ge.Volley); Assert.AreEqual(newGE.Exchange, ge.Exchange); Assert.AreEqual(newGE.Turn, ge.Turn); BeamBatterySystem b1 = new BeamBatterySystem() { Arcs = "FP,F,FS", Rating = 2 }; ScreenSystem d1 = new ScreenSystem() { StatusString = "Operational" }; HullSystem h1 = new HullSystem() { HullType = HullTypeProperty.Average }; var b2 = b1.Clone() as ArcWeaponSystem; var d2 = d1.Clone() as DefenseSystem; var h2 = h1.Clone() as HullSystem; h1.HullType = HullTypeProperty.Strong; var h1a = h1.Clone() as HullSystem; h1a.HullType = HullTypeProperty.Super; var h2a = h2.Clone() as HullSystem; var a1 = new ArmorSystem() { TotalArmor = "4,5", RemainingArmor = "4,5" }; DefenseSystem a2 = (DefenseSystem)a1.Clone(); ((ArmorSystem)a2).TotalArmor = "5,5"; ((ArmorSystem)a2).RemainingArmor = "4,4"; var a2a = a1.Clone() as DefenseSystem; b2.Arcs = "AP, P, FP"; d2.StatusString = "Damaged"; Console.WriteLine($"B1 is a {b1.GetType().FullName} and its clone B2 is a {b2.GetType().FullName}"); Assert.AreEqual(b1.GetType(), b2.GetType()); Console.WriteLine($"D1 is a {d1.GetType().FullName} and its clone D2 is a {d2.GetType().FullName}"); Console.WriteLine($"H1 is a {h1.GetType().FullName} and its clone H2 is a {h2.GetType().FullName}"); Console.WriteLine($"A1 is a {a1.GetType().FullName} and its clone A2 is a {a2.GetType().FullName}"); Console.WriteLine($"Changing H1's HullType and then making a clone H1a, which is also a {h1a.GetType().FullName}"); Console.WriteLine($"Making a clone of H2 H2a, which is also a {h2a.GetType().FullName}"); Console.WriteLine($"B1 arcs : [{b1.Arcs}]"); Console.WriteLine($"B2 arcs : [{b2.Arcs}]"); Console.WriteLine($"D1 status: [{d1.StatusString}]"); Console.WriteLine($"D2 status: [{d2.StatusString}]"); Console.WriteLine($"H1 type : [{h1.HullType}]"); Console.WriteLine($"H1a type : [{h1a.HullType}]"); Console.WriteLine($"H2 type : [{h2.HullType}]"); Console.WriteLine($"H2a type : [{h2a.HullType}]"); Console.WriteLine($"A1 totalArmor : [{a1.TotalArmor}]"); Console.WriteLine($"A2 totalArmor : [{((ArmorSystem)a2).TotalArmor}] (Cloned as DefenseSystem, cast to ArmorSystem)"); // Ensure cloning results in no type changes Assert.AreEqual(d1.GetType(), d2.GetType()); Assert.AreEqual(h1.GetType(), h2.GetType()); Assert.AreEqual(a1.GetType(), a2.GetType()); // Ensure cloning results in separate references Assert.AreNotEqual(h1.HullType, h1a.HullType); Assert.AreNotEqual(h1.HullType, h2.HullType); Assert.AreNotEqual(b1.Arcs, b2.Arcs); Assert.AreNotEqual(a1.TotalArmor, ((ArmorSystem)a2).TotalArmor); // Ensure cloning results in identical values unless changed Assert.AreEqual(h2.HullType, h2a.HullType); }