예제 #1
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            base.DrawSelf(spriteBatch);
            CalculatedStyle innerDim = GetInnerDimensions();
            Vector2         position = new Vector2(innerDim.X - 5, innerDim.Y - 15);
            ModItem         modItem  = item?.modItem;

            if (modItem != null)
            {
                if (modItem is EnergyItem)
                {
                    EnergyItem energyItem = modItem as EnergyItem;
                    if (energyItem.isFull())
                    {
                        spriteBatch.DrawString(Main.fontMouseText, "Full!", position, Color.White);
                    }
                    else
                    {
                        spriteBatch.DrawString(Main.fontMouseText, "Charging", position, Color.White);
                    }
                }
                else
                {
                    spriteBatch.DrawString(Main.fontMouseText, "Can't charge", position, Color.White);
                }
            }
        }
예제 #2
0
    void CheckCollision(Collider other)
    {
        if (!IsOperationable)
        {
            return;
        }

        ObstacleItem obstacle = other.gameObject.GetComponent <ObstacleItem>();

        if (obstacle != null)
        {
            if (energySkillCdController.Active)
            {
                energySkillCdController.Active = false;
            }
            else
            {
                GameControl.Instance.GameOver();
            }
            return;
        }

        BombItem bombItem = other.gameObject.GetComponent <BombItem>();

        if (bombItem != null)
        {
            bombItem.Trigger();
            return;
        }

        bool       eat        = false;
        EnergyItem energyItem = other.gameObject.GetComponent <EnergyItem> ();

        if (energyItem != null)
        {
            energyValueController.AddValue(energyItem.Value);
            eat = true;
        }

        MassItem massItem = other.gameObject.GetComponent <MassItem>();

        if (massItem != null)
        {
            Config config = Config.Instance;
            if (_massItem.Value >= massItem.Value * config.absorbLimit)
            {
                // eat it
                _massItem.Value += massItem.Value * config.absorbRate;
                eat              = true;
            }
        }

        if (eat)
        {
            GameControl.Instance.RemoveItem(other.gameObject);
        }
    }
예제 #3
0
        public Price ConsumptionPrice()
        {
            var consumption = new EnergyItem(Consumption, InvoiceParams.M3GasUnit)
            {
                Description = $"Consumption in m3 of gas with Conversion Factor {InvoiceParams.ConversionFactor} kWh."
            };

            return(new ItemPrice(Contract.KWhPrice, consumption));
        }
예제 #4
0
    internal void GiveEnergy(EnergyItem energyItem)
    {
        int newEnergy = energy.Value + energyItem.energy;

        if (newEnergy > maxEnergy.Value)
        {
            newEnergy = maxEnergy.Value;
        }

        energy.Value = newEnergy;
    }
예제 #5
0
    private void BuyGreen()
    {
        int test = GreenEnergyDropDown.value;

        money.text = int.Parse((float.Parse(money.text) - float.Parse(greenEnergyItems[test].getPrice().ToString())).ToString()).ToString();
        float en = (float.Parse(energy.text) + (float)(float.Parse(greenEnergyItems[test].getAmount().ToString()) * 1000f));

        energy.text = string.Format("{0:n0}", en);
        int amount = random.Next(100, 5000);
        int price  = random.Next(30, 120);

        greenEnergyItems[test] = new EnergyItem(amount, amount * price, price, test.ToString());
        string gridText = string.Format("{0,-15}\t{1,-7}\t{2,-10}\t{3,-7}\n", "Seller", "MWh", "Total Price", "$/MWh");

        for (int i = 0; i < 4; i++)
        {
            gridText += string.Format("{0,-15}\t{1,-9:n0}\t{2,-12:n0}\t{3,-7:n0}\n", greenEnergyItems[i].getSeller(), greenEnergyItems[i].getAmount(), greenEnergyItems[i].getPrice(), greenEnergyItems[i].getPricePerUnit());
        }
        GreenGridText.text  = gridText;
        GreenPriceText.text = string.Format("{0:n0}", greenEnergyItems[test].getPrice());
    }
예제 #6
0
 public void PickupEnergy(EnergyItem item)
 {
     _energy += item.energyContent;
     _energy  = Mathf.Min(_energy, maxEnergy);
     Destroy(item.gameObject);
 }
예제 #7
0
    public bool ExplodeAction(Vector3 explosionPos, float radius)
    {
        Vector3 closestPoint = _coll.ClosestPointOnBounds(explosionPos);
        float   distance     = Vector3.Distance(closestPoint, explosionPos);

        if (radius > distance)
        {
            int   pieceNum  = bombPiecesRangeController.RandInRange();
            float currValue = 0;
            {
                EnergyItem energyItem = GetComponent <EnergyItem> ();
                if (energyItem != null)
                {
                    currValue        = energyItem.Value;
                    energyItem.Value = currValue * (1 - bombRate);
                }
                MassItem massItem = GetComponent <MassItem> ();
                if (massItem != null)
                {
                    currValue      = massItem.Value;
                    massItem.Value = currValue * (1 - bombRate);
                }
                currValue = currValue * bombRate;
            }
            while (pieceNum > 1)
            {
                float resValue = currValue / pieceNum;
                if (resValue > explodeLimit)
                {
                    for (int i = 0; i < pieceNum; i++)
                    {
                        GameObject item       = Instantiate(piecePerfab);
                        EnergyItem energyItem = item.GetComponent <EnergyItem> ();
                        float      baseValue  = 0;
                        if (energyItem != null)
                        {
                            baseValue        = energyItem.Value;
                            energyItem.Value = resValue;
                        }
                        MassItem massItem = item.GetComponent <MassItem> ();
                        if (massItem != null)
                        {
                            baseValue      = massItem.Value;
                            massItem.Value = resValue;
                        }

                        item.transform.localScale = item.transform.localScale * resValue / baseValue;
                        item.transform.position   = gameObject.transform.position + new Vector3(Random.Range(-1 * pieceRange, 1 * pieceRange), 0, Random.Range(-1 * pieceRange, 1 * pieceRange));
                        item.transform.SetParent(GameControl.Instance.bombItemsHolder.transform, true);
                    }
                    return(true);
                }
                else
                {
                    pieceNum--;
                }
            }
        }

        return(false);
    }
예제 #8
0
        public void MergeFrom(VaultItem other)
        {
            if (other == null)
            {
                return;
            }
            if (other.Id.Length != 0)
            {
                Id = other.Id;
            }
            if (other.Cap != 0L)
            {
                Cap = other.Cap;
            }
            if (other.RelativeValue != 0)
            {
                RelativeValue = other.RelativeValue;
            }
            if (other.VaultCategoryGmtId.Length != 0)
            {
                VaultCategoryGmtId = other.VaultCategoryGmtId;
            }
            switch (other.VaultItemTypeCase)
            {
            case VaultItemTypeOneofCase.CurrencyItem:
                if (CurrencyItem == null)
                {
                    CurrencyItem = new global::WUProtos.Data.CurrencyVaultItem();
                }
                CurrencyItem.MergeFrom(other.CurrencyItem);
                break;

            case VaultItemTypeOneofCase.StaminaItem:
                if (StaminaItem == null)
                {
                    StaminaItem = new global::WUProtos.Data.StaminaVaultItem();
                }
                StaminaItem.MergeFrom(other.StaminaItem);
                break;

            case VaultItemTypeOneofCase.DetectorItem:
                if (DetectorItem == null)
                {
                    DetectorItem = new global::WUProtos.Data.DarkDetectorVaultItem();
                }
                DetectorItem.MergeFrom(other.DetectorItem);
                break;

            case VaultItemTypeOneofCase.ContainerItem:
                if (ContainerItem == null)
                {
                    ContainerItem = new global::WUProtos.Data.ContainerVaultItem();
                }
                ContainerItem.MergeFrom(other.ContainerItem);
                break;

            case VaultItemTypeOneofCase.RunestoneItem:
                if (RunestoneItem == null)
                {
                    RunestoneItem = new global::WUProtos.Data.RunestoneVaultItem();
                }
                RunestoneItem.MergeFrom(other.RunestoneItem);
                break;

            case VaultItemTypeOneofCase.PotionItem:
                if (PotionItem == null)
                {
                    PotionItem = new global::WUProtos.Data.Potion.PotionVaultItem();
                }
                PotionItem.MergeFrom(other.PotionItem);
                break;

            case VaultItemTypeOneofCase.PotionIngredient:
                if (PotionIngredient == null)
                {
                    PotionIngredient = new global::WUProtos.Data.Potion.PotionIngredientVaultItem();
                }
                PotionIngredient.MergeFrom(other.PotionIngredient);
                break;

            case VaultItemTypeOneofCase.EnergyItem:
                if (EnergyItem == null)
                {
                    EnergyItem = new global::WUProtos.Data.EnergyVaultItem();
                }
                EnergyItem.MergeFrom(other.EnergyItem);
                break;

            case VaultItemTypeOneofCase.CauldronTimeItem:
                if (CauldronTimeItem == null)
                {
                    CauldronTimeItem = new global::WUProtos.Data.CauldronTimeItem();
                }
                CauldronTimeItem.MergeFrom(other.CauldronTimeItem);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
예제 #9
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (vaultItemTypeCase_ == VaultItemTypeOneofCase.CurrencyItem)
            {
                hash ^= CurrencyItem.GetHashCode();
            }
            if (vaultItemTypeCase_ == VaultItemTypeOneofCase.StaminaItem)
            {
                hash ^= StaminaItem.GetHashCode();
            }
            if (vaultItemTypeCase_ == VaultItemTypeOneofCase.DetectorItem)
            {
                hash ^= DetectorItem.GetHashCode();
            }
            if (vaultItemTypeCase_ == VaultItemTypeOneofCase.ContainerItem)
            {
                hash ^= ContainerItem.GetHashCode();
            }
            if (vaultItemTypeCase_ == VaultItemTypeOneofCase.RunestoneItem)
            {
                hash ^= RunestoneItem.GetHashCode();
            }
            if (vaultItemTypeCase_ == VaultItemTypeOneofCase.PotionItem)
            {
                hash ^= PotionItem.GetHashCode();
            }
            if (vaultItemTypeCase_ == VaultItemTypeOneofCase.PotionIngredient)
            {
                hash ^= PotionIngredient.GetHashCode();
            }
            if (vaultItemTypeCase_ == VaultItemTypeOneofCase.EnergyItem)
            {
                hash ^= EnergyItem.GetHashCode();
            }
            if (vaultItemTypeCase_ == VaultItemTypeOneofCase.CauldronTimeItem)
            {
                hash ^= CauldronTimeItem.GetHashCode();
            }
            if (Cap != 0L)
            {
                hash ^= Cap.GetHashCode();
            }
            if (RelativeValue != 0)
            {
                hash ^= RelativeValue.GetHashCode();
            }
            if (VaultCategoryGmtId.Length != 0)
            {
                hash ^= VaultCategoryGmtId.GetHashCode();
            }
            hash ^= (int)vaultItemTypeCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }