Ejemplo n.º 1
0
        public void BuildRoom()
        {
            // Game Objects
            this.objects = new Dictionary <byte, Dictionary <int, GameObject> > {
                [(byte)LoadOrder.Platform]     = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.Enemy]        = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.Item]         = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.TrailingItem] = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.Character]    = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.Projectile]   = new Dictionary <int, GameObject>()
            };

            // Object Coordination and Cleanup
            this.markedForAddition = new List <GameObject>();
            this.markedForRemoval  = new List <GameObject>();

            // Build Tilemap with Correct Dimensions
            short xCount, yCount;

            RoomGenerate.DetectRoomSize(Systems.handler.levelContent.data.rooms[roomID], out xCount, out yCount);

            this.tilemap = new TilemapLevel(xCount, yCount);

            // Additional Components
            this.colors      = new ColorToggles();
            this.trackSys    = new TrackSystem();
            this.roomExits   = new RoomExits();
            this.queueEvents = new QueueEvent(this);

            // Generate Room Content (Tiles, Objects)
            RoomGenerate.GenerateRoom(this, Systems.handler.levelContent, roomID);

            // Prepare the Full Track System
            this.trackSys.SetupTrackSystem();
        }
Ejemplo n.º 2
0
 private void Awake()
 {
     tracks = FindObjectOfType <TrackSystem>();
     if (selectionLine == null)
     {
         selectionLine = GetComponentInChildren <LineRenderer>();
     }
     if (cam == null)
     {
         cam = Camera.main;
     }
 }
Ejemplo n.º 3
0
        public static string Puzzle2(string input)
        {
            var ts = new TrackSystem(Common.ParseStringArray(input));

            for (int i = 0; i < 100000; i++)
            {
                ts.NextTick(out string crashCoordinates);
                if (ts.NumCarts == 1)
                {
                    return($"{ts.FirstCart.X},{ts.FirstCart.Y}");
                }
            }
            return($"No solution after 100000 ticks, still {ts.NumCarts} in system");
        }
        public void Update(float pSeconds)
        {
            Escape();

            IntroFinished();
            mController0.UpdateController();
            mController1.UpdateController();
            bool tankMoved = false;

            foreach (Player p in m_Teams)
            {
                tankMoved = tankMoved | p.DoTankControls(pSeconds);
            }

            m_World.Update(pSeconds);

            m_World.CollideAllTheThingsWithPlayArea(mPlayAreaRectangle);

            if (tankMoved)
            {
                tankMoveSound.Play();
            }
            else
            {
                tankMoveSound.Pause();
            }
            List <int> remainingTeamsList = remainingTeams();

            if (remainingTeamsList.Count <= 1)
            {
                int winner = -1;
                if (remainingTeamsList.Count == 1)
                {
                    winner = remainingTeamsList[0];
                }
                Reset();
                Tankontroller.Instance().SM().Transition(new GameOverScene(mBackgroundTexture, m_Teams, winner));
            }

            m_SecondsTillTracksAdded -= pSeconds;
            if (m_SecondsTillTracksAdded <= 0)
            {
                m_SecondsTillTracksAdded += SECONDS_BETWEEN_TRACKS_ADDED;
                TrackSystem trackSystem = TrackSystem.GetInstance();
                foreach (Player p in m_Teams)
                {
                    trackSystem.AddTrack(p.Tank.GetWorldPosition(), p.Tank.GetRotation(), p.Tank.Colour());
                }
            }
        }
Ejemplo n.º 5
0
        public static string Puzzle1(string input)
        {
            var    ts = new TrackSystem(Common.ParseStringArray(input));
            string crashCoordinate;

            for (int i = 0; i < 1000; i++)
            {
                ts.NextTick(out crashCoordinate);
                if (crashCoordinate != "")
                {
                    return(crashCoordinate);
                }
            }
            return("No crash in 1000 ticks");
        }
Ejemplo n.º 6
0
 private void Awake()
 {
     tracks   = FindObjectOfType <TrackSystem>();
     trackpos = Vector2Int.RoundToInt(new Vector2(transform.position.x, transform.position.z));
 }
Ejemplo n.º 7
0
 private void Awake()
 {
     rb          = GetComponent <Rigidbody>();
     trackSystem = GetComponent <TrackSystem>();
 }
        public void Draw(float pSeconds)
        {
            Tankontroller.Instance().GDM().GraphicsDevice.Clear(Color.CornflowerBlue);

            m_SpriteBatch.Begin();

            m_SpriteBatch.Draw(mBackgroundTexture, mBackgroundRectangle, Color.White);

            foreach (Player player in m_Teams)
            {
                if (player.GUI != null)
                {
                    player.GUI.Draw(m_SpriteBatch);
                }
            }

            m_SpriteBatch.Draw(mPixelTexture, mPlayAreaOutlineRectangle, Color.Black);
            m_SpriteBatch.Draw(mPixelTexture, mPlayAreaRectangle, DGS.Instance.GetColour("COLOUR_GROUND"));

            TrackSystem.GetInstance().Draw(m_SpriteBatch);

            // bullet background
            int       bulletRadius = 10;
            int       radius       = bulletRadius + 2 * DGS.Instance.GetInt("PARTICLE_EDGE_THICKNESS");
            Rectangle bulletRect   = new Rectangle(0, 0, radius, radius);

            foreach (Player p in m_Teams)
            {
                List <Bullet> bullets = p.Tank.GetBulletList();
                foreach (Bullet b in bullets)
                {
                    bulletRect.X = (int)b.Position.X - radius / 2;
                    bulletRect.Y = (int)b.Position.Y - radius / 2;
                    m_SpriteBatch.Draw(m_BulletTexture, bulletRect, Color.Black);
                }
            }

            World.Particles.ParticleManager.Instance().Draw(m_SpriteBatch);

            // bullet colour
            bulletRect.Width  = bulletRadius;
            bulletRect.Height = bulletRadius;
            foreach (Player p in m_Teams)
            {
                List <Bullet> bullets = p.Tank.GetBulletList();
                foreach (Bullet b in bullets)
                {
                    bulletRect.X = (int)b.Position.X - bulletRadius / 2;
                    bulletRect.Y = (int)b.Position.Y - bulletRadius / 2;
                    m_SpriteBatch.Draw(m_BulletTexture, bulletRect, b.Colour);
                }
            }

            Rectangle trackRect = new Rectangle(0, 0, m_TankLeftTrackTexture.Width, m_TankLeftTrackTexture.Height / 15);

            float tankScale = (float)mPlayAreaRectangle.Width / (50 * 40);

            for (int i = 0; true; i++)
            {
                Tank t = m_World.GetTank(i);
                if (t == null)
                {
                    break;
                }
                if (t.Health() > 0)
                {
                    trackRect.Y = t.LeftTrackFrame() * m_TankLeftTrackTexture.Height / 15;
                    m_SpriteBatch.Draw(m_TankLeftTrackTexture, t.GetWorldPosition(), trackRect, t.Colour(), t.GetRotation(), new Vector2(m_TankBaseTexture.Width / 2, m_TankBaseTexture.Height / 2), tankScale, SpriteEffects.None, 0.0f);
                    trackRect.Y = t.RightTrackFrame() * m_TankLeftTrackTexture.Height / 15;
                    m_SpriteBatch.Draw(m_TankRightTrackTexture, t.GetWorldPosition(), trackRect, t.Colour(), t.GetRotation(), new Vector2(m_TankBaseTexture.Width / 2, m_TankBaseTexture.Height / 2), tankScale, SpriteEffects.None, 0.0f);
                    m_SpriteBatch.Draw(m_TankBaseTexture, t.GetWorldPosition(), null, t.Colour(), t.GetRotation(), new Vector2(m_TankBaseTexture.Width / 2, m_TankBaseTexture.Height / 2), tankScale, SpriteEffects.None, 0.0f);
                    if (t.Fired() == 0)
                    {
                        m_SpriteBatch.Draw(m_CannonTexture, t.GetCannonWorldPosition(), null, t.Colour(), t.GetCannonWorldRotation(), new Vector2(m_CannonTexture.Width / 2, m_CannonTexture.Height / 2), tankScale, SpriteEffects.None, 0.0f);
                    }
                    else
                    {
                        m_SpriteBatch.Draw(m_CannonFireTexture, t.GetCannonWorldPosition(), null, t.Colour(), t.GetCannonWorldRotation(), new Vector2(m_CannonTexture.Width / 2, m_CannonTexture.Height / 2), tankScale, SpriteEffects.None, 0.0f);
                    }
                }
                else
                {
                    m_SpriteBatch.Draw(m_TankBrokenTexture, t.GetWorldPosition(), null, t.Colour(), t.GetRotation(), new Vector2(m_TankBrokenTexture.Width / 2, m_TankBrokenTexture.Height / 2), tankScale, SpriteEffects.None, 0.0f);
                }
            }

            /*       Vector2 bulletOffset = new Vector2(m_BulletTexture.Width / 2, m_BulletTexture.Height / 2);
             *     foreach (Player p in m_Teams)
             *     {
             *         List<Bullet> bullets = p.Tank.GetBulletList();
             *         foreach (Bullet b in bullets)
             *         {
             *             m_SpriteBatch.Draw(m_BulletTexture, b.Position, null, p.Colour, 0, bulletOffset, 1f, SpriteEffects.None, 0.0f);
             *         }
             *     }
             */
            foreach (RectWall w in m_World.Walls)
            {
                w.DrawOutlines(m_SpriteBatch);
            }

            foreach (RectWall w in m_World.Walls)
            {
                w.Draw(m_SpriteBatch);
            }

            m_SpriteBatch.End();
        }
        // private Effect m_Shader;
        // private RenderTarget2D m_ShaderRenderTarget; // might not need this
        // private Texture2D m_ShaderTexture; // might not need this

        public GameScene()
        {
            Tankontroller game = (Tankontroller)Tankontroller.Instance();

            m_TankBaseTexture       = game.CM().Load <Texture2D>("Tank-B-05");
            m_TankBrokenTexture     = game.CM().Load <Texture2D>("BrokenTank");
            m_TankRightTrackTexture = game.CM().Load <Texture2D>("Tank track B-R");
            m_TankLeftTrackTexture  = game.CM().Load <Texture2D>("Tank track B-L");
            m_CannonTexture         = game.CM().Load <Texture2D>("cannon");
            m_CannonFireTexture     = game.CM().Load <Texture2D>("cannonFire");
            m_BulletTexture         = game.CM().Load <Texture2D>("circle");
            mPlayAreaTexture        = game.CM().Load <Texture2D>("playArea");
            mPixelTexture           = game.CM().Load <Texture2D>("block");
            TrackSystem.SetupStaticMembers(game.CM().Load <Texture2D>("track"));
            TeamGUI.SetupStaticTextures(
                game.CM().Load <Texture2D>("port1"),
                game.CM().Load <Texture2D>("port2"),
                game.CM().Load <Texture2D>("port3"),
                game.CM().Load <Texture2D>("port4"),
                game.CM().Load <Texture2D>("port5"),
                game.CM().Load <Texture2D>("port6"),
                game.CM().Load <Texture2D>("port7"),
                game.CM().Load <Texture2D>("port8"));

            JackIcon.SetupStaticTextures(
                game.CM().Load <Texture2D>("leftTrackForward"),
                game.CM().Load <Texture2D>("leftTrackBackwards"),
                game.CM().Load <Texture2D>("rightTrackForward"),
                game.CM().Load <Texture2D>("rightTrackBackwards"),
                game.CM().Load <Texture2D>("fire"),
                game.CM().Load <Texture2D>("charge"),
                game.CM().Load <Texture2D>("none"),
                game.CM().Load <Texture2D>("turretLeft"),
                game.CM().Load <Texture2D>("turretRight"));
            PowerBar.SetupStaticTextures(game.CM().Load <Texture2D>("powerBar_border"),
                                         game.CM().Load <Texture2D>("powerBar_power"));

            m_CircleTexture = game.CM().Load <Texture2D>("circle");

            m_SpriteBatch = new SpriteBatch(game.GDM().GraphicsDevice);

            /*m_Shader = game.CM().Load<Effect>("shader");
             * m_ShaderRenderTarget = new RenderTarget2D(game.GDM().GraphicsDevice,
             *  game.GDM().GraphicsDevice.PresentationParameters.BackBufferWidth,
             *  game.GDM().GraphicsDevice.PresentationParameters.BackBufferHeight);
             * m_ShaderTexture = new Texture2D(game.GDM().GraphicsDevice,
             *  game.GDM().GraphicsDevice.PresentationParameters.BackBufferWidth,
             *  game.GDM().GraphicsDevice.PresentationParameters.BackBufferHeight, false, m_ShaderRenderTarget.Format);
             */
            mBackgroundTexture        = game.CM().Load <Texture2D>("background_01");
            mBackgroundRectangle      = new Rectangle(0, 0, game.GDM().GraphicsDevice.Viewport.Width, game.GDM().GraphicsDevice.Viewport.Height);
            mPlayAreaRectangle        = new Rectangle(game.GDM().GraphicsDevice.Viewport.Width * 2 / 100, game.GDM().GraphicsDevice.Viewport.Height * 25 / 100, game.GDM().GraphicsDevice.Viewport.Width * 96 / 100, game.GDM().GraphicsDevice.Viewport.Height * 73 / 100);
            mPlayAreaOutlineRectangle = new Rectangle(mPlayAreaRectangle.X - 5, mPlayAreaRectangle.Y - 5, mPlayAreaRectangle.Width + 10, mPlayAreaRectangle.Height + 10);
            introMusicInstance        = game.ReplaceCurrentMusicInstance("Music/Music_intro", false);

            mController0 = Tankontroller.Instance().Controller0();
            mController1 = Tankontroller.Instance().Controller1();
            mController2 = Tankontroller.Instance().Controller2();
            mController3 = Tankontroller.Instance().Controller3();
            mController0.ResetJacks();
            mController1.ResetJacks();
            if (DGS.Instance.GetInt("NUM_PLAYERS") > 2)
            {
                mController2.ResetJacks();
                if (DGS.Instance.GetInt("NUM_PLAYERS") > 3)
                {
                    mController3.ResetJacks();
                }
            }

            //loopMusicInstance = game.GetSoundManager().GetLoopableSoundEffectInstance("Music/Music_loopable");  // Put the name of your song here instead of "song_title"
            // game.ReplaceCurrentMusicInstance("Music/Music_loopable", true);
            tankMoveSound = game.GetSoundManager().GetLoopableSoundEffectInstance("Sounds/Tank_Tracks");  // Put the name of your song here instead of "song_title"

            if (DGS.Instance.GetInt("NUM_PLAYERS") < 4)
            {
                setupNot4Player(mPlayAreaRectangle);
            }
            else
            {
                setup4Player(mPlayAreaRectangle);
            }
            foreach (Player p in m_Teams)
            {
                m_World.AddTank(p.Tank);
            }
        }
Ejemplo n.º 10
0
 private void Awake()
 {
     trackSystem = GetComponent <TrackSystem>();
 }