Exemple #1
0
        void timer_Tick(object sender, EventArgs e)
        {
            Color tribe = tribes[r.Next(0, tribes.Length)];

            int minAmount = 5;

            if (minAmount > playerSwarm.Members.Count / 2)
            {
                minAmount = 0;
            }

            int membersAmount = r.Next(minAmount, playerSwarm.Members.Count / 2);

            if (membersAmount >= 100)
            {
                membersAmount = 100;
            }

            foreach (Swarm swarm in swarms)
            {
                if (!swarm.PlayerControlled)
                {
                    if (swarm.Color == tribe)
                    {
                        swarm.AddMembers(membersAmount);
                        return;
                    }
                }
            }

            Swarm newSwarm = new Swarm(
                membersAmount,
                new PointF((float)r.Next(100, this.Width - 100), (float)r.Next(100, this.Height - 100)),
                tribe);

            swarms.Add(newSwarm);
        }
Exemple #2
0
        public GameForm()
            : base("Dewd", new Size(1024, 768), false)
        {
            InitializeGraphics();

            playerName = Utility.UserName;

            scores = new HighScoreTable(@"Data\HighScores.xml", 15);
            scores.Load();

            this.font = new Microsoft.DirectX.Direct3D.Font(this.Device, new System.Drawing.Font("Tahoma", 10));

            sprite = new Sprite(this.Device);
            texture = TextureLoader.FromFile(this.Device, @"Data\Graphics\dot.png");

            playerPosition = new PointF(this.Width / 2, this.Height / 2);

            playerSwarm = new Swarm(
                25,
                playerPosition,
                Color.Lime);

            playerSwarm.PlayerControlled = true;

            highestSwarm = 25;

            tribes = new Color[4]
            {
                Color.Black,
                Color.Crimson,
                Color.Orange,
                Color.Snow
            };

            this.swarms.Add(playerSwarm);

            timer = new Timer();
            timer.Interval = 5000;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Enabled = true;
            timer.Start();

            // defining our screen sized quad, note the Z value of 1f to place it in the background
            backgroundVertices[0].Position = new Vector4(0, 0, 1f, 1f);
            backgroundVertices[0].Color = System.Drawing.Color.SteelBlue.ToArgb();

            backgroundVertices[1].Position = new Vector4(this.ClientSize.Width, 0, 1f, 1f);
            backgroundVertices[1].Color = System.Drawing.Color.SteelBlue.ToArgb();

            backgroundVertices[2].Position = new Vector4(0, this.ClientSize.Height, 1f, 1f);
            backgroundVertices[2].Color = System.Drawing.Color.DarkSlateBlue.ToArgb();

            backgroundVertices[3].Position = new Vector4(this.ClientSize.Width, this.ClientSize.Height, 1f, 1f);
            backgroundVertices[3].Color = System.Drawing.Color.DarkSlateBlue.ToArgb();

            backgroundIndices = new short[] { 0, 1, 2, 1, 3, 2 };

            Utility.Timer(DirectXTimer.Start);

            timer_Tick(null, null);
            timer_Tick(null, null);
        }
Exemple #3
0
        void timer_Tick(object sender, EventArgs e)
        {
            Color tribe = tribes[r.Next(0, tribes.Length)];

            int minAmount = 5;

            if (minAmount > playerSwarm.Members.Count / 2)
                minAmount = 0;

            int membersAmount = r.Next(minAmount, playerSwarm.Members.Count / 2);

            if (membersAmount >= 100)
                membersAmount = 100;

            foreach (Swarm swarm in swarms)
            {
                if (!swarm.PlayerControlled)
                {
                    if (swarm.Color == tribe)
                    {
                        swarm.AddMembers(membersAmount);
                        return;
                    }
                }
            }

            Swarm newSwarm = new Swarm(
                membersAmount,
                new PointF((float)r.Next(100, this.Width - 100), (float)r.Next(100, this.Height - 100)),
                tribe);

            swarms.Add(newSwarm);
        }
Exemple #4
0
        public GameForm()
            : base("Dewd", new Size(1024, 768), false)
        {
            InitializeGraphics();

            playerName = Utility.UserName;

            scores = new HighScoreTable(@"Data\HighScores.xml", 15);
            scores.Load();

            this.font = new Microsoft.DirectX.Direct3D.Font(this.Device, new System.Drawing.Font("Tahoma", 10));

            sprite  = new Sprite(this.Device);
            texture = TextureLoader.FromFile(this.Device, @"Data\Graphics\dot.png");

            playerPosition = new PointF(this.Width / 2, this.Height / 2);

            playerSwarm = new Swarm(
                25,
                playerPosition,
                Color.Lime);

            playerSwarm.PlayerControlled = true;

            highestSwarm = 25;

            tribes = new Color[4]
            {
                Color.Black,
                Color.Crimson,
                Color.Orange,
                Color.Snow
            };

            this.swarms.Add(playerSwarm);

            timer          = new Timer();
            timer.Interval = 5000;
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Enabled  = true;
            timer.Start();

            // defining our screen sized quad, note the Z value of 1f to place it in the background
            backgroundVertices[0].Position = new Vector4(0, 0, 1f, 1f);
            backgroundVertices[0].Color    = System.Drawing.Color.SteelBlue.ToArgb();

            backgroundVertices[1].Position = new Vector4(this.ClientSize.Width, 0, 1f, 1f);
            backgroundVertices[1].Color    = System.Drawing.Color.SteelBlue.ToArgb();

            backgroundVertices[2].Position = new Vector4(0, this.ClientSize.Height, 1f, 1f);
            backgroundVertices[2].Color    = System.Drawing.Color.DarkSlateBlue.ToArgb();

            backgroundVertices[3].Position = new Vector4(this.ClientSize.Width, this.ClientSize.Height, 1f, 1f);
            backgroundVertices[3].Color    = System.Drawing.Color.DarkSlateBlue.ToArgb();

            backgroundIndices = new short[] { 0, 1, 2, 1, 3, 2 };

            Utility.Timer(DirectXTimer.Start);

            timer_Tick(null, null);
            timer_Tick(null, null);
        }