internal Player(string name,Map m,int PlayerID) { Map = m; Name = name; mainUnit = new Unit(m); mainUnit.Position = new Vector(100, 100); }
public BattleQueue(Game game, Unit[] party, Unit[] enemies, int length) : base(game) { this.length = length; turnList = new List<Turn>(); this.party = party; this.enemies = enemies; units = new List<Unit>(); }
private Stats stats; // Overall stats #endregion Fields #region Constructors public Unit(String name, Stats stats, Vector2 position) { this.name = name; this.stats = stats; this.currentStats = stats; this.position = position; this.attackState = false; this.positionState = PositionState.Stay; this.positionTarget = this; //movement = new MoveTimer(0,6.0f, position, position, stats.speed); movement = new MoveTimer(0,6.0f, position, position, currentStats.speed); }
/// <summary> /// Agressive Intellegence Dellegate /// This will blindly attack the closest living opponent, then charge /// after it. /// </summary> /// <param name="me">The unit this AI is making decisions for.</param> public void Agressive(Unit me) { Unit target = null; float targetDistance = float.MaxValue, nextDistance; foreach (Unit opp in this.opponents) { if (opp.CurrentStats.health > 0) { if (target == null) { target = opp; targetDistance = Vector2.Distance( me.Position, opp.Position); } else { nextDistance = Vector2.Distance( me.Position, opp.Position); if (nextDistance < targetDistance) { targetDistance = nextDistance; target = opp; } } } } me.setAttackTarget(target); me.setPositionState(PositionState.Charge); me.setPositionTarget(target); }
public AI(Unit[] team, Unit[] opponents) { this.team = team; this.opponents = opponents; }
public Projectile(Map m,Unit o) : base(m) { Owner = o; }
public void setPositionTarget(Vector2 target) { Unit dummy = new Unit(target); positionTarget = dummy; }
public void setPositionTarget(Unit target) { positionTarget = target; }
public static int SpeedComparison(Unit x, Unit y) { return x.CurrentStats.speed.CompareTo (y.CurrentStats.speed); }
public void useItem(Unit target, IUseable item) { }
public void useSkill(Unit target, IUseable skill) { }
public void guard(Unit target, IUseable usable) { }
public void escape(Unit target, IUseable usable) { }
/** * Attack: [actor, target] * Skill: [actor, target(optional)] * Change: Not an Action, just a menu option * Guard: [actor] * Item: [actor, target, item] * Escape: [actor] */ public void attack(Unit target, IUseable useable) { }
private bool hasNoSurvivor( Unit[] team ) { foreach( Unit unit in team ) { if( unit.CurrentStats.health > 0 ) { return false; } } return true; }
public void setAttackTarget(Unit target) { attackState = true; attackTarget = target; }
private void Reset() { oldState = Keyboard.GetState(); oldMouseState = Mouse.GetState(); Stats defaultStats = new Stats(2.68F, 20, 5, 10); Vector2 unitPosition = new Vector2( 4f / 16f * BattleConstants.SCREEN_WIDTH, 3f / 9f * BattleConstants.SCREEN_HEIGHT); // Initialize enemy positions for (int i = 0; i < enemyCount; i++) { enemyTeam[i] = new Unit( "Enemy", defaultStats, new Vector2(unitPosition.X, unitPosition.Y) ); unitPosition.Y += BattleConstants.SCREEN_HEIGHT / 9f; } // Initialize player positions unitPosition.X = 12f / 16f * BattleConstants.SCREEN_WIDTH; unitPosition.Y = 3f / 9f * BattleConstants.SCREEN_HEIGHT; for (int i = 0; i < playerCount; i++) { playerTeam[i] = new Unit( "Player", defaultStats, new Vector2(unitPosition.X, unitPosition.Y)); unitPosition.Y += BattleConstants.SCREEN_HEIGHT / 9f; } queue.Initialize(); queue.Visible = true; // Initialize AI enemyAI = new AI(enemyTeam, playerTeam); foreach(Unit unit in enemyTeam) { unit.intelligence = enemyAI.Agressive; } foreach (BattleMenu menu in menus) { if (menu != null) { menu.Visible = false; } } endGameMenu.Visible = false; turnPlayIndex = 0; turnInputIndex = 0; menuState = new Stack<InputState>(); gameState = GameState.Initial; }
public void setSelectedUnit(Unit selectedUnit) { this.selectedUnit = selectedUnit; }