コード例 #1
0
    public TowerNode(TowerBlueprint tower)
    {
        height     = 300f;
        spacing    = 35f;
        colorBegin = "<color=#FF8000><b>";
        colorEnd   = "</b></color>";

        title       = tower.name;
        type        = tower.towertype;
        towerPrefab = tower.towerPrefab;
        range       = tower.range;
        dps         = tower.dps;
        attackRate  = tower.attackrate;
        cost        = tower.cost;
    }
コード例 #2
0
    public override void Draw(Rect rect, GUIStyle style)
    {
        GUIStyle textStyle = new GUIStyle();

        textStyle.richText = true;


        Rect baseRect = new Rect(10f, 30f, rect.size.x - 30f, 30f);

        textStyle.alignment = TextAnchor.MiddleCenter;
        EditorGUI.LabelField(baseRect, colorBegin + "TowerBlueprint" + colorEnd, textStyle);
        textStyle.alignment = TextAnchor.UpperLeft;

        float marginLeft  = 5f;
        float marginRight = marginLeft + 0f;

        title       = DrawStat("Title", baseRect, marginLeft, marginRight, spacing, title, textStyle);
        type        = DrawStat("Tower Type", baseRect, marginLeft, marginRight, 2 * spacing, type, textStyle);
        towerPrefab = DrawStat("Tower Prefab", baseRect, marginLeft, marginRight, 3 * spacing, towerPrefab, textStyle);
        range       = DrawStat("Range", baseRect, marginLeft, marginRight, 4 * spacing, range, true, GetTower().getMinRange(), GetTower().getMaxRange(), textStyle);
        dps         = DrawStat("Damage/Sec", baseRect, marginLeft, marginRight, 5 * spacing, dps, true, 0, GetTower().getMaxDPS(), textStyle);
        attackRate  = DrawStat("Attackrate", baseRect, marginLeft, marginRight, 6 * spacing, attackRate, true, 0.1f, 10f, textStyle);
        cost        = DrawStat("Tower Cost", baseRect, marginLeft, marginRight, 7 * spacing, cost, false, 0, 0, textStyle);
    }
コード例 #3
0
 private TowerBlueprint.TowerType DrawStat(string name, Rect rect, float marginLeft, float marginRight, float topOffset, TowerBlueprint.TowerType _type, GUIStyle _style)
 {
     GUI.Label(new Rect(rect.position.x + marginLeft, rect.position.y + topOffset, rect.size.x - marginRight, rect.size.y / 2f), colorBegin + name + colorEnd, _style);
     return((TowerBlueprint.TowerType)EditorGUI.EnumPopup(new Rect(rect.position.x + marginLeft, rect.position.y + topOffset + 15f, rect.size.x - marginRight, rect.size.y / 2f), _type));
 }