示例#1
0
        public clsDriverAI createDriverAI(clsCar car, Vector2 exitLocation)
        {
            clsDriverAI ai = new clsDriverAI(this, car, exitLocation);

            actors.Add((intActor)ai);
            return(ai);
        }
示例#2
0
        public clsDriverAI spawnCarAI(Vector2 worldLocation, Vector2 direction, Vector2 velocity, Vector2 destination)
        {
            clsCar      car = createCar(worldLocation, direction, velocity); // spanw car
            clsDriverAI AI  = createDriverAI(car, destination);              // create AI for the car

            return(AI);
        }
示例#3
0
        new public void update(float currentTime)
        {
            if (currentTime > nextSpawnTime)
            {
                // is it clear to spawn?
                if (this.worldToSpawnIn.getTileFromWorldLocation(this.location).worldObjects.Count <= 1)
                {
                    // get the next spawn time
                    nextSpawnTime = currentTime + worldToSpawnIn.random.Next(maxSpawnTime);

                    switch (this.spawnTypeName)
                    {
                    case "car":
                        Vector2 spawnLocation = randomizeVector(worldToSpawnIn, this.location);     // randomizes car location slightly

                        clsExit exit = null;
                        while (exit == null)
                        {
                            exit = (clsExit)worldToSpawnIn.getRandomWorldObject("exit");
                            if ((spawnLocation - exit.location).Length() < 300)
                            {
                                exit = null;
                            }
                        }

                        clsDriverAI driver = worldToSpawnIn.spawnCarAI(spawnLocation, this.direction, new Vector2(0, 0), exit.location);
                        driver.car.color = new Color(worldToSpawnIn.random.Next(0, 255), worldToSpawnIn.random.Next(0, 255), worldToSpawnIn.random.Next(0, 255));
                        break;
                    }
                    base.addForce(new Vector2(0, 0)); // not sure why we add no force
                }
            }

            // always apply physpics
            base.update(currentTime);
        }