Exemplo n.º 1
0
    private void Awake()
    {
        Panels      = new Dictionary <string, GameObject>();
        UIbackgroud = Resources.Load <Sprite>("Sprites/Stone") as Sprite;
        ArialFont   = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
        myGO        = new GameObject();
        resUI       = GetComponent <ResUI>();

        Canvas myCanvas;



        // Canvas

        myGO.name = "TestCanvas";
        myGO.AddComponent <Canvas>();

        myCanvas = myGO.GetComponent <Canvas>();
        myGO.AddComponent <CanvasScaler>();
        myGO.AddComponent <GraphicRaycaster>();
        myCanvas.renderMode = RenderMode.ScreenSpaceOverlay;

        // vytvori eventsystem k fungovani tlacitka
        GameObject listener = new GameObject("EventSystem", typeof(EventSystem));

        listener.AddComponent <StandaloneInputModule>();
        listener.AddComponent <BaseInput>();
    }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     resUI          = GetComponent <ResUI>();
     camera         = GetComponentInParent <Camera>();
     gameControls   = GetComponent <GameControls>();
     repairBuilding = GetComponent <RepairBuilding>();
 }
Exemplo n.º 3
0
    void Start()
    {
        resUI          = GetComponent <ResUI>();
        ui             = GetComponent <UI>();
        HospitalPanel  = new GameObject();
        HospitalText   = new GameObject();
        HospitalButton = new GameObject();


        ui.CreatePanel(
            HospitalPanel,
            "HospitalPanel",
            ui.myGO,
            ui.UIbackgroud,
            0.5f,
            new Vector3(0f, 0f, 0f),
            new Vector2(0.30f, 0.30f),
            new Vector2(0f, 0f),
            new Vector2(0f, 0f),
            new Vector2(0f, 0f),
            new Vector2(0f, 0f),
            ui);

        ui.createButton(HospitalButton,
                        HospitalPanel,
                        "WorkerButton",
                        new Vector3(0f, 0f, 0f),
                        new Vector2(1f, 1f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f));

        HospitalButton.GetComponent <Button>().onClick.AddListener(() => { Heal(); });

        ui.CreateText(HospitalText,
                      HospitalButton,
                      "Heal Cost per Unit " +
                      " 10W " +
                      "10G",
                      ui.ArialFont,
                      new Vector2(1f, 1f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f)
                      );
    }
Exemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        resUI        = GetComponent <ResUI>();
        ui           = GetComponent <UI>();
        mainBuilding = GetComponent <MainBuilding>();

        BarracksPanel = new GameObject();

        WarriorButton = new GameObject();
        WarriorText   = new GameObject();

        RangeUnitButton = new GameObject();
        RangeUnitText   = new GameObject();

        ui.CreatePanel(
            BarracksPanel,
            "BarracksPanel",
            ui.myGO,
            ui.UIbackgroud,
            0.5f,
            new Vector3(0f, 0f, 0f),
            new Vector2(0.30f, 0.30f),
            new Vector2(0f, 0f),
            new Vector2(0f, 0f),
            new Vector2(0f, 0f),
            new Vector2(0f, 0f),
            ui);

        ui.createButton(WarriorButton,
                        BarracksPanel,
                        "WarriorButton",
                        new Vector3(0f, 0f, 0f),
                        new Vector2(0.5f, 1f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f));

        WarriorButton.GetComponent <Button>().onClick.AddListener(() => { mainBuilding.RecruitUnit(GetComponent <Prefabs>().ListOFUnits["Warrior"]); });

        ui.createButton(RangeUnitButton,
                        BarracksPanel,
                        "RangeUnitButton",
                        new Vector3(0f, 0f, 0f),
                        new Vector2(1f, 1f),
                        new Vector2(0.5f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f));

        RangeUnitButton.GetComponent <Button>().onClick.AddListener(() => { mainBuilding.RecruitUnit(GetComponent <Prefabs>().ListOFUnits["RangeUnit"]); });

        ui.CreateText(WarriorText,
                      WarriorButton,
                      "Warrior " +
                      " 50W " +
                      "100G",
                      ui.ArialFont,
                      new Vector2(1f, 1f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f)
                      );

        ui.CreateText(RangeUnitText,
                      RangeUnitButton,
                      "Range Unit " +
                      " 100W " +
                      "50G",
                      ui.ArialFont,
                      new Vector2(1f, 1f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f)
                      );
    }
Exemplo n.º 5
0
    void Start()
    {
        resUI                = GetComponent <ResUI>();
        ui                   = GetComponent <UI>();
        MainBuildingPanel    = new GameObject();
        MainBuildingSubPanel = new GameObject();
        WorkerButton         = new GameObject();
        TextWorkerButton     = new GameObject();

        SoldierButton     = new GameObject();
        TextSoldierButton = new GameObject();

        ui.CreatePanel(
            MainBuildingPanel,
            "MainBuildingPanel",
            ui.myGO,
            ui.UIbackgroud,
            0.5f,
            new Vector3(0f, 0f, 0f),
            new Vector2(0.30f, 0.30f),
            new Vector2(0f, 0f),
            new Vector2(0f, 0f),
            new Vector2(0f, 0f),
            new Vector2(0f, 0f),
            ui);

        ui.createButton(WorkerButton,
                        MainBuildingPanel,
                        "WorkerButton",
                        new Vector3(0f, 0f, 0f),
                        new Vector2(0.5f, 1f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f));

        WorkerButton.GetComponent <Button>().onClick.AddListener(() => { RecruitUnit(GetComponent <Prefabs>().ListOFUnits["Builder"]); });

        ui.createButton(SoldierButton,
                        MainBuildingPanel,
                        "SoldierButton",
                        new Vector3(0f, 0f, 0f),
                        new Vector2(1f, 1f),
                        new Vector2(0.5f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f),
                        new Vector2(0f, 0f));

        SoldierButton.GetComponent <Button>().onClick.AddListener(() => { RecruitUnit(GetComponent <Prefabs>().ListOFUnits["Soldier"]); });

        ui.CreateText(TextWorkerButton,
                      WorkerButton,
                      "Worker  10W  50G",
                      ui.ArialFont,
                      new Vector2(1f, 1f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f)
                      );

        ui.CreateText(TextSoldierButton,
                      SoldierButton,
                      "Peasant   10W  50G",
                      ui.ArialFont,
                      new Vector2(1f, 1f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f),
                      new Vector2(0f, 0f)
                      );
    }
Exemplo n.º 6
0
 void Awake()
 {
     ui    = GetComponent <UI>();
     resUI = GetComponent <ResUI>();
 }