public MainList(ICanyonShooterGame game, string menuName, MenuDescription menuXml, bool hori) : base(game as ICanyonShooterGame) { this.menuXml = menuXml; init(menuName, hori); this.menuName = menuName; foreach (MenupartDescription i in menuXml.MenuParts) { if (i.Name == menuName) { Vector2 ButtonMessure = new Vector2(); for (int g = 0; g < i.ButtonCount; g++) { ButtonMessure.X += i.Buttons[g].width; ButtonMessure.Y += i.Buttons[g].height; } this.leftshift = new Button(game, "LeftShift", new Rectangle((int)((game.Graphics.Device.Viewport.Width - 398 + (i.StartPosition.X - 398)) - 23 - i.ShiftOffset.X), (int)i.StartPosition.Y, 23, 72), "shift_left", true, this); this.rightshift = new Button(game, "RightShift", new Rectangle((int)( (game.Graphics.Device.Viewport.Width - 398 + (i.StartPosition.X - 398 - 3)) + i.ShiftOffset.X + ButtonMessure.X + ((i.ButtonCount - 1) * i.Spacer.X)), (int)i.StartPosition.Y, 23, 72), "shift_right", true, this); } } }
public NormalList(ICanyonShooterGame game, string menuName, MenuDescription menuXml, bool hori) : base(game as ICanyonShooterGame) { this.menuXml = menuXml; this.menuName = menuName; init(menuName, hori); }
public Physics(ICanyonShooterGame game, bool multiThreading) : base(game as Game) { this.game = game; Simulator.CreateMethod = OdeSimulator.CreateOdeSimulator; simulator = Simulator.Create(); // Simulator erzeugen; simulator.StepSize = 0.012f; // 0.0167f ~ 60 Hz physics update rate. simulator.MaxContacts = 4; UpdateOrder = int.MaxValue - 10; SetupContactGroups(); this.multiThreading = multiThreading; if (multiThreading) { createdObjects = new LockingQueue <IPhysicsObject>(); destroyedObjects = new LockingQueue <IPhysicsObject>(); thread = new Thread(RunMultiThreaded); thread.Priority = ThreadPriority.Highest; thread.Start(); } else { createdObjects = new NonLockingQueue <IPhysicsObject>(); destroyedObjects = new NonLockingQueue <IPhysicsObject>(); } }
public TowerAI(ICanyonShooterGame game, EnemyDescription desc) : base(game, "Enemy-TankAI") { this.game = game; id = createdTanks++; // Set the tank model SetModel(desc.Model); LocalScale = new Vector3(4f, 4f, 4f); LocalPosition = desc.RelativeSpawnLocation; dir = new Vector3(0, 0, -1); // Physics Config ConnectedToXpa = true; this.Static = true; ContactGroup = ContactGroup.Enemies; LocalPosition = desc.RelativeSpawnLocation; // Initialize AI-States of TowerAI AIStates = new AIStateMachine(game, this); AIStates.AddState(new TowerAIObserving(game.World.Players[0])); AIStates.AddState(new TowerAIAttackPlayer(game.World.Players[0])); AIStates.DebugAI = false; }
public Sunlight(ICanyonShooterGame game, Color color, Vector3 direction) : base(game as Game) { this.game = game; this.color = color; this.direction = direction; }
public BasicProjectile(ICanyonShooterGame game, Vector3 startPos, Vector3 direction, string soundName, WeaponHolderType weaponHolderType) : base(game) { if (game != null) { this.game = game; } else { throw new Exception("game can't be null!"); } ConnectedToXpa = true; if (weaponHolderType == WeaponHolderType.Player) { ContactGroup = ContactGroup.PlayerProjectiles; } if (weaponHolderType == WeaponHolderType.Enemy) { ContactGroup = ContactGroup.EnemyProjectiles; } Direction = direction; LocalPosition = startPos; FromPosition = startPos; if (soundName != String.Empty || soundName != "") { sound = game.Sounds.CreateSound(soundName); sound.Play(); } }
/// <summary> /// Constructor /// </summary> /// <param name="game">game is the Canyonshootergame</param> public Intro(ICanyonShooterGame game) : base(game as Game) { this.game = game; this.Visible = true; introtext = game.Content.Load <IntroDescription>("Content\\Intro\\Intro"); }
public void LoadContent(ICanyonShooterGame game) { font = game.Content.Load <SpriteFont>("Arial"); header = game.Content.Load <Texture2D>("Content\\Textures\\Menu\\listboxheader"); leftside = game.Content.Load <Texture2D>("Content\\Textures\\Menu\\listboxleft"); rightside = game.Content.Load <Texture2D>("Content\\Textures\\Menu\\listboxright"); background = game.Content.Load <Texture2D>("Content\\Textures\\Menu\\listboxback"); statusrow = game.Content.Load <Texture2D>("Content\\Textures\\Menu\\listboxstatus"); buttonsback = game.Content.Load <Texture2D>("Content\\Textures\\Menu\\buttonback"); if (scrollable) { scrollbar.LoadContent(); } List.LoadContent(); Buttons.LoadContent(); foreach (Button i in this.List) { if (SlideBars != null) { if (SlideBars.ContainsKey(i.getButtonName())) { SlideBars[i.getButtonName()].LoadContent(); } } } }
public DebrisEmitter(ICanyonShooterGame game, string modelName, int maxInstanceCount, float minSize, float maxSize) : base(game, "debris emitter") { this.game = game; this.modelName = modelName; this.minSize = minSize; this.maxSize = maxSize; if (maxInstanceCount > 50) { throw new Exception("Constants instancing doesn't support more than 50 instances."); } instanceData = new Matrix[maxInstanceCount]; instances = new ITransformable[maxInstanceCount]; for (int i = 0; i < maxInstanceCount; i++) { instanceData[i] = Matrix.Identity; instances[i] = null; } Type = new DebrisEmitterTypeSphere(game, 100, 200); if (game.Graphics.Device != null) { LoadContent(); } }
/// <summary> /// loads this from a hud description file /// </summary> /// <param name="name">Which Hud file to load from.</param> public Hud(ICanyonShooterGame game, string name) : base(game as Game) { this.game = game; this.DrawOrder = (int)DrawOrderType.Hud; }
public bool AddScore(Score score, ICanyonShooterGame game, int difficulty, bool newnames) { //this.LoadFromFile(); if (highscores[difficulty].Count < MAX_COUNT) { if (newnames) { score.Playername = game.GameStates.Profil.CurrentProfil.Playername; } highscores[difficulty].Add(score); SortList(difficulty); } else { if (score.Highscore > highscores[difficulty][highscores[difficulty].Count - 1].Highscore) { if (newnames) { score.Playername = game.GameStates.Profil.CurrentProfil.Playername; ////ABÄNDERN } highscores[difficulty].Add(score); SortList(difficulty); highscores[difficulty].RemoveAt(highscores.Count - 1); } else { return(false); } } return(this.SaveToFile()); }
public HudBarControl(string name, GameTime gameTime, ICanyonShooterGame game, String text, SpriteFont font, String background, Vector2 pos, Vector2 size, float timeToLive, Anchor anchor, HUDEffectType effect) : base(name, gameTime, pos, pos, timeToLive, anchor, effect) { tc = new HudTextControl(name + "_text", gameTime, text, font, new Color(), pos, timeToLive, anchor, effect); sc = new HudSpriteControl(name + "_sprite", gameTime, game, size, background, pos, timeToLive, anchor, effect); Value = 100; }
private void SetCamera(ICanyonShooterGame game) { cam = new PerspectiveCamera(game); cam.Parent = this; cam.LocalPosition = new Vector3(0, 9, 24); cam.Fov = 90; }
/// <summary> /// Initializes a new instance of the <see cref="Item"/> class. /// </summary> /// <param name="game">The game.</param> /// <param name="itemDescription">The item description.</param> public Item(ICanyonShooterGame game, string itemDescription) : base(game, itemDescription) { this.game = game; // Load Weapon Description desc = game.Content.Load <ItemDescription>("Content\\Items\\" + itemDescription); switch (desc.NameValue) { case "HEALTH": SetModel("item_health"); break; case "SHIELD": SetModel("item_shield"); break; default: SetModel("item_health"); break; } LocalScale = new Vector3(20, 20, 20); ConnectedToXpa = true; ContactGroup = ContactGroup.Items; InfluencedByGravity = false; TimeLiving = 0; if (game.Graphics.ShadowMappingSupported) { game.World.Sky.Sunlight.ShadowMapLow.Scene.AddDrawable(this); game.World.Sky.Sunlight.ShadowMapHigh.Scene.AddDrawable(this); } }
public StaticObject(ICanyonShooterGame game, StaticObjectDescription desc) : base(game, desc.Name) { this.game = game; StaticDescription sd = game.Content.Load <StaticDescription>("Content/Statics/" + desc.Name); SetModel(sd.Model); //TODO: Implement Position relative to canyon from XML Config (additive) DataLayer.Level.LevelCache c = game.World.Level.Cache[desc.SegmentId]; ContactGroup = Engine.Physics.ContactGroup.Statics; CanyonSegment = desc.SegmentId; // Get the position from current canyon segment LocalPosition = game.World.Level.Cache[desc.SegmentId].APos + sd.Position; Vector3 canyonDir = game.World.Level.Cache[desc.SegmentId].ADir; canyonDir.Normalize(); // Rotate the player to zero LocalRotation = Quaternion.Identity; LocalRotation = Helper.RotateTo(canyonDir, new Vector3(0, 0, -100)); //Velocity = Vector3.Zero; if (game.Graphics.ShadowMappingSupported) { game.World.Sky.Sunlight.ShadowMapLow.Scene.AddDrawable(this); game.World.Sky.Sunlight.ShadowMapHigh.Scene.AddDrawable(this); } }
public RenderTarget2DAdapter(ICanyonShooterGame game, int width, int height, int numberLevels, SurfaceFormat format, RenderTargetUsage usage, DepthFormat depthFormat) { this.game = game; CreateRenderTarget(format, width, height, numberLevels, usage); depthStencilBuffer = new DepthStencilBuffer(game.Graphics.Device, width, height, depthFormat, MultiSampleType.None, 0); }
/// <summary> /// Constructor of the Modelchooser /// </summary> public Chooser(ICanyonShooterGame game) : base(game as Game) { this.game = game; this.Visible = true; modelRotation = new Vector2(0, 0); }
/// <summary> /// Constructor for Including Score /// /// </summary> public Menu(ICanyonShooterGame game, string name, bool score) : base(game as Game) { assetName = "Config\\" + name + ".xml"; this.game = game; this.currentMenu = name; menuXml = game.Content.Load <MenuDescription>("Content\\Menu\\" + name); this.visible = true; this.isActive = true; steuerung = new MenuControl(this, game); //Erstellung des Hauptmenüs MainList Menu = new MainList(game, name, menuXml, true); CurrentList = Menu; shifts = Menu; this.scoring = score; if (score) { this.startscoring = true; this.score = game.GameStates.Score; } this.DrawOrder = (int)DrawOrderType.Menu; }
public PointLight(ICanyonShooterGame game, float r, float g, float b) : base(game as Game) { transformable = new Transformable(game, this, null); this.game = game; color = new Color(new Vector3(r, g, b)); }
private void InitializeShaderSelector(ICanyonShooterGame game) { // initialize shader selector shaderSelector = new ShaderSelector(game); shaderSelector.RegisterEffect("Color"); shaderSelector.RegisterEffect("ColorConstantsInstancing"); shaderSelector.RegisterEffect("ColorHardwareInstancing"); shaderSelector.RegisterEffect("Depth"); shaderSelector.RegisterEffect("DepthConstantsInstancing"); shaderSelector.RegisterEffect("DepthHardwareInstancing"); shaderSelector.RegisterEffect("Light"); shaderSelector.RegisterEffect("LightConstantsInstancing"); shaderSelector.RegisterEffect("LightHardwareInstancing"); shaderSelector.RegisterEffect("Shadow"); shaderSelector.RegisterEffect("ShadowConstantsInstancing"); shaderSelector.RegisterEffect("ShadowHardwareInstancing"); shaderSelector.RegisterEffect("Texture"); shaderSelector.RegisterEffect("TextureConstantsInstancing"); shaderSelector.RegisterEffect("TextureHardwareInstancing"); shaderSelector.RegisterEffect("Wireframe"); shaderSelector.RegisterEffect("WireframeConstantsInstancing"); shaderSelector.RegisterEffect("WireframeHardwareInstancing"); shaderSelector.RegisterEffect("NormalMapping"); shaderSelector.InitializeDepthShaders(); }
/// <summary> /// Initializes a new instance of the <see cref="WaypointObject"/> class. /// </summary> /// <param name="game">The game.</param> /// <param name="desc">The desc.</param> public WaypointObject(ICanyonShooterGame game, WaypointObjectDescription desc) : base(game, "Waypoint") { this.game = game; ConnectedToXpa = true; Static = true; SetModel(desc.Model); //game.GameStates.Profil. secondsToAdd = desc.TimeInSeconds; CanyonSegment = desc.SegmentId; DataLayer.Level.LevelCache c = game.World.Level.Cache[desc.SegmentId]; //Vector3 canyonPosition = new Vector3(c.APosX, c.APosY, c.APosZ); //Quaternion rotation = Helper.RotateTo(game.World.Level.Cache[desc.SegmentId].ADir, -Vector3.UnitZ); //LocalPosition = Vector3.Transform(desc.RelativeSpawnLocation, rotation) + canyonPosition; ContactGroup = Engine.Physics.ContactGroup.Waypoint; // Get the position from current canyon segment LocalPosition = game.World.Level.Cache[desc.SegmentId].APos; Vector3 canyonDir = game.World.Level.Cache[desc.SegmentId].ADir; canyonDir.Normalize(); // Rotate the player to zero LocalRotation = Quaternion.Identity; LocalRotation = Helper.RotateTo(canyonDir, new Vector3(0, 0, -100)); //Velocity = Vector3.Zero; if (game.Graphics.ShadowMappingSupported) { game.World.Sky.Sunlight.ShadowMapLow.Scene.AddDrawable(this); game.World.Sky.Sunlight.ShadowMapHigh.Scene.AddDrawable(this); } }
public PointLight(ICanyonShooterGame game, Color color) : base(game as Game) { transformable = new Transformable(game, this, null); this.game = game; this.color = color; }
public Finish(ICanyonShooterGame game) : base(game, "Final") { this.game = game; SetModel("Final"); LocalScale = new Vector3(10, 10, 10); }
/// <summary> /// /// </summary> /// <param name="game"></param> /// <param name="direction"></param> /// <param name="angle">half opening angle in degrees (180 -> sphere)</param> /// <param name="minVelocity"></param> /// <param name="maxVelocity"></param> public DebrisEmitterTypeCone(ICanyonShooterGame game, Vector3 direction, float angle, float minVelocity, float maxVelocity) : base(game) { Debug.Assert(!float.IsNaN(direction.X)); this.direction = direction; this.angleAsRadiants = MathHelper.ToRadians(angle); this.minVelocity = minVelocity; this.maxVelocity = maxVelocity; // compute a vector which is perpendicular to direction // find a direction which is NOT nearly colinear to direction (otherwise cross product will be too small) if (Math.Abs(Vector3.Dot(direction, new Vector3(1, 0, 0))) < 0.9f) { // use vector 1,0,0 perpendicularDirection = Vector3.Cross(direction, new Vector3(1, 0, 0)); } else { // use vector 0,1,0 perpendicularDirection = Vector3.Cross(direction, new Vector3(0, 1, 0)); } direction.Normalize(); perpendicularDirection.Normalize(); }
/// <summary> /// Ordinary constructor. /// </summary> /// <param name="game">The main CanyonShooter game object</param> public Ghost(ICanyonShooterGame game) : base(game, "PlayerElcode") { EnabledChanged += (Player2_EnabledChanged); // Set player profile values SetModel(game.GameStates.Profil.CurrentProfil.Model); BankingFactor = game.GameStates.Profil.CurrentProfil.Banking; DriftFactor = game.GameStates.Profil.CurrentProfil.Drift; TranslationGap = game.GameStates.Profil.CurrentProfil.Translation; RollFactor = game.GameStates.Profil.CurrentProfil.Rolling; MaxDecay = game.GameStates.Profil.CurrentProfil.Brake; AutoLevel = game.GameStates.Profil.CurrentProfil.AutoLevel; Health = game.GameStates.Profil.CurrentProfil.Health; MinSpeed = game.GameStates.Profil.CurrentProfil.Speed; Shield = game.GameStates.Profil.CurrentProfil.Shield; SpeedGap = game.GameStates.Profil.CurrentProfil.Acceleration; // Initialize player environment LocalPosition = new Vector3(0, 0, 0); ConnectedToXpa = true; ContactGroup = ContactGroup.None; InfluencedByGravity = false; this.game = game; //SetCamera(game); // Set sound listener for 3D sound listener = new SoundListener(game); game.Sounds.SoundListener = listener; }
public OrthographicCamera(ICanyonShooterGame game, int width, int height) : base(game) { this.width = width; this.height = height; MakeProjectionMatrix(); }
/// <summary> /// Constructor /// </summary> /// <param name="game">current Canyonshootergame</param> public Profil(ICanyonShooterGame game) : base(game as Game) { this.game = game; question = false; BildXml = game.Content.Load <ProfilDescription>("Content\\Profil\\" + "Profil"); ProfilXml = new List <ProfilProperties>(); GrafikList = new Dictionary <string, object>(); SoundList = new Dictionary <string, object>(); SteuerungList = new Dictionary <string, object>(); SpielereinstellungenList = new Dictionary <string, object>(); grafikDat = new Dictionary <string, string>(); soundDat = new Dictionary <string, string>(); steuerungDat = new Dictionary <string, string>(); spielereinstellungenDat = new Dictionary <string, string>(); namenKeysSound = new List <string>(); namenKeysGrafik = new List <string>(); namenKeysSteuerung = new List <string>(); namenKeysSpielereinstellungen = new List <string>(); this.Visible = true; steuerung = new ProfilControl(this, game); CurrentList = new ButtonList(game, BildXml); counter = 0; }
// Konstuktor // Dieser Konstruktor kann von außen nicht erreicht werden. public HSlideBar(ICanyonShooterGame game, Button but, Vector2 pos, float minValue, float maxValue, float Startvalue, float stepSize, int faktor, int cut) : base(game as Game) { this.game = game; this.caller = but; this.StartPosition = pos; this.factor = faktor; this.currentValue = Startvalue; this.maxValue = maxValue; this.minValue = minValue; this.stepSize = stepSize; this.ButtonHeightForContent = (int)Math.Ceiling((double)(but.Height - 8)); this.cut = cut; this.minus = new Button(game, "Minus", calculateRectangle(new Vector2(StartPosition.X, StartPosition.Y + 4), ButtonHeightForContent, ButtonHeightForContent), MinusImage, true, this); minus.Buttonpressed += new ActionEventHandler(MinusPressed); this.BarPosition = new Vector2(minus.Position.Right, minus.Position.Top + (minus.Position.Height / 2) - (BarHeight / 2)) + ButtonOffset; this.minPushPosition = this.BarPosition + new Vector2(6, 0); this.maxPushPosition = this.BarPosition + new Vector2(BarWidth - 6 - makerwidth, 0); this.PushLenght = maxPushPosition.X - minPushPosition.X; Vector2 pluspos = new Vector2(this.BarPosition.X + BarWidth, this.minus.Position.Y) + ButtonOffset; this.plus = new Button(game, "Plus", calculateRectangle(pluspos, ButtonHeightForContent, ButtonHeightForContent), PlusImage, true, this); plus.Buttonpressed += new ActionEventHandler(PlusPressed); calculatingMakerPos(Startvalue); barRec = calculateRectangle(new Vector2(this.BarPosition.X, BarPosition.Y - 5), 27, (int)(BarPosition.X + (int)(BarWidth - 6 - makerwidth)) - (int)(BarPosition.X + 6) + 19); }
public Dialog(ICanyonShooterGame game, OptionDescription xml, int district, Dictionary <string, object> Data, Dictionary <string, string> Format, List <string> Names) : base(game as Game) { this.game = game; this.xml = xml; this.Data = Data; this.Format = Format; this.Names = Names; this.district = district; this.visible = true; this.list = new OptionList(game, xml, district, Data, Format, Names, false, this); OptMod = new Dictionary <string, OptionModulationButton>(); SlideMod = new Dictionary <string, HSlideBar>(); int counter = Names.Count; foreach (Button g in this.list) { OptionModulationButton opt = getOptionModulationButton(g, Names[Names.Count - counter]); if (opt != null) { OptMod.Add(g.getButtonName(), opt); } else { HSlideBar hsb = getSlideBar(g, Names[Names.Count - counter]); if (hsb != null) { SlideMod.Add(g.getButtonName(), hsb); } } counter--; } foreach (OptionpartDescription i in xml.OptionParts) { if (i.Number == this.district) { this.Position = new Rectangle(game.Graphics.Device.Viewport.Width - 398 + (i.Position.X - 398), i.Position.Y, i.Position.Width, list.Height + i.Position.Height); this.startposition = new Vector2(game.Graphics.Device.Viewport.Width - 398 + (i.StartPosition.X - 398), i.StartPosition.Y); foreach (OptionButtonDescription g in i.Buttons) { if (g.ButtonName == "Akzeptieren") { accept = new Button(game, g.ButtonName, startposition, g.height, g.width, "OptionDialog\\" + g.ButtonImage, true, this); } else if (g.ButtonName == "Ablehnen") { decline = new Button(game, g.ButtonName, startposition, g.height, g.width, "OptionDialog\\" + g.ButtonImage, true, this); } } } } }
public Listbox(ICanyonShooterGame game, Vector2 pos, bool scroll, MenuDescription xml, int district, Dictionary <string, object> Data, Dictionary <string, string> Format, List <string> Names) : base(district) { this.isActive = true; this.visible = true; this.game = game; this.style = 1; this.Position = pos; this.scrollable = scroll; this.data = Data; this.BoxContentPosition = new Vector2(Position.X + 7, Position.Y + 30); this.BoxContentHeight = this.BoxHeight - 30 - 31; this.Titel = "Optionen: "; switch (difficulty) { case 0: this.Titel += "Spielereinstellungen"; break; case 1: this.Titel += "Grafik"; break; case 2: this.Titel += "Sound"; break; case 3: this.Titel += "Steuerung"; break; default: break; } //Building the Member for the Buttons and Scores this.List = new OptionList(game, game.Content.Load <OptionDescription>("Content\\Menu\\OptionMenu"), district, BoxContentPosition, Data, Format, Names, false, this); this.Buttons = new NormalList(game, ButtonPosition(xml), "OptionList", xml, true); this.Scrolling(); this.intializeScrollbar(); slideBars = new Dictionary <string, HSlideBar>(); int counter = Names.Count; foreach (Button g in this.List) { HSlideBar hsb = getSlideBar(g, Names[Names.Count - counter]); if (hsb != null) { slideBars.Add(g.getButtonName(), hsb); } counter--; } }