コード例 #1
0
ファイル: PuzzleTile.cs プロジェクト: chilscher/Cityscapes
    private float minBuildingScale  = 0.5f;  //the smallest size that a building will be relative to the highest size. So if this is 0.5, then a #1 building will be half the dimensions of a #3 building on a small city (where the max building size is 3)

    public void initialize(int solution, Transform parent, int maxValue, GameManager gameManager)
    {
        //create the PuzzleTile object, called by PuzzleGenerator
        this.solution    = solution;
        this.maxValue    = maxValue;
        this.gameManager = gameManager;

        background = transform.GetChild(0).GetComponent <SpriteRenderer>();
        road       = transform.GetChild(1).GetComponent <SpriteRenderer>();
        building   = transform.GetChild(2).GetComponent <SpriteRenderer>();
        number     = transform.GetChild(3).GetComponent <SpriteRenderer>();
        redBorder  = transform.GetChild(4).GetComponent <SpriteRenderer>();

        // pick a random tile rotation direction
        if (randomRotation)
        {
            int[] directions = new int[] { 0, 90, 180, 270 };
            int   r          = StaticVariables.rand.Next(4);
            building.transform.Rotate(new Vector3(0, 0, directions[r]));
        }
        //set colors and sprites from the current skin
        setNumberColors();
        building.sprite = gameManager.skin.buildingSprite;
        road.color      = InterfaceFunctions.getColorFromString(gameManager.skin.streetColor);
    }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: chilscher/Cityscapes
    private void createCorner(Vector2 p, float scale, int rot, Transform parent)
    {
        //add a street corner to the puzzle display. They serve no mechanical purpose and are just there to look nice
        GameObject corner = Instantiate(streetCorner);

        corner.transform.position    = p;
        corner.transform.localScale *= scale;
        corner.transform.Rotate(new Vector3(0, 0, rot));
        corner.transform.parent = parent;


        corner.GetComponent <SpriteRenderer>().color = InterfaceFunctions.getColorFromString(skin.streetColor);


        Vector3 pos = corner.transform.localPosition;

        pos.z = 0;
        corner.transform.localPosition = pos;
    }
コード例 #3
0
ファイル: SideHintTile.cs プロジェクト: chilscher/Cityscapes
    public void initialize(int hintValue)
    {
        //creates the sideHintTile. Here goes all of the code that defines the private variables used later
        this.hintValue = hintValue;
        background     = transform.GetChild(0).GetComponent <SpriteRenderer>();
        arrow          = transform.GetChild(1).GetComponent <SpriteRenderer>();
        number         = transform.GetChild(2).GetComponent <SpriteRenderer>();
        redBorder      = transform.GetChild(3).GetComponent <SpriteRenderer>();

        setNumberColors();
        addNumberToTile(hintValue);

        Skin tempSkin = StaticVariables.skin;

        if (StaticVariables.isTutorial)
        {
            tempSkin = StaticVariables.allSkins[0];
        }
        background.GetComponent <SpriteRenderer>().color = InterfaceFunctions.getColorFromString(tempSkin.streetColor);
    }