Exemple #1
0
    public void PressedCell(TileSetter tile)
    {
        if (!isActivated)
        {
            return;
        }

        cubeMaster.TrySetPlayerPos(tile.location, orientation);
    }
    // for funsies
    //private HashSet<Vector2> spawnerSet;ev

    // Start is called before the first frame update
    void Start()
    {
        main     = this;
        camera   = Camera.main.gameObject;
        player   = PlayerClass.main.gameObject;
        spawners = new List <SpawnerClass>();
        for (int i = 0; i < spritesToMatch.Count; i++)
        {
            spawners.Add(new SpawnerClass(spritesToMatch[i], enemiesToMatch[i]));
        }
        tm = this.gameObject.GetComponent <Tilemap>();
        Vector3Int starter = new Vector3Int(0, 0, 0);

        otherTiles = floorPillars.gameObject.GetComponent <TileSetter>();
        Vector3Int ender = new Vector3Int(otherTiles.getWidth() - 1, otherTiles.getHeight() - 1, 0);

        tm.BoxFill(ender, theFloor, starter.x, starter.y, ender.x, ender.y);
        width  = otherTiles.getWidth();
        height = otherTiles.getHeight();
        //Debug.Log(width);
        initialSpawnersLeft = spawnersLeft;
        for (int i = 0; i < height; i++)
        {
            genRowSpawners(i);
            //Debug.Log(i);
        }
        if (initialSpawnersLeft == spawnersLeft && initialSpawnersLeft > 0)
        {
            Vector3Int  v = new Vector3Int(width - 1, height - 1, 0);
            SpawnerTile t = chooseSpawner(v);
            spawnerTiles.Add(t);
            theSpawners.SetTile(v, t);
        }
        genWalls();
        int larger = Math.Max(width, height);

        camera.transform.position = new Vector3(width / 2.0f, height / 2.0f, -10);
        camera.GetComponent <Camera>().orthographicSize = (camScaling / 10.0f) * larger;
        Vector2[] thePoints = { new Vector2(-20, -20), new Vector2(width + 20, -20), new Vector2(width + 20, height + 20), new Vector2(-20, height + 20), new Vector2(-20, -20) };
        theWalls = GameObject.Find("Walls");
        theWalls.GetComponent <EdgeCollider2D>().points     = thePoints;
        theWalls.GetComponent <EdgeCollider2D>().edgeRadius = 20;
        if (TryGetComponent <RedDragonFloor>(out RedDragonFloor rdf))
        {
            rdf.changeCamera(camera);
        }

        StartCoroutine("beAsleep");
    }
Exemple #3
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Ray        ray = Cam.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit))
         {
             TileSetter tile = hit.collider.GetComponent <TileSetter>();
             if (tile != null)
             {
                 tile.Press();
             }
         }
     }
 }
 void Start()
 {
     tileSetter = GameObject.Find("BuildingPlacer").GetComponent <TileSetter>();
     button     = GetComponent <Button>();
     button.onClick.AddListener(LoadToPlace);
 }