示例#1
0
        private Vector3 GetCapsuleAxis(UpgradeViewReceiver receiver, CapsuleCollider cc)
        {
            switch (cc.direction)
            {
            case 0:
                return(receiver.transform.right);

            case 1:
                return(receiver.transform.up);
            }
            return(receiver.transform.forward);
        }
示例#2
0
 public void ApplyUpgradeRecipe(InventoryItemView craftView, Receipe receipe, int amount)
 {
     this._currentIngredientIndex = 0;
     this._recipe                  = receipe;
     this._craftView               = craftView;
     this._currentReceiver         = null;
     this._upPositionV             = craftView.transform.position + this._upPosition.parent.TransformDirection(new Vector3(0.5f, -1.05f, 0f));
     this._upRotation              = craftView.transform.rotation * Quaternion.Euler(30f, 0f, 0f);
     this._receivers               = this._craftView.GetAllComponentsInChildren <UpgradeViewReceiver>();
     this._downPosition            = this._craftView.transform.position;
     this._downRotation            = this._craftView.transform.rotation;
     this._state                   = UpgradeCog.States.MoveUp;
     this._totalUpgrades           = amount;
     this._implantsDone            = 0;
     this._totalIngredientImplants = 0;
     this._craftingCog.enabled     = false;
     base.enabled                  = true;
     Scene.HudGui.ShowValidCraftingRecipes(null);
     Scene.HudGui.ShowUpgradesDistribution(this._recipe._productItemID, this._recipe._ingredients[1]._itemID, 1);
 }
示例#3
0
 public void Shutdown()
 {
     if (this.SupportedItemsCache[this._currentIngredientItemId]._amount > 0)
     {
         float num = (float)((this._totalIngredientImplants - this._implantsDone) / this.SupportedItemsCache[this._currentIngredientItemId]._amount);
         for (int i = 1; i < this._recipe._ingredients.Length; i++)
         {
             this._craftingCog.Add(this._recipe._ingredients[i]._itemID, Mathf.FloorToInt((float)this._recipe._ingredients[i]._amount * num), (WeaponStatUpgrade.Types)(-2));
         }
     }
     this._currentReceiver = null;
     this._craftView.transform.position = Vector3.Slerp(this._upPositionV, this._downPosition, 1f);
     this._craftView.transform.rotation = Quaternion.Slerp(this._upRotation, this._downRotation, 1f);
     this._state  = UpgradeCog.States.Idle;
     base.enabled = false;
     this._craftingCog.CheckForValidRecipe();
     Scene.HudGui.UpgradePlacementGizmo.gameObject.SetActive(false);
     Scene.HudGui.ManualUpgradingInfo.SetActive(false);
     Scene.HudGui.HideUpgradesDistribution();
 }
示例#4
0
 private void NextIngredient()
 {
     if (this._currentReceiver != null)
     {
         if (this._disableMainColliderAfter)
         {
             this._currentReceiver._mainCollider.enabled = false;
             this._disableMainColliderAfter = false;
         }
         if (this._disableFilterColliderAfter)
         {
             this._currentReceiver._filterCollider.enabled = false;
             this._disableFilterColliderAfter = false;
         }
         this._currentReceiver = null;
     }
     if (++this._currentIngredientIndex < this._recipe._ingredients.Length)
     {
         if (this._supportedItemsCache.ContainsKey(this._recipe._ingredients[this._currentIngredientIndex]._itemID))
         {
             this._currentIngredientItemId = this._recipe._ingredients[this._currentIngredientIndex]._itemID;
             UpgradeViewReceiver[] receivers = this._receivers;
             for (int i = 0; i < receivers.Length; i++)
             {
                 UpgradeViewReceiver upgradeViewReceiver = receivers[i];
                 foreach (int current in upgradeViewReceiver._acceptedItemIds)
                 {
                     if (current == this._currentIngredientItemId)
                     {
                         this._currentReceiver = upgradeViewReceiver;
                         break;
                     }
                 }
                 if (this._currentReceiver != null)
                 {
                     break;
                 }
             }
             if (this._currentReceiver != null)
             {
                 this._implantsDone            = 0;
                 this._totalIngredientImplants = this._totalUpgrades * this._recipe._ingredients[this._currentIngredientIndex]._amount * this.SupportedItemsCache[this._currentIngredientItemId]._amount;
                 int amountOfUpgrades = this._craftingCog._inventory.GetAmountOfUpgrades(this._recipe._productItemID, this._currentIngredientItemId);
                 if (this._totalIngredientImplants + amountOfUpgrades >= this.SupportedItemsCache[this._currentIngredientItemId]._maxViewsPerItem)
                 {
                     this._totalIngredientImplants = this.SupportedItemsCache[this._currentIngredientItemId]._maxViewsPerItem - amountOfUpgrades;
                 }
                 this._stateStartTime = Time.realtimeSinceStartup;
                 if (!this._currentReceiver._mainCollider.enabled)
                 {
                     this._currentReceiver._mainCollider.enabled = true;
                     this._disableMainColliderAfter = true;
                 }
                 if (!this._currentReceiver._filterCollider.enabled)
                 {
                     this._currentReceiver._filterCollider.enabled = true;
                     this._disableFilterColliderAfter = true;
                 }
                 if (this._currentReceiver._filterCollider is CapsuleCollider)
                 {
                     CapsuleCollider capsuleCollider = (CapsuleCollider)this._currentReceiver._filterCollider;
                     this._circlePatternCapsuleFilterPivot = this.GetCapsuleAxis(this._currentReceiver, capsuleCollider) * ((float)UnityEngine.Random.Range(-1, 1) * (capsuleCollider.height / 2f)) + capsuleCollider.center;
                 }
                 this._circlePatternRotation = UnityEngine.Random.rotation;
             }
             else
             {
                 Debug.Log(string.Concat(new string[]
                 {
                     "No upgrade receiver for '",
                     ItemDatabase.ItemById(this._recipe._ingredients[this._currentIngredientIndex]._itemID)._name,
                     "' found on '",
                     this._craftView.name,
                     "' (for '",
                     this._recipe._name,
                     "')"
                 }));
             }
         }
         else
         {
             Debug.Log(string.Concat(new string[]
             {
                 "Unsupported item used in upgrade receipe : '",
                 this._recipe._name,
                 "', UpgradeCog is missing view for '",
                 ItemDatabase.ItemById(this._recipe._ingredients[this._currentIngredientIndex]._itemID)._name,
                 "'"
             }));
         }
     }
     else
     {
         this._stateStartTime = Time.realtimeSinceStartup;
         this._state          = UpgradeCog.States.MoveDown;
     }
 }