public static DrawingGroup CrateMiningModule(MiningModule m) { DrawingGroup g = null; m.SceneMgr.Invoke(new Action(() => { BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = new Uri("pack://application:,,,/resources/images/mining-module/module.png"); bi.DecodePixelWidth = m.Radius * 4; bi.EndInit(); g = new DrawingGroup(); ImageDrawing img = new ImageDrawing(); img.ImageSource = bi; img.Rect = new Rect(new Size(m.Radius * 2, m.Radius * 2)); TransformGroup tg = new TransformGroup(); tg.Children.Add(new TranslateTransform(m.Position.X, m.Position.Y)); tg.Children.Add(new RotateTransform(m.Rotation, m.Radius, m.Radius)); g.Transform = tg; g.Children.Add(img); })); return(g); }
/// <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); } } }
private void SendColorChange(MiningModule module) { NetOutgoingMessage msg = me.SceneMgr.CreateNetMessage(); msg.Write((int)PacketType.MODULE_COLOR_CHANGE); msg.Write(module.Owner.GetId()); msg.Write(module.Owner.GetPlayerColor()); me.SceneMgr.SendMessage(msg); }
private void SendDamage(int damage, ISceneObject obj, MiningModule me) { NetOutgoingMessage msg = me.SceneMgr.CreateNetMessage(); msg.Write((int)PacketType.OBJECTS_TAKE_DAMAGE); msg.Write(me.Owner.GetId()); msg.Write(1); msg.Write(damage); msg.Write(obj.Id); me.SceneMgr.SendMessage(msg); }
protected override void InitControl(Entities.ISceneObject me) { Vulnerable = true; hp = MaxHp; if (me is MiningModule) { module = me as MiningModule; } else { throw new Exception("ModuleDamageControl must be attached to MiningModule object"); } }
public static MiningModule CreateMiningModule(SceneMgr mgr, Vector position, Player owner) { MiningModule module = new MiningModule(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId()), owner); module.Position = position; module.Radius = 10; module.Color = Colors.Crimson; ModuleDamageControl mc = new ModuleDamageControl(); mc.MaxHp = SharedDef.SPECTATOR_MAX_HP; module.AddControl(mc); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = module.Center; cs.Radius = module.Radius; module.CollisionShape = cs; ControlableDeviceControl dc = new ControlableMiningModuleControl(); module.AddControl(dc); LinearRotationControl rc = new LinearRotationControl(); rc.RotationSpeed = SharedDef.SPECTATOR_MODULE_ROTATION_SPEED; module.AddControl(rc); HpRegenControl hc = new HpRegenControl(); hc.MaxRegenTime = SharedDef.SPECTATOR_HP_REGEN_CD; hc.RegenTimer = SharedDef.SPECTATOR_HP_REGEN_CD; hc.RegenSpeed = SharedDef.SPECTATOR_REGEN_SPEED; module.AddControl(hc); module.AddControl(new RespawningObjectControl()); module.AddControl(new StickySphereCollisionShapeControl()); module.SetGeometry(SceneGeometryFactory.CrateMiningModule(module)); return(module); }
public static ISceneObject SpectatorActionReadinessIndicator(ISpectatorAction a, MiningModule parent, double rotation, Color begin, Color end, Color stroke) { SimpleSphere s = new SimpleSphere(a.SceneMgr, IdMgr.GetNewId(a.SceneMgr.GetCurrentPlayer().GetId())); s.Color = a.CastingColor; s.Radius = 6; s.Category = DrawingCategory.PLAYER_OBJECTS; Vector offset = new Vector(parent.Radius + 15, 0).Rotate(rotation); s.SetGeometry(SceneGeometryFactory.CreateRadialGradientEllipseGeometry(a.SceneMgr, s.Radius, begin, end, stroke, parent.Center + offset, 1)); CenterCloneControl ccc = new CenterCloneControl(parent); ccc.Offset = offset; s.AddControl(ccc); return(s); }
public static MiningModuleIntegrityBar CreateMiningModuleIntegrityBar(SceneMgr mgr, MiningModule module, Player owner) { MiningModuleIntegrityBar arc = new MiningModuleIntegrityBar(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); arc.Color = owner.Data.SpecialColor; arc.Radius = module.Radius + 5; CenterCloneControl pControl = new CenterCloneControl(module); arc.AddControl(pControl); HpBarControl hControl = new HpBarControl(arc); module.AddControl(hControl); arc.SetGeometry(SceneGeometryFactory.CreateArcSegments(arc)); return(arc); }