コード例 #1
0
ファイル: KamidroneAI.cs プロジェクト: chrwoizi/canyonshooter
 private void InfoMessage(string message)
 {
     if (ShowEnemyInfo)
     {
         GraphicalConsole.GetSingleton(game).WriteLine(String.Format("Enemy{0}: {1}", EnemyNr, message), 0);
     }
 }
コード例 #2
0
ファイル: Ghost.cs プロジェクト: chrwoizi/canyonshooter
 /// <summary>
 /// Inflicts damage.
 /// </summary>
 /// <param name="value">The amount of damage.</param>
 public void ReceiveDamage(int value)
 {
     if (value < 0)
     {
         throw new Exception("Not allowed");
     }
     GraphicalConsole.GetSingleton(game).WriteLine(string.Format("You got {0} Damage!", value), 1);
     if (shield > 0)
     {
         int shieldDamage = (int)(value * shieldDamageAbsorbtion);
         int newShield    = shield - shieldDamage;
         if (newShield < 0)
         {
             int remaining = (int)(-newShield / shieldDamageAbsorbtion);
             health   -= remaining;
             newShield = 0;
         }
         shield = newShield;
     }
     else
     {
         health -= value;    // no shield, apply pure damage
     }
     // handle health-state
     if (health <= 0)
     {
         Explode();
         health = 0;
     }
 }
コード例 #3
0
        /// <summary>
        /// Adds the state to the AI Machine
        /// </summary>
        /// <param name="state">The state.</param>
        public void AddState(IAIState state)
        {
            States.Add(state.Name, state);
            if (States.Count == 1)
            {
                currentState = state.Name;
                lastState    = state.Name;
            }

            state.Manager = this;

            if (DebugAI)
            {
                GraphicalConsole.GetSingleton(game).WriteLine(
                    string.Format("AI-DEBUG:    Begin {0}.OnInit()", state.Name), 0);
            }

            States[state.Name].OnInit(); // Call OnExit()

            if (DebugAI)
            {
                GraphicalConsole.GetSingleton(game).WriteLine(
                    string.Format("AI-DEBUG:    End {0}.OnInit()", state.Name), 0);
            }
        }
コード例 #4
0
ファイル: World.cs プロジェクト: chrwoizi/canyonshooter
        private void ObjectTests()
        {
            // Items
            AddObject(new Item(game, "Health_Medium"));

            // static test

            /*Static static1 = new Static(game, "Rock");
             * static1.LocalPosition = new Vector3(50, -100, -1000);
             * AddObject(static1);
             *
             * Vector3[] positions = new Vector3[2];
             * Quaternion[] rotations = new Quaternion[2];
             * float[] scales = new float[2];
             * positions[0] = new Vector3(50, -100, -900);
             * positions[1] = new Vector3(50, -100, -1100);
             * rotations[0] = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), (float)Math.PI / 4);
             * rotations[1] = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), -(float)Math.PI / 4);
             * scales[0] = 0.5f;
             * scales[1] = 0.5f;
             * Statics statics1 = new Statics(game, 0, "Rocks", positions, rotations, scales, true);
             * AddObject(statics1);*/

            // debris test

            /*debris2 = new DebrisEmitter(game, "debrisTest", 50, 0.5f, 1.0f);
             * debris2.LocalPosition = new Vector3(50, 200, -1000);
             * debris2.Type = new DebrisEmitterTypeVolumeOOBB(game, new Vector3(100, 100, 200));
             * AddObject(debris2);
             * if (!Helper.Lock("Debris Test 2", TimeSpan.FromSeconds(15)))
             *  debris2.Emit(50);
             *
             * debris3 = new DebrisEmitter(game, "debrisTest", 20, 0.5f, 1.0f);
             * debris3.LocalPosition = new Vector3(-230, 0, -1000);
             * debris3.Type = new DebrisEmitterTypeCone(game, new Vector3(1, 0, 0), 10, 10, 50);
             * AddObject(debris3);
             * if (!Helper.Lock("Debris Test 3", TimeSpan.FromSeconds(15)))
             *  debris3.Emit(20);*/

            MovingPointLight light1 = new MovingPointLight(game, Color.Green, new Vector3(-100, 50, -400), new Vector3(150, 0, 0), Vector3.UnitY, 0.02f);

            AddPointLight(light1);
            components.Add(light1);
            MovingPointLight light2 = new MovingPointLight(game, new Color(150, 0, 0), new Vector3(100, 50, -400), new Vector3(-150, 0, 0), Vector3.UnitY, 0.02f);

            AddPointLight(light2);
            components.Add(light2);

            // physics test

            //            EnablePlayerPhysics();
            GraphicalConsole.GetSingleton(game).RegisterObjectFunction(this, "World", "EnablePlayerPhysics");

            if (game.Graphics.ShadowMappingSupported)
            {
                sky.Sunlight.ShadowMapLow.Scene.AddDrawable(canyon);
                sky.Sunlight.ShadowMapHigh.Scene.AddDrawable(player);
                sky.Sunlight.ShadowMapHigh.Scene.AddDrawable(canyon);
            }
        }
コード例 #5
0
ファイル: CameraBase.cs プロジェクト: chrwoizi/canyonshooter
 public void ZoomOut(float zoomLength)
 {
     if (LocalPosition.X != float.NaN)
     {
         LocalPosition -= this.Direction * zoomLength;
         GraphicalConsole.GetSingleton(game).WriteLine("Camera ZoomOut - Position:" + LocalPosition.ToString(), 0);
     }
 }
コード例 #6
0
 public void LoadLevel(string levelname)
 {
     if (File.Exists(string.Format("GameClasses\\World\\Levels\\{0}.csl", levelname)))
     {
         GameStates.SetStateGame(levelname);
     }
     else
     {
         GraphicalConsole.GetSingleton(this).WriteLine("Error: Level not found!", 0);
     }
 }
コード例 #7
0
ファイル: Intercom.cs プロジェクト: chrwoizi/canyonshooter
 public static void SendMessage(string message, bool speak)
 {
     if (Game != null)
     {
         GraphicalConsole.GetSingleton(Game).WriteLine(message, 1);
     }
     if (speak)
     {
         Thread speakThread = new Thread(SpeakInternal);
         speakThread.Start(message);
     }
 }
コード例 #8
0
 /// <summary>
 /// Sets the secondary weapon.
 /// </summary>
 /// <param name="type">The type.</param>
 public void SetSecondaryWeapon(WeaponType type)
 {
     if (weapons.ContainsKey(type))
     {
         if (primaryWeapon != weapons[type])
         {
             secondaryWeapon = weapons[type];
         }
         else
         {
             GraphicalConsole.GetSingleton(game).WriteLine(
                 string.Format("Weapon not avaible: {0}.", type.ToString()), 0);
         }
     }
 }
コード例 #9
0
        public void ChangeState(string name)
        {
            if (!States.ContainsKey(name))
            {
                GraphicalConsole.GetSingleton(game).WriteLine("AI-ERROR:    Can't find state: " + name, 0);
                return;
            }
            if (DebugAI)
            {
                GraphicalConsole.GetSingleton(game).WriteLine(
                    string.Format("AI-DEBUG:    Begin {0}.OnExit()", currentState), 0);
            }

            States[currentState].OnExit(); // Call OnExit()

            if (DebugAI)
            {
                GraphicalConsole.GetSingleton(game).WriteLine(
                    string.Format("AI-DEBUG:    End {0}.OnExit()", currentState), 0);
            }


            if (DebugAI)
            {
                GraphicalConsole.GetSingleton(game).WriteLine(
                    string.Format("AI-DEBUG:    {0} ---> {1}", currentState, name), 0);
            }


            // Change States
            lastState    = currentState;
            currentState = name;


            if (DebugAI)
            {
                GraphicalConsole.GetSingleton(game).WriteLine(
                    string.Format("AI-DEBUG:    Begin {0}.OnEnter()", currentState), 0);
            }

            States[currentState].OnEnter(); // Call OnEnter()

            if (DebugAI)
            {
                GraphicalConsole.GetSingleton(game).WriteLine(
                    string.Format("AI-DEBUG:    End {0}.OnEnter()", currentState), 0);
            }
        }
コード例 #10
0
        public void UpdateAI(GameTime gameTime)
        {
            this.gameTime = gameTime;

            if (DebugAI)
            {
                GraphicalConsole.GetSingleton(game).WriteLine(
                    string.Format("AI-DEBUG:    Begin {0}.Update()", currentState), 0);
            }

            States[currentState].Update();

            if (DebugAI)
            {
                GraphicalConsole.GetSingleton(game).WriteLine(
                    string.Format("AI-DEBUG:    End {0}.Update()", currentState), 0);
            }
        }
コード例 #11
0
        /// <summary>
        /// Assigns the weapon slot to the weapon defined by Weapontype type.
        /// Sets the specified position, rotation and scale
        /// </summary>
        /// <param name="type">The type.</param>
        private void AssignWeaponSlot(WeaponType type)
        {
            if (weaponHolder == null)
            {
                return;
            }

            // For rotating the weapons while aiming, we need a special Transformable that hold
            // the correct rotated weapon model.
            // With this, we are able to rotate the connector only.

            ITransformable weaponConnector = new Transformable(game);

            weaponConnector.Parent = weaponHolder;
            weapons[type].Parent   = weaponConnector;

            if (weaponHolder.WeaponSlots == null)
            {
                return;
            }

            bool success = false;

            foreach (WeaponSlot slot in weaponHolder.WeaponSlots)
            {
                if (slot.WeaponType == type)
                {
                    //Set start-location and rotation of each weapon on its specified slot.
                    weapons[type].LocalPosition = slot.Position;
                    weapons[type].LocalRotation =
                        Quaternion.CreateFromAxisAngle(slot.RotationAxis, slot.RotationAngle);
                    weapons[type].LocalScale = slot.Scaling;

                    success = true;
                    break;
                }
            }

            if (!success)
            {
                GraphicalConsole.GetSingleton(game).WriteLine("No WeaponSlot for weapon " + type + " in weapon holder " + weaponHolder.Name, 0);
            }
        }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CanyonShooterGame"/> class.
        /// </summary>
        public CanyonShooterGame(string[] args)
        {
            Args   = new Arguments(args);
            states = new GameStates(this, Components);
            config = new Config();
            graphicsDeviceManager = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);

            graphics          = new Graphics(this, graphicsDeviceManager);
            this.Window.Title = " CanyonShooter";

            Intercom.Game = this;

            #region Commandline Parameter Settings:

            #region Parameter: --setShaderModel

            if (Args["setShaderModel"] == "2")
            {
                graphics.ShaderModel3SupportedOverride = true;
            }
            #endregion

            #region Parameter: --debug

            if (Args["debug"] == "1")
            {
                debugMode = true;
            }
            #endregion

            #region Parameter: --multiThreaded
            // Physik Intialisierung

            /*if (Args["multiThreaded"] != null)
             * {
             *  if(Args["multiThreaded"] == "1")
             *      physics = new Physics(this, true);
             *  else
             *  {
             *      physics = new Physics(this, false);
             *      Components.Add(physics);
             *  }
             * }
             * else*/// automatically set threading-mode
            {
                /*if (Environment.ProcessorCount > 1)
                 * {
                 *  physics = new Physics(this, true);
                 * }
                 * else*/
                {
                    physics = new Physics(this, false);
                    Components.Add(physics);
                }
            }
            #endregion

            #region Parameter: --testAudio
            // Test Audio Framework *******************************
            if (Args["testAudio"] == "1")
            {
                TestAudioPlayback test1 = new TestAudioPlayback();
                test1.SetUp(this);
                test1.TestMinigunPlayback();
                test1.TearDown();

                TestAudio3D test2 = new TestAudio3D();
                test2.SetUp(this);
                test2.TestPlayback3D();
                test2.TearDown();
            }
            #endregion

            #endregion

            // Create sound system by M.Rodriguez
            sounds = new SoundSystem(this);

            // Set global volumes by M.Rodriguez
            sounds.EffectVolume = 1.0f;
            sounds.MusicVolume  = 0.3f;

            // Initialisieren der einzelnen Komponenten:
            input      = new Input(this);
            renderer   = new Renderer(this, Components);
            effects    = new EffectFactory(this);
            highscores = new Highscores(this);

            GraphicalConsole.GetSingleton(this).RegisterObjectProperty(graphics, "Graphics", "Fullscreen");

            GraphicalConsole.GetSingleton(this).RegisterObjectProperty(renderer, "Renderer", "DrawCollisionShapes");

            GraphicalConsole.GetSingleton(this).RegisterObjectFunction(Args, "Args", "ListParameters");
            if (Args["enable3DMouse"] == "1")
            {
                hasSpaceMouse = true;
                device        = new TDxInput.Device();
            }
            states.SetStateStart();

            // states.SetStateDebugMode();
        }
コード例 #13
0
ファイル: GameStates.cs プロジェクト: chrwoizi/canyonshooter
        public void SetStateGame(string levelname)
        {
            if (score != null)
            {
                score.Reset();
            }
            score = null;

            game.Graphics.ShadowMappingSupportedOverride = !profil.CurrentProfil.Shadow;
            game.Graphics.AllowFogShaders = profil.CurrentProfil.Fog;

            Reset();


            components.Add(game.Physics);

            game.Input.MouseMovement = new Vector2(0, 0);

            hud = new Hud(game, "test");
            components.Add(hud);
            components.Add(GraphicalConsole.GetSingleton(game));
            GraphicalConsole.GetSingleton(game).RegisterObjectFunction(game, "Game", "Exit");
            GraphicalConsole.GetSingleton(game).RegisterObjectFunction(game.Input, "Input", "Bind");

            GraphicalConsole.GetSingleton(game).WriteLine(string.Format("Loading Level: {0}", levelname), 0);
            game.World = new World(game, levelname, components);

            components.Add(game.World);


            GraphicalConsole.GetSingleton(game).RegisterObjectFunction(game, "Game", "LoadLevel");


            Cheats cheats = new Cheats(game);

            components.Add(cheats);
            GraphicalConsole.GetSingleton(game).RegisterObjectProperty(cheats, "OneBananaProblem", "GodMode");
            score = new Score();

            // set post processing
            game.Renderer.PostProcessType = PostProcessType.BloomAndBlur;

            game.Renderer.Camera = game.World.Players[0].Camera;
            inputFocus           = game.World;
            if (welcomeSound == null)
            {
                welcomeSound = game.Sounds.CreateSound("Welcome");
            }
            welcomeSound.Play();
            game.Sounds.MusicBox(MusicBoxStatus.Play);

            TrafficLight trafficLight = new TrafficLight(game, TrafficLightGreenCallback);

            trafficLight.LocalPosition = game.World.Players[0].GlobalPosition + new Vector3(0, 130, -200);
            trafficLight.CanyonSegment = 0;
            game.World.AddObject(trafficLight);
            trafficLight.Start();
            //Gameplayed = true;

            // player shall wait until the trafficLight shows green
            game.World.Players[0].Enabled = false;
        }