public Result(bool bHasNightBattle,bool practice) { Friend = new FleetState(); Enemy = new FleetState(); HasNightBattle = bHasNightBattle; Practice = practice; }
public Result(Result orig) { MatchState = orig.MatchState; HasNightBattle = orig.HasNightBattle; Friend = new FleetState(orig.Friend); Enemy = new FleetState(orig.Enemy); Practice = orig.Practice; }
public FleetStateViewModel(FleetState source) { this.Source = source; this.CompositeDisposable.Add(new PropertyChangedEventListener(source) { (sender, args) => this.RaisePropertyChanged(args.PropertyName), }); this.Sortie = new SortieViewModel(source); this.CompositeDisposable.Add(this.Sortie); this.Homeport = new HomeportViewModel(source); this.CompositeDisposable.Add(this.Homeport); }
public static FleetState AddBasicFleet(string _player) { var _units = CreateUnits(Game.Manager.BasicFleet, _player); var _fleet = new FleetState(_player, "Basic Fleet", _units); foreach (var unit in _fleet.Units) { var X_position = (float)Game.Random.Next(-200, 200); var Y_position = (float)Game.Random.Next(-200, 200); var position = new Vector3(X_position, 0, Y_position); unit.Position = position; } return(_fleet); }
private void revealFleet() { fleetRevealCounter++; if (fleetRevealCounter < alienRevealDelay) { return; } fleetRevealCounter = 0; fleet[fleetIndex].SetActive(true); fleetIndex++; if (fleetIndex == fleet.Length) { fleetIndex = 0; state = FleetState.MoveFleet; } }
public void QuickBattle() { Game.NetworkManager.onlineScene = "Battle"; Game.PlayerName = "Player"; var _player = new Player("Player", 0u, true); Game.Manager.Players.Add(_player); var _enemy = new Player("Enemy", 0u, true); Game.Manager.Players.Add(_enemy); foreach (var player in Game.Manager.Players) { var _units = BattleSetup.CreateUnits(Game.Manager.BasicFleet, player.Name); var _fleet = new FleetState(player.Name, "Basic Fleet", _units); player.fleet = _fleet; } Game.NetworkManager.StartupHost(); }
public static void DeployFleet(FleetState _fleet) { var register = Game.Register; foreach (var _unit in _fleet.Units) { var unitType = register.GetUnitType(_unit.UnitType); var unit = (Unit)Instantiate(unitType); unit.transform.position = _unit.Position; unit.setUnitState(_unit); unit.SelectedWeapon = unit.Weapons.First(); unit.SelectedAction = unit.Actions.First(); Battle.AllUnits.Add(unit); Battle.VisibleUnits.Add(unit); unit.gameObject.name = unit.DsiplayName + "(" + unit.state.Owner + ")"; } }
public void Prime(FleetState _fleet) { fleet = _fleet; if (ownerName != null) { ownerName.text = fleet.Owner; } if (fleetName != null) { fleetName.text = fleet.Name; } if (unitCount != null) { unitCount.text = fleet.Units.Count().ToString(); } }
public Player(string _name, uint _id, bool _human, FleetState _fleet) { this.Name = _name; this.ConnectionID = _id; this.connected = true; if (_human) { this.ReadyStatus = false; } else { this.ReadyStatus = true; } this.human = _human; fleet = _fleet; }
public Player(string _name, uint _id, bool _human) { this.Name = _name; this.ConnectionID = _id; this.connected = true; if (_human) { this.ReadyStatus = false; } else { this.ReadyStatus = true; } this.human = _human; fleet = new FleetState(this.Name, "Basic Fleet"); var _units = BattleSetup.CreateUnits(Game.Manager.BasicFleet, this.Name); fleet.Units = _units; }
public HomeportViewModel(FleetState state) : base(state) { this.Condition = new ConditionViewModel(state.Condition); this.CompositeDisposable.Add(this.Condition); }
IEnumerator ExecuteAttackOrder_EnterState() { D.Log("{0}.ExecuteAttackOrder_EnterState called. Target = {1}.", FullName, CurrentOrder.Target.FullName); _moveTarget = CurrentOrder.Target; _moveSpeed = Speed.FleetFull; Call(FleetState.Moving); yield return null; // required immediately after Call() to avoid FSM bug if (_isDestinationUnreachable) { CurrentState = FleetState.Idling; yield break; } if (!(CurrentOrder.Target as IMortalTarget).IsAlive) { // Moving Return()s if the target dies CurrentState = FleetState.Idling; yield break; } Call(FleetState.Attacking); yield return null; // required immediately after Call() to avoid FSM bug CurrentState = FleetState.Idling; }
public FleetState(FleetState orig) { Formation = orig.Formation; SearchResult = orig.SearchResult; Ships = new ShipState[] { new ShipState(orig.Ships[0]),new ShipState(orig.Ships[1]), new ShipState(orig.Ships[2]),new ShipState(orig.Ships[3]), new ShipState(orig.Ships[4]),new ShipState(orig.Ships[5]) }; }
public SortieViewModel(FleetState state) : base(state) { SortieInfo = state.GetFleet().SortieInfo; }
public FleetView() { InitializeComponent(); this.Paint += (s, e) => { var g = e.Graphics; var Width = this.Width - this.Padding.Left - this.Padding.Right; var Height = this.Height - this.Padding.Top - this.Padding.Bottom; g.TranslateTransform(this.Padding.Left, this.Padding.Top); IEnumerable <Ship> Ships = null; int nw = 0, y = 0; #region Draw Header using (SolidBrush b = new SolidBrush(Color.FromArgb(0x30, 0x90, 0x90, 0x90))) g.FillRectangle(b, new Rectangle(0, 0, Width, 24)); if (this.Fleet != null && this.Fleet.Ships != null) { int x = 4; FleetState state = this.Fleet.State; if (state != null) { string[] texts = new string[] { "레벨 합계: " + state.TotalLevel.ToString(), "평균: " + Math.Round(state.AverageLevel, 2).ToString(), "색적: " + Math.Round(state.ViewRange, 2).ToString(), string.Format( "제공: {0}-{1} ({2} %)", state.MinAirSuperiorityPotential.ToString(), state.MaxAirSuperiorityPotential.ToString(), Math.Round(state.EncounterPercent, 2) ), state.Speed.ToStateString() }; foreach (var text in texts) { Size sz = TextRenderer.MeasureText(text, this.Font); TextRenderer.DrawText(g, text, this.Font, new Rectangle(x, y + 5, sz.Width, sz.Height), Color.White); x += sz.Width + 8; } x -= 4; } nw = x; } y += 24 + 1; #endregion #region Draw Fleet Name using (SolidBrush b = new SolidBrush(Color.FromArgb(0x30, 0x90, 0x90, 0x90))) g.FillRectangle(b, new Rectangle(0, y, 30, Height - y)); using (SolidBrush b = new SolidBrush(Color.White)) { var FleetName = Fleet?.Name ?? "함대명"; using (Bitmap buffer = new Bitmap(30, Height - y, PixelFormat.Format32bppArgb)) { using (Graphics g2 = Graphics.FromImage(buffer)) { Size sz = TextRenderer.MeasureText(FleetName, this.Font); g2.TranslateTransform(-sz.Width / 2, -sz.Height / 2, MatrixOrder.Append); g2.RotateTransform(-90, MatrixOrder.Append); g2.TranslateTransform(15, (Height - y) / 2, MatrixOrder.Append); g2.DrawString(FleetName, this.Font, b, 0, 0); } g.DrawImage(buffer, new Rectangle(0, y, 30, Height - y)); } } #endregion if (this.Fleet == null || this.Fleet.Ships == null) { return; // No elements to draw } Ships = this.Fleet.Ships; if (Ships.Count() == 0) { return; } #region Draw Ships var w1 = TextRenderer.MeasureText("Lv.", new Font(this.Font.FontFamily, 9)).Width - 4; var w2 = TextRenderer.MeasureText("HP:", new Font(this.Font.FontFamily, 9)).Width - 6; var cells = new int[] { 0, 0, 0, 0 }; cells[0] = Ships.Max(x => TextRenderer.MeasureText(x.Info.ShipType.Name, new Font(this.Font.FontFamily, 8)).Width) + 4; cells[1] = Ships.Max(x => TextRenderer.MeasureText(x.Info.Name, new Font(this.Font.FontFamily, 15)).Width) + 4; cells[2] = w1 + Ships.Max(x => TextRenderer.MeasureText(x.Level.ToString(), new Font(this.Font.FontFamily, 10)).Width) + 8; cells[3] = w2 + Ships.Max(x => TextRenderer.MeasureText(x.HP.Current.ToString(), new Font(this.Font.FontFamily, 11)).Width - 8 + TextRenderer.MeasureText("/" + x.HP.Maximum.ToString(), new Font(this.Font.FontFamily, 9)).Width ) + 8; SlotItemMap.Clear(); foreach (var ship in Ships) { if (ship == null) { continue; } var x = 30; Size sz; #region 함종명 TextRenderer.DrawText( g, ship.Info.ShipType.Name, new Font(this.Font.FontFamily, 8), new Rectangle(x + 4, y - 3, cells[0], 28), Color.FromArgb(0x30, 0x90, 0x90, 0x90), TextFormatFlags.Right | TextFormatFlags.Bottom ); x += cells[0]; #endregion #region 함선명 TextRenderer.DrawText( g, ship.Info.Name, new Font(this.Font.FontFamily, 15), new Rectangle(x, y, cells[1], 28), Color.White, TextFormatFlags.Left | TextFormatFlags.Bottom ); x += cells[1]; #endregion #region 함선레벨 TextRenderer.DrawText( g, "Lv.", new Font(this.Font.FontFamily, 9), new Rectangle(x, y - 2, w1, 28), Color.FromArgb(0x30, 0x90, 0x90, 0x90), TextFormatFlags.Left | TextFormatFlags.Bottom ); TextRenderer.DrawText( g, ship.Level.ToString(), new Font(this.Font.FontFamily, 11), new Rectangle(x + w1, y - 1, cells[2] - w1, 28), Color.White, TextFormatFlags.Left | TextFormatFlags.Bottom ); x += cells[2]; #endregion #region 함선 체력 sz = TextRenderer.MeasureText(ship.HP.Current.ToString(), new Font(this.Font.FontFamily, 11)); TextRenderer.DrawText( g, "HP:", new Font(this.Font.FontFamily, 9), new Rectangle(x, y + 2, cells[1], 16), Color.FromArgb(0x30, 0x90, 0x90, 0x90), TextFormatFlags.Left | TextFormatFlags.Bottom ); TextRenderer.DrawText( g, ship.HP.Current.ToString(), new Font(this.Font.FontFamily, 11), new Rectangle(x + w2, y, cells[1], 16), Color.White, TextFormatFlags.Left | TextFormatFlags.Bottom ); TextRenderer.DrawText( g, "/" + ship.HP.Maximum.ToString(), new Font(this.Font.FontFamily, 9), new Rectangle(x + w2 + sz.Width - 8, y + 2, cells[1], 16), Color.FromArgb(0x30, 0x90, 0x90, 0x90), TextFormatFlags.Left | TextFormatFlags.Bottom ); DrawProgress(g, new Rectangle(x + 2, y + 20, cells[3] - 8 - 4, 6), ship.HP); x += cells[3]; #endregion #region 함선 피로도 using (SolidBrush b = new SolidBrush(GetCondColor(ship.ConditionType))) g.FillRectangle(b, new Rectangle(x + 4, y + 4, 12, 12)); TextRenderer.DrawText( g, ship.Condition.ToString(), new Font(this.Font.FontFamily, 9), new Rectangle(x + 16, y + 3, 24, 16), Color.White, TextFormatFlags.Left | TextFormatFlags.Top ); TextRenderer.DrawText( g, "피로도", new Font(this.Font.FontFamily, 7), new Rectangle(x + 2, y + 18, 40, 16), Color.FromArgb(0x30, 0x90, 0x90, 0x90), TextFormatFlags.Left | TextFormatFlags.Top ); x += 48; #endregion #region 함선 연료/탄약 DrawProgress(g, new Rectangle(x - 6, y + 6, 44, 6), ship.Fuel, 5); DrawProgress(g, new Rectangle(x - 6, y + 18, 44, 6), ship.Bull, 5); x += 44; #endregion #region 장비 foreach (var item in ship.Slots) { if (item == null || !item.Equipped) { continue; } SlotItemMap.Add(new Rectangle(x, y + 2, 36, 28), item); DrawSlotItem(g, item, x, y + 2); x += 38; } if (ship.ExSlotExists && ship.ExSlot.Equipped) { using (Pen p = new Pen(Color.FromArgb(0x90, 0x90, 0x90, 0x90))) g.DrawLine(p, x + 2, y + 2, x + 2, y + 28); x += 7; var item = ship.ExSlot; SlotItemMap.Add(new Rectangle(x, y + 2, 36, 28), item); DrawSlotItem(g, item, x, y + 2); x += 38; } x -= 2; #endregion nw = Math.Max(nw, x); y += 32; } #endregion for (var i = 0; i < Ships.Count(x => x != null); i++) { using (Pen p = new Pen(Color.FromArgb(0x30, 0x90, 0x90, 0x90))) g.DrawLine(p, 30, y - i * 32 - 1, nw, y - i * 32 - 1); } var ResultSize = new Size( nw + this.Padding.Left + this.Padding.Right, y + this.Padding.Top + this.Padding.Bottom ); if (ResultSize.Width != LatestSize.Width || ResultSize.Height != LatestSize.Height) { LatestSize = ResultSize; this.PerformAutoScale(); this.PerformLayout(); } }; this.MouseMove += (s, e) => { if (!this.SlotItemMap.Any(x => x.Key.Contains(e.X, e.Y))) { CurrentItem = null; toolTip.Hide(this); return; } var item = this.SlotItemMap.FirstOrDefault(x => x.Key.Contains(e.X, e.Y)).Value.Item; if (item == CurrentItem) { return; } CurrentItem = item; toolTip.Show(CurrentItem.NameWithLevel, this); }; this.MouseDown += (s, e) => { if (!this.SlotItemMap.Any(x => x.Key.Contains(e.X, e.Y))) { CurrentItem = null; toolTip.Hide(this); return; } var item = this.SlotItemMap.FirstOrDefault(x => x.Key.Contains(e.X, e.Y)).Value.Item; CurrentItem = item; toolTip.Show(CurrentItem.NameWithLevel, this); }; var toolTipFont = new Font(this.Font.FontFamily, 10); toolTip.Popup += (s, e) => { if (CurrentItem == null) { e.Cancel = true; return; } var sz = TextRenderer.MeasureText(CurrentItem.NameWithLevel, toolTipFont); e.ToolTipSize = new Size(sz.Width + 6, sz.Height + 6); }; toolTip.Draw += (s, e) => { var g = e.Graphics; g.Clear(Color.FromArgb(0x27, 0x27, 0x2F)); g.DrawRectangle( new Pen(Color.FromArgb(0x44, 0x44, 0x4A), 1.0f), new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width - 1, e.Bounds.Height - 1) ); TextRenderer.DrawText( g, e.ToolTipText, toolTipFont, e.Bounds, Color.FromArgb(255, 255, 255), TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter ); }; }
protected QuickStateViewViewModel(FleetState state) { this.State = state; }
IEnumerator ExecuteJoinFleetOrder_EnterState() { D.Log("{0}.ExecuteJoinFleetOrder_EnterState called.", FullName); _moveTarget = CurrentOrder.Target; D.Assert(CurrentOrder.Speed == Speed.None, "{0}.JoinFleetOrder has speed set to {1}.".Inject(FullName, CurrentOrder.Speed.GetValueName())); _moveSpeed = Speed.FleetStandard; Call(FleetState.Moving); yield return null; // required immediately after Call() to avoid FSM bug if (_isDestinationUnreachable) { CurrentState = FleetState.Idling; yield break; } // we've arrived so transfer the ship to the fleet we are joining var fleetToJoin = CurrentOrder.Target as FleetCmdModel; var ship = Elements[0] as ShipModel; // IMPROVE more than one ship? TransferShip(ship, fleetToJoin); // removing the only ship will immediately call FleetState.Dead }
// QuickStateView は ContentControl に対し型ごとの DataTemplate を適用する形で実現するので // 状況に応じた型がそれぞれ必要。これはその 1 つ。 public SortieViewModel(FleetState state) : base(state) { }
IEnumerator ExecuteMoveOrder_EnterState() { D.Log("{0}.ExecuteMoveOrder_EnterState called.", FullName); _moveTarget = CurrentOrder.Target; _moveSpeed = CurrentOrder.Speed; Call(FleetState.Moving); yield return null; // required immediately after Call() to avoid FSM bug // Return()s here - move error or not, we idle if (_isDestinationUnreachable) { //TODO how to handle move errors? D.Error("{0} move order to {1} is unreachable.", FullName, CurrentOrder.Target.FullName); } CurrentState = FleetState.Idling; }
void Start() { state = FleetState.InitialiseFleet; direction = FleetDirection.LeftToRight; }
private void moveFleet() { GameObject alien = fleet[fleetIndex]; float currentX = alien.transform.position.x; float currentY = alien.transform.position.y; switch (direction) { case FleetDirection.LeftToRight: alien.transform.position = new Vector2(currentX + xSpeed, currentY); break; case FleetDirection.DownLeft: case FleetDirection.DownRight: alien.transform.position = new Vector2(currentX, currentY - ySpeed); break; case FleetDirection.RightToLeft: alien.transform.position = new Vector2(currentX - xSpeed, currentY); break; } if (alien.transform.position.x < minX) { minX = alien.transform.position.x; } if (alien.transform.position.x > maxX) { maxX = alien.transform.position.x; } if (alien.transform.position.y < minY) { minY = alien.transform.position.y; } fleetIndex++; if (fleetIndex == fleet.Length) { fleetIndex = 0; if (changeDirection()) { switch (direction) { case FleetDirection.LeftToRight: direction = FleetDirection.DownRight; break; case FleetDirection.DownLeft: direction = FleetDirection.LeftToRight; break; case FleetDirection.DownRight: direction = FleetDirection.RightToLeft; break; case FleetDirection.RightToLeft: direction = FleetDirection.DownLeft; break; } if (minY < -3) { state = FleetState.FleetLanded; } minX = 0; maxX = 0; minY = 0; } if (state != FleetState.FleetLanded) { pauseCounter = 16; state = FleetState.PauseFleet; } } }