Exemple #1
0
        /// <summary>
        /// Spawns a truck at a given starting location, with a set target location as well as a type and amount of stock to carry
        /// </summary>
        /// <param name="startingX">X value of starting location</param>
        /// <param name="startingZ">Z value of starting location</param>
        /// <param name="targetX">X value of target location</param>
        /// <param name="targetZ">Z value of target location</param>
        /// <param name="stockType">Type of stock the truck is carrying</param>
        /// <param name="stockCount">Amount of stock the truck is carrying</param>
        public void SpawnTruck(float startingX, float startingZ, float targetX, float targetZ, cStock.StockType stockType, int stockCount)
        {
            oEntity newEntity;

            newEntity = new oEntity("Truck");
            newEntity.AddComponent(new cTransform(new Vector3(startingX, 0, startingZ), new Vector3(1.5708f, 0, 0), new Vector3(0.5f, 0.25f, 0.25f)));
            newEntity.AddComponent(new cGeometry("Shape Geometries/SquareGeometry.txt"));
            newEntity.AddComponent(new cTexture("Sprite Textures/Trock.fw.png"));
            newEntity.AddComponent(new cShader());
            newEntity.AddComponent(new cAI(new Vector2(startingX, startingZ), new Vector3(startingX, 0, startingZ), new Vector2(targetX, targetZ), new Vector3(targetX, 0, targetZ)));
            newEntity.AddComponent(new cSpeed(2.0f));
            newEntity.AddComponent(new cStock(stockType, stockCount));
            MainEntry.entityManager.AddEntity(newEntity);
            MainEntry.systemManager.AssignNewEntity(newEntity);
            trucks.Add(newEntity);
        }
Exemple #2
0
        private void CreateEntities()
        {
            oEntity newEntity;

            //Random number generators for x and y co-ordinates
            Random rndX       = new Random();
            Random rndY       = new Random();
            Random rndColour  = new Random();
            int    carCounter = 0;

            //Randomly spawns cars around the map
            while (carCounter < 20)
            {
                //Generates random x and y co-ordinates
                int    x       = rndX.Next(0, MapLoader.mapX);
                int    y       = rndY.Next(0, MapLoader.mapY);
                int    colour  = rndColour.Next(0, 4);
                string texture = "";

                switch (colour)
                {
                case 0:
                {
                    texture = "Sprite Textures/RedCar.fw.png";
                    break;
                }

                case 1:
                {
                    texture = "Sprite Textures/GreenCar.fw.png";
                    break;
                }

                case 2:
                {
                    texture = "Sprite Textures/BlueCar.fw.png";
                    break;
                }

                case 3:
                {
                    texture = "Sprite Textures/YellowCar.fw.png";
                    break;
                }
                }

                if (MapLoader.map[x, y].Passable == true)
                {
                    //Randomly pathing cars
                    newEntity = new oEntity("Car");
                    newEntity.AddComponent(new cTransform(new Vector3(x, 0, y), new Vector3(1.5708f, 0, 0), new Vector3(0.3f, 0.2f, 0.25f)));
                    newEntity.AddComponent(new cGeometry("Shape Geometries/SquareGeometry.txt"));
                    newEntity.AddComponent(new cTexture(texture));
                    newEntity.AddComponent(new cShader());
                    newEntity.AddComponent(new cAI(new Vector2(x, y), new Vector3(x, 0, y)));
                    newEntity.AddComponent(new cSpeed(3.0f));
                    MainEntry.entityManager.AddEntity(newEntity);
                    MainEntry.systemManager.AssignNewEntity(newEntity);

                    carCounter++;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Spawns a randomly coloured car at a random passable node on the map
        /// </summary>
        public void SpawnRandomCar()
        {
            oEntity newEntity;
            bool    carSpawned = false;

            while (carSpawned != true)
            {
                //Random number generators for x and y co-ordinates
                Random rndX      = new Random();
                Random rndY      = new Random();
                Random rndColour = new Random();

                //Generates random x and y co-ordinates
                int    x       = rndX.Next(0, MapLoader.mapX);
                int    y       = rndY.Next(0, MapLoader.mapY);
                int    colour  = rndColour.Next(0, 4);
                string texture = "";

                switch (colour)
                {
                case 0:
                {
                    texture = "Sprite Textures/RedCar.fw.png";
                    break;
                }

                case 1:
                {
                    texture = "Sprite Textures/GreenCar.fw.png";
                    break;
                }

                case 2:
                {
                    texture = "Sprite Textures/BlueCar.fw.png";
                    break;
                }

                case 3:
                {
                    texture = "Sprite Textures/YellowCar.fw.png";
                    break;
                }
                }

                //Checks if node location is passable
                if (MapLoader.map[x, y].Passable == true)
                {
                    //Randomly pathing cars
                    newEntity = new oEntity("Car");
                    newEntity.AddComponent(new cTransform(new Vector3(x, 0, y), new Vector3(1.5708f, 0, 0), new Vector3(0.3f, 0.2f, 0.25f)));
                    newEntity.AddComponent(new cGeometry("Shape Geometries/SquareGeometry.txt"));
                    newEntity.AddComponent(new cTexture(texture));
                    newEntity.AddComponent(new cShader());
                    newEntity.AddComponent(new cAI(new Vector2(x, y), new Vector3(x, 0, y)));
                    newEntity.AddComponent(new cSpeed(3.0f));
                    MainEntry.entityManager.AddEntity(newEntity);
                    MainEntry.systemManager.AssignNewEntity(newEntity);

                    carSpawned = true;
                }
            }
        }