private void chooseCharacterButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(nameInput.Text)) { Label erroLabel = new Label(); erroLabel.Text = "You must enter character name before you press \"Choose character\" button"; erroLabel.Enabled = true; erroLabel.Visible = true; var labelLocation = new Point(200,450); erroLabel.Font = new Font(FontFamily.GenericSerif, 10); erroLabel.Location = labelLocation; erroLabel.AutoSize = true; this.Controls.Add(erroLabel); } else { if (this.warriorRadioButton.Checked) { Player player = new Warrior(new Position(0, 0), nameInput.Text); CreatePlayerAndStartGame(player); } else if (this.archerRadioButton.Checked) { Player player = new Archer(new Position(0, 0), nameInput.Text); CreatePlayerAndStartGame(player); } else if (this.mageRadioButton.Checked) { Player player = new Mage(new Position(0, 0), nameInput.Text); CreatePlayerAndStartGame(player); } } }
private DataHeroes() { if (SaveData.isHaveData(saveDataFileName)) { archerExp = instance.archerExp; sniperExp = instance.sniperExp; rogueExp = instance.rogueExp; dukunExp = instance.dukunExp; archerLocked = instance.archerLocked; sniperLocked = instance.sniperLocked; rogueLocked = instance.rogueLocked; dukunLocked = instance.dukunLocked; } else { archerExp = 0; sniperExp = 0; rogueExp = 0; dukunExp = 0; archerLocked = true; sniperLocked = true; rogueLocked = true; dukunLocked = true; } archerModel = new Archer(archerExp, archerLocked); sniperModel = new Sniper(sniperExp, sniperLocked); dukunModel = new Dukun(dukunExp, dukunLocked); rogueModel = new Rogue(rogueExp, rogueLocked); }
public IUnit Train(string type, Game.Point coords) { IUnit unit = null; switch (type) { case ("Peasant"): { unit = new Peasant(coords); break; } case ("Archer"): { unit = new Archer(coords); break; } //case ("Clubman"): // { // building = new BowWorkshop(coords); // break; // } //case ("SwordFighter"): // { // building = new Tower(coords); // break; // } default: break; } return unit; }
public void convertArcher(NPC npc){ if ( ressource.blood >= 1 && ressource.holyWater>=2) { ressource.blood --; ressource.holyWater -=2; int position = npc.position; npc = new Archer (); npc.setPosition (position); this.party.addNPC (npc); } }
public void convertToArcher(NPC target) { var npc = new Archer (); npc.name = "converted archer"; npc.hp += target.hp; npc.maxHp += target.maxHp; npc.mp += target.mp; npc.maxMp += target.maxMp; npc.position = target.position; Game.removeNPC (target); target.killNPC (); Board.tiles [npc.position].npc = npc; messiah.party.addNPC (npc); messiah.party.p.removeArcherResource (); Game.addNPC (npc); }
public override void Update() { base.Update(); if (this.CycleCounter % 2 == 0 && this.CycleCounter != 0) { var gold = new Gold(); this.AddResource(gold); this.ResourceCycle = 0; } if (this.CycleCounter % 3 == 0 && this.CycleCounter != 0) { var archer = new Archer(); this.AddUnit(archer); this.Engine.DB.AddUnit(archer); this.UnitCycle = 0; } }
public void SetArcherObject(ref Archer archerObject) { this.archerObject = archerObject; }
Animator animator; // creating a Animator Object to reference to the animator in script void Start() { archer = gameObject.GetComponentInParent <Archer> (); // getting component from parent Gameobject animator = gameObject.GetComponentInParent <Animator> (); }
// Use this for initialization void Start() { mapdata = GetComponent <MapData>(); archer = GameObject.Find("archer").GetComponent <Archer>(); }
void Awake() { switch (PlayerStatus.playerData.characterNumber) { case 0: // 青年を出す処理を書く break; case 1: // ムキムキを出す player = PhotonNetwork.Instantiate("Player/mukimuki", new Vector3(PlayerStatus.playerData.x, PlayerStatus.playerData.y, PlayerStatus.playerData.z), Quaternion.identity, 0); break; case 2: // 少女を出す break; case 3: // BBAを出す break; } // 職業によって処理分け switch (PlayerStatus.playerData.job) { // アーチャー case 0: // アーチャーを入れる Archer archer = player.AddComponent <Archer>(); // PhotonViewの通信を使うリストにアーチャーを登録する player.GetComponent <PhotonView>().ObservedComponents.Add(archer); // アニメーションを変更する player.GetComponent <Animator>().runtimeAnimatorController = archerAnimationController; break; case 1: // ウォーリアを入れる Warrior warrior = player.AddComponent <Warrior>(); // PhotonViewの通信を使うリストにアーチャーを登録する player.GetComponent <PhotonView>().ObservedComponents.Add(warrior); warrior.Initialize(); Debug.Log(warrior.GetPlayerData().name); // アニメーションを変更する player.GetComponent <Animator>().runtimeAnimatorController = warriorAnimationController; break; case 2: // ソーサラーを入れる Sorcerer sorcerer = player.AddComponent <Sorcerer>(); // PhotonViewの通信を使うリストにアーチャーを登録する player.GetComponent <PhotonView>().ObservedComponents.Add(sorcerer); // アニメーションを変更する player.GetComponent <Animator>().runtimeAnimatorController = sorcererAnimationController; break; case 3: // アーチャーを入れる Monk monk = player.AddComponent <Monk>(); // PhotonViewの通信を使うリストにアーチャーを登録する player.GetComponent <PhotonView>().ObservedComponents.Add(monk); // アニメーションを変更する player.GetComponent <Animator>().runtimeAnimatorController = monkAnimationController; break; } }
new void Update() { //Add Knight to queue by pressing 1 if (selected && Input.GetKeyDown(KeyCode.Alpha1)) { if (player.getUnitManager().getUnitCount() + player.getUnitManager().getRectruitingUnitCount() < player.getUnitManager().getUnitLimit() && player.GetRessourceManager().hasRessources(Knight.getCost()) && recruitingCount < recruitingLimit) { if (unitTimers.Count > 0) { unitTimers.Add(new UnitTimer(unitTimers[unitTimers.Count - 1].getEndTime() + KnightRecruitTime, KNIGHTID, KnightRecruitTime)); player.getUnitManager().addRecruitingUnitCount(player.getSpawner().getKnightComponent().getunitCountSize()); } else { unitTimers.Add(new UnitTimer(Time.time + KnightRecruitTime, KNIGHTID, KnightRecruitTime)); player.getUnitManager().addRecruitingUnitCount(player.getSpawner().getKnightComponent().getunitCountSize()); } player.GetRessourceManager().removeRessources(Knight.getCost()); recruitingCount++; } } //Add Archer to queue by pressing 1 else if (selected && Input.GetKeyDown(KeyCode.Alpha2)) { if (player.getUnitManager().getUnitCount() + player.getUnitManager().getRectruitingUnitCount() < player.getUnitManager().getUnitLimit() && player.GetRessourceManager().hasRessources(Archer.getCost()) && recruitingCount < recruitingLimit) { if (unitTimers.Count > 0) { unitTimers.Add(new UnitTimer(unitTimers[unitTimers.Count - 1].getEndTime() + ArchetRecruitTime, ARCHERID, ArchetRecruitTime)); player.getUnitManager().addRecruitingUnitCount(player.getSpawner().getArcherComponent().getunitCountSize()); } else { unitTimers.Add(new UnitTimer(Time.time + ArchetRecruitTime, ARCHERID, ArchetRecruitTime)); player.getUnitManager().addRecruitingUnitCount(player.getSpawner().getArcherComponent().getunitCountSize()); } player.GetRessourceManager().removeRessources(Archer.getCost()); recruitingCount++; } } //Spawning if queuetime is over if (unitTimers.Count > 0) { float currentLoadingPoint = (Time.time - (unitTimers[0].getEndTime() - unitTimers[0].getTotalTime())) / unitTimers[0].getTotalTime(); if (currentLoadingPoint > nextLoadingBarStep) { spawnProgressBar.fillAmount = nextLoadingBarStep; nextLoadingBarStep += loadingBarSteps; } if (Time.time > unitTimers[0].getEndTime()) { spawnProgressBar.fillAmount = 1; nextLoadingBarStep = loadingBarSteps; switch (unitTimers[0].getId()) { case 0: RecruitKnight(); break; case 1: RecruitArcher(); break; } unitTimers.RemoveAt(0); recruitingCount--; } } base.Update(); }
void SkeletonAtk(GameObject Skeleton, GameObject player, Knight knightinfo, Archer archerinfo, Assassin assassininfo, Wizard wizardinfo, Hwang hwanginfo, King kinginfo, Skeleton Enemyinfo) { Enemyinfo = Skeleton.GetComponent <Skeleton>(); Debug.Log(player.name); if (player.name == "knight" || player.name == "knight(Clone)") { knightinfo = player.GetComponent <Knight>(); knightinfo.hp -= Enemyinfo.atk; if (knightinfo.hp <= 0) { Destroy(player); } } if (player.name == "Archer" || player.name == "Archer(Clone)") { archerinfo = player.GetComponent <Archer>(); archerinfo.hp -= Enemyinfo.atk; if (archerinfo.hp <= 0) { Destroy(player); } } if (player.name == "Assassin" || player.name == "Assassin(Clone)") { assassininfo = player.GetComponent <Assassin>(); assassininfo.hp -= Enemyinfo.atk; if (assassininfo.hp <= 0) { Destroy(player); } } if (player.name == "Hwang" || player.name == "Hwang(Clone)") { hwanginfo = player.GetComponent <Hwang>(); hwanginfo.hp -= Enemyinfo.atk; if (hwanginfo.hp <= 0) { Destroy(player); } } if (player.name == "Wizard" || player.name == "Wizard(Clone)") { wizardinfo = player.GetComponent <Wizard>(); wizardinfo.hp -= Enemyinfo.atk; if (wizardinfo.hp <= 0) { Destroy(player); } } if (player.name == "King" || player.name == "King(Clone)") { kinginfo = player.GetComponent <King>(); kinginfo.hp -= Enemyinfo.atk; if (kinginfo.hp <= 0) { Destroy(player); } } Enemyanim = GameObject.FindGameObjectWithTag("skeleton").GetComponent <Animator>(); Enemyanim.SetTrigger("atk"); }
public override void ChangeStates(Archer character) { character.TurnCount = Up; IsExist = false; }
static void Main(string[] args) { int pilihan, pilihan1, pilihan2; int ulang = 1; Random rand = new Random(); Characters karakter; IMonsters monster; Console.WriteLine("Character & Monster Status"); Console.WriteLine("Pilih Kategori yang anda lihat : (1/2)"); Console.WriteLine("1.Character Job"); Console.WriteLine("2.Monster "); pilihan = Convert.ToInt32(Console.ReadLine()); switch (pilihan) { case 1: Console.WriteLine("Pilih Job Status yang ingin anda lihat : "); Console.WriteLine("1.Soldier"); Console.WriteLine("2.Archer"); pilihan1 = Convert.ToInt32(Console.ReadLine()); switch (pilihan1) { case 1: karakter = new Soldier(); karakter.CharacterJob(); break; case 2: karakter = new Archer(); karakter.CharacterJob(); break; } break; case 2: Console.WriteLine("Pilih Monsters yang akan discan : (1/2)"); Console.WriteLine("1.Slime"); Console.WriteLine("2.Orc"); pilihan2 = Convert.ToInt32(Console.ReadLine()); switch (pilihan2) { case 1: { monster = new Slime(); monster.Status(); } break; case 2: monster = new ORC(); monster.Status(); break; } break; } Console.ReadKey(); }
void Start() { Character hero = new Character(); hero.PrintCharacterStats();//hero = "AB" Character hero2 = hero; hero2.PrintCharacterStats(); //hero2 = "AB" hero2.name = "Madonna"; hero.PrintCharacterStats(); //hero = "M" hero2.PrintCharacterStats(); //hero2 = "M" Character heroine = new Character("Lara Croft"); heroine.PrintCharacterStats(); Weapon sword = new Weapon("Espada roma", 5); sword.PrintWeaponStats(); //sword = "ER" Weapon sword2 = sword; sword2.PrintWeaponStats(); //sword2 = "ER" sword2.name = "Excalibur"; sword2.damage = 255; sword.PrintWeaponStats(); //sword = "ER" sword2.PrintWeaponStats(); //sword2 = "Ex" Paladin p = new Paladin(); Paladin p2 = new Paladin("Juan Gabriel", sword); p2.PrintCharacterStats(); Archer a = new Archer("Legolas", new Weapon("Arco de los bosques", 7) ); Magician m = new Magician("Gandalf"); List <Character> party = new List <Character>(); party.Add(p2); party.Add(a); party.Add(m); foreach (Character c in party) { c.PrintCharacterStats(); } //El script está en la cámara //Podemos consultar otros componentes de la cámara Transform theTransform = GetComponent <Transform>(); Debug.Log(theTransform.position); Debug.Log(theTransform.rotation); Camera cam = GetComponent <Camera>(); Debug.Log(cam.fieldOfView); GameObject myLight = GameObject.Find("Directional Light"); Transform t = myLight.GetComponent <Transform>(); Debug.Log("La luz está en: " + t.position); }
public static void HandleAbnormalityBegin(S_ABNORMALITY_BEGIN p) { AbnormalityManager.BeginAbnormality(p.AbnormalityId, p.TargetId, p.Duration, p.Stacks); if (!SettingsManager.ClassWindowSettings.Enabled) { return; } switch (SessionManager.CurrentPlayer.Class) { case Class.Mystic: Mystic.CheckHurricane(p); Mystic.CheckBuff(p); break; case Class.Warrior: Warrior.CheckBuff(p); break; case Class.Valkyrie: Valkyrie.CheckRagnarok(p); break; case Class.Archer: Archer.CheckFocus(p); Archer.CheckFocusX(p); Archer.CheckSniperEye(p); break; case Class.Lancer: Lancer.CheckArush(p); Lancer.CheckGshout(p); Lancer.CheckLineHeld(p); break; case Class.Priest: Priest.CheckBuff(p); break; case Class.Brawler: Brawler.CheckBrawlerAbnormal(p); break; case Class.Ninja: Ninja.CheckFocus(p); break; case Class.Sorcerer: Sorcerer.CheckBuff(p); break; case Class.Reaper: Reaper.CheckBuff(p); break; case Class.Slayer: Slayer.CheckBuff(p); break; case Class.Berserker: Berserker.CheckBuff(p); break; } }
static void Main(string[] args) { Knight knight = new Knight(100f, 15f, 15f); Archer archer = new Archer(80f, 30f, 10f); Wizard wizard = new Wizard(50f, 40f, 5f); Barbarian barbarian = new Barbarian(150f, 20f, 5f); Crossbowman crossbowman = new Crossbowman(100f, 30f, 15f); Necromancer necromancer = new Necromancer(80f, 20f, 10f); Platoon platoon1 = new Platoon(1); Platoon platoon2 = new Platoon(2); platoon1.AddSoldier(knight); platoon1.AddSoldier(archer); platoon1.AddSoldier(wizard); platoon2.AddSoldier(barbarian); platoon2.AddSoldier(crossbowman); platoon2.AddSoldier(necromancer); Soldier soldier1; Soldier soldier2; bool checkSoldiersInPlatoon = true; Random rand = new Random(); while (checkSoldiersInPlatoon != false) { for (int i = 0; i < platoon1.Count; i++) { for (int y = 0; y < platoon2.Count; y++) { soldier1 = platoon2.GetSoldier(y); soldier2 = platoon1.GetSoldier(i); int index = rand.Next(0, 2); if (index == 0) { platoon2.Atack(soldier1, soldier2.Damage); } else { soldier1.DoSpeciallSkill(); } Atack(platoon1, platoon2, y, soldier1, soldier2); } } for (int i = 0; i < platoon2.Count; i++) { for (int y = 0; y < platoon1.Count; y++) { soldier1 = platoon1.GetSoldier(y); soldier2 = platoon2.GetSoldier(i); platoon1.Atack(soldier1, soldier2.Damage); int index = rand.Next(0, 2); if (index == 0) { Atack(platoon1, platoon2, y, soldier1, soldier2); } else { soldier1.DoSpeciallSkill(); } } } checkSoldiersInPlatoon = platoon1.CheckSoldiersInPlatoon(); checkSoldiersInPlatoon = platoon1.CheckSoldiersInPlatoon(); Console.ReadKey(); } bool checkPlatoon1 = platoon1.CheckSoldiersInPlatoon(); bool checkPlatoon2 = platoon2.CheckSoldiersInPlatoon(); if (checkPlatoon1 == false) { Console.WriteLine("Взвод № 1 уничтожен"); } if (checkPlatoon2 == false) { Console.WriteLine("Взвод № 2 уничтожен"); } Console.ReadKey(); }
// Start is called before the first frame update void Start() { this.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); cam = Camera.main; archer = FindObjectOfType <Archer>(); }
private void Awake() { _instance = this; DontDestroyOnLoad(gameObject); player = GameObject.FindObjectOfType <Archer>(); }
public ArcherLeveling(Archer hero, int level) : base(level) { archer = hero; }
public override void draw(SpriteBatch s) { base.draw(s); for (int i = 0; i < _playingButtons.Count - 1; i++) { if (_playingButtons[i]._drawTooltip == true) { switch (i) { default: break; case 0: s.DrawString(font, "Move units", ToolTipPos, Color.DarkOrange); break; case 1: Farm e = new Farm(null, new Vector2(0, 0), BuildingAndUnit.faction.Human); { s.DrawString(font, "Produce Farm, Gold:" + e.GoldCost + "+ Lumber:" + e.LumberCost, ToolTipPos, Color.DarkOrange); } break; case 2: WorkerUnit w = new WorkerUnit(null); { s.DrawString(font, "Produce Worker, Gold:" + w.GoldCost + "+ Food:" + w._foodCost, ToolTipPos, Color.DarkOrange); } break; case 3: s.DrawString(font, "Stop selected units", ToolTipPos, Color.DarkOrange); break; case 4: Barracks B = new Barracks(null, new Vector2(0, 0), BuildingAndUnit.faction.Human); s.DrawString(font, "Barracks, Gold:" + B.GoldCost + "Lumber:" + B.LumberCost, ToolTipPos, Color.DarkOrange); break; case 5: BasicMeleeUnit b = new Footman(null, new Vector2(0, 0)); s.DrawString(font, "Footman, Gold:" + b.GoldCost + "Lumber:" + b.LumberCost + "Food:" + b.FoodCost, ToolTipPos, Color.DarkOrange); break; case 6: s.DrawString(font, "Attack", ToolTipPos, Color.DarkOrange); break; case 7: s.DrawString(font, "Chop trees", ToolTipPos, Color.DarkOrange); break; case 8: Archer a = new Archer(null, new Vector2(0, 0)); s.DrawString(font, "Archer, Gold:" + a.GoldCost + "Lumber:" + a.LumberCost + "Food:" + a.FoodCost, ToolTipPos, Color.DarkOrange); break; case 9: s.DrawString(font, " - ", ToolTipPos, Color.Black); break; case 10: //Barracks B = new Barracks(null, new Vector2(0, 0), BuildingAndUnit.faction.Human); //s.DrawString(font, "Barracks, Gold:"+ B.GoldCost + "Lumber:" + B.LumberCost , ToolTipPos, Color.DarkOrange); break; case 11: s.DrawString(font, "- ", ToolTipPos, Color.Black); break; case 12: s.DrawString(font, " - ", ToolTipPos, Color.Black); break; } } } _minimap.draw(s); s.Draw(_minimapBorder, new Vector2(0, GameEnvironment.getCamera().getScreenSize().Y - 300), Color.White); //foreach (BasicMeleeUnit q in hudUnits.OfType<BasicMeleeUnit>()) if (hudUnits != null) { int i = 0; foreach (BuildingAndUnit e in hudUnits.OfType <BuildingAndUnit>()) { if (e is ProductionBuilding) { if ((e as ProductionBuilding)._producingUnit) { DrawingHelper.DrawRectangle(new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 60, 400, 20), s, Color.SaddleBrown, 2); s.Draw(GameEnvironment.getAssetManager().GetSprite("Sprites/HUD/Healthbar"), new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 60, (int)(400 * (float)((float)(e as ProductionBuilding)._unitProductionTimer / (float)(e as ProductionBuilding)._unitProductionTime)), 20), Color.White); //DrawingHelper.DrawRectangle(new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 60, (int)(400*(float)((float)(e as ProductionBuilding)._unitProductionTimer / (float)(e as ProductionBuilding)._unitProductionTime)), 20), s, Color.Green, 2); } } e.Healthbar(s, new Vector2((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 120), 1); s.Draw(e.Sprite, new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 120, 64, 64), Color.White); i++; if (i > 9) { break; } } } }
static void Main(string[] args) { var address = new AddressBookBuilder(); address.ActualNumber = 1830; address.StreetName = "Meridain Ave"; address.LocationName = "South Beach Apt"; Console.WriteLine(address); // var oldBoat = new Boat("Trirton", "Outboard Engine type"); oldBoat.Buy("Frank"); Console.WriteLine(oldBoat); // /*var horse = new Animal {Name = "Mr. Ed", FavoriteFood = "Grass",Greeting = "Hello Wilbur"}; //No constructor in class so we set out here. * horse.Speak(); * horse.Eat();*/ // var horse2 = new Horse { Name = "Clippity Clop" }; horse2.Speak(); horse2.Eat(); horse2.ShoeMyHorse(); // var Betsy = new Cow { Name = "Betsy" }; Betsy.Speak(); Betsy.Eat(); Betsy.GiveMilk(); // var lancelot = new Knight(); var legolas = new Archer(); var merlin = new Wizard(); var sgtPatton = new RifleSoldier(); var pvtGump = new GrenadierSoldier(); // var modernArmy = new List <Soldier>(); modernArmy.Add(sgtPatton); modernArmy.Add(pvtGump); modernArmy.ForEach(fighter => fighter.Attack()); // var army = new List <Warrior>(); army.Add(lancelot); army.Add(legolas); army.Add(merlin); army.ForEach(fighter => fighter.Attack()); // var pegasus1 = new Pegasus(40, 30); pegasus1.IncreaseSpeed(20); pegasus1.DecreaseSpeed(10); pegasus1.FlapWings(10); pegasus1.Glide(5); Console.WriteLine(pegasus1); // var car1 = new Car("Volks", "GTI", 210, 25000); car1.IncreaseHP(50); car1.DecreaseHP(20); car1.IncreaseValue(6000); car1.DecreaseValue(1000); Console.WriteLine(car1); // var sportsCar1 = new SportsCar("Porsche", "911", 350, 90000); sportsCar1.IncreaseHP(50); sportsCar1.CustomParts.IncreaseValue(20); sportsCar1.IncreaseHpToSportCarLevels(); Console.WriteLine(sportsCar1); // Console.ReadLine(); }
public Archer_DeadState(Entity _entity, FiniteStateMachine _stateMachine, string _animBoolName, D_DeadState _stateData, Archer _archer) : base(_entity, _stateMachine, _animBoolName, _stateData) { archer = _archer; }
private void Start() { //Find healthBar = GetComponent <Image>(); archer = FindObjectOfType <Archer>(); }
public static PlayerUnit create_punit(int ID, int owner_ID) { PlayerUnit pu = null; if (ID == WARRIOR) { pu = new Warrior(); } else if (ID == SPEARMAN) { pu = new Spearman(); } else if (ID == ARCHER) { pu = new Archer(); } else if (ID == MINER) { pu = new Miner(); } else if (ID == INSPIRATOR) { pu = new Inspirator(); } else if (ID == SEEKER) { pu = new Seeker(); } else if (ID == GUARDIAN) { pu = new Guardian(); } else if (ID == ARBALEST) { pu = new Arbalest(); } else if (ID == SKIRMISHER) { pu = new Skirmisher(); } else if (ID == PALADIN) { pu = new Paladin(); } else if (ID == MENDER) { pu = new Mender(); } else if (ID == DRUMMER) { pu = new Drummer(); } else if (ID == PIKEMAN) { pu = new Pikeman(); } else if (ID == CARTER) { pu = new Carter(); } else if (ID == DRAGOON) { pu = new Dragoon(); } else if (ID == SCOUT) { pu = new Scout(); } else if (ID == SHIELD_MAIDEN) { pu = new ShieldMaiden(); } pu.owner_ID = owner_ID; return(pu); }
public Village(Game1 g, GraphicsDevice gd, ContentManager c, PlayerClasses playerClass) : base(g, gd, c) { #region local variables var playerScale = 1f; var inventoryTexture = content.Load <Texture2D>("Inventory"); var slotTexture = content.Load <Texture2D>("InventorySlot"); int inventorySlots = 6; var healthPotionTexture = content.Load <Texture2D>("HealthPotion"); var manaPotionTexture = content.Load <Texture2D>("ManaPotion"); var font = content.Load <SpriteFont>("Font"); var healthBarTexture = content.Load <Texture2D>("HealthBarBorder"); var healthTexture = content.Load <Texture2D>("Health"); var staminaTexture = content.Load <Texture2D>("Stamina"); var anivilTexture = content.Load <Texture2D>("Anvil"); var background = content.Load <Texture2D>("VillageBackground"); var box = content.Load <Texture2D>("Box"); var startingSwordTexture = content.Load <Texture2D>("StartingSword"); var startingBowTexture = content.Load <Texture2D>("StartingBow"); var startingWarriorBreastplate = content.Load <Texture2D>("StartingWarriorBreastplate"); var startingArcherBreastplate = content.Load <Texture2D>("StartingArcherBreastplate"); var startingWarriorHelmet = content.Load <Texture2D>("StartingWarriorHelmet"); var startingArcherHelmet = content.Load <Texture2D>("StartingArcherHelmet"); var startingBoots = content.Load <Texture2D>("StartingBoots"); var blackSmithAnimations = new Dictionary <string, Animation>() { { "Idle", new Animation(content.Load <Texture2D>("Blacksmith"), 3, game.Scale) }, }; var shopkeeperAnimations = new Dictionary <string, Animation>() { { "Idle", new Animation(content.Load <Texture2D>("Shopkeeper"), 1, game.Scale) }, }; #endregion switch (playerClass) { case PlayerClasses.Warrior: { var animations = new Dictionary <string, Animation>() { { "Idle", new Animation(content.Load <Texture2D>("Warrior"), 1, playerScale * game.Scale) }, { "WalkRight", new Animation(content.Load <Texture2D>("WalkRight"), 3, playerScale * game.Scale) }, { "WalkLeft", new Animation(content.Load <Texture2D>("WalkLeft"), 3, playerScale * game.Scale) } }; player = new Warrior(animations, g.Scale) { Position = new Vector2(0.05f * game.Width, 0.4f * game.Height), InventoryManager = new InventoryManager(inventoryTexture, slotTexture, font, inventorySlots, new Vector2(0.75f * game.Width, 0.05f * game.Height), game.Scale), HealthBar = new HealthBar(healthBarTexture, healthTexture, new Vector2(0.03f * game.Width, 0.9f * game.Height), game.Scale) }; if (player is StaminaUser) { (player as StaminaUser).StaminaBar = new StaminaBar(healthBarTexture, staminaTexture, new Vector2(0.03f * game.Width, 0.95f * game.Height), game.Scale); } player.InventoryManager.AddItem(new StartingSword(startingSwordTexture, game.Scale)); player.InventoryManager.AddItem(new StartingWarriorHelmet(startingWarriorHelmet, game.Scale)); player.InventoryManager.AddItem(new StartingWarriorBreastplate(startingWarriorBreastplate, game.Scale)); player.InventoryManager.AddItem(new StartingBoots(startingBoots, game.Scale)); player.InventoryManager.EquipmentManager = new EquipmentManager(inventoryTexture, slotTexture, font, new Vector2(0.02f * game.Width, 0.05f * game.Height), game.Scale); player.InventoryManager.EquipmentManager.EquipmentSlots = new List <InventorySlot>() { new WarriorHelmetSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.075f * game.Width, 0.07f * game.Height) }, new NecklaceSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.075f * game.Width, 0.07f * game.Height + slotTexture.Height * game.Scale) }, new WarriorBreastplateSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.075f * game.Width, 0.07f * game.Height + 2 * slotTexture.Height * game.Scale) }, new BootsSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.075f * game.Width, 0.07f * game.Height + 3 * slotTexture.Height * game.Scale) }, new SwordSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.025f * game.Width, 0.07f * game.Height + 2 * slotTexture.Height * game.Scale) }, new ShieldSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.125f * game.Width, 0.07f * game.Height + 1 * slotTexture.Height * game.Scale) }, new RingSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.125f * game.Width, 0.07f * game.Height + 2 * slotTexture.Height * game.Scale) } }; break; } case PlayerClasses.Archer: { var animations = new Dictionary <string, Animation>() { { "Idle", new Animation(content.Load <Texture2D>("Archer"), 1, playerScale * game.Scale) }, { "WalkRight", new Animation(content.Load <Texture2D>("WalkRight"), 3, playerScale * game.Scale) }, { "WalkLeft", new Animation(content.Load <Texture2D>("WalkLeft"), 3, playerScale * game.Scale) } }; player = new Archer(animations, g.Scale) { Position = new Vector2(0.05f * game.Width, 0.4f * game.Height), InventoryManager = new InventoryManager(inventoryTexture, slotTexture, font, inventorySlots, new Vector2(0.75f * game.Width, 0.05f * game.Height), game.Scale), HealthBar = new HealthBar(healthBarTexture, healthTexture, new Vector2(0.03f * game.Width, 0.9f * game.Height), game.Scale) }; if (player is StaminaUser) { (player as StaminaUser).StaminaBar = new StaminaBar(healthBarTexture, staminaTexture, new Vector2(0.03f * game.Width, 0.95f * game.Height), game.Scale); } player.InventoryManager.AddItem(new StartingBow(startingBowTexture, game.Scale)); player.InventoryManager.AddItem(new StartingArcherHelmet(startingArcherHelmet, game.Scale)); player.InventoryManager.AddItem(new StartingArcherBreastplate(startingArcherBreastplate, game.Scale)); player.InventoryManager.AddItem(new StartingBoots(startingBoots, game.Scale)); player.InventoryManager.EquipmentManager = new EquipmentManager(inventoryTexture, slotTexture, font, new Vector2(0.02f * game.Width, 0.05f * game.Height), game.Scale); player.InventoryManager.EquipmentManager.EquipmentSlots = new List <InventorySlot>() { new ArcherHelmetSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.075f * game.Width, 0.07f * game.Height) }, new NecklaceSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.075f * game.Width, 0.075f * game.Height + slotTexture.Height * game.Scale) }, new ArcherBreastplateslot(slotTexture, font, game.Scale) { Position = new Vector2(0.075f * game.Width, 0.07f * game.Height + 2 * slotTexture.Height * game.Scale) }, new BootsSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.075f * game.Width, 0.07f * game.Height + 3 * slotTexture.Height * game.Scale) }, new BowSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.025f * game.Width, 0.07f * game.Height + 2 * slotTexture.Height * game.Scale) }, new RingSlot(slotTexture, font, game.Scale) { Position = new Vector2(0.125f * game.Width, 0.07f * game.Height + 2 * slotTexture.Height * game.Scale) } }; break; } case PlayerClasses.Wizard: { //Not implemented yet //player = new Wizard(content.Load<Texture2D>("Archer"), g.Scale); if (player is ManaUser) { (player as ManaUser).InventoryManager.AddItem(new ManaPotion(manaPotionTexture, game.Scale), 2); } break; } } player.InventoryManager.AddItem(new HealthPotion(healthPotionTexture, game.Scale), 2); components = new List <Component> { new Sprite(background, g.Scale) { Position = new Vector2(0, 0) }, }; movingComponents = new List <Component> { new Blacksmith(blackSmithAnimations) { Position = new Vector2(0.813f * game.Width, 0.33f * game.Height) }, new Shopkeeper(shopkeeperAnimations) { Position = new Vector2(0.513f * game.Width, 0.40f * game.Height) }, new Sprite(box, g.Scale) { Position = new Vector2(0.813f * game.Width, 0.55f * game.Height) }, new Sprite(anivilTexture, g.Scale) { Position = new Vector2(0.813f * game.Width, 0.45f * game.Height) }, player }; if (player is StaminaUser) { uiComponents = new List <Component> { player.InventoryManager, player.HealthBar, (player as StaminaUser).StaminaBar }; } }
private void PlacePawns() { ///Never spend 6 minutes doing something by hand when you can spend 6 hours failing to automate it //red Pawn defR0 = new Defender(false, new Cord(0, 3)); Pawn defR1 = new Defender(false, new Cord(0, 7)); Pawn defR2 = new Defender(false, new Cord(1, 4)); Pawn defR3 = new Defender(false, new Cord(1, 5)); Pawn defR4 = new Defender(false, new Cord(1, 6)); Pawn defR5 = new Defender(false, new Cord(2, 5)); Pawn magR0 = new Mag(false, new Cord(0, 4)); Pawn magR1 = new Mag(false, new Cord(0, 6)); Pawn kingR = new King(false, new Cord(0, 5)); Pawn assassinR0 = new Assassin(false, new Cord(0, 0)); Pawn assassinR1 = new Assassin(false, new Cord(0, 10)); Pawn archerR0 = new Archer(false, new Cord(0, 1)); Pawn archerR1 = new Archer(false, new Cord(0, 9)); Pawn axemanR0 = new Axeman(false, new Cord(0, 2)); Pawn axemanR1 = new Axeman(false, new Cord(0, 8)); Pawn axemanR2 = new Axeman(false, new Cord(1, 2)); Pawn axemanR3 = new Axeman(false, new Cord(1, 8)); B[0, 3].PawnOnField = defR0; B[0, 7].PawnOnField = defR1; B[1, 4].PawnOnField = defR2; B[1, 5].PawnOnField = defR3; B[1, 6].PawnOnField = defR4; B[2, 5].PawnOnField = defR5; B[0, 4].PawnOnField = magR0; B[0, 6].PawnOnField = magR1; B[0, 5].PawnOnField = kingR; B[0, 0].PawnOnField = assassinR0; B[0, 10].PawnOnField = assassinR1; B[0, 1].PawnOnField = archerR0; B[0, 9].PawnOnField = archerR1; B[0, 2].PawnOnField = axemanR0; B[0, 8].PawnOnField = axemanR1; B[1, 2].PawnOnField = axemanR2; B[1, 8].PawnOnField = axemanR3; //blue Pawn defB0 = new Defender(true, new Cord(10, 3)); Pawn defB1 = new Defender(true, new Cord(10, 7)); Pawn defB2 = new Defender(true, new Cord(9, 4)); Pawn defB3 = new Defender(true, new Cord(9, 5)); Pawn defB4 = new Defender(true, new Cord(9, 6)); Pawn defB5 = new Defender(true, new Cord(8, 5)); Pawn magB0 = new Mag(true, new Cord(10, 4)); Pawn magB1 = new Mag(true, new Cord(10, 6)); Pawn kingB = new King(true, new Cord(10, 5)); Pawn assassinB0 = new Assassin(true, new Cord(10, 0)); Pawn assassinB1 = new Assassin(true, new Cord(10, 10)); Pawn archerB0 = new Archer(true, new Cord(10, 1)); Pawn archerB1 = new Archer(true, new Cord(10, 9)); Pawn axemanB0 = new Axeman(true, new Cord(10, 2)); Pawn axemanB1 = new Axeman(true, new Cord(10, 8)); Pawn axemanB2 = new Axeman(true, new Cord(9, 2)); Pawn axemanB3 = new Axeman(true, new Cord(9, 8)); B[10, 3].PawnOnField = defB0; B[10, 7].PawnOnField = defB1; B[9, 4].PawnOnField = defB2; B[9, 5].PawnOnField = defB3; B[9, 6].PawnOnField = defB4; B[8, 5].PawnOnField = defB5; B[10, 4].PawnOnField = magB0; B[10, 6].PawnOnField = magB1; B[10, 5].PawnOnField = kingB; B[10, 0].PawnOnField = assassinB0; B[10, 10].PawnOnField = assassinB1; B[10, 1].PawnOnField = archerB0; B[10, 9].PawnOnField = archerB1; B[10, 2].PawnOnField = axemanB0; B[10, 8].PawnOnField = axemanB1; B[9, 2].PawnOnField = axemanB2; B[9, 8].PawnOnField = axemanB3; }
// Start is called before the first frame update void Start() { archer = playerObj.GetComponent <Archer>(); }
/// <summary> /// Should be done from the Loadtextures method of the parent class /// Otherwise the NullReference exception will be thrown /// </summary> public void ConvertParent() { this.archerObject = this.parent as Archer; }
static void Main(string[] args) { // 1. strategy pattern Console.WriteLine("1"); // note that all of these are treated as actors rather than their specific type Actor knight = new Strategy.Knight(); knight.Attack(); knight.Defend(); Actor wizard = new Wizard(); wizard.Attack(); wizard.Defend(); Actor archer = new Archer(); archer.Attack(); archer.Defend(); // allows you to operate on objects without caring what they are doing, only that they can perform that operation List <Actor> actors = new List <Actor>() { new Strategy.Knight(), new Wizard(), new Archer() }; foreach (Actor actor in actors) { actor.Attack(); actor.Defend(); } // 2. observer pattern Console.WriteLine("2"); Queen queen = new Queen(); List <Zergling> zerglings = new List <Zergling>(); for (int i = 0; i < 3; i++) { zerglings.Add(new Zergling(queen)); } queen.SetState("DEAD"); // 3. decorator Console.WriteLine("3"); // make a gun GunChassis machineGun = new HeavyGunChassis(); // add automatic mod machineGun = new Automatic(machineGun); Console.WriteLine(machineGun.GetAccuracy()); Console.WriteLine(machineGun.GetRateOfFire()); // make a sniper.. GunChassis sniper = new LightGunChassis(); sniper = new Scope(sniper); Console.WriteLine(sniper.GetAccuracy()); Console.WriteLine(sniper.GetRateOfFire()); // make the sniper automatic! sniper = new Automatic(sniper); Console.WriteLine(sniper.GetAccuracy()); Console.WriteLine(sniper.GetRateOfFire()); // 4. abstract factory Console.WriteLine("4"); ConfigurationFactory assaultShipFactory = new AssaultConfigurationFactory(); Spaceship assaultShip = new AssaultShip(assaultShipFactory); assaultShip.Activate(); ConfigurationFactory transportShipFactory = new HeavyTransportConfigurationFactory(); Spaceship transportShip = new HeavyTransportShip(transportShipFactory); transportShip.Activate(); // Fleet fleet = new Fleet(assaultShip, transportShip); // 5. singleton Console.WriteLine("5"); Singleton.Instance.DoAThing(); // 6. command pattern Console.WriteLine("6"); // set up some receivers Character roy = new Character("Roy"); Character targetDummy = new Character("Dummy"); // set up invoker BattleActionInvoker royActionInvoker = new BattleActionInvoker(); // some commands royActionInvoker.SetBasicAction( new AttackBattleAction(targetDummy, 10)); royActionInvoker.SetSpecialAction( new EscapeBattleAction(roy)); // perform basic attack! royActionInvoker.PerformBasicAction(); // equip an item royActionInvoker.SetBasicAction( new UseItemBattleAction(new Item())); // use an item! royActionInvoker.PerformBasicAction(); // escape! royActionInvoker.PerformSpecialAction(); // 7. adapter pattern Console.WriteLine("7"); Shop shop = new Shop(); OurShopItem ourShopItem = new OurShopItem(); NewVendorProduct newVendorProduct = new NewVendorProduct(); // add our shop item shop.AddToCart(ourShopItem); // we can't add the new vendor product using our cart because it does not match our interface // shop.AddToCart(newVendorProduct); // our adapter conforms to our interface NewVendorProductAdapter newVendorProductAdapter = new NewVendorProductAdapter(newVendorProduct); shop.AddToCart(newVendorProductAdapter); shop.Checkout(); // 8. facade pattern Console.WriteLine("7"); Eye leftEye = new Eye("Green"); Eye rightEye = new Eye("Green"); Mouth mouth = new Mouth(); // put all those subsystems into the Face (Facade) // The face is asked to do work (express an emotion) and knows // how to call the subsystems methods to accomplish that Face face = new Face(leftEye, rightEye, mouth); face.ExpressJoy(); face.ExpressSad(); face.ExpressMurderousIntent(); // 9. Template Method // create some combos ComboAttack comboAttack = new BoxerCombo(); ComboAttack fencerAttack = new FencerCombo(); // execute them directly comboAttack.Execute(); fencerAttack.Execute(); // add them to a collection Queue <ComboAttack> comboAttacks = new Queue <ComboAttack>(); comboAttacks.Enqueue(comboAttack); comboAttacks.Enqueue(fencerAttack); // call any of them without caring about their implementation comboAttacks.Dequeue().Execute(); comboAttacks.Dequeue().Execute(); // 10. Iterator IBag <Loot> goldBag = new GoldBag(10, true); IIterator <Loot> goldBagIterator = goldBag.GetIterator(); IBag <Loot> equipmentBag = new EquipmentBag( new EquipmentLoot[] { new EquipmentLoot("Shirt"), new EquipmentLoot("Pants"), new EquipmentLoot("Shoes") }); IIterator <Loot> equipmentIterator = equipmentBag.GetIterator(); List <IIterator <Loot> > iterators = new List <IIterator <Loot> >() { goldBagIterator, equipmentIterator }; // just having fun with polymorphism foreach (IIterator <Loot> iterator in iterators) { iterator.Current().Open(); // the important part is that we dont care how the collection is implemented, we just iterate through to the end // the iterator could be pulling randomly or popping from a stack/queue and it doesn't matter while (iterator.HasNext()) { iterator.Next().Open(); } } // 11. Composite Node edmonton = new NodeComposite("Edmonton"); Node westEdmonton = new NodeComposite("West Edmonton"); Node aldergrove = new NodeLeaf("Aldergrove"); Node callingwood = new NodeLeaf("Callingwood"); Node southEdmonton = new NodeComposite("South Edmonton"); Node millwoods = new NodeLeaf("Mill Woods"); Node strathcona = new NodeLeaf("Strathcona"); edmonton.Add(westEdmonton); edmonton.Add(southEdmonton); westEdmonton.Add(aldergrove); westEdmonton.Add(callingwood); southEdmonton.Add(millwoods); southEdmonton.Add(strathcona); edmonton.Print(); // print all of edmonton areas and neighborhoods westEdmonton.Print(); // only print west edmonton neighborhoods strathcona.Print(); // print just strathcona // 12. State Pattern Car car = new Car(); car.TurnKey(); car.Drive("North"); car.Brake(); car.Drive("West"); car.TurnKey(); // car is already on, state won't change car.Brake(); car.TurnOff(); // 13. Proxy IKnight trevor = new Proxy.Knight(); IKnight leeroy = new Proxy.Knight(); IKnight tony = new Proxy.KnightInTraining(); List <IKnight> _famousTrio = new List <IKnight>() { trevor, leeroy, tony }; foreach (IKnight trioMember in _famousTrio) { trioMember.DoTraining(); trioMember.DoLocalAdventure(); trioMember.DoEpicAdventure(); // tony won't go on the epic adventure that he was not ready for! } // 14: Flyweight SpriteFactory spriteFactory = new SpriteFactory(); // even though we have all these millions of sprites, we have saved a ton memory // because our factory reuses existing immutable colors and textures List <Sprite> sprites = new List <Sprite>(); sprites.Add(spriteFactory.GetSprite("red", "spooky", false)); sprites.Add(spriteFactory.GetSprite("red", "scary", false)); sprites.Add(spriteFactory.GetSprite("blue", "spooky", false)); sprites.Add(spriteFactory.GetSprite("blue", "scary", false)); sprites.Add(spriteFactory.GetSprite("red", "scary", false)); sprites.Add(spriteFactory.GetSprite("red", "spooky", false)); sprites.Add(spriteFactory.GetSprite("red", "spooky", false)); sprites.Add(spriteFactory.GetSprite("red", "spooky", false)); sprites.Add(spriteFactory.GetSprite("red", "scary", false)); sprites.Add(spriteFactory.GetSprite("blue", "spooky", false)); sprites.Add(spriteFactory.GetSprite("blue", "scary", false)); sprites.Add(spriteFactory.GetSprite("red", "scary", false)); sprites.Add(spriteFactory.GetSprite("red", "spooky", false)); sprites.Add(spriteFactory.GetSprite("red", "spooky", false)); }
public override IUnit CreateUnit() { Archer archer = new Archer(); return(archer); }
static void Main(string[] args) { //eventually want the player to choose class and name Console.WriteLine("What character do you want to play as? 1 - Archer, 2 - Warrior, 3 - Mage"); var userChoice = Console.ReadLine(); Console.WriteLine("Enter your hero's name: "); var userName = Console.ReadLine(); Character player; if (userChoice == "1") { player = new Archer(userName); } else if (userChoice == "2") { player = new Warrior(userName); } else { player = new Mage(userName); } //maybe roll a dice to determine computers class var computerPick = new Dice(3); var computerClass = computerPick.GetRoll(); Character computer; if (computerClass == 1) { computer = new Archer("Legolas"); } else if (computerClass == 2) { computer = new Warrior("Gimli"); } else { computer = new Mage("Gandalf"); } do { var playerTurn = player.Attack(); var computerTurn = computer.Attack(); Console.WriteLine($"{player.GetName()} rolled a {playerTurn.AttackRoll}"); Console.WriteLine($"{computer.GetName()} rolled a {computerTurn.AttackRoll}"); var computerTakesHit = computer.Hit(playerTurn); var playerTakesHit = player.Hit(computerTurn); Console.WriteLine($"{computer.GetName()} took {computerTakesHit.DamageTaken}!"); if (computerTakesHit.DidBlock || computerTakesHit.DidDodge) { Console.WriteLine($"{computer.GetName()} dodged/blocked the attack!"); } Console.WriteLine($"{player.GetName()} took {playerTakesHit.DamageTaken}!"); if (playerTakesHit.DidBlock || playerTakesHit.DidDodge) { Console.WriteLine($"{player.GetName()} dodged/blocked the attack!"); } player.EndOfRound(); computer.EndOfRound(); }while (!player.IsDead() && !computer.IsDead()); if (player.IsDead()) { Console.WriteLine($"{player.GetName()} is dead! Computer wins!"); } else { Console.WriteLine($"{computer.GetName()} is dead! Player wins!"); } }
public Archer_RangeAttackState(Entity _entity, FiniteStateMachine _stateMachine, string _animBoolName, Transform _attackPosition, D_RangeAttackState _stateData, Archer _archer) : base(_entity, _stateMachine, _animBoolName, _attackPosition, _stateData) { archer = _archer; }
private void initializeGame() { MoveTowardsTarget movement_script_current; MeleeCombatAI melee_combat_script; Unit unit; GameObject[] preset_units_man_at_arms = GameObject.FindGameObjectsWithTag("PlayerUnit_MAA"); GameObject[] preset_units_archer = GameObject.FindGameObjectsWithTag("PlayerUnit_ARCHER"); GameObject unit_faction_leader = GameObject.FindGameObjectWithTag("PlayerUnit_FL"); foreach(GameObject elem in preset_units_man_at_arms) { unit = new ManAtArms(); unit.setGameObject(elem); ObjectBank.instance().addPlayerUnit(ref unit); unit.setCombatFocus(Unit.OFFENSIVE_FOCUS); movement_script_current = elem.GetComponent<MoveTowardsTarget>(); movement_script_current.setUnitAgility(unit.getAgility()); } foreach (GameObject elem in preset_units_archer) { unit = new Archer(); unit.setGameObject(elem); ObjectBank.instance().addPlayerUnit(ref unit); unit.setCombatFocus(Unit.OFFENSIVE_FOCUS); movement_script_current = elem.GetComponent<MoveTowardsTarget>(); movement_script_current.setUnitAgility(unit.getAgility()); } if (unit_faction_leader != null) { unit = new FactionLeader(); unit.setGameObject(unit_faction_leader); ObjectBank.instance().addPlayerUnit(ref unit); unit.setCombatFocus(Unit.OFFENSIVE_FOCUS); movement_script_current = unit_faction_leader.GetComponent<MoveTowardsTarget>(); movement_script_current.setUnitAgility(unit.getAgility()); } //Enemy units. preset_units_man_at_arms = GameObject.FindGameObjectsWithTag("EnemyUnit_MAA"); preset_units_archer = GameObject.FindGameObjectsWithTag("EnemyUnit_ARCHER"); foreach (GameObject elem in preset_units_man_at_arms) { unit = new ManAtArms(); unit.setGameObject(elem); ObjectBank.instance().addEnemyUnit(ref unit); unit.setCombatFocus(Unit.DEFENSIVE_FOCUS); melee_combat_script = elem.GetComponent<MeleeCombatAI>(); melee_combat_script.initialize(Unit.MAX_HIT_POINTS, unit.getDefaultMorale(), unit.getArmor().getDamageReductionFactor()); movement_script_current = elem.GetComponent<MoveTowardsTarget>(); movement_script_current.setUnitAgility(unit.getAgility()); } foreach (GameObject elem in preset_units_archer) { unit = new Archer(); unit.setGameObject(elem); ObjectBank.instance().addEnemyUnit(ref unit); unit.setCombatFocus(Unit.DEFENSIVE_FOCUS); movement_script_current = elem.GetComponent<MoveTowardsTarget>(); movement_script_current.setUnitAgility(unit.getAgility()); } Debug.Log("Number player units: " + ObjectBank.instance().getUnitList().Length ); Debug.Log("Number enemy units: " + ObjectBank.instance().getEnemyUnitList().Length ); }
public void MainGame() { singleton = Singleton.getInstance(); singleton.playerInteract.GetTitle("MiniRPG"); bool in_game = true; singleton.playerInteract.WriteStr("Придумай имя своей команды: "); string playerTeamName = singleton.playerInteract.GetStr(); List <string> ComputerTeamNames = new List <string>() { "Печеньки", "Доминаторы", "Хакеры", "Лисы", "RJ", "название команды которое я не придумал" }; int computerNumber = singleton.GetRandom(0, 6); string computerTeamName = ComputerTeamNames[computerNumber]; singleton.playerInteract.WriteLineStr($"Компьютер выбрал имя - {computerTeamName}"); singleton.playerInteract.WriteLineStr("Введи кол-во персонажей в команде(1-6)"); int heroes = singleton.playerInteract.GetNumber(singleton.playerInteract.GetStr(), 6, 1); List <Hero> playerHeroes = new List <Hero>(); List <Hero> computerHeroes = new List <Hero>(); List <Hero> allHeroes = new List <Hero>(); Wizard globalWizard = new Wizard(); Thief globalThief = new Thief(); PotionMaker globalPotionMaker = new PotionMaker(); Berserk globalBerserk = new Berserk(); Archer globalArcher = new Archer(); Warrior globalWarrior = new Warrior(); allHeroes.Add(globalWarrior); allHeroes.Add(globalArcher); allHeroes.Add(globalBerserk); allHeroes.Add(globalPotionMaker); allHeroes.Add(globalThief); allHeroes.Add(globalWizard); Team playerTeam = new Team(playerTeamName, playerHeroes, false); Team computerTeam = new Team(computerTeamName, computerHeroes, true); singleton.playerInteract.WriteLineStr($"Вводи номера персонажей, которых хочешь добавить в свою команду({heroes})"); for (int i = 0; i < 6; ++i) { singleton.playerInteract.WriteInt(i + 1); allHeroes[i].PrintInfo(); } GetHeroes(playerTeam, heroes, allHeroes); GetHeroes(computerTeam, heroes, allHeroes); System.Threading.Thread.Sleep(1000); singleton.playerInteract.GetTitle($"MiniRPG: {playerTeamName} vs {computerTeamName}"); Console.Clear(); while (in_game) { //данные о командах playerTeam.PrintTeamInfo(); singleton.playerInteract.WriteSkip(); computerTeam.PrintTeamInfo(); //генерация атакующих героев и целей int playerAttackerNum = GetAttackHero(playerTeam, computerTeam, heroes, false); int playerTargetNum = GetTargetHero(playerTeam, computerTeam, heroes, false); singleton.playerInteract.WriteSkip(); int computerAttackerNum = GetAttackHero(playerTeam, computerTeam, heroes, true); int computerTargetNum = GetTargetHero(playerTeam, computerTeam, heroes, true); Console.Clear(); //атака int damage = playerTeam.Attack(playerTeam.ReturnHero(playerAttackerNum - 1), computerTeam.ReturnHero(playerTargetNum - 1)); singleton.playerInteract.WriteLineStr($"{playerTeam.ReturnHero(playerAttackerNum - 1).Name} ({playerTeamName}) нанес {damage} урона {computerTeam.ReturnHero(playerTargetNum - 1).Name} ({computerTeamName})"); int computerDamage = computerTeam.Attack(computerTeam.ReturnHero(computerAttackerNum), playerTeam.ReturnHero(computerTargetNum)); singleton.playerInteract.WriteLineStr($"{computerTeam.ReturnHero(computerAttackerNum).Name} ({computerTeamName}) нанес {computerDamage} урона {playerTeam.ReturnHero(computerTargetNum).Name} ({playerTeamName})"); //проверка команд if (IsGameOver(playerTeam, computerTeam, heroes)) { in_game = false; Console.Clear(); if (!playerTeam.CheckTeamLive(playerTeam, heroes) && !computerTeam.CheckTeamLive(computerTeam, heroes)) { Console.ForegroundColor = ConsoleColor.Cyan; singleton.playerInteract.WriteLineStr("Ничья! "); } else if (playerTeam.CheckTeamLive(playerTeam, heroes)) { Console.ForegroundColor = ConsoleColor.Yellow; singleton.playerInteract.WriteLineStr("Вы победили! "); singleton.playerInteract.GetTitle("Победа!"); } else { Console.ForegroundColor = ConsoleColor.DarkRed; singleton.playerInteract.WriteLineStr("Вы проиграли..."); singleton.playerInteract.GetTitle("Поражение..."); } } } }
void Start() { // Classes called with the same name, point to the same memory place Character hero = new Character(); hero.PrintCharacterStatus(); Character heroine = new Character("Lara Croft"); heroine.PrintCharacterStatus(); // example Character hero2 = hero; hero2.PrintCharacterStatus(); // If you change one of them hero2.name = "Carlos"; // Result hero.PrintCharacterStatus(); hero2.PrintCharacterStatus(); // It does not happen the same with the Structures // Because does not point to the same memory place Weapon sword = new Weapon("Wood Sword", 5); Weapon sword2 = sword; sword2.name = "Excalibur"; sword2.damage = 1000; sword.PrintWeaponStats(); sword2.PrintWeaponStats(); Paladin Paladin1 = new Paladin("Arhur", sword); Archer Archer1 = new Archer("Legolas", new Weapon("Magic arch", 25)); Magician Magician1 = new Magician("Grandalf"); List <Character> party = new List <Character>(); party.Add(Paladin1); party.Add(Archer1); party.Add(Magician1); foreach (Character c in party) { c.PrintCharacterStatus(); } // El script de esta camara // Podemos consultar sus componentes Transform theTransform = GetComponent <Transform>(); Debug.Log(theTransform.position); Debug.Log(theTransform.rotation); GameObject myLight = GameObject.Find("Directional Light"); Transform t = myLight.GetComponent <Transform>(); Debug.Log("la lus está en:" + t.position); }