public void InitializePrograms()
 {
     try
     {
         DB        db   = Factory.Instance.Model.Data;
         MinerAlgo algo = null;
         foreach (MinerAlgo item in db.MinerAlgos)
         {
             if (item.Name == MainCoin.Algorithm.Name)
             {
                 //found the algo. check to see alredy configured miners
                 algo = item;
                 break;
             }
         }
         if (algo != null)
         {
             List <MinerProgram> programs = algo.MinerPrograms;
             //if (programs != null && programs.Count > 0)
             //{
             //at least 1 program is there
             Hashtable progs   = new Hashtable();
             Hashtable scripts = new Hashtable();
             foreach (MinerProgram item in programs)
             {
                 progs.Add(item.ProgramType, item);
             }
             foreach (MinerScript item in MinerData.MinerScripts)
             {
                 scripts.Add(item.ProgramType, item);
             }
             foreach (IMinerProgram item in MinerPrograms)
             {
                 MinerProgram p   = progs[item.Type] as MinerProgram;
                 MinerScript  scr = scripts[item.Type] as MinerScript;
                 if (p != null)
                 {
                     item.MinerEXE    = p.Exepath;
                     item.MinerFolder = p.ExeFolder;
                 }
                 if (scr != null)
                 {
                     item.BATFILE   = scr.BATfile;
                     item.BATCopied = scr.BATCopied;
                     item.AutomaticScriptGeneration = scr.AutomaticScriptGeneration;
                     if (scr.MiningIntensity != 0)
                     {
                         item.MiningIntensity = scr.MiningIntensity;
                     }
                     item.LoadScript();
                 }
             }
             //}
         }
     }
     catch (Exception e)
     {
     }
 }
Exemple #2
0
    private void GenerateMiner()
    {
        GameObject  newMiner = Instantiate(miner, getTopObject().transform.position, Quaternion.identity);
        MinerScript minerSc  = newMiner.GetComponent(typeof(MinerScript)) as MinerScript;

        minerSc.setDirection(getBottomObject().transform.position);
        RoadScript roadSc = GetComponent(typeof(RoadScript)) as RoadScript;

        minerSc.setRoadMovingOn(roadSc);
    }
Exemple #3
0
    public void UpdateMinerUI(MinerScript MinerScript)
    {
        GoldStorage.GetComponent <MeterScript>().SetMeter(MinerScript.Gold / MinerScript.maxGold);
        nameText.GetComponent <Text>().text = MinerScript.minerName;

        for (int i = 0; i < GameObject.Find("InfoPanel").transform.childCount; i++)
        {
            GameObject.Find("InfoPanel").transform.GetChild(i).gameObject.SetActive(false);
        }

        nameText.SetActive(true);
        GoldStorage.SetActive(true);
    }
Exemple #4
0
    // This function takes a Unit's UnitScript, makes it selected, and deselects any other units that were selected.
    // If null is passed in, it will just deselect everything.
    // This function also populates the nameText UI element with the currently selected unit's name, and also ensures
    // that the namePanel UI element is only active is a unit is selected.
    public void SelectUnit(GameObject SelectGameobject)
    {
        // Get an array of all GameObjects that have the tag "Unit".
        GameObject[] units = GameObject.FindGameObjectsWithTag("Unit");
        // Loop through all units and make sure they are not selected.
        if (units.Length > 0)
        {
            for (int i = 0; i < units.Length; i++)
            {
                UnitScript unitScript = units[i].GetComponent <UnitScript>();
                unitScript.selected = false;
                unitScript.UpdateVisuals();
            }
        }

        GameObject baseObj    = GameObject.FindGameObjectWithTag("Base");
        BaseScript baseScript = baseObj.GetComponent <BaseScript>();

        baseScript.selected = false;
        baseScript.UpdateVisuals();

        GameObject[] BulletFactorys = GameObject.FindGameObjectsWithTag("BulletFactory");
        if (BulletFactorys.Length > 0)
        {
            for (int i = 0; i < BulletFactorys.Length; i++)
            {
                BulletFactoryScript BulletFactoryScript = BulletFactorys[i].GetComponent <BulletFactoryScript>();
                BulletFactoryScript.selected = false;
                BulletFactoryScript.UpdateVisuals();
            }
        }

        GameObject[] LaserFactorys = GameObject.FindGameObjectsWithTag("LaserFactory");
        if (LaserFactorys.Length > 0)
        {
            for (int i = 0; i < LaserFactorys.Length; i++)
            {
                LaserFactoryScript LaserFactoryScript = LaserFactorys[i].GetComponent <LaserFactoryScript>();
                LaserFactoryScript.selected = false;
                LaserFactoryScript.UpdateVisuals();
            }
        }

        GameObject[] Enginers = GameObject.FindGameObjectsWithTag("Enginer");
        if (Enginers.Length > 0)
        {
            for (int i = 0; i < Enginers.Length; i++)
            {
                EnginerScript EnginerScript = Enginers[i].GetComponent <EnginerScript>();
                EnginerScript.selected = false;
                EnginerScript.UpdateVisuals();
            }
        }

        GameObject[] Miners = GameObject.FindGameObjectsWithTag("Miner");
        if (Miners.Length > 0)
        {
            for (int i = 0; i < Miners.Length; i++)
            {
                MinerScript MinerScript = Miners[i].GetComponent <MinerScript>();
                MinerScript.selected = false;
                MinerScript.UpdateVisuals();
            }
        }

        GameObject[] GoldMines = GameObject.FindGameObjectsWithTag("GoldMine");
        if (GoldMines.Length > 0)
        {
            for (int i = 0; i < GoldMines.Length; i++)
            {
                GoldMineScript GoldMineScript = GoldMines[i].GetComponent <GoldMineScript>();
                GoldMineScript.selected = false;
            }
        }

        if (SelectGameobject.tag == "Unit")
        {
            SelectUnitObj = SelectGameobject;
            selectedUnit  = SelectGameobject.GetComponent <UnitScript>();

            if (SelectGameobject != null)
            {
                // If there is a selected, mark it as selected, update its visuals, and update the UI elements.
                selectedUnit.selected = true;

                UpdateUI(selectedUnit);

                selectedUnit.UpdateVisuals();
            }
            else
            {
                // If we get in here, it means that the toSelect parameter was null, and that means that we
                // should deactivate the namePanel.
                namePanel.SetActive(false);
            }
        }

        if (SelectGameobject.tag == "Base")
        {
            BaseScript BaseScript = SelectGameobject.GetComponent <BaseScript>();

            if (SelectGameobject != null)
            {
                // If there is a selected, mark it as selected, update its visuals, and update the UI elements.
                BaseScript.selected = true;

                UpdateBaseUI(BaseScript);

                BaseScript.UpdateVisuals();
            }
            else
            {
                // If we get in here, it means that the toSelect parameter was null, and that means that we
                // should deactivate the namePanel.
                namePanel.SetActive(false);
            }
        }

        if (SelectGameobject.tag == "BulletFactory")
        {
            BulletFactoryScript BulletFactoryScript = SelectGameobject.GetComponent <BulletFactoryScript>();

            if (SelectGameobject != null)
            {
                // If there is a selected, mark it as selected, update its visuals, and update the UI elements.
                BulletFactoryScript.selected = true;

                UpdateBulletFactoryUI(BulletFactoryScript);

                BulletFactoryScript.UpdateVisuals();
            }
            else
            {
                // If we get in here, it means that the toSelect parameter was null, and that means that we
                // should deactivate the namePanel.
                namePanel.SetActive(false);
            }
        }

        if (SelectGameobject.tag == "LaserFactory")
        {
            LaserFactoryScript LaserFactoryScript = SelectGameobject.GetComponent <LaserFactoryScript>();

            if (SelectGameobject != null)
            {
                // If there is a selected, mark it as selected, update its visuals, and update the UI elements.
                LaserFactoryScript.selected = true;

                UpdateLaserFactoryUI(LaserFactoryScript);

                LaserFactoryScript.UpdateVisuals();
            }
            else
            {
                // If we get in here, it means that the toSelect parameter was null, and that means that we
                // should deactivate the namePanel.
                namePanel.SetActive(false);
            }
        }

        if (SelectGameobject.tag == "Enginer")
        {
            EnginerScript EnginerScript = SelectGameobject.GetComponent <EnginerScript>();

            if (SelectGameobject != null)
            {
                // If there is a selected, mark it as selected, update its visuals, and update the UI elements.
                EnginerScript.selected = true;

                UpdateEnginerUI(EnginerScript);

                EnginerScript.UpdateVisuals();
            }
            else
            {
                // If we get in here, it means that the toSelect parameter was null, and that means that we
                // should deactivate the namePanel.
                namePanel.SetActive(false);
            }
        }

        if (SelectGameobject.tag == "Miner")
        {
            MinerScript MinerScript = SelectGameobject.GetComponent <MinerScript>();

            if (SelectGameobject != null)
            {
                // If there is a selected, mark it as selected, update its visuals, and update the UI elements.
                MinerScript.selected = true;

                UpdateMinerUI(MinerScript);

                MinerScript.UpdateVisuals();
            }
            else
            {
                // If we get in here, it means that the toSelect parameter was null, and that means that we
                // should deactivate the namePanel.
                namePanel.SetActive(false);
            }
        }

        if (SelectGameobject.tag == "GoldMine")
        {
            SelectGoldMine = SelectGameobject;
            GoldMineScript GoldMineScript = SelectGameobject.GetComponent <GoldMineScript>();

            if (SelectGameobject != null)
            {
                // If there is a selected, mark it as selected, update its visuals, and update the UI elements.
                GoldMineScript.selected = true;

                UpdateGoldMineUI(GoldMineScript);

                //GoldMineScript.UpdateVisuals();
            }
            else
            {
                // If we get in here, it means that the toSelect parameter was null, and that means that we
                // should deactivate the namePanel.
                namePanel.SetActive(false);
            }
        }
    }
Exemple #5
0
 public void SlowMiner()
 {
     _playerMiner       = _miner.GetComponent <MinerScript>() as MinerScript;
     _playerMiner.speed = 1;
     StartCoroutine(speedTime());
 }