示例#1
0
    private void EnsureInit()
    {
        if (mLightRendererObject == null)
        {
            mLightRendererObject = LightSpriteBuilder.BuildDefault(gameObject, new Color(0, 0, 0, 0), 12);
        }

        directional.OnDirectionChange.AddListener(OnDirectionChange);

        if (lightSprite == null)
        {
            lightSprite = mLightRendererObject.GetComponent <LightSprite>();
        }

        if (currentState == null)
        {
            ChangeCurrentState(InitialState);
        }

        if (traitRequired == null)
        {
            traitRequired = currentState.TraitRequired;
        }

        if (!isWithoutSwitch)
        {
            switchState = InitialState == LightMountState.On;
        }
    }
        public void ReInit(ItemTrait material, int amount)
        {
            currentAmount = amount;
            materialType  = material;
            foreach (var element in Elements)
            {
                string nameBeforeIndex = element.name.Split('~')[0];
                switch (nameBeforeIndex)
                {
                case "MaterialName":
                    ((NetUIElement <string>)element).SetValueServer(CraftingManager.MaterialSheetData[material].displayName + ":");
                    break;

                case "MaterialAmount":
                    ((NetUIElement <string>)element).SetValueServer(currentAmount + " cm3");
                    amountLabel = element as NetLabel;
                    break;

                case "OneSheetButton":
                    buttonOne = element as NetInteractiveButton;
                    break;

                case "TenSheetButton":
                    buttonTen = element as NetInteractiveButton;
                    break;

                case "FiftySheetButton":
                    buttonFifty = element as NetInteractiveButton;
                    break;
                }
            }
            UpdateButtonVisibility();
        }
 public void SetValues(ItemTrait material, int amount, GUI_MaterialsList matListDisplay)
 {
     materialList = matListDisplay;
     materialType = material;
     labelAmount.SetValueServer($"{amount} cm3");
     labelName.SetValueServer(material.name);
 }
示例#4
0
        // Helper used by the two methods above
        public static void RemoveCharacterAttributesByTrait(Models.Character player, ItemTrait trait)
        {
            switch (trait.RelevantCharacterAttribute)
            {
            case AttributeStrings.Defense:
                player.Attributes.Defense -= trait.TraitValue;
                break;

            case AttributeStrings.Dexterity:
                player.Attributes.Dexterity -= trait.TraitValue;
                break;

            case AttributeStrings.Luck:
                player.Attributes.Luck -= trait.TraitValue;
                break;

            case AttributeStrings.Stamina:
                player.Attributes.Stamina  -= trait.TraitValue;
                player.MaximumHealthPoints -= CharacterDefaults.HealthPerStaminaPointIncrease * trait.TraitValue;
                player.HealthPoints        -= CharacterDefaults.HealthPerStaminaPointIncrease * trait.TraitValue;
                break;

            case AttributeStrings.Strength:
                player.Attributes.Strength -= trait.TraitValue;
                break;

            case AttributeStrings.Wisdom:
                player.Attributes.Wisdom -= trait.TraitValue;
                break;

            case AttributeStrings.MaxCarryingCapacity:
                player.Attributes.MaximumCarryingCapacity -= trait.TraitValue;
                break;
            }
        }
        public override void Setup()
        {
            var itemEntry = itemPool.PickRandom();

            itemTrait = itemEntry.Key;

            // randomizes the amount needed to complete the shipment, with a minimum of 2/3rds of the default value and a maximum of 1 and 1/3rd of the default
            requiredAmount = Random.Range(itemEntry.Value - itemEntry.Value / 3, itemEntry.Value + itemEntry.Value / 3);

            var report = new StringBuilder();

            report.AppendFormat(description, itemTrait.name, MatrixManager.MainStationMatrix.GameObject.scene.name, requiredAmount);
            report.AppendLine("\n\nAsteroid coordinates are as follows:");
            var index = 0;

            foreach (var location in CentComm.asteroidLocations)
            {
                index++;
                if (index != 1)
                {
                    report.Append(" - ");
                }
                report.AppendFormat("<size=24>{0}</size>", Vector2Int.RoundToInt(location));
                if (index == 4)
                {
                    report.Append("\n");
                    index = 0;
                }
            }
            description = report.ToString();
        }
示例#6
0
 public void DispenseSheet(int amountOfSheets, ItemTrait material, Vector3 worldPos)
 {
     if (TryRemoveSheet(material, amountOfSheets))
     {
         var materialToSpawn = CraftingManager.MaterialSheetData[material].RefinedPrefab;
         Spawn.ServerPrefab(materialToSpawn, worldPos, transform.parent, count: amountOfSheets);
     }
 }
 // Constructor: Add the reference to all the Trait Objects here
 public ItemTraitCreator()
 {
     BatteryPercentage        = GameItemTraits.BatteryPercentage;
     DefensePlusOne           = GameItemTraits.DefensePlusOne;
     LuckPlusOne              = GameItemTraits.LuckPlusOne;
     CarryingCapacityPlusTen  = GameItemTraits.CarryingCapacityPlusTen;
     CarriedItemCountMinusOne = GameItemTraits.CarriedItemCountMinusOne;
 }
        public int TryRemoveSheet(ItemTrait material, int quantity)
        {
            quantity = Mathf.Min(quantity, MaterialList[material] / Cm3PerSheet);
            var Cm3Used = Cm3PerSheet * quantity;

            ConsumeMaterial(material, Cm3Used);
            UpdateGUIs.Invoke();
            return(quantity);
        }
示例#9
0
    private void EnsureInit()
    {
        if (isInit)
        {
            return;
        }
        if (mLightRendererObject == null)
        {
            mLightRendererObject = LightSpriteBuilder.BuildDefault(gameObject, new Color(0, 0, 0, 0), 12);
        }

        if (spriteRenderer == null)
        {
            spriteRenderer = GetComponentInChildren <SpriteRenderer>();
        }

        if (spriteRendererLightOn == null)
        {
            spriteRendererLightOn = GetComponentsInChildren <SpriteRenderer>().Length > 1
                        ? GetComponentsInChildren <SpriteRenderer>()[1] : GetComponentsInChildren <SpriteRenderer>()[0];
        }

        if (lightSprite == null)
        {
            lightSprite = mLightRendererObject.GetComponent <LightSprite>();
        }

        if (emergencyLightAnimator == null)
        {
            emergencyLightAnimator = GetComponent <EmergencyLightAnimator>();
        }

        if (integrity == null)
        {
            integrity = GetComponent <Integrity>();
        }

        if (directional == null)
        {
            directional = GetComponent <Directional>();
        }

        if (currentState == null)
        {
            ChangeCurrentState(InitialState);
        }

        if (traitRequired == null)
        {
            traitRequired = currentState.TraitRequired;
        }

        if (!isWithoutSwitch)
        {
            switchState = InitialState == LightMountState.On;
        }
    }
示例#10
0
 public bool TryRemoveSheet(ItemTrait material, int quantity)
 {
     quantity *= Cm3PerSheet;
     if (MaterialList[material] >= quantity)
     {
         ConsumeMaterial(material, quantity);
         UpdateGUIs.Invoke();
         return(true);
     }
     return(false);
 }
示例#11
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is ItemTrait traitParam)
            {
                selectedTrait = traitParam;
                Log.Info($"navigated to with trait {selectedTrait.TraitId}");
            }

            eventAggregator.Subscribe(this);
            UpdateViewModel();
        }
        public bool TryAddSheet(ItemTrait material, int quantity)
        {
            quantity *= Cm3PerSheet;
            var totalSum = currentResources + quantity;

            if (infiniteStorage || totalSum <= maximumResources)
            {
                AddMaterial(material, quantity);
                UpdateGUIs.Invoke();
                return(true);
            }
            return(false);
        }
示例#13
0
    /// <inheritdoc cref="ItemAttributes.HasTrait"/>
    /// <param name="toCheck">object to check, can be null</param>
    /// <param name="expectedTrait"></param>
    /// <returns></returns>
    public static bool HasItemTrait(GameObject toCheck, ItemTrait expectedTrait)
    {
        if (toCheck == null)
        {
            return(false);
        }
        var attrs = toCheck.GetComponent <ItemAttributesV2>();

        if (attrs == null)
        {
            return(false);
        }
        return(attrs.HasTrait(expectedTrait));
    }
示例#14
0
        public override void Setup()
        {
            var itemEntry = itemPool.PickRandom();

            itemTrait = itemEntry.Key;

            // randomizes the amount needed to complete the shipment, with a minimum of 2/3rds of the default value and a maximum of 1 and 1/3rd of the default
            requiredAmount = Random.Range(itemEntry.Value - itemEntry.Value / 3, itemEntry.Value + itemEntry.Value / 3);

            var report = new StringBuilder();

            report.AppendFormat(description, itemTrait.name, MatrixManager.MainStationMatrix.GameObject.scene.name, requiredAmount);
            description = report.ToString();
        }
        public void DispenseMaterialSheet(int amountOfSheets, ItemTrait materialType)
        {
            if (materialStorage.TryRemoveMaterialSheet(materialType, amountOfSheets))
            {
                Spawn.ServerPrefab(materialStorage.ItemTraitToMaterialRecord[materialType].materialPrefab,
                                   registerObject.WorldPositionServer + Vector3Int.down, transform.parent, count: amountOfSheets);

                UpdateGUI();
            }
            else
            {
                //Not enough materials to dispense
            }
        }
示例#16
0
        public bool WillInteract(HandApply interaction, NetworkSide side)
        {
            if (!DefaultWillInteract.Default(interaction, side))
            {
                return(false);
            }

            InsertedMaterialType = materialStorage.FindMaterial(interaction.HandObject);
            if (InsertedMaterialType != null)
            {
                return(true);
            }
            return(false);
        }
示例#17
0
 private void Awake()
 {
     registerTile = GetComponent <RegisterTile>();
     construction = GetComponent <LightFixtureConstruction>();
     if (mLightRendererObject == null)
     {
         mLightRendererObject = LightSpriteBuilder.BuildDefault(gameObject, new Color(0, 0, 0, 0), 12);
     }
     lightSprite = mLightRendererObject.GetComponent <LightSprite>();
     if (!isWithoutSwitch)
     {
         switchState = InitialState == LightMountState.On;
     }
     ChangeCurrentState(InitialState);
     traitRequired = currentState.TraitRequired;
 }
        public int TryRemoveSheet(ItemTrait material, int quantity)
        {
            if (MaterialList[material] < Cm3PerSheet)
            {
                return(0);
            }
            var Cm3Used = Cm3PerSheet * quantity;

            if (MaterialList[material] < Cm3Used)
            {
                quantity = MaterialList[material] / Cm3PerSheet;
                Cm3Used  = Cm3PerSheet * quantity;
            }
            ConsumeMaterial(material, Cm3Used);
            UpdateGUIs.Invoke();
            return(quantity);
        }
示例#19
0
    public Item CheckNearby(Creature creature, ItemTrait trait = ItemTrait.Default)//for puffballs to pick stuff up
    {
        List <Item> items = new List <Item>();

        Collider[] hitColliders = Physics.OverlapSphere(transform.position, 8f);//LAYER MASK LATER
        foreach (Collider c in hitColliders)
        {
            if (c.transform == transform)
            {
                continue;
            }
            if (c.CompareTag("Item") || c.CompareTag("Food"))
            {
                Item item = c.GetComponent <Item>();
                if (!item.held)
                {
                    if (trait == ItemTrait.Default)
                    {
                        if (creature.mind.likes.Contains(item.trait))
                        {
                            items.Add(item);
                        }
                    }
                    else
                    {
                        if (item.trait == trait)
                        {
                            items.Clear();
                            items.Add(item);
                            break;
                        }
                    }
                }
            }
        }
        //for now just pick up the first one
        if (items.Count > 0)
        {
            return(items[0]);
        }
        else
        {
            return(null);
        }
    }
示例#20
0
        private void Awake()
        {
            objectBehaviour = GetComponent <ObjectBehaviour>();
            construction    = GetComponent <LightFixtureConstruction>();
            if (mLightRendererObject == null)
            {
                mLightRendererObject = LightSpriteBuilder.BuildDefault(gameObject, new Color(0, 0, 0, 0), 12);
            }

            lightSprite = mLightRendererObject.GetComponent <LightSprite>();
            if (isWithoutSwitch == false)
            {
                switchState = InitialState == LightMountState.On;
            }

            ChangeCurrentState(InitialState);
            traitRequired = currentState.TraitRequired;
            RefreshBoxCollider();
        }
示例#21
0
        private int TryCompleteBounty(ItemTrait itemTrait, int count)
        {
            for (var i = ActiveBounties.Count - 1; i >= 0; i--)
            {
                var activeBounty = ActiveBounties[i];
                if (activeBounty.Demands.ContainsKey(itemTrait))
                {
                    if (activeBounty.Demands[itemTrait] >= count)
                    {
                        activeBounty.Demands[itemTrait] -= count;
                        count = 0;
                        CheckBountyCompletion(activeBounty);
                        break;
                    }
                    count -= activeBounty.Demands[itemTrait];
                    activeBounty.Demands[itemTrait] = 0;
                    CheckBountyCompletion(activeBounty);
                }
            }

            return(count);
        }
        // Helper used by the two methods above
        public static void AddCharacterAttributesByTrait(Models.Character player, ItemTrait trait)
        {
            switch (trait.RelevantCharacterAttribute)
            {
            case AttributeStrings.Defense:
                player.Attributes.Defense += trait.TraitValue;
                break;

            case AttributeStrings.Dexterity:
                player.Attributes.Dexterity += trait.TraitValue;
                break;

            case AttributeStrings.Luck:
                player.Attributes.Luck += trait.TraitValue;
                break;

            case AttributeStrings.Stamina:
                player.Attributes.Stamina  += trait.TraitValue;
                player.MaximumHealthPoints += CharacterDefaults.StaminaPerPointIncrease * trait.TraitValue;
                player.HealthPoints        += CharacterDefaults.StaminaPerPointIncrease * trait.TraitValue;
                break;

            case AttributeStrings.Strength:
                player.Attributes.Strength += trait.TraitValue;
                break;

            case AttributeStrings.Wisdom:
                player.Attributes.Wisdom += trait.TraitValue;
                break;

            case AttributeStrings.MaxCarryingCapacity:
                player.Attributes.MaximumCarryingCapacity += trait.TraitValue;
                break;

            case AttributeStrings.CarriedItemsCount:
                player.Attributes.CarriedItemsCount += trait.TraitValue;
                break;
            }
        }
        public bool WillInteract(HandApply interaction, NetworkSide side)
        {
            if (!DefaultWillInteract.Default(interaction, side))
            {
                return(false);
            }

            if (!interaction.HandSlot.IsEmpty)
            {
                //Checks if materialStorage has the materialRecord
                foreach (ItemTrait material in materialStorage.ItemTraitToMaterialRecord.Keys)
                {
                    if (Validations.HasItemTrait(interaction.HandObject, material))
                    {
                        InsertedMaterialType = material;
                        return(true);
                    }
                    ;
                }
            }

            return(false);
        }
示例#24
0
 public AllowedTraitList(ItemTrait allowedTrait)
 {
     AllowedTrait = allowedTrait;
 }
 private void ConsumeMaterial(ItemTrait material, int quantity)
 {
     MaterialList[material] -= quantity;
     currentResources       -= quantity;
 }
 private void AddMaterial(ItemTrait material, int quantity)
 {
     MaterialList[material] += quantity;
     currentResources       += quantity;
 }
 /// <summary>
 /// Dynamically removes the specified trait from this item attributes
 /// </summary>
 /// <param name="toAdd"></param>
 public void RemoveTrait(ItemTrait toRemove)
 {
     traits.Remove(toRemove);
 }
 public bool TryAddSheet(ItemTrait InsertedMaterialType, int materialSheetAmount)
 {
     return(usedStorage.TryAddSheet(InsertedMaterialType, materialSheetAmount));
 }
示例#29
0
 /// <summary>
 /// Checks if the used object has the indicated trait
 /// </summary>
 /// <param name="interaction"></param>
 /// <param name="expectedTrait"></param>
 /// <returns></returns>
 public static bool HasUsedItemTrait(Interaction interaction, ItemTrait expectedTrait)
 {
     return(HasItemTrait(interaction.UsedObject, expectedTrait));
 }
 /// <summary>
 /// Dynamically adds the specified trait to this item attributes
 /// </summary>
 /// <param name="toAdd"></param>
 public void AddTrait(ItemTrait toAdd)
 {
     traits.Add(toAdd);
 }