Esempio n. 1
0
 void ResearchReinforcedBuildings()
 {
     selectedObj      = inputScript.selectedObj;
     buildingScript   = selectedObj.GetComponent <BuildingController>();
     blacksmithScript = selectedObj.GetComponent <BlacksmithController>();
     blacksmithScript.ResearchReinforcedBuildings();
 }
Esempio n. 2
0
 void ResearchBasicArmourSmithing()
 {
     selectedObj      = inputScript.selectedObj;
     buildingScript   = selectedObj.GetComponent <BuildingController>();
     blacksmithScript = selectedObj.GetComponent <BlacksmithController>();
     blacksmithScript.ResearchBasicArmourSmithing();
 }
Esempio n. 3
0
 void ResearchArtisanWeaponSmithingButton()
 {
     selectedObj      = inputScript.selectedObj;
     buildingScript   = selectedObj.GetComponent <BuildingController>();
     blacksmithScript = selectedObj.GetComponent <BlacksmithController>();
     blacksmithScript.ResearchArtisanWeaponSmithing();
 }
Esempio n. 4
0
    private void Start()
    {
        currentScene     = SceneManager.GetActiveScene().name;
        healthController = healthControllerContainer.GetComponent <HealthController>();
        moneySystem      = moneySystemContainer.GetComponent <MoneySystem>();
        questManager     = questContainer.GetComponent <QuestManager>();
        menu             = menuContainer.GetComponent <PauseMenuScript>();
        blacksmith       = blacksmithContainer.GetComponent <BlacksmithController>();

        if (SaveWorker.SaveExists() && PlayerPrefs.GetString("newGame") == "false")
        {
            Load();
        }
        if (currentScene == "FirstScene")
        {
            PlayerPrefs.SetString("newGame", "false");
        }

        Save();
    }
Esempio n. 5
0
    // Left click controller
    public void LeftClick()
    {
        // Check for all selectable units in the game
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 350))
        {
            if (hit.collider.tag == "Ground" && (!Input.GetKey(KeyCode.LeftShift)))
            {
                DeselectUnits();
                UI.CloseAllPanels();
            }
            else if (hit.collider.tag == "Enemy Unit" && (!Input.GetKey(KeyCode.LeftShift)))
            {
                DeselectUnits();
                selectedObj  = hit.collider.gameObject;
                selectedInfo = selectedObj.GetComponent <UnitSelection>();
                unitScript   = selectedObj.GetComponent <UnitController>();

                selectedInfo.selected = true;
                //  OPEN ENEMY PANELS!!
                // UnitSelection indicators
                selectedObj.transform.GetChild(2).gameObject.GetComponent <Projector>().material.SetColor("_Color", Color.red);
                selectedObj.transform.GetChild(2).gameObject.SetActive(true);
                // unitAudio = selectedObj.GetComponent<AudioSource>();
                // unitAudio.clip = unitAudioClip;
                // unitAudio.Play();
                // isSelected = true;
                UI.EnemySelect();
            }
            else if (hit.collider.tag == "Selectable")
            {
                DeselectUnits();
                selectedObj = hit.collider.gameObject;
                if (!selectedObjects.Contains(selectedObj))
                {
                    selectedObjects.Add(selectedObj);
                }
                else
                {
                    selectedObjects.Remove(selectedObj);
                }

                selectedObj.transform.GetChild(2).gameObject.GetComponent <Projector>().material.SetColor("_Color", Color.green);
                selectedInfo = selectedObj.GetComponent <UnitSelection>();
                unitScript   = selectedObj.GetComponent <UnitController>();

                if (selectedInfo.selected == true)
                {
                    DeselectUnits();
                }
                else if (Input.GetKey(KeyCode.LeftShift))
                {
                    if (!unitScript.isDead)
                    {
                        selectedInfo.selected = true;

                        // UnitSelection indicators
                        selectedObj.transform.GetChild(2).gameObject.SetActive(true);
                        playerAudio.clip = unitAudioClip;
                        playerAudio.Play();
                        if (!unitScript.isDead)
                        {
                            isSelected = true;
                        }

                        if (unitScript.unitType == "Worker")
                        {
                            UI.WorkerSelect();
                        }
                        else if (unitScript.unitType == "Swordsman")
                        {
                            UI.SwordsmanSelect();
                        }
                        else if (unitScript.unitType == "Archer")
                        {
                            UI.ArcherSelect();
                        }
                        else if (unitScript.unitType == "Wizard")
                        {
                            UI.WizardSelect();
                        }
                        else if (unitScript.unitType == "Footman")
                        {
                            UI.FootmanSelect();
                        }
                    }
                }
                else
                {
                    if (!unitScript.isDead)
                    {
                        GameObject[] selectedIndicators = GameObject.FindGameObjectsWithTag("SelectedIndicator");
                        for (int j = 0; j < selectedIndicators.Length; j++)
                        {
                            selectedIndicators[j].transform.gameObject.SetActive(false);
                            selectedIndicators[j].transform.parent.GetComponent <UnitSelection>().selected = false;
                        }

                        selectedInfo.selected = true;

                        // UnitSelection indicators
                        selectedObj.transform.GetChild(2).gameObject.SetActive(true);
                        playerAudio.clip = unitAudioClip;
                        playerAudio.Play();
                        if (!unitScript.isDead)
                        {
                            isSelected = true;
                        }

                        if (unitScript.unitType == "Worker")
                        {
                            UI.WorkerSelect();
                        }
                        else if (unitScript.unitType == "Swordsman")
                        {
                            UI.SwordsmanSelect();
                        }
                        else if (unitScript.unitType == "Archer")
                        {
                            UI.ArcherSelect();
                        }
                        else if (unitScript.unitType == "Wizard")
                        {
                            UI.WizardSelect();
                        }
                        else if (unitScript.unitType == "Footman")
                        {
                            UI.FootmanSelect();
                        }
                    }
                }
            }
            else if (hit.collider.tag == "Enemy Unit" || hit.collider.tag == "Player 1" || hit.collider.tag == "Foundation" || hit.collider.tag == "Barracks" || hit.collider.tag == "House" || hit.collider.tag == "Resource" || hit.collider.tag == "Fort" || hit.collider.tag == "Blacksmith" || hit.transform.tag == "Stables")
            {
                UI.CloseAllPanels();
                if (selectedObjects.Count >= 0)
                {
                    DeselectUnits();
                }
                selectedObj = hit.collider.gameObject;

                if (selectedObj.tag == "Player 1")
                {
                    buildingScript = selectedObj.GetComponent <BuildingController>();

                    if (buildingScript.unitType == "Lumber Yard")
                    {
                        selectedObj.transform.GetChild(0).gameObject.SetActive(true);
                        UI.LumberYardSelect();
                    }
                    else if (buildingScript.unitType == "Town Hall")
                    {
                        selectedObj.transform.GetChild(0).gameObject.SetActive(true);
                        townHallScript = selectedObj.GetComponent <TownHallController>();
                        isTraining     = townHallScript.isTraining;
                        SwapProgressIcon();
                        if (isTraining)
                        {
                            UI.TownHallTraining();
                        }
                        else
                        {
                            UI.TownHallSelect();
                        }
                    }
                }
                else if (selectedObj.tag == "House")
                {
                    selectedObj.transform.GetChild(0).gameObject.SetActive(true);
                    UI.HouseSelect();
                }
                else if (selectedObj.tag == "Resource")
                {
                    selectedObj.transform.GetChild(0).gameObject.SetActive(true);
                    UI.ResourceSelect();
                }
                else if (selectedObj.tag == "Foundation")
                {
                    selectedObj.transform.GetChild(0).gameObject.SetActive(true);
                    foundationScript = selectedObj.GetComponent <FoundationController>();
                    isBuilding       = foundationScript.isBuilding;
                    if (isBuilding)
                    {
                        SwapProgressIcon();
                        UI.FoundationBuilding();
                    }
                    else
                    {
                        UI.FoundationSelect();
                    }
                }
                else if (selectedObj.tag == "Blacksmith")
                {
                    blacksmithScript = selectedObj.GetComponent <BlacksmithController>();
                    selectedObj.transform.GetChild(0).gameObject.SetActive(true);
                    isTraining = blacksmithScript.isTraining;
                    SwapProgressIcon();
                    if (isTraining)
                    {
                        UI.BlacksmithTraining();
                    }
                    else
                    {
                        UI.BlacksmithSelect();
                    }
                }
                else if (selectedObj.tag == "Barracks")
                {
                    selectedObj.transform.GetChild(0).gameObject.SetActive(true);
                    barracksScript = selectedObj.GetComponent <BarracksController>();
                    isTraining     = barracksScript.isTraining;
                    SwapProgressIcon();
                    if (isTraining)
                    {
                        UI.BarracksTraining();
                    }
                    else
                    {
                        UI.BarracksSelect();
                    }
                }
                else if (selectedObj.tag == "Stables")
                {
                    selectedObj.transform.GetChild(0).gameObject.SetActive(true);
                    UI.StablesSelect();
                }
            }
            else if (hit.collider.tag != "Selectable" && (!Input.GetKey(KeyCode.LeftShift)))
            {
                DeselectUnits();
                UI.CloseAllPanels();
            }
        }
    }