Exemplo n.º 1
0
    public virtual void Awake()
    {
        _inventory = GetComponent <InventoryController>();
        _placer    = GetComponent <TilePlacer>();

        //load();
    }
Exemplo n.º 2
0
    /* Здесь такое вроде не нужно будет
     * public void SetOnClickListener(Predicate<string> onClickAction)
     * {
     *  button.onClick.AddListener(delegate { onClickAction(inputField.text); });
     * }
     */
    public void ShowDialog(string[] elements, string buttonText = "Ok")
    {
        TileEditor te = GameObject.FindObjectOfType <TileEditor>();

        if (te != null)
        {
            te.SetDefault();
        }
        TilePlacer tp = GameObject.FindObjectOfType <TilePlacer>();

        if (tp != null)
        {
            tp.CancelPlacing();
        }

        dialogCanvas.SetActive(true);
        scrollRect.content.sizeDelta        = new Vector2(0, 17 * elements.Length);
        contentText.rectTransform.sizeDelta = new Vector2(160 * 4, 16 * 5 * elements.Length);
        contentText.text = "";
        foreach (string elem in elements)
        {
            contentText.text += elem + "\n";
        }
        button.GetComponentInChildren <Text>().text = buttonText;
    }
    private void Start()
    {
        if (tilePlacer == null)
        {
            tilePlacer = GetComponentInChildren <TilePlacer>();
        }

        tilePlacer.roadSize = trackSize;

        if (IsFinite)
        {
            tilePlacer.GenerateFiniteTrack(tilePlacer.roadSize);
        }
        else
        {
            tilePlacer.SetupInfiniteGeneration(ScrollOverNextTiles, true, true, false);
        }

        for (int i = 0; i < tilePlacer.spawnedTiles.Length; i++)
        {
            curveTracker.AddCurve(ref progress, tilePlacer.spawnedTiles[i].progressCurve);
        }

        tilePlacer.isSetup = true;

        vehicle.transform.position  = curveTracker.GetPoint(0f);
        vehicle.transform.forward   = curveTracker.GetOrientedPoint(0f).forward;
        vehicle.transform.position += vehicle.transform.forward * 3f;
        vehicle.transform.position += vehicle.transform.up * 1f;
    }
Exemplo n.º 4
0
    // Blooms are great for making irregular, but roundish shapes like bodies of water
    public void BlockingExplosion(int x, int y, int level, TilePlacer spritePlacer)
    {
        if (Random.Range (0, level) < 1 || x < 0 || y < 0 || x >= this.width || y >= this.height) {
            return;
        }

        Tile tile = this.tileMap[x, y];

        if (tile.biome != this.getBiomeNumber() || tile.blocking || tile.path) {
            return;
        }

        if (tile.item == null) {
            tile.blocking = true;
            spritePlacer(x, y);
        }

        for (int i = -1; i <= 1; i++) {
            for (int j = -1; j <= 1; j++) {
                if (Random.Range(0, 10) > 3 && (j != 0 || i == 1)) {
                    BlockingExplosion(x + i, y + j, level - 1, spritePlacer);
                }
            }
        }
    }
Exemplo n.º 5
0
    // Blooms are great for making irregular, but roundish shapes like bodies of water
    public void BlockingExplosion(int x, int y, int level, TilePlacer spritePlacer)
    {
        if (Random.Range(0, level) < 1 || x < 0 || y < 0 || x >= this.width || y >= this.height)
        {
            return;
        }

        Tile tile = this.tileMap[x, y];

        if (tile.biome != this.getBiomeNumber() || tile.blocking || tile.path)
        {
            return;
        }

        if (tile.item == null)
        {
            tile.blocking = true;
            spritePlacer(x, y);
        }

        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (Random.Range(0, 10) > 3 && (j != 0 || i == 1))
                {
                    BlockingExplosion(x + i, y + j, level - 1, spritePlacer);
                }
            }
        }
    }
    void Awake()
    {
        EventManager.AddListener <KeyPressedEvent>(OnKeyPressed);

        tilePlacer     = FindObjectOfType <TilePlacer>();
        tileSwapper    = FindObjectOfType <TileSwapper>();
        uiRelatedStuff = FindObjectOfType <UIRelatedStuff>();
    }
Exemplo n.º 7
0
    void Start()
    {
        _tilePlacer = FindObjectOfType <TilePlacer>();
        ChangeLayer(1);
        SelectTile(1);

        UpdateTileRowPositions();
    }
Exemplo n.º 8
0
 private void FindObjectReferences()
 {
     tilePlacer        = FindObjectOfType <TilePlacer>();
     gameMode          = FindObjectOfType <GameMode>();
     foreGroundTilemap = GameObject.FindGameObjectWithTag("Drawing Tilemap").GetComponent <Collider2D>();
     levelLoader       = FindObjectOfType <LevelLoader>();
     stars             = GameObject.FindGameObjectsWithTag("Star");
     movingPlatforms   = GameObject.FindObjectsOfType <MovingPlatform>();
 }
    void Awake()
    {
        tilePlacer  = FindObjectOfType <TilePlacer>();
        levelLoader = FindObjectOfType <LevelLoader>();

        if (!levelLoader.isFromLevelLoader)
        {
            isBlank = true;
        }
    }
Exemplo n.º 10
0
    void Start()
    {
        mp = GetComponent<MarkerPlacer> ();
        tp = GetComponent<TilePlacer> ();
        am = GetComponent<AssetManager>();

        mp.enabled = false;
        tp.enabled = true;

        tp.SetCurrentTile("com.antimatterinc.darkxtiles.default:default_floor");
    }
Exemplo n.º 11
0
 // Perlin is faster than blooms and creates a maze-like structure, which is great for forests
 // blockingRatio: float between 0f and 1f; 1f is no blocking and 0f is all blocking
 // blockingSize: how large thick the walls of the maze are, recommended .2f
 public void PerlinGenerator(List <Tile> tiles, TilePlacer spritePlacer, float blockingRatio, float blockingSize)
 {
     foreach (Tile tile in tiles)
     {
         float noise = Mathf.PerlinNoise((float)tile.x * blockingSize, (float)tile.y * blockingSize);
         if (noise > blockingRatio && !tile.path && tile.item == null)
         {
             tile.blocking = true;
             spritePlacer(tile.x, tile.y);
         }
     }
 }
Exemplo n.º 12
0
    void Awake()
    {
        tilePlacer     = FindObjectOfType <TilePlacer>();
        levelLoader    = FindObjectOfType <LevelLoader>();
        uiRelatedStuff = FindObjectOfType <UIRelatedStuff>();
        backdrop       = GameObject.Find("Backdrop");

        tileSize = 5;

        xTiles = yTiles = 0;
        eventSystem.firstSelectedGameObject = xTilesIF.gameObject;
    }
Exemplo n.º 13
0
 void Start()
 {
     Input.simulateMouseWithTouches = false;
     tilePlacer = FindObjectOfType <TilePlacer>();
     vCam       = GetComponent <CinemachineVirtualCamera>();
     confiner   = GetComponent <CinemachineConfiner>();
     maxSize    = Mathf.Min(confiner.m_BoundingShape2D.bounds.extents.y, confiner.m_BoundingShape2D.bounds.extents.x * (1 / Camera.main.aspect)) * 0.99f;
     if (vCam != null && confiner != null)
     {
         cameraInitialSize = vCam.m_Lens.OrthographicSize;
         CalcCameraLimits();
     }
 }
Exemplo n.º 14
0
    public UIInputBox(Vector2 position)
    {
        TileEditor te = GameObject.FindObjectOfType <TileEditor>();

        te.SetDefault();
        TilePlacer tp = GameObject.FindObjectOfType <TilePlacer>();

        tp.CancelPlacing();

        dialogCanvas = GameObject.Instantiate(Resources.Load("Prefabs/InputBoxPrefab")) as GameObject;
        dialogCanvas.transform.position = new Vector3(position.x, position.y, 0);
        button     = dialogCanvas.GetComponentInChildren <Button>();
        inputField = dialogCanvas.GetComponentInChildren <InputField>();
        title      = dialogCanvas.GetComponentInChildren <Text>();
        HideDialog();
    }
Exemplo n.º 15
0
        public void ShowDialog()
        {
            TileEditor te = GameObject.FindObjectOfType <TileEditor>();

            te.SetDefault();
            TilePlacer tp = GameObject.FindObjectOfType <TilePlacer>();

            tp.CancelPlacing();

            List <string> fileNames = GetFilesList();

            dialogCanvas.SetActive(true);

            for (int i = 0; i < fileNames.Count; i++)
            {
                if (!buttons.ContainsKey(fileNames[i]))
                {
                    GameObject newButton = GameObject.Instantiate(Resources.Load("Prefabs/ButtonPrefab")) as GameObject;
                    newButton.transform.position = contentField.transform.position;

                    newButton.transform.position += new Vector3(0.06f, -i * 0.55f - 0.06f, 0);
                    newButton.GetComponent <RectTransform>().SetParent(contentField.transform);
                    newButton.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);

                    newButton.GetComponentInChildren <Text>().text = fileNames[i];

                    newButton.GetComponent <Button>().onClick.AddListener(delegate
                    {
                        ChooseLevelTask(newButton.GetComponentInChildren <Text>().text);
                    });
                    buttons.Add(fileNames[i], newButton);
                }
            }

            scrollRect.content.sizeDelta = new Vector2(0, (float)Math.Max(25 * fileNames.Count, 100.1));

            cancelButton.GetComponentInChildren <Text>().text = "Отмена";
            cancelButton.onClick.AddListener(CancelTask);
        }
Exemplo n.º 16
0
 // Perlin is faster than blooms and creates a maze-like structure, which is great for forests
 // blockingRatio: float between 0f and 1f; 1f is no blocking and 0f is all blocking
 // blockingSize: how large thick the walls of the maze are, recommended .2f
 public void PerlinGenerator(List<Tile> tiles, TilePlacer spritePlacer, float blockingRatio, float blockingSize)
 {
     foreach (Tile tile in tiles) {
         float noise = Mathf.PerlinNoise((float)tile.x * blockingSize, (float)tile.y * blockingSize);
         if (noise > blockingRatio && !tile.path && tile.item == null) {
             tile.blocking = true;
             spritePlacer(tile.x, tile.y);
         }
     }
 }
Exemplo n.º 17
0
 void Awake()
 {
     tileSwapper = FindObjectOfType <TileSwapper>();
     tilePlacer  = FindObjectOfType <TilePlacer>();
 }
Exemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     regions    = new MapRegions();
     renderer   = GetComponent <SpriteRenderer>();
     tilePlacer = FindObjectOfType <TilePlacer>();
 }
Exemplo n.º 19
0
 // Use this for initialization
 void Start()
 {
     cameraPos           = transform.position;
     cameraHeightCurrent = Camera.main.orthographicSize;
     tilePlacer          = FindObjectOfType <TilePlacer>();
 }
Exemplo n.º 20
0
 void Awake()
 {
     placer = this;
 }
 void Start()
 {
     uiRelatedStuff  = FindObjectOfType <UIRelatedStuff>();
     cameraBehaviour = FindObjectOfType <CameraBehaviour>();
     tilePlacer      = FindObjectOfType <TilePlacer>();
 }
 void Start()
 {
     tilePlacer = FindObjectOfType <TilePlacer>();
     isBlank    = true;
 }
Exemplo n.º 23
0
 void Awake()
 {
     instance = this;
 }