public void AddMember(IAI ai) { Debug.Assert(!m_members.Contains(ai)); m_members.Add(ai); ai.Worker.Destructed += OnDestructed; }
private void btnNewGame_Click(object sender, EventArgs e) { using (var newGameForm = new NewGame()) { newGameForm.Player1AI = _newGamePlayer1AIStatus; newGameForm.Player2AI = _newGamePlayer2AIStatus; if (newGameForm.ShowDialog() == DialogResult.OK) { _newGamePlayer1AIStatus = newGameForm.Player1AI; _newGamePlayer2AIStatus = newGameForm.Player2AI; Player player1 = new Player("Player 1", Player.Player1TokenColour, Player.Player1HighlightColour, newGameForm.Player1AI); Player player2 = new Player("Player 2", Player.Player2TokenColour, Player.Player2HighlightColour, newGameForm.Player2AI); _gameController = new GameController(this, dropBoard, player1, player2); dropBoard.InitializeGameState(_gameController); } } }
public void SetTankAI(IAI tankAI) { if (tankAI == null) { throw new NullReferenceException("tankAI is null!"); } this.tankAI = tankAI; }
public MainWindow() { InitializeComponent(); this.game = new Game(); this.DataContext = game; AI = new AIMinMax(); InitBoardUI(); }
public PlayerController(IPlayerReposytory playerRepository, IGameBoard board, IAI aimimax) { _playerRepository = playerRepository ?? throw new ArgumentNullException(nameof(playerRepository)); _board = board ?? throw new ArgumentNullException(nameof(board)); _aimimax = aimimax ?? throw new ArgumentNullException(nameof(aimimax)); _playerX = _playerRepository.LoadDefaultPlayerList()[0]; _playerO = _playerRepository.LoadDefaultPlayerList()[1]; }
public void StartBehavior(IAI self, CombatState target) { _target = target; _self = self; _combat = _self.Combat; _lastKnownPostion = _target.transform.position; _self.SetAtomicAction(ActionType.AIRotate, _self, _target.transform.position, GameManager.FixedGameTime); }
public EnemyState(IAI AI, Enemy enemy) : base(enemy) { isClimbing = false; ai = AI; health = Stat.Health(400); speed = Stat.Speed(85); damage = Stat.Damage(50); }
public Tester(string name, IAI ai) { this.name = name; this.ai = ai; scores = new List <int>(); rankings = new List <int>(); players = new List <IPlayer>(); }
private void InitialAI(IAI tankAI) { commonServer = new AICommonServer(mapSize); tank.SetTankAI(tankAI); tankAI.OrderServer = tank; tankAI.CommonServer = commonServer; GameManager.ObjMemoryMgr.AddSingle(tank); }
public void stuff2(IAI other) { int x = 7; other.val = x; val = x; x = other.val; x = val; val = other.val; }
public Enemy(Spritemap spritemap, IAI ai, float x, float y) : base(x, y) { this.spritemap = spritemap; this.ai = ai; this.AddComponent <Image>(this.spritemap); this.touchDamage = 15; }
/// <summary> /// Provides the extra text for the <see cref="AdvancedPropertyDescriptor"/> for a /// <see cref="IAI"/>. /// </summary> /// <param name="v">The value.</param> /// <returns>The extra text to display.</returns> static string ExtraTextProvider_IAI(IAI v) { if (v == null) { return(null); } return(AIFactory.Instance.GetAIName(v.ID)); }
public IAI GetAIInterfacObject() { IAI result = null; if (this.loaded) { result = this.loadedObject as IAI; } return(result); }
public AIPlayer(IAI AI, Level level, Point location, int score = 0) : base(level, location, score) { this.AI = AI; AI.GameStart(this, 3); startNextActionThreadAsync(); OnPlayerAction += delegate(PlayerGameObject obj) { startNextActionThreadAsync(); }; }
public static void SimulateAction(IAI _ai, Vector3 _target, float _startTime) { Vector3 _tempTarget = new Vector3(_target.x, _ai.transform.position.y, _target.z); Vector3 _up = _ai.transform.up; Vector3 _dir = _tempTarget - _ai.transform.position; float _angle = Util.AngleBetweenVector3(_ai.transform.forward, _dir, _up); _ai.SetAction(new ValueTargetAction(ActionType.AIRotate, _angle, _target, _startTime)); float _endTime = Math.Abs(_angle) / _ai.RotationSpeed + _startTime; _ai.SetAction(new ValueTargetAction(ActionType.AIRotateUnset, _angle, _target, _endTime)); }
public Enemy(Vector2 position, string enemyState) { Position = position; FuturePosition = position; // make the unit not move when spawned. Velocity = new Vector2(1f, 1f); EnemyAI = new AI(this, "Enemy"); if (enemyState == "Bandit") { EnemyState = new Bandit(this); } }
public void SetAtomicAction(ActionType _type, IAI _ai, Vector3 _target, float _time) { _history.SpliceOffPossibleFuture(); if (_currentAction != null) { SetAction(_currentAction.Unset()); } switch (_type) { case ActionType.AIRotate: AARotate.SimulateAction(_ai, _target, _time); break; } }
private void AIInitial(IAI tankAI1, IAI tankAI2) { commonServer = new AICommonServer(mapRect); tankAI1.CommonServer = commonServer; tankAI1.OrderServer = tank1; tank1.SetTankAI(tankAI1); tankAI2.CommonServer = commonServer; tankAI2.OrderServer = tank2; tank2.SetTankAI(tankAI2); //GameManager.ObjMemoryMgr.AddSingle( tank1 ); //GameManager.ObjMemoryMgr.AddSingle( tank2 ); }
/// <summary> /// Attempts to set the Character's AI. /// </summary> /// <param name="aiName">The name of the new AI to use.</param> /// <returns> /// True if the AI was successfully set; otherwise false. /// </returns> public override bool SetAI(string aiName) { var newAI = _aiFactory.Create(aiName, this); if (newAI == null) { _ai = null; return(false); } Debug.Assert(newAI.Actor == this); _ai = newAI; return(true); }
private void UpdatePlayerComboValues(IAI playerAI, ComboBox playerCombo, ComboBox aiDifficultyCombo) { _updateingPlayerAI = true; if (playerAI == null) { playerCombo.Text = PlayerOptions.Human.ToString(); aiDifficultyCombo.Visible = false; } else { playerCombo.Text = PlayerOptions.AI.ToString(); aiDifficultyCombo.Text = playerAI.Difficulty.ToString(); aiDifficultyCombo.Visible = true; } _updateingPlayerAI = false; }
private void InitialDrawMgr(IAI tankAI1, IAI tankAI2) { if (tankAI1 is ManualControl) { DrawMgr.SetCondition( delegate(IDrawableObj obj) { if (tank1.IsDead) { return(true); } if (tank1.Rader.PointInRader(obj.Pos) || obj == tank1 || ((obj is ShellNormal) && ((ShellNormal)obj).Firer == tank1)) { return(true); } else { return(false); } }); } if (tankAI2 is ManualControl) { DrawMgr.SetCondition( delegate(IDrawableObj obj) { if (tank2.IsDead) { return(true); } if (tank2.Rader.PointInRader(obj.Pos) || obj == tank2 || ((obj is ShellNormal) && ((ShellNormal)obj).Firer == tank2)) { return(true); } else { return(false); } }); } }
private void PlayerOrAIOptionChanged(ref IAI playerAI, ComboBox playerCombo, ComboBox aiDifficultyCombo) { if (_updateingPlayerAI) { return; } if (playerCombo.Text == PlayerOptions.Human.ToString()) { playerAI = null; aiDifficultyCombo.Visible = false; } else if (playerCombo.Text == PlayerOptions.AI.ToString()) { AI.AIDifficulty diff = FourRow.AI.AIDifficulty.Medium; if (!string.IsNullOrEmpty(aiDifficultyCombo.Text)) { diff = (AI.AIDifficulty)Enum.Parse(typeof(AI.AIDifficulty), aiDifficultyCombo.Text); } playerAI = new AI.AIBase(diff); cmbPlayer2AIDifficulty.Visible = true; } }
public BoardPanel() : base() { //this.DoubleBuffered = true; this.ResizeRedraw = true; this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.Opaque | ControlStyles.AllPaintingInWmPaint, true); //Initialize board for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { Board[i, j] = new Square(); Board[i, j].Colour = CheckerColour.Empty; } } //Setup Pieces for (int i = 0; i < 8; i += 1) { int offset = 0; if (i % 2 != 0) { offset++; } for (int j = offset; j < 8; j += 2) { if (i < 3) { Board[i, j].Colour = CheckerColour.Red; } if (i > 4) { Board[i, j].Colour = CheckerColour.Black; } } } AI = new AI_Tree(); AI.Colour = CheckerColour.Black; AdvanceTurn(); }
static async Task Main(string[] args) { // in a .net program, paths will be relative to the location of the application dll (probably down in bin/Debug/(etc)). string filePath = "../../../data.json"; // should be next to this file. var persistence = new JsonFilePersistence(filePath); Console.WriteLine("Let's Play Rock Paper Scissors!"); // Creates new instances of game and score var playerGame = new RPSgame(); Task <Score> playerScoreTask = persistence.ReadAsync(); List <IAI> ais = GetAllAIs(); var random = new Random(); // Sets initial last user choice to null so AI knows not to consider string lastPlay = null; //Gather's user's initial choiuce Console.WriteLine("Choose rock (r), paper (p), or scissors(s). Enter x to quit."); string playerChoice = Console.ReadLine(); var playerScore = await playerScoreTask; playerScore.WinHappened += () => { Console.WriteLine("(win via event)"); }; // Loops through game until player chooses to quit. while (playerChoice != "x") { // randomly choose an AI to respond with IAI whichAi = ais[random.Next(ais.Count)]; // Sends info to AI to choose play string comChoice = whichAi.ChooseRPS(lastPlay); // Sends player and AI choice to RPSgame to resolve win/loss playerGame.Play(playerChoice, comChoice, playerScore); // Updates last play for AI decision making lastPlay = playerChoice; // Prompts for more input/exiting game Console.WriteLine($"Your current record is: {playerScore.winCount} Wins - {playerScore.lossCount} Losses - {playerScore.tieCount} Ties "); Console.WriteLine("Play again? Choose r, p, s, or x to quit."); playerChoice = Console.ReadLine(); } await persistence.WriteAsync(playerScore); }
public BoardPanel(string typegame) { switch (typegame) { case "jvj": _ai = null; _ai2 = null; init_game(); break; case "jvia": _ai = new AI_Random() { Colour = CheckerColour.Red }; _ai2 = null; init_game(); break; case "iavia": _ai = new AI_Random { Colour = CheckerColour.Red }; _ai2 = new AI_Random { Colour = CheckerColour.Black }; init_game(); break; default: _ai = null; _ai2 = null; init_game(); break; } //this.DoubleBuffered = true; ResizeRedraw = true; SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.Opaque | ControlStyles.AllPaintingInWmPaint, true); AdvanceTurn(); }
public FindPathGameScreen(IAI tankAI) { BaseGame.CoordinMgr.SetScreenViewRect(scrnRect); camera = new Camera(2, cameraStartPos, 0f); compass = new Compass(new Vector2(740, 540)); camera.Enable(); InitialBackGround(); InitialScene(); InitialAI(tankAI); camera.Focus(tank, true); GameTimer timer = new GameTimer(5, delegate() { TextEffectMgr.AddRiseFadeInScrnCoordin("test FadeUp in Scrn!", new Vector2(100, 100), 1f, Color.Black, LayerDepth.Text, GameFonts.Lucida, 300, 0.5f); TextEffectMgr.AddRiseFade("test FadeUp in Login!", new Vector2(100, 100), 1f, Color.White, LayerDepth.Text, GameFonts.Lucida, 300, 0.5f); }); }
public UnitType( string name, Material material, Mesh mesh, Shape collisionShape, Sphere boundingSphere, float maxHealth, float density, IAI ai, Type controllerType ) { Name = name; Material = material; Mesh = mesh; CollisionShape = collisionShape; BoundingSphere = boundingSphere; MaxHealth = maxHealth; Density = density; AI = ai; ControllerType = controllerType; }
private void InitialDrawMgr(IAI tankAI1, IAI tankAI2) { DrawMgr.SetCondition( delegate(IDrawableObj obj) { return(true); }); //if (tankAI1 is ManualControl) //{ // DrawMgr.SetCondition( // delegate(IDrawableObj obj) // { // if (tank1.IsDead) // return true; // if (tank1.Rader.PointInRader(obj.Pos) || obj == tank1 || // ((obj is ShellNormal) && ((ShellNormal)obj).Firer == tank1)) // return true; // else // return false; // }); //} //if (tankAI2 is ManualControl) //{ // DrawMgr.SetCondition( // delegate(IDrawableObj obj) // { // if (tank2.IsDead) // return true; // if (tank2.Rader.PointInRader(obj.Pos) || obj == tank2 || // ((obj is ShellNormal) && ((ShellNormal)obj).Firer == tank2)) // return true; // else // return false; // }); //} }
public DuelGameScreen(IAI TankAI1, IAI TankAI2) { BaseGame.CoordinMgr.SetScreenViewRect(scrnViewRect); camera = new Camera(2.6f, new Vector2(150, 112), 0); camera.maxScale = 4.5f; camera.minScale = 2f; camera.Enable(); InitialBackGround(); sceneMgr = new SceneMgr(); SceneInitial(); GameManager.LoadScene(sceneMgr); RuleInitial(); AIInitial(TankAI1, TankAI2); InitialDrawMgr(TankAI1, TankAI2); InitialStartTimer(); }
public Game(AIStrategy aiStrategy, bool serialize) { _serialize = serialize; if (_serialize) { _gameHistories = _jsonPersistence.Read(); } switch (aiStrategy) { case AIStrategy.Random: _ai = new RandomAI(); break; case AIStrategy.AlwaysWins: _ai = new AlwaysWinsAI(); break; case AIStrategy.AlwaysLoses: _ai = new AlwaysLosesAI(); break; } }
public Player(string name, Color tokenColour, Color highlightColour, IAI ai) : this(name, tokenColour, highlightColour) { _ai = ai; }
private void AIInitial( IAI tankAI1, IAI tankAI2 ) { commonServer = new AICommonServer( mapRect ); tankAI1.CommonServer = commonServer; tankAI1.OrderServer = tank1; tank1.SetTankAI( tankAI1 ); tankAI2.CommonServer = commonServer; tankAI2.OrderServer = tank2; tank2.SetTankAI( tankAI2 ); //GameManager.ObjMemoryMgr.AddSingle( tank1 ); //GameManager.ObjMemoryMgr.AddSingle( tank2 ); }
private void InitialDrawMgr( IAI tankAI1, IAI tankAI2 ) { if (tankAI1 is ManualControl) { DrawMgr.SetCondition( delegate( IDrawableObj obj ) { if (tank1.IsDead) return true; if (tank1.Rader.PointInRader( obj.Pos ) || obj == tank1 || ((obj is ShellNormal) && ((ShellNormal)obj).Firer == tank1)) return true; else return false; } ); } if (tankAI2 is ManualControl) { DrawMgr.SetCondition( delegate( IDrawableObj obj ) { if (tank2.IsDead) return true; if (tank2.Rader.PointInRader( obj.Pos ) || obj == tank2 || ((obj is ShellNormal) && ((ShellNormal)obj).Firer == tank2)) return true; else return false; } ); } }
public void SetTankAI( IAI tankAI ) { if (tankAI == null) throw new NullReferenceException( "tankAI is null!" ); this.tankAI = tankAI; }
public Player(IAI ai) : this() { this.ai = ai; this.ai.Player = this; }
public void RemoveMember(IAI ai) { Debug.Assert(m_members.Contains(ai)); m_members.Remove(ai); }
private void InitialDrawMgr(IAI tankAI1, IAI tankAI2) { DrawMgr.SetCondition( delegate(IDrawableObj obj) { return true; }); //if (tankAI1 is ManualControl) //{ // DrawMgr.SetCondition( // delegate(IDrawableObj obj) // { // if (tank1.IsDead) // return true; // if (tank1.Rader.PointInRader(obj.Pos) || obj == tank1 || // ((obj is ShellNormal) && ((ShellNormal)obj).Firer == tank1)) // return true; // else // return false; // }); //} //if (tankAI2 is ManualControl) //{ // DrawMgr.SetCondition( // delegate(IDrawableObj obj) // { // if (tank2.IsDead) // return true; // if (tank2.Rader.PointInRader(obj.Pos) || obj == tank2 || // ((obj is ShellNormal) && ((ShellNormal)obj).Firer == tank2)) // return true; // else // return false; // }); //} }
public Agent(IEntity entity, IAI ai, float maxSpeed) { this.Entity = entity; this.AI = ai; this.MaxSpeed = maxSpeed; }
public DuelGameScreen( IAI TankAI1, IAI TankAI2 ) { BaseGame.CoordinMgr.SetScreenViewRect( scrnViewRect ); camera = new Camera( 2.6f, new Vector2( 150, 112 ), 0 ); camera.maxScale = 4.5f; camera.minScale = 2f; camera.Enable(); InitialBackGround(); sceneMgr = new SceneMgr(); SceneInitial(); GameManager.LoadScene( sceneMgr ); RuleInitial(); AIInitial( TankAI1, TankAI2 ); InitialDrawMgr( TankAI1, TankAI2 ); InitialStartTimer(); }
private void InitialAI( IAI tankAI ) { commonServer = new AICommonServer( mapSize ); tank.SetTankAI( tankAI ); tankAI.OrderServer = tank; tankAI.CommonServer = commonServer; GameManager.ObjMemoryMgr.AddSingle( tank ); }
public int AddPlayer(IAI ai) { players.Add(new KeyValuePair<IAI, Player>(ai, new Player(this))); return players.Count - 1; }
internal void SetAI(IAI _ai) { ai = _ai; }
/// <summary> /// Provides the extra text for the <see cref="AdvancedPropertyDescriptor"/> for a /// <see cref="IAI"/>. /// </summary> /// <param name="v">The value.</param> /// <returns>The extra text to display.</returns> static string ExtraTextProvider_IAI(IAI v) { if (v == null) return null; return AIFactory.Instance.GetAIName(v.ID); }
// Use this for initialization void Start() { m_AI = new AIIdle(); m_GameObj = GetComponent <IGameObject>(); Time.timeScale = 2.0f; // 加速. }
public static Player NewPlayer1(IAI ai) { return new Player("Player 1", Player1TokenColour, Player1HighlightColour, ai); }
public static Player NewPlayer2(IAI ai) { return new Player("Player 2", Player2TokenColour, Player2HighlightColour, ai); }
public FindPathGameScreen( IAI tankAI ) { BaseGame.CoordinMgr.SetScreenViewRect( scrnRect ); camera = new Camera( 2, cameraStartPos, 0f ); compass = new Compass( new Vector2( 740, 540 ) ); camera.Enable(); InitialBackGround(); InitialScene(); InitialAI( tankAI ); camera.Focus( tank, true ); GameTimer timer = new GameTimer( 5, delegate() { TextEffectMgr.AddRiseFadeInScrnCoordin( "test FadeUp in Scrn!", new Vector2( 100, 100 ), 1f, Color.Black, LayerDepth.Text, GameFonts.Lucida, 300, 0.5f ); TextEffectMgr.AddRiseFade( "test FadeUp in Login!", new Vector2( 100, 100 ), 1f, Color.White, LayerDepth.Text, GameFonts.Lucida, 300, 0.5f ); } ); }