void Start() { ES = GameObject.Find("EnemySpawn").GetComponent <EnemySpawn>(); transform.LookAt(Vector3.zero); int RandomType = 0; switch (RandomType = Random.Range(0, 3)) { case 0: opponentType = OpponentType.C_Normal; tag = "E_Normal"; break; case 1: opponentType = OpponentType.C_Chocolate; tag = "E_Chocolate"; break; case 2: opponentType = OpponentType.C_Jam; tag = "E_Jam"; break; } anim = GetComponent <Animator>(); }
void Awake() { gameStop = false; _tr = transform; whenKick_State_1 = scr.bonObjMan.whenKick_State_1_Norm; enSprTr = enSpr.transform; kickSpeed = scr.pMov.kickSpeed0; if (_enType != OpponentType.Goalkeeper) { _enType = scr.buf.oppType; enSpr.sprite = scr.buf.enSpr; maxSpeed = scr.pMov.maxSpeed0 * scr.buf.enSkillSpeed / 100f; jumpForce = scr.pMov.jumpForce0 * scr.buf.enSkillJump / 100f; kickTorque = scr.pMov.kickTorque0 * scr.buf.enSkillKick / 100f; } else { enSpr.sprite = scr.buf.enSpr_1; maxSpeed = scr.pMov.maxSpeed0 * scr.buf.enSkillSpeed_1 / 100f; jumpForce = scr.pMov.jumpForce0 * scr.buf.enSkillJump_1 / 100f; kickTorque = scr.pMov.kickTorque0 * scr.buf.enSkillKick_1 / 100f; } SKJ_Upgrades(); jumpForceDef = jumpForce; JointAngleLimits2D limits = legHJ.limits; JointMotor2D motor = legHJ.motor; legHJ.limits = limits; motor.maxMotorTorque = 0; legHJ.motor = motor; }
/// <summary> /// Znajdź przeciwnika planszy na podstawie typu. /// </summary> /// <param name="opponentType">typ szukanego przeciwnika</param> /// <param name="message">wiadomośc, przekazywana w razie porażki</param> /// <returns></returns> public static OpponentDao FindBoardElementByType(OpponentType opponentType, out String message) { try { var query = from b in DataManager.DataBaseContext.Opponents where b.OpponentType == opponentType select b; if (query.Any()) { message = null; return(Mapper.Map <OpponentDao>(query.First())); } message = "Nie znaleziono szukanego przeciwnika"; return(null); } catch (Exception e) { var declaringType = MethodBase.GetCurrentMethod().DeclaringType; if (declaringType != null) { Logger.LogMessage(declaringType.Name, MethodBase.GetCurrentMethod().Name, e.StackTrace); } message = e.Message; } return(null); }
public AIBrain(ActorAI actor) { this.Actor = actor; this.goalEvaluator = new GoalEvaluator(actor); this.decisionManager = new AIDecisionManager(actor, this); LifeFleeThreshold = actor.AIHealth.MaxHealthPoints * LifeFleeThresholdFactor; lastLifePointLevel = actor.AIHealth.MaxHealthPoints; ResetActualPerception(); currentOpponentType = OpponentType.None; InjuredByDeathCircle = false; DeathCircleIsClosing = false; }
public Ship(OpponentType oppType) { if (oppType == OpponentType.FamousCaptain) { SetValues(Consts.ShipSpecs[Consts.MaxShip].Type); for (int i = 0; i < Shields.Length; i++) { AddEquipment(Consts.Shields[(int)ShieldType.Reflective]); } for (int i = 0; i < Weapons.Length; i++) { AddEquipment(Consts.Weapons[(int)WeaponType.MilitaryLaser]); } AddEquipment(Consts.Gadgets[(int)GadgetType.NavigatingSystem]); AddEquipment(Consts.Gadgets[(int)GadgetType.TargetingSystem]); Crew[0] = Game.CurrentGame.Mercenaries[(int)CrewMemberId.FamousCaptain]; } else if (oppType == OpponentType.Bottle) { SetValues(ShipType.Bottle); } else { int tries = oppType == OpponentType.Mantis ? (int)Game.CurrentGame.Difficulty + 1 : Math.Max(1, Game.CurrentGame.Commander.Worth / 150000 + (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); GenerateOpponentShip(oppType); GenerateOpponentAddCrew(); GenerateOpponentAddGadgets(tries); GenerateOpponentAddShields(tries); GenerateOpponentAddWeapons(tries); if (oppType != OpponentType.Mantis) { GenerateOpponentSetHullStrength(); } if (oppType != OpponentType.Police) { GenerateOpponentAddCargo(oppType == OpponentType.Pirate); } } }
static IPlayer GetOpponent(OpponentType opponentType) { var defaultOpponent = new AlphaBetaTreeSearchBotPlayer(6); switch (opponentType) { case OpponentType.Human: return(new HumanConsolePlayer()); case OpponentType.AlphaBeta: return(defaultOpponent); case OpponentType.NegaMaxCache: return(new NegaMaxWithCachingBotPlayer(6)); } return(defaultOpponent); }
public bool ShipTypeLikely(ShipType shipType, OpponentType oppType) { bool likely = false; int diffMod = Math.Max(0, (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); switch (oppType) { case OpponentType.Pirate: likely = (int)ActivityPirates + diffMod >= (int)Consts.ShipSpecs[(int)shipType].Pirates; break; case OpponentType.Police: likely = (int)ActivityPolice + diffMod >= (int)Consts.ShipSpecs[(int)shipType].Police; break; case OpponentType.Trader: likely = (int)ActivityTraders + diffMod >= (int)Consts.ShipSpecs[(int)shipType].Traders; break; } return likely; }
public Match Load(OpponentType opponentType) { var player = new Player(); var opponent = new Opponent(opponentType); var length = _matchConfiguration.MatchLength; var games = new Game[length]; for (var i = 0; i < length; i++) { games[i] = new Game { Result = null }; } return(new Match { Player = player, Opponent = opponent, Games = games }); }
public override void ChildDeserialize(GenericReader reader) { /*int version = */ reader.ReadEncodedInt(); EnterBridge = reader.ReadBool(); EnterGreenZone = reader.ReadBool(); EnterYellowZone = reader.ReadBool(); EnterBlueZone = reader.ReadBool(); EnterRedZone = reader.ReadBool(); EnterTreasureZone = reader.ReadBool(); KilledRonins = reader.ReadInt(); KilledSouls = reader.ReadInt(); Opponent = (OpponentType)reader.ReadInt(); SendRoninKarma = reader.ReadBool(); SendSoulsKarma = reader.ReadBool(); Choice = (ChoiceType)reader.ReadInt(); }
public void SetRandomData() { int lg = Random.value < 0.5f ? 1 : 2; int max_ind = lg == 1? scr.alPrScr.openedPlayers.Length : scr.alPrScr.openedPlayers_2.Length; int ind = Mathf.FloorToInt(((float)max_ind - 0.01f) * Random.value); SetPlayerData(ind, lg); is2Enemies = Random.value > 0.5f ? true : false; oppType = Random.value > 0.5f ? OpponentType.Bycicle : OpponentType.Classic; lg = Random.value < 0.5f ? 0 : 1; SetEnemyData(0, lg); if (is2Enemies) { lg = Random.value < 0.5f ? 0 : 1; SetEnemyData(1, lg); } }
public MoveChoice GetNextMove(OpponentType opponentType, MoveChoice?previousMove) { var values = Enum.GetValues(typeof(MoveChoice)); if (opponentType == OpponentType.Random || !previousMove.HasValue) { var random = new Random(); return((MoveChoice)values.GetValue(random.Next(values.Length))); } var rules = _rulesManager.GetRules(); var beatenRule = rules.FirstOrDefault(_ => _.BeatsMoveChoice == previousMove.Value); if (beatenRule == null) { throw new RulesException($"Rule not found where BeatsMoveChoice is {previousMove.Value}"); } return(beatenRule.MoveChoice); }
public Ship(OpponentType oppType) { if (oppType == OpponentType.FamousCaptain) { SetValues(Consts.ShipSpecs[Consts.MaxShip].Type); for (int i = 0; i < Shields.Length; i++) AddEquipment(Consts.Shields[(int)ShieldType.Reflective]); for (int i = 0; i < Weapons.Length; i++) AddEquipment(Consts.Weapons[(int)WeaponType.MilitaryLaser]); AddEquipment(Consts.Gadgets[(int)GadgetType.NavigatingSystem]); AddEquipment(Consts.Gadgets[(int)GadgetType.TargetingSystem]); Crew[0] = Game.CurrentGame.Mercenaries[(int)CrewMemberId.FamousCaptain]; } else if (oppType == OpponentType.Bottle) { SetValues(ShipType.Bottle); } else { int tries = oppType == OpponentType.Mantis ? (int)Game.CurrentGame.Difficulty + 1 : Math.Max(1, Game.CurrentGame.Commander.Worth / 150000 + (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); GenerateOpponentShip(oppType); GenerateOpponentAddCrew(); GenerateOpponentAddGadgets(tries); GenerateOpponentAddShields(tries); GenerateOpponentAddWeapons(tries); if (oppType != OpponentType.Mantis) GenerateOpponentSetHullStrength(); if (oppType != OpponentType.Police) GenerateOpponentAddCargo(oppType == OpponentType.Pirate); } }
public bool ShipTypeLikely(ShipType shipType, OpponentType oppType) { bool likely = false; int diffMod = Math.Max(0, (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); switch (oppType) { case OpponentType.Pirate: likely = (int)ActivityPirates + diffMod >= (int)Consts.ShipSpecs[(int)shipType].Pirates; break; case OpponentType.Police: likely = (int)ActivityPolice + diffMod >= (int)Consts.ShipSpecs[(int)shipType].Police; break; case OpponentType.Trader: likely = (int)ActivityTraders + diffMod >= (int)Consts.ShipSpecs[(int)shipType].Traders; break; } return(likely); }
private static void Play(OpponentType opponentType) { using (var scope = Container.BeginLifetimeScope()) { var matchManager = scope.Resolve <IMatchManager>(); _match = matchManager.Load(opponentType); for (var i = 0; i < _match.Games.Length; i++) { TakeTurn(matchManager, i); var matchResult = matchManager.IsGameOver(_match); if (matchResult == null) { continue; } Printer.PrintMatchResult(matchResult); break; } } Printer.PrintContinue(); }
private int EnemyIndex(int _num, int _lg) { OpponentType oppType_0 = OpponentType.Bycicle; Names.PlayerName oppName = Names.PlayerName.Aguero; Names.PlayerName_2 oppName_2 = Names.PlayerName_2.Baggio; switch (_careerGame.oppsNumAndAge) { case OpponentsNumAndAge.Main: oppType_0 = _careerGame.oppsMain[_num].oppType; oppName = _careerGame.oppsMain[_num].oppName; break; case OpponentsNumAndAge.Legend: oppType_0 = _careerGame.oppsLegend[_num].oppType; oppName_2 = _careerGame.oppsLegend[_num].oppName_2; break; case OpponentsNumAndAge.Main_Main: oppType_0 = _careerGame.oppsMain[_num].oppType; oppName = _careerGame.oppsMain[_num].oppName; break; case OpponentsNumAndAge.Legend_Legend: oppType_0 = _careerGame.oppsLegend[_num].oppType; oppName_2 = _careerGame.oppsLegend[_num].oppName_2; break; case OpponentsNumAndAge.Main_Legend: if (_num == 0) { oppType_0 = _careerGame.oppsMain[0].oppType; oppName = _careerGame.oppsMain[0].oppName; } else if (_num == 1) { oppType_0 = _careerGame.oppsLegend[0].oppType; oppName_2 = _careerGame.oppsLegend[0].oppName_2; } break; case OpponentsNumAndAge.Legend_Main: if (_num == 0) { oppType_0 = _careerGame.oppsLegend[0].oppType; oppName_2 = _careerGame.oppsLegend[0].oppName_2; } else if (_num == 1) { oppType_0 = _careerGame.oppsMain[0].oppType; oppName = _careerGame.oppsMain[0].oppName; } break; } switch (_num) { case 0: oppType = oppType_0; break; case 1: oppType_1 = oppType_0; break; } int _index = 0; if (_lg == 0) { for (int i = 0; i < scr.prMng.itemList.Count; i++) { if (oppName == scr.prMng.itemList[i].player) { _index = i; break; } } } else if (_lg == 1) { for (int i = 0; i < scr.prMng.itemList_2.Count; i++) { if (oppName_2 == scr.prMng.itemList_2[i].player) { _index = i; break; } } } return(_index); }
public override void ChildDeserialize( GenericReader reader ) { /*int version = */ reader.ReadEncodedInt(); EnterBridge = reader.ReadBool(); EnterGreenZone = reader.ReadBool(); EnterYellowZone = reader.ReadBool(); EnterBlueZone = reader.ReadBool(); EnterRedZone = reader.ReadBool(); EnterTreasureZone = reader.ReadBool(); KilledRonins = reader.ReadInt(); KilledSouls = reader.ReadInt(); Opponent = (OpponentType) reader.ReadInt(); SendRoninKarma = reader.ReadBool(); SendSoulsKarma = reader.ReadBool(); Choice = (ChoiceType) reader.ReadInt(); }
public Opponent(OpponentType opponentType) { OpponentType = opponentType; }
private void GenerateOpponent(OpponentType oppType) { Opponent = new Ship(oppType); }
public void CreatesMatch_WithCorrectOpponentType(OpponentType opponentType) { var match = _matchManager.Load(opponentType); match.Opponent.OpponentType.Should().Be(opponentType); }
private void GenerateOpponentShip(OpponentType oppType) { Commander cmdr = Game.CurrentGame.Commander; PoliticalSystem polSys = Game.CurrentGame.WarpSystem.PoliticalSystem; if (oppType == OpponentType.Mantis) { SetValues(ShipType.Mantis); } else { ShipType oppShipType; int tries = 1; switch (oppType) { case OpponentType.Pirate: // Pirates become better when you get richer tries = 1 + cmdr.Worth / 100000; tries = Math.Max(1, tries + (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); break; case OpponentType.Police: // The police will try to hunt you down with better ships if you are // a villain, and they will try even harder when you are considered to // be a psychopath (or are transporting Jonathan Wild) if (cmdr.PoliceRecordScore < Consts.PoliceRecordScorePsychopath || cmdr.Ship.WildOnBoard) { tries = 5; } else if (cmdr.PoliceRecordScore < Consts.PoliceRecordScoreVillain) { tries = 3; } else { tries = 1; } tries = Math.Max(1, tries + (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); break; } if (oppType == OpponentType.Trader) { oppShipType = ShipType.Flea; } else { oppShipType = ShipType.Gnat; } int total = 0; for (int i = 0; i < Consts.MaxShip; i++) { ShipSpec spec = Consts.ShipSpecs[i]; if (polSys.ShipTypeLikely(spec.Type, oppType)) { total += spec.Occurrence; } } for (int i = 0; i < tries; i++) { int x = Functions.GetRandom(total); int sum = -1; int j = -1; do { j++; if (polSys.ShipTypeLikely(Consts.ShipSpecs[j].Type, oppType)) { if (sum > 0) { sum += Consts.ShipSpecs[j].Occurrence; } else { sum = Consts.ShipSpecs[j].Occurrence; } } } while (sum < x && j < Consts.MaxShip); if (j > (int)oppShipType) { oppShipType = Consts.ShipSpecs[j].Type; } } SetValues(oppShipType); } }
private void GenerateOpponentShip(OpponentType oppType) { Commander cmdr = Game.CurrentGame.Commander; PoliticalSystem polSys = Game.CurrentGame.WarpSystem.PoliticalSystem; if (oppType == OpponentType.Mantis) SetValues(ShipType.Mantis); else { ShipType oppShipType; int tries = 1; switch (oppType) { case OpponentType.Pirate: // Pirates become better when you get richer tries = 1 + cmdr.Worth / 100000; tries = Math.Max(1, tries + (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); break; case OpponentType.Police: // The police will try to hunt you down with better ships if you are // a villain, and they will try even harder when you are considered to // be a psychopath (or are transporting Jonathan Wild) if (cmdr.PoliceRecordScore < Consts.PoliceRecordScorePsychopath || cmdr.Ship.WildOnBoard) tries = 5; else if (cmdr.PoliceRecordScore < Consts.PoliceRecordScoreVillain) tries = 3; else tries = 1; tries = Math.Max(1, tries + (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); break; } oppShipType = oppType == OpponentType.Trader ? ShipType.Flea : ShipType.Gnat; int total = 0; for (int i = 0; i < Consts.MaxShip; i++) { ShipSpec spec = Consts.ShipSpecs[i]; if (polSys.ShipTypeLikely(spec.Type, oppType)) total += spec.Occurrence; } for (int i = 0; i < tries; i++) { int x = Functions.GetRandom(total); int sum = -1; int j = -1; do { j++; if (polSys.ShipTypeLikely(Consts.ShipSpecs[j].Type, oppType)) { if (sum > 0) sum += Consts.ShipSpecs[j].Occurrence; else sum = Consts.ShipSpecs[j].Occurrence; } } while (sum < x && j < Consts.MaxShip); if (j > (int)oppShipType) oppShipType = Consts.ShipSpecs[j].Type; } SetValues(oppShipType); } }