예제 #1
0
    public void BuildObject()
    {
        Scene currentScene = SceneManager.GetActiveScene();

        if (currentScene.name == "GameScene" || currentScene.name == "GameScene_ai")
        {
            GameManager._i.counterInc();
        }

        Vector3 pos = new Vector3(Random.Range(col.bounds.min.x, col.bounds.max.x),
                                  transform.position.y,
                                  Random.Range(col.bounds.min.z, col.bounds.max.z));

        GameObject newObj = gameObject;

        newObj = Instantiate(models[Random.Range(0, models.Length)], pos, transform.rotation);

        // Only convert BAD props to enemies
        if (newObj.tag == "BAD")
        {
            if (Random.Range(0, ENEMY_CHANCE_RECIPROCAL) == 0)
            {
                // Attach enemy script
                newObj.AddComponent <Enemy2>();
                Debug.Log("Enemy spawned!");
            }
        }

        // Set Colour
        Chute.col_ids colour = (Chute.col_ids)Random.Range(0, 6); // int rand is maximally exclusive
        newObj.GetComponent <Renderer>().material.color = Chute.getColour(colour);

        // Add wrapper if requested
        if (newObj.tag == "GOOD" && WRAPPED_CHANCE_RECIPROCAL >= 0)
        {
            if (Random.Range(0, WRAPPED_CHANCE_RECIPROCAL) == 0)
            {
                newObj.AddComponent <WrappingHandler>();
                //newObj.GetComponent<WrappingHandler>().SetColour(colour);
            }
        }

        // Attach Audio Effects
        newObj.AddComponent <FMODUnity.StudioEventEmitter>();
        var tmp = newObj.GetComponent <FMODUnity.StudioEventEmitter>();

        tmp.Event        = eventEmitter.Event;
        tmp.CollisionTag = eventEmitter.CollisionTag;
        tmp.PlayEvent    = eventEmitter.PlayEvent;
    }
예제 #2
0
 public static ClientChute Client(this Chute obj)
 {
     return((ClientChute)obj);
 }
예제 #3
0
 public Level(Chute chute, Obstacle obstacle, Curve difficulty)
 {
     _chute      = chute;
     _obstacle   = obstacle;
     _difficulty = difficulty;
 }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     chute        = GetComponent <Chute>();
     needNewSpawn = true;
 }