public BallCollision(BallActor a_Actor)
 {
     m_Actor = a_Actor;
     m_CheckMaxDisplacement = 25;
     m_UpdateMaxDisplacement = 25;
     UpdateCollision();
 }
示例#2
0
        protected override void Update(GameTime a_GameTime)
        {
            Input.Update();

            if (m_IsGameStarted == false)
            {
                if (Input.Gesture.GestureType == GestureType.Tap)
                {
                    MediaPlayer.Play(Audio.Song);
                    MediaPlayer.IsRepeating = true;
                    MediaPlayer.Volume = 0.1f;

                    m_IsGameStarted = true;
                }

                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.Space))
                {
                    m_IsGameStarted = true;
                }
            }
            else
            {
                ActorManager.Update(a_GameTime);
                ProjectileManager.Update(a_GameTime);
                EmitterManager.Update(a_GameTime);
                WeaponManager.Update(a_GameTime);
                CollisionManager.Update(a_GameTime);
                ScoreManager.Update(a_GameTime);

            #if WINDOWS
                if (Input.MulitKeyPressInput(Microsoft.Xna.Framework.Input.Keys.Q))
                {
                    selectedTile = new TileActor("Sprite/Tile_CopperFloor", Input.MousePosition - Camera.Position, false, false);
                }
                if (Input.MulitKeyPressInput(Microsoft.Xna.Framework.Input.Keys.W))
                {
                    selectedTile = new TileActor("Sprite/Tile_Copper", Input.MousePosition - Camera.Position, true, false);
                }

                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.E))
                {
                    selectedTile = new TileActor("Sprite/Tile_CopperWall", Input.MousePosition - Camera.Position, true, false);
                }
                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.A))
                {
                    selectedTile = new TileActor("Sprite/Tile_MetalFloor", Input.MousePosition - Camera.Position, false, false);
                }
                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.S))
                {
                    selectedTile = new TileActor("Sprite/Tile_Metal", Input.MousePosition - Camera.Position, true, false);
                }
                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.D))
                {
                    selectedTile = new TileActor("Sprite/Tile_MetalWall", Input.MousePosition - Camera.Position, true, false);
                }
                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.R))
                {
                    selectedTile = new TileActor("Sprite/Tile_RockWall", Input.MousePosition - Camera.Position, true, true);
                }
                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.T))
                {
                    selectedTile = new AreaActor(Input.MousePosition - Camera.Position, (int)AreaType.Start);
                }
                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.G))
                {
                    selectedTile = new AreaActor(Input.MousePosition - Camera.Position, (int)AreaType.Finish);
                }
                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.F))
                {
                    selectedTile = new BallActor(Input.MousePosition - Camera.Position, (int)BallType.Bomb);
                }
                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.Y))
                {
                    selectedTile = new TurretActor(Input.MousePosition - Camera.Position, (int)TurretType.Standard);
                }

                if (selectedTile != null)
                {
                    selectedTile.Position = Input.MousePosition - Camera.Position;
                }

                if (selectedTile is TileActor && Input.MouseLeftDrag)
                {
                    ActorManager.SafeAdd(((TileActor)selectedTile).Clone());
                }

                if (selectedTile is BallActor && Input.MouseLeftPressed)
                {
                    ActorManager.SafeAdd(((BallActor)selectedTile).Clone());
                }

                if (selectedTile is TurretActor && Input.MouseLeftPressed)
                {
                    ActorManager.SafeAdd(((TurretActor)selectedTile).Clone());
                }

                if (selectedTile is AreaActor && Input.MouseLeftPressed)
                {
                    ActorManager.SafeAdd(((AreaActor)selectedTile).Clone());
                }

                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.F2))
                {
                    SaveFileDialog save = new SaveFileDialog();
                    save.Filter = "ASCII file (*.xml)|*.xml";
                    save.ShowDialog();

                    string path = save.FileName;
                    if (path == string.Empty) { return; }

                    List<Data.BaseActor> List = new List<Data.BaseActor>();
                    for (int loop = 0; loop < ActorManager.List.Count; loop++)
                    {
                        if (ActorManager.List[loop] is TileActor)
                        {
                            TileActor data = (TileActor)ActorManager.List[loop];
                            Data.TileActor temp = new Data.TileActor(data.FilePathToTexture, data.Position, data.IsCollidable, data.IsDestructable);
                            List.Add(temp);
                        }

                        if (ActorManager.List[loop] is BallActor)
                        {
                            BallActor data = (BallActor)ActorManager.List[loop];
                            Data.BallActor temp = new Data.BallActor(data.Position, (int)data.BallType);
                            List.Add(temp);
                        }

                        if (ActorManager.List[loop] is TurretActor)
                        {
                            TurretActor data = (TurretActor)ActorManager.List[loop];
                            Data.TurretActor temp = new Data.TurretActor(data.Position, (int)data.TurretType);
                            List.Add(temp);
                        }

                        if (ActorManager.List[loop] is AreaActor)
                        {
                            AreaActor data = (AreaActor)ActorManager.List[loop];
                            Data.AreaActor temp = new Data.AreaActor(data.Position, (int)data.AreaType);
                            List.Add(temp);
                        }
                    }

                    XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
                    xmlWriterSettings.Indent = true;

                    XmlWriter xmlWriter = XmlWriter.Create(path, xmlWriterSettings);
                    IntermediateSerializer.Serialize(xmlWriter, List, null);
                    xmlWriter.Close();
                }

                if (Input.SingleKeyPressInput(Microsoft.Xna.Framework.Input.Keys.F3))
                {
                    OpenFileDialog open = new OpenFileDialog();
                    open.Filter = "ASCII file (*.xml)|*.xml";
                    open.ShowDialog();

                    string path = open.FileName;
                    if (path == string.Empty) { return; }

                    XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();

                    XmlReader xmlReader = XmlReader.Create(path, xmlReaderSettings);
                    List<Data.BaseActor> tempList = IntermediateSerializer.Deserialize<List<Data.BaseActor>>(xmlReader, null);
                    xmlReader.Close();

                    for (int loop = 0; loop < tempList.Count; loop++)
                    {
                        if (tempList[loop] is Data.TileActor)
                        {
                            ActorManager.List.Add(new TileActor(tempList[loop].FilePathToTexture, tempList[loop].Position, tempList[loop].IsCollidable, tempList[loop].IsDestructable));
                        }

                        if (tempList[loop] is Data.BallActor)
                        {
                            Data.BallActor temp = (Data.BallActor)tempList[loop];
                            ActorManager.List.Add(new BallActor(temp.Position, (int)temp.BallType));
                        }

                        if (tempList[loop] is Data.TurretActor)
                        {
                            Data.TurretActor temp = (Data.TurretActor)tempList[loop];
                            ActorManager.List.Add(new TurretActor(temp.Position, (int)temp.TurretType));
                        }

                        if (tempList[loop] is Data.AreaActor)
                        {
                            Data.AreaActor temp = (Data.AreaActor)tempList[loop];
                            ActorManager.List.Add(new AreaActor(temp.Position, (int)temp.AreaType));
                        }
                    }
                }
            #endif
            }

            #if WINDOWS
            float speed = 5;

            if (Input.MulitKeyPressInput(Microsoft.Xna.Framework.Input.Keys.Down))
            {
                Camera.Position += new Vector2(0, -speed);
            }
            if (Input.MulitKeyPressInput(Microsoft.Xna.Framework.Input.Keys.Up))
            {
                Camera.Position += new Vector2(0, speed);
            }
            if (Input.MulitKeyPressInput(Microsoft.Xna.Framework.Input.Keys.Right))
            {
                Camera.Position += new Vector2(-speed, 0);
            }
            if (Input.MulitKeyPressInput(Microsoft.Xna.Framework.Input.Keys.Left))
            {
                Camera.Position += new Vector2(speed, 0);
            }
            #endif

            base.Update(a_GameTime);
        }