/// <summary> /// vytvori hraci action bar, input manager a zbrane a bazi nebo mining module /// </summary> /// <param name="p">hrac kteremu se maji vytvorit objekty</param> private void CreateActiveObjectsOfPlayer(Player p) { if (p.IsActivePlayer()) { p.CreateWeapons(); p.Baze = SceneObjectFactory.CreateBase(this, p); BaseIntegrityBar ellipse = SceneObjectFactory.CreateBaseIntegrityBar(this, p); HpBarControl control = new HpBarControl(ellipse); p.Baze.AddControl(control); DelayedAttachToScene(ellipse); DelayedAttachToScene(p.Baze); } else { if (p.Device == null) { MiningModule obj = SceneObjectFactory.CreateMiningModule(this, p.Data.MiningModuleStartPos, p); DelayedAttachToScene(obj); DelayedAttachToScene(SceneObjectFactory.CreateMiningModuleIntegrityBar(this, obj, p)); p.Device = obj; } } if (p.IsCurrentPlayer()) { actionBarMgr = new ActionBarMgr(this); StateMgr.AddGameState(actionBarMgr); if (p.IsActivePlayer()) { inputMgr = new PlayerInputMgr(p, this, actionBarMgr); actionBarMgr.CreateActionBarItems(p.GetActions <IPlayerAction>(), false); InitAutomaticMineLauncher(); } else { if (p.Device.HasControlOfType <MiningModuleControl>()) { return; } MiningModuleControl mc = new MiningModuleControl(); mc.Owner = p; p.Device.AddControl(mc); inputMgr = new SpectatorInputMgr(p, this, p.Device, actionBarMgr); actionBarMgr.CreateActionBarItems(p.GetActions <ISpectatorAction>(), true); SceneObjectFactory.CreateSpectatorActionReadinessIndicators(p); } } }
public static DrawingGroup CreateArcSegments(BaseIntegrityBar arc) { DrawingGroup d = null; arc.SceneMgr.Invoke(new Action(() => { d = new DrawingGroup(); d.Children.Add(new GeometryDrawing(new SolidColorBrush(arc.Color), new Pen(Brushes.Black, 1), CreateArc(arc))); TransformGroup tg = new TransformGroup(); tg.Children.Add(new TranslateTransform(arc.Position.X, arc.Position.Y)); d.Transform = tg; })); return(d); }
public static BaseIntegrityBar CreateBaseIntegrityBar(SceneMgr mgr, Player owner) { BaseIntegrityBar arc = new BaseIntegrityBar(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); Color c = owner.GetPlayerColor(); c.A = 0x55; arc.Color = c; arc.FullAngle = (float)Math.PI; arc.Width = (float)owner.Baze.Size.Width / 2 + 2; arc.Height = (float)owner.Baze.Size.Height + 3; //hack kvuli neeliptickym rozmerum baze arc.Position = owner.Baze.Position + (new Vector(owner.Baze.Size.Width / 2, owner.Baze.Size.Height)); arc.StartPoint = new Point(0, owner.Baze.Size.Height + 3); arc.SetGeometry(SceneGeometryFactory.CreateArcSegments(arc)); return(arc); }
private static PathGeometry CreateArc(BaseIntegrityBar e) { ArcSegment arc = new ArcSegment(); PathFigure figure = new PathFigure(); figure.StartPoint = e.StartPoint; arc = new ArcSegment(); arc.SweepDirection = SweepDirection.Clockwise; arc.IsLargeArc = true; arc.Size = new Size(e.Width, e.Height); arc.Point = e.ComputeEllipsePoint(0); e.SetArc(arc); figure.Segments.Add(arc); PathGeometry geom = new PathGeometry(); geom.Figures.Add(figure); return(geom); }