Example #1
0
 public Unit(Vector3 Pos, Random r, HQ h)
     : this(r, h)
 {
     this.Pos = Pos;
     bounds = new Circle(Pos, (float)Math.Sqrt(0.5f*0.5f + 0.25f * 0.25f));
     viewCircle = new Circle(Pos, viewRadius);
     radioCircle = new Circle(Pos, radioRadius);
 }
Example #2
0
        public Unit(Random r, HQ h)
        {
            rand = r;
            setUpBehaviors();
            visibleObjects = new Buffer<GameObject>(20);
            radioObjects = new Buffer<GameObject>(20);
            inbox = new Buffer<Message>(20);
            outbox = new Buffer<Message>(20);

            headquarters = h;
            id = idCounter;
            idCounter++;
        }
Example #3
0
        private void initializeTeams(int teamCount)
        {
            for (int i = 0; i < teamCount; i++)
            {
                //This code initializes each team member in a circle
                //around their HQ

                float angle = i * MathHelper.TwoPi / teamCount;
                angle += MathHelper.PiOver4;

                Vector2 center = new Vector2(gridLength / 2, gridLength / 2);

                Vector2 teamSpawn = center + new Vector2((float)Math.Cos(angle) * (gridLength/2f) * 0.9f, (float)Math.Sin(angle) * (gridLength/2f) * 0.9f);
                HQ hq = new HQ(new Vector3(teamSpawn, 0), teamColors[i], rand, map);
                hqs.Add(hq);

                for (int j = 0; j < unitsPerTeam; j++)
                {
                    Vector2 spawnPoint = randomPointInCircle(teamSpawn, gridLength/20f);
                    Unit u = new Unit(new Vector3(spawnPoint, 0), rand, hqs[i]);
                    u.Map = map;
                    u.TeamColor = teamColors[i];
                    u.RotateTo(new Vector3(gridLength / 2f, gridLength / 2f, 0f));
                    units.Add(u);
                    hq.AddUnit(u);
                }
            }
        }