Exemplo n.º 1
0
    void Update()
    {
        if (selectedObject)
        {
            selectedItemPanel.SetActive(true);
            Upgradable upgradeComponent = selectedObject.GetComponent <Upgradable> ();
            Item       itemComponent    = selectedObject.GetComponent <Item> ();
            if (upgradeComponent)
            {
                if (upgradeComponent.isUpgradable())
                {
                    upgradeCost.text = upgradeComponent.getUpgradeCost().ToString();
                    upgradeButton.gameObject.SetActive(true);
                }
                else
                {
                    upgradeCost.text = "N/A";
                    upgradeButton.gameObject.SetActive(false);
                }
                sellAmount.text = upgradeComponent.getSellValue().ToString();
                if (itemComponent)
                {
                    selectedItemText.text    = itemComponent.itemName + " (Level " + upgradeComponent.level + ")";
                    selectedItemImage.sprite = itemComponent.getImage();
                }
            }
        }
        else
        {
            selectedItemPanel.SetActive(false);
        }

        moneyAmount.text = money.ToString();
    }
Exemplo n.º 2
0
 private void Awake()
 {
     sr           = GetComponent <SpriteRenderer>();
     wallCollider = GetComponent <Collider2D>();
     fixable      = GetComponent <Fixable>();
     upgradable   = GetComponent <Upgradable>();
 }
Exemplo n.º 3
0
    public void upgrade()
    {
        Upgradable upgrader = selectedObject.GetComponent <Upgradable>();

        if (upgrader.isUpgradable() && money >= upgrader.getUpgradeCost())
        {
            money -= upgrader.getUpgradeCost();
            upgrader.Upgrade();
        }
    }
Exemplo n.º 4
0
    //sell the current selected item
    public void sell()
    {
        Upgradable upgrader = selectedObject.GetComponent <Upgradable>();

        if (upgrader)
        {
            money += upgrader.getSellValue();
            Destroy(selectedObject);
            selectedObject = null;
        }
    }
Exemplo n.º 5
0
    //sell a given item
    public void sell(GameObject item)
    {
        Upgradable upgrader = item.GetComponent <Upgradable>();

        if (upgrader)
        {
            money += upgrader.getSellValue();
            Destroy(item);
            item = null;
        }
    }
Exemplo n.º 6
0
    void Update()
    {
        /*if (Input.GetMouseButtonDown (0)) {
         *      Ray ray = gameCamera.GetComponent<Camera> ().ScreenPointToRay (Input.mousePosition);
         *      RaycastHit hit;
         *      if ( Physics.Raycast (ray,out hit,100.0f)){
         *              //suppose i have two objects here named obj1 and obj2.. how do i select obj1 to be transformed
         *              GameObject hitObject = hit.collider.gameObject;
         *              if(hitObject != null && hitObject.GetComponent<OutlineComponent>() != null) {
         *                      if(selectedObject == hitObject)
         *                      {
         *                              setSelectedItem (null);
         *                      }
         *                      else {
         *                              setSelectedItem (hitObject);
         *                      }
         *              }
         *      }
         * }*/
        if (selectedObject)
        {
            selectedItemPanel.SetActive(true);
            Upgradable upgradeComponent = selectedObject.GetComponent <Upgradable> ();
            Item       itemComponent    = selectedObject.GetComponent <Item> ();
            if (upgradeComponent)
            {
                if (upgradeComponent.isUpgradable())
                {
                    upgradeCost.text = upgradeComponent.getUpgradeCost().ToString();
                    upgradeButton.gameObject.SetActive(true);
                }
                else
                {
                    upgradeCost.text = "N/A";
                    upgradeButton.gameObject.SetActive(false);
                }
                sellAmount.text = upgradeComponent.getSellValue().ToString();
                if (itemComponent)
                {
                    selectedItemText.text    = itemComponent.itemName + " (Level " + upgradeComponent.level + ")";
                    selectedItemImage.sprite = itemComponent.getImage();
                }
            }
        }
        else
        {
            selectedItemPanel.SetActive(false);
        }

        moneyAmount.text = money.ToString();
    }
Exemplo n.º 7
0
    private void FixedUpdate()
    {
        //print(movement);
        Upgradable speedUpgrade = FindUpgradable("Speed");

        if (isFreezing)
        {
            rb.velocity = movement * freezingMovementSpeed * speedUpgrade.GetScaler();
        }
        else if (isMining)
        {
            rb.velocity = movement * miningMovementSpeed * speedUpgrade.GetScaler();
        }
        else
        {
            rb.velocity = movement * movementSpeed * speedUpgrade.GetScaler();
        }
    }
Exemplo n.º 8
0
    //sell a given item
    public void sell(GameObject item)
    {
        Upgradable   upgrader = item.GetComponent <Upgradable>();
        Purchaseable purchase = item.GetComponent <Purchaseable>();

        if (purchase)
        {
            if (purchase.WasPurchased())
            {
                if (upgrader)
                {
                    money += upgrader.getSellValue();
                }
                else
                {
                    money += purchase.GetPrice();
                }
            }
            Destroy(item);
            item = null;
        }
    }
Exemplo n.º 9
0
 public void LoadUpgrade(Upgradable upgrade)
 {
     _availableUpgrades.Add(upgrade.ToString());
     _upgradeDictionary.Add(upgrade.ToString(), upgrade);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Saves the equipment.
        /// </summary>
        /// <returns>Equipment Object</returns>
        public Equipment SaveEquipment()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "InsertUpdate_Equipment";
                command.Parameters.Add(dbconn.GenerateParameterObj("@EquipmentID", SqlDbType.Int, EquipmentID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@EquipmentName", SqlDbType.VarChar, EquipmentName.ToString(), 50));
                command.Parameters.Add(dbconn.GenerateParameterObj("@EquipmentDescription", SqlDbType.VarChar, EquipmentDescription.ToString(), 400));
                command.Parameters.Add(dbconn.GenerateParameterObj("@EquipmentTypeID", SqlDbType.Int, EquipmentTypeID.ToString(), 0));

                command.Parameters.Add(dbconn.GenerateParameterObj("@EquipmentWeight", SqlDbType.Decimal, EquipmentWeight.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@EquipmentCost", SqlDbType.Int, EquipmentCost.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@BookID", SqlDbType.Int, BookID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Upgradable", SqlDbType.Bit, Upgradable.ToString(), 0));

                result = command.ExecuteReader();

                result.Read();
                SetReaderToObject(ref result);
            }
            catch
            {
                Exception e = new Exception();
                this._insertUpdateOK = false;
                this._insertUpdateMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this);
        }
Exemplo n.º 11
0
        private static void BotVoid()
        {
            LocalizationController.SetLanguage(Config.language);
            while (true)
            {
                Thread.Sleep(100);
                if (Config.sleepenabled)
                {
                    Sleeping.Sleep();
                }

                if ((DateTime.Now - _lastdefinv).TotalSeconds >= 10)
                {
                    if (Config.autoupgrade)
                    {
                        Buildings.AutoUpgrade(Config.upgradeonlyfactory);
                    }

                    if (Config.autoship)
                    {
                        Outposts.ConfirmOutpost();
                        Upgradable.UpgradeUpgradable();
                        Contractor.UpgradeContractor();
                        Ships.AutoShip();
                    }

                    if (Config.collectfish)
                    {
                        FishPier.CollectFish();
                    }

                    if (Config.collectmuseum)
                    {
                        Museum.CollectMuseum();
                    }

                    if (Config.collectfactory)
                    {
                        Buildings.CollectMaterials();
                    }

                    if (Config.prodfactory)
                    {
                        Factories.ProduceFactories();
                    }

                    if (Config.finishupgrade)
                    {
                        Buildings.FinishUpgrade();
                    }

                    _lastdefinv = DateTime.Now;
                }

                if (Config.barrelhack && (DateTime.Now - _lastbarrel).TotalSeconds >= Config.barrelinterval)
                {
                    Barrels.CollectBarrel();
                    _lastbarrel = DateTime.Now;
                }
            }
        }
Exemplo n.º 12
0
 public void AddToDictionary(Upgradable u)
 {
     copterUpgrades.Add(u.Name, u);
 }
Exemplo n.º 13
0
 public void AddUpgrade(Upgradable upgrade)
 {
     _upgrades.Add(upgrade.ToString());
     ReferenceLibrary.Instance.GetUpgrade(_upgrades[_upgrades.Count - 1]).ApplyUpgrade(this);
 }
Exemplo n.º 14
0
    private void Update()
    {
        // get WASD movement
        movement = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));

        // rotate to look at mouse
        Ray     ray   = Camera.main.ScreenPointToRay(Input.mousePosition);
        Vector2 dir   = ((Vector2)ray.origin - (Vector2)transform.position).normalized;
        float   angle = -Mathf.Atan2(-dir.y, dir.x) * Mathf.Rad2Deg;

        transform.rotation = Quaternion.Euler(0, 0, angle);

        // freeze gun
        Upgradable costUpgrade       = FindUpgradable("Cost");
        float      upgradedGunCost   = freezeGunCost * costUpgrade.GetScaler();
        float      upgradeCircleCost = freezeCircleCost * costUpgrade.GetScaler();

        //print(upgradedGunCost);
        if (Input.GetMouseButtonDown(0) && freezePower > upgradedGunCost)
        {
            freezeCone.GetComponent <ParticleSystem>().Play();
            isFreezing = true;
            audioController.Play("Freeze gun");
        } // start freezing
        if (Input.GetMouseButton(0) && isFreezing)
        {
            freezePower -= freezeGunCost;
        } // when using freeze gun
        if (Input.GetMouseButtonUp(0) || freezePower <= 0)
        {
            freezeCone.GetComponent <ParticleSystem>().Stop();
            isFreezing = false;
            audioController.Stop("Freeze gun");
        } // end freezing

        // freeze cone
        if (Input.GetMouseButtonUp(1) && freezePower > upgradeCircleCost)
        {
            //print((Vector2)ray.origin);
            audioController.Play("Freeze circle");
            freezePower -= freezeCircleCost;
            GameObject freezeCircle = Instantiate(freezeCirclePrefab, (Vector2)ray.origin, Quaternion.identity);
            Destroy(freezeCircle, freezeCircleTime);
        } // spawn freeze circle

        // health UI
        healthBar.fillAmount      = health / maxHealth;
        canvas.transform.rotation = Quaternion.identity;
        //print(health);

        // freeze power bar
        freezePowerBar.fillAmount = freezePower / maxFreezePower;

        // update power up texts
        foreach (Upgradable upgradable in upgradables)
        {
            upgradable.text.text = "LV: " + upgradable.GetLV().ToString();
        }

        // death
        if (health <= 0)
        {
            SceneManager.LoadSceneAsync("Gameover");
            audioController.Stop();
            audioController.Play("Player death");
        }

        // mining sound
        if (isMining && !audioController.IsPlaying("Mine"))
        {
            audioController.Play("Mine");
        }
        if (!isMining && audioController.IsPlaying("Mine"))
        {
            audioController.Stop("Mine");
        }
    }