public void SpawnCollectable()
    {
        Debug.Log("Try Spawn");
        SimpleMovingObject smo = (SimpleMovingObject)Instantiate(Resources.Load <SimpleMovingObject>("Obstacles/Collectables/Collectable"));

        smo.transform.position = new Vector3(spawnSpot.transform.position.x, spawnSpot.transform.position.y + Random.Range(smo.spawnOffset.x, smo.spawnOffset.y), 0); //position is relative to spawnspot with an additional offset
        smo.gameManager        = this;
    }
    public void SpawnBuilding()
    {
        int buildingNumber     = Random.Range(1, 6);
        SimpleMovingObject smo = (SimpleMovingObject)Instantiate(Resources.Load <SimpleMovingObject>("Obstacles/Buildings/Building_" + buildingNumber));

        smo.transform.position = new Vector3(spawnSpot.transform.position.x, smo.transform.position.y, 0);
        smo.gameManager        = this;
        buildingCount         += 1;
        timer = 0;
    }
 public void SpawnDynamic()
 {
     if (Random.Range(0f, 1f) > (0.95f - (float)buildingCount / 20))
     {
         int buildingNumber     = Random.Range(1, 4);
         SimpleMovingObject smo = (SimpleMovingObject)Instantiate(Resources.Load <SimpleMovingObject>("Obstacles/Dynamic/HeliCroco_" + buildingNumber));
         smo.transform.position = new Vector3(spawnSpot.transform.position.x, spawnSpot.transform.position.y + Random.Range(smo.spawnOffset.x, smo.spawnOffset.y), 0); //position is relative to spawnspot with an additional offset
         smo.gameManager        = this;
         buildingCount          = 0;
     }
 }
Beispiel #4
0
        public void LinearMotion()
        {
            var testCase = (Action <Vector, int, Point>) delegate(Vector vel, int nsteps, Point end) {
                var instance = new SimpleMovingObject(0, 0);
                instance.Velocity = vel;
                for (int i = 0; i < nsteps; i++)
                {
                    instance.OnBeginStep();
                }
                Assert.Equal(0, (end - instance.Location).Magnitude, 10);
            };

            testCase(new Vector(1, 0), 1000, new Point(1000, 0));
            testCase(new Vector(Math.Sqrt(2), Angle.Deg(45)), 1000, new Point(1000, 1000));
            testCase(new Vector(4, 4), 1000, new Point(4000, 4000));
            testCase(new Vector(1.1, 0), 1000, new Point(1100, 0));
        }