static void Main(string[] args) { // ei go na pochva Battlefield game = new Battlefield(); game.Start(); // i do tuka ne stigam }
public Battlefield() { _instance = this; //InitBattleField(new MapObject(){ w = 3, h = 3 }); su = new Submarine(); sh = new Ship(); }
public Ship(int field_w, int field_h) { InitShip(field_w, field_h); bf = Battlefield.Instance; su = Submarine.Instance; _instance = this; }
public Explosion(Battlefield bf, int x, int y) { X = x; Y = y; T = 0; _battlefield = bf; _dead = false; }
public Ship() { //InitShip(_possiblePositions); bf = Battlefield.Instance; su = Submarine.Instance; history = new List<List<Point>> (); _instance = this; }
void Start() { Debug.Log ("!!! MULTIPLAYER INITIATED !!!"); _instance = this; bf = BattlefieldScript.Instance; bfc = bf.bf; su = Submarine.Instance; sh = Ship.Instance; la = LanguageScript.Instance; mo = move.Instance; reward = new Reward (false, 5); }
// Use this for initialization void Start () { _instance = this; bf = new Battlefield(); bf = Battlefield.Instance; su = Submarine.Instance; sh = Ship.Instance; InitField(); transform.FindChild("autoMove_btn").GetComponent<Button>().onClick.AddListener(DoAutoMove); transform.FindChild("shMove_btn").GetComponent<Button>().onClick.AddListener(DoShipMove); transform.FindChild("suMove_btn").GetComponent<Button>().onClick.AddListener(DoSubmarineMove); }
// Use this for initialization void Start() { map = new Battlefield(10, 10); GameObject terr = Resources.Load("Prefabs/DefaultTerrainPrefab") as GameObject; float xOffset = 0.5f; float yOffset = 0.0f; float zOffset = 0.5f; for(int i = 0; i < map.battleTerrainSize.length; ++i){ for(int j = 0; j < map.battleTerrainSize.width; ++j){ yOffset = geo.SampleHeight(new Vector3(i + xOffset, 0.1f, j + zOffset)); Debug.Log(yOffset); GameObject clone = Instantiate(terr, new Vector3(i + xOffset, 0.1f + yOffset, j + zOffset), Quaternion.identity) as GameObject; clone.name = "Cell_" + i.ToString() + "_" + j.ToString(); deformCell(clone); } } }
public void Setup() { _battlefield=new Battlefield(null); }
public void CalcStats(Battlefield bf, CardGO cardGO, bool apply = true) { if (!apply) { Strength = GetBaseStrength(); ClearBonds(); Morale = 0; Horn = false; cardGO.GetComponent <CardGO>().UpdateStrengthText(); } else if (!Hero) { //1. apply Weather effects if (bf.Weather) { Strength = 1; } else { Strength = GetBaseStrength(); } //2. apply Bond effects if (Ability == Abilities.Bond) { ClearBonds(); int index = bf.Cards.IndexOf(cardGO); int tempindex = -1; while (index + tempindex >= 0 && bf.Cards[index + tempindex].GetComponent <CardGO>().Card.Name == cardGO.Card.Name) { AddBond(); tempindex--; } tempindex = 1; while (index + tempindex <= bf.Cards.Count - 1 && bf.Cards[index + tempindex].GetComponent <CardGO>().Card.Name == cardGO.Card.Name) { AddBond(); tempindex++; } for (int i = 0; i < Bond; i++) { Strength += GetBaseStrength(); } } //3. apply Morale effects if (bf.Morale > 0 && Ability != Abilities.Morale) { Morale = bf.Morale; Strength += Morale; } else if (bf.Morale > 1 && Ability == Abilities.Morale) { Morale = bf.Morale; Strength += Morale - 1; } //4.1 apply Horn effect from Horn unit cards Horn = false; if (bf.ZoneHorn.HasHorn) { HornZone hz = bf.ZoneHorn; if (hz.SpecialHorn != null) { Strength += Strength; Horn = true; } //check to see this card is not doubling itself else if ((Ability == Abilities.Horn && hz.UnitHorns.Count > 1) || (Ability != Abilities.Horn && hz.UnitHorns.Count > 0)) { Strength += Strength; Horn = true; } } //update Strength text cardGO.GetComponent <CardGO>().UpdateStrengthText(); } }
public override HashSet <Coord> getTotalAttackZone(int myX, int myY, Battlefield battlefield, Character character) { return(new HashSet <Coord>(getAttackZone(myX, myY, battlefield, character))); }
public void HitWater(Player player, Player computer, Position iShootPosition, Battlefield battlefield, IPositionParser positionParser) { // Display Graphic GraphicManager.DisplayBattleView(player, computer, battlefield); //Sound Effects SoundEffects.HitWaterSoundPlayer(); //information Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine(" \" Shoot [ {0} ]\" ", positionParser.BackParser(iShootPosition)); Console.WriteLine(); Console.Write(" LOST "); //Thread.Sleep(500); //Console.Write("..."); //Thread.Sleep(1000); Console.ReadKey(); }
public override void OnPointerClick(PointerEventData eventData) { base.OnPointerClick(eventData); if (eventData.button == PointerEventData.InputButton.Left) { if (Highlighted) { //If no card is selected, select this one if (selectedCard == null) { Select(this); } //If this card is already selected, deselect it then unhighlight all selected zones else if (IsSelectedCard) { if (specialHighlight.Count != 0) { UnHighlightAllSpecial(); } Select(null); } //If another card (in the player's hand) is already selected, //deselect that one and select this one else { if (specialHighlight.Count != 0) { UnHighlightAllSpecial(); } Deselect(SelectedCard); Select(this); } if (IsSelectedCard) //card is being selected { Card c = cardGO.Card; //print(GetComponent<CardGO>().InZone); //highlight zones depending on who's turn it is //if it's a spy, reverse //TODO //add enum for P1, P2, and Both (for scorch special cards) bool highlightPlayerOne; if (!c.Special) { if (((UnitCard)c).Ability == Card.Abilities.Spy) { highlightPlayerOne = (Manager.manager.PlayerOnesTurn) ? false : true; } else { highlightPlayerOne = (Manager.manager.PlayerOnesTurn) ? true : false; } } else { highlightPlayerOne = (Manager.manager.PlayerOnesTurn) ? true : false; } //Highlight relevant Zone(s) for Card c Manager.manager.HighlightNewZone(cardGO.Card, highlightPlayerOne); //UnHighlight(this); } else //card is being deselected { Highlight(this); } } else if (SpecialHighlighted) { if (SelectedCard.cardGO.Card.Ability == Card.Abilities.Decoy) { print("DECOY: " + gameObject.name); //play the decoy card in this card's slot, and return this card to hand //print(cardGO.Zone.Cards.IndexOf(cardGO) + ", " + cardGO.Zone.Cards.Count); int index = cardGO.Zone.Cards.IndexOf(cardGO); SelectedCard.cardGO.MoveTo(cardGO.Zone, index); SelectedCard.transform.SetSiblingIndex(index); Battlefield old = (Battlefield)cardGO.Zone; cardGO.ApplyEffects(old, false); ((UnitCard)cardGO.Card).CalcStats(old, cardGO, false); cardGO.MoveTo(Manager.manager.GetZone(Zone.Types.Hand)); StartCoroutine(old.RecalcStatsAtEndOfFrame()); //reset card effects UnHighlightAllSpecial(); Deselect(this); } } } else if (eventData.button == PointerEventData.InputButton.Right) { //display big version of card. //set examiningCard = true; //lock out highlighting/selecting cards } }
public SniperRifle([NotNull] Battlefield battlefield, Point position) : base(battlefield, position, "Sniper Rifle") { }
//Added for use by AI public abstract List <Coord> getAttackZone(int myX, int myY, Battlefield battlefield, Character character);
public BeginTurn(Battlefield battlefield, Deck deck, Hand hand) { this.battlefield = battlefield; this.deck = deck; this.hand = hand; }
private void Card_CardDestroyed(object sender, EventArgs e) { Battlefield.Remove(((CardEventArgs)e).Card, TargetZone.Graveyard); }
private static void GenerateVesselsOnBattlefield(Battlefield battlefield) { var field = battlefield.Field; Random rndm = new Random(); //LOOP THROUGH PLACING THE 10 VESSELS (1 TANKER => 2 SUBMARINES => 3 CARRIERS => 4 BOATS) for (int vesselCount = 1; vesselCount <= 10; vesselCount++) { string vessel = string.Empty; // GET THE TYPE OF VESSEL BASED ON VESSELCOUNT switch (vesselCount) { case 1: vessel = BattlefieldElements.slotTanker; break; case 2: case 3: vessel = BattlefieldElements.slotSubmarine; break; case 4: case 5: case 6: vessel = BattlefieldElements.slotCarrier; break; case 7: case 8: case 9: case 10: vessel = BattlefieldElements.slotBoat; break; } // PLACE TANKER / SUBMARINE / CARRIER if (vesselCount >= 1 && vesselCount <= 6) { while (true) { int rowRandom = rndm.Next(0, 10); int colRandom = rndm.Next(0, 10); int horizontalOrVertical = rndm.Next(0, 2); // IS IT IN CORNER? if (BattlefieldValidator.CheckIfSlotIsInCorner(rowRandom, colRandom)) { continue; } // IS IT ON EDGE? else if (BattlefieldValidator.CheckIfSlotIsOnEdge(rowRandom, colRandom)) { if (CheckIfPlacingVesselOnEdgeIsPossible(field, rowRandom, colRandom, vessel)) { PlaceVesselOnEdge(field, rowRandom, colRandom, vessel); break; } } // IS IT IN THE MIDDLE? else { // HORIZONTAL if (horizontalOrVertical == 0) { if (CheckIfPlacingVesselInTheMiddleIsPossible(field, rowRandom, colRandom, horizontalOrVertical, vessel)) { PlaceVesselInTheMiddle(field, rowRandom, colRandom, horizontalOrVertical, vessel); break; } } // VERTICAL else { if (CheckIfPlacingVesselInTheMiddleIsPossible(field, rowRandom, colRandom, horizontalOrVertical, vessel)) { PlaceVesselInTheMiddle(field, rowRandom, colRandom, horizontalOrVertical, vessel); break; } } } } } // PLACE BOAT else { while (true) { int rowRandom = rndm.Next(0, 10); int colRandom = rndm.Next(0, 10); if (CheckIfAllSlotsAroundAreEmptyOrOccuppied(field, rowRandom, colRandom)) { PlaceBoat(field, rowRandom, colRandom); break; } } } } }
static void Main(string[] args) { var battlefield = new Battlefield(); List <MonsterController> allMonsterControllers = new List <MonsterController>(); bool runAway = false; Console.WriteLine("========= Thorn and Bramble Battlefield View - ver 0.0.1a =========\n\n"); Console.WriteLine("What is your player's name?"); string playerName = Console.ReadLine(); var player = new PlayerController(playerName); battlefield.SpawnPlayer(ref player); Console.WriteLine("Welcome " + playerName + " to Thorn And Bramble Battle: 0.0.1a. How many monsters do you want to fight against? (1-5)"); int numberOfMonsters = int.Parse(Console.ReadLine()); Console.Write("Spawning Monsters ..."); for (int i = 0; i < numberOfMonsters; i++) { Console.Write("."); string monsterName = "Monster " + (i + 1); var monster = new MonsterController(); monster.Name = monsterName; allMonsterControllers.Add(monster); battlefield.SpawnMonster(ref monster); } Console.WriteLine(numberOfMonsters + " spawned! Battle Begins in 3 ... 2 ... 1... Battle Start!"); battlefield.NewRound(); while (battlefield.MonsterCount > 0 && battlefield.PlayerCount > 0 || !runAway) { var actor = battlefield.NextToAct(); string actingName = actor.Name; Console.WriteLine("\r\nCurrent Initiative Is: " + battlefield.CurrentInitiative + " and " + actingName + " is up!"); if (battlefield.NextToAct().GetType() == typeof(MonsterController)) { double chanceToHit = battlefield.CalculateAttackChance(actor.Name, "Strike", player.Name) * 100; double damage = battlefield.CalculateTotalDamage(actor.Name, "Strike"); Console.WriteLine("\r\n" + actingName + " attacks with Strike! There is a " + chanceToHit + "% chance it will hit and do " + damage + " points of damage!"); if (battlefield.Attack(actor.Name, "Strike", player.Name)) { Console.WriteLine("\r\nThe attack succeded! You now have " + player.Stat("HealthCurrent") + " health left"); } else { Console.WriteLine("\r\nThe Monster Missed! whew!"); } battlefield.AdvanceTurn(); } else { Console.WriteLine("\r\nIt's your turn! What would you like to do?\r\n1. Attack \r\n2. Run away! "); int choice = int.Parse(Console.ReadLine()); if (choice == 1) { Console.WriteLine("\r\nWhich Monster?"); int i = 1; foreach (var monster in allMonsterControllers) { Console.WriteLine(i + ". " + monster.Name); i++; } int monsterChoice = int.Parse(Console.ReadLine()); var attackedMonster = allMonsterControllers[monsterChoice - 1]; double chanceToHit = battlefield.CalculateAttackChance(actor.Name, "Strike", attackedMonster.Name) * 100; double damage = battlefield.CalculateTotalDamage(actor.Name, "Strike"); Console.WriteLine("\r\n" + actingName + " attacks with Strike! There is a " + chanceToHit + "% chance it will hit and do " + damage + " points of damage!"); if (battlefield.Attack(actor.Name, "Strike", attackedMonster.Name)) { Console.WriteLine("\r\nThe attack succeded! " + attackedMonster.Name + " has " + attackedMonster.Stat("HealthCurrent") + " health left!"); if (attackedMonster.Stat("HealthCurrent") == 0) { Console.WriteLine("\r\nYou killed " + attackedMonster.Name + "!"); allMonsterControllers.Remove(attackedMonster); } } else { Console.WriteLine("\r\nAww! You missed!"); } } else { Console.WriteLine("\r\nRun away!"); runAway = true; break; } battlefield.AdvanceTurn(); } } if (battlefield.PlayerCount == 0) { Console.WriteLine("\r\nSo ends the journey of " + playerName); } else if (battlefield.MonsterCount == 0) { Console.WriteLine("\r\nHurray! You have defeated all the monsters! Well fought!"); } else { Console.WriteLine("You got away safely... the shivers are in your blood now..."); } }
protected Movable([NotNull] Battlefield battlefield) { Battlefield = battlefield ?? throw new ArgumentNullException(nameof(battlefield)); }
public override void SpecialSkill(Unit targetUnitStack = null, Battlefield bf = null) { SkillName = "Double Shoot"; OffensivePoints *= 2; TimeoutToRefreshSkill = 3; }
private void PickUpFirstAidKit(FirstAidKit firstAidKit) { Regeneration.Regenerate(firstAidKit.RegenerationAmount); Battlefield.Remove(firstAidKit); }
public void Move(Battlefield bf) { }
/// <inheritdoc /> public override GameTypeCommand GetGameTypeCommand(Battlefield battlefield) { return(new GameTypeCommand(battlefield.ROBOTS_IN_TEAM, GameType.DEADMATCH)); }
public abstract HashSet <Coord> getTotalAttackZone(int myX, int myY, Battlefield battlefield, Character character);
public Grenade([NotNull] Battlefield battlefield, Point position) : base(battlefield, position, "Grenade") { }
/// <inheritdoc /> /// <summary> /// GameType is flagCapture. /// </summary> public override GameTypeCommand GetGameTypeCommand(Battlefield battlefield) { return(new GameTypeCommand(battlefield.ROBOTS_IN_TEAM, GameType.CAPTURE_FLAG)); }
// Use this for initialization void Start() { myBattlefield = GetComponentInParent <Battlefield>(); myTarget = new TargetInfo(); }
public void HitShip(Player player, Player computer, Position shootPosition, List <Ship> enermyShips, Battlefield battlefield) { Ship hittedShip = HittedShip(shootPosition, enermyShips); // Display Graphic GraphicManager.DisplayBattleView(player, computer, battlefield); // remove Hit Position RemoveHitPosition(shootPosition, enermyShips); //isSunk or isHit SunkenHitInfo(hittedShip); }
public Pistol([NotNull] Battlefield battlefield, Point position) : base(battlefield, position, "Pistol") { }
public override void PerformSpecialAction() { // TODO: implement special action logic Battlefield.DisplayMessage($"{FullyQualifiedName} just used his special action!"); }
// Update is called once per frame void Update() { if (HexGM.isBattleRound()) { /* * Check whether to display health bars */ if (unit != null && !barsActive) { activateBars(true); } if (barsActive && unit == null) { activateBars(false); } else if (barsActive && unit != null) { setHealthColor(unit.isAlly); healthBar.value = (float)unit.currentHealth / unit.health; manaBar.value = (float)unit.currentMana / unit.mana; } /* * Combat logic here */ if (unit != null && unit.readyToAttack()) { // figure out which tile to attack List <BaseTileHandler> bthl = battlefield.getClosestEnemy(coordinate, unit.isAlly); if (bthl != null) { BaseTileHandler bth = bthl[0]; int distance = Battlefield.getDistance(this.coordinate, bth.getCoordinate()); if (!(distance <= unit.range)) { // it's out of range, move instead, we already got the shortest path so try to move along the path // the first unit is the target, so we want to start with the furthest possible range from the target for (int i = unit.range; i > 0; i--) { if (bthl[i].getCurrentUnit() == null) { if (bthl[i].setUnit(this.unit)) { this.resetDefault(); return; } } } for (int i = unit.range; i < bthl.Count; i++) { if (bthl[i].getCurrentUnit() == null) { if (bthl[i].setUnit(this.unit)) { this.resetDefault(); return; } } } } else { // Create the bullet, it'll be responsible for it's own destruction var newBullet = Instantiate(AllyBullet, this.transform.position, Quaternion.identity); newBullet.transform.SetParent(this.transform.parent.parent); if (!unit.isAlly) { newBullet.GetComponent <Image>().color = Color.red; } BulletHandler b = newBullet.gameObject.GetComponent <BulletHandler>(); b.setDestination(this.transform.position, bth, unit); } } } } else if (barsActive) { activateBars(false); } }
public static void StartBattle(CombatPlanetEvent @event) { Battlefield = new Battlefield(PlayerController.Ship, @event.EnemyShipData.GetEnemyShip(new Vector2(100))); Battlefield.StartTurn(); }
public Bot([NotNull] Battlefield battlefield, BotAI botAI) : base(battlefield) { Regeneration = new Regeneration(this); Init(battlefield, botAI); }
public LocationService(Battlefield field) { _field = field; }
public void defeated(Battlefield battlefield) { Destroy(this.gameObject); battlefield.charactersUnits[this.getCharacter(battlefield)].Remove(this); }
public void Setup() { _battlefield = new Battlefield(60, 60, 1000, 60); }
//returns true if the enemy was destroyed by battle public abstract Task <bool> doBattleWith(Unit enemy, Tile enemyTile, Battlefield battlefield);
public void SetUp() { _battlefield = new Battlefield(800,800,1000,60); }
public List <Card> returnTargetList(Gamestate gs, Player performingPlayer, ICondition cond, Battlefield currentBattlefield) { List <Card> returnList = new List <Card>(); if (currentBattlefield == null) { foreach (Personality per in performingPlayer.opposingPlayer.cardsInPlay) { foreach (Attachment att in per.attachedCards) { if (cond.doesCardMeetCondition(att)) { returnList.Add(att); } } } } else { foreach (Personality per in currentBattlefield.opposingCards(performingPlayer)) { foreach (Attachment att in per.attachedCards) { if (cond.doesCardMeetCondition(att)) { returnList.Add(att); } } } } return(returnList); }
public override void SpecialSkill(Unit targetUnitStack = null, Battlefield bf = null) { SkillName = "Marshes"; this.stackSpeed *= 2; TimeoutToRefreshSkill = 3; }
public Battlefield() { _instance = this; InitBattleField(); }