Beispiel #1
0
    private void Start()
    {
        // Creating a container for the cave
        Transform container = (new GameObject("_Cave Container")).transform;

        container.SetParent(this.transform); // Append it to the game manager

        // Selecting a theme for our cave
        GroundTheme[] themes = this.subResource.FindResources <GroundTheme>().ToArray();
        GroundTheme   theme  = themes[UnityEngine.Random.Range(0, themes.Length)];

        // Instantiating the cave generator
        this.caveGenerator = new Cave(this.caveWidth, this.caveLength, 100, this.caveCell, container, theme);

        // Generate field and set skin
        this.caveGenerator.GenerateRectangularField(true);
        this.caveGenerator.Skin();

        // Prepare a protagonist
        foreach (Protagonist p in this.Prepare <Protagonist>(1, FieldCellType.Inner))
        {
            p.GameManager = this;
        }
        // Prepare food objects
        foreach (Food f in this.Prepare <Food>(this.foodRate, FieldCellType.Inner))
        {
            f.Cell = this.caveGenerator.FindCell(new IntVector2(f.transform.position));
        }
        // Prepare ammu boxes
        foreach (Ammu a in this.Prepare <Ammu>(this.ammuRate, FieldCellType.Inner))
        {
            a.Cell = this.caveGenerator.FindCell(new IntVector2(a.transform.position));
        }
        // Prepare antagonists
        foreach (Antagonist a in this.Prepare <Antagonist>(this.antagonistRate, FieldCellType.Inner))
        {
            a.GameManager = this;
        }

        // Adjust the camera position
        this.MoveCamera(this.SourceList <Protagonist>()[0].Position.ToVector2());
    }
Beispiel #2
0
 // Overriding the constructor
 public Cave(int width, int length, int fillRate, FieldCell cell, Transform container, GroundTheme theme)
     : base(width, length, fillRate, cell, container)
 {
     this.caveTheme = theme;
 }