예제 #1
0
        public static int CalculateLocalPrice(int baseValue, IWIBase item)
        {
            if (item == null)
            {
                return(baseValue);
            }

            object wearableStateObject = null;

            if (item.GetStateOf <Wearable>(out wearableStateObject))
            {
                WearableState w = (WearableState)wearableStateObject;
                if (w != null)
                {
                    baseValue += Mathf.CeilToInt(Mathf.Max(0, w.ColdProtection * Globals.BaseValueWearable));
                    baseValue += Mathf.CeilToInt(Mathf.Max(0, w.HeatProtection * Globals.BaseValueWearable));
                    baseValue += Mathf.CeilToInt(Mathf.Max(0, w.EnergyProtection * Globals.BaseValueWearable));
                    baseValue += Mathf.CeilToInt(Mathf.Max(0, w.VisibilityChange * Globals.BaseValueWearable));
                    baseValue += Mathf.CeilToInt(Mathf.Max(0, w.StrengthChange * Globals.BaseValueWearable));
                }
            }
            else
            {
                Debug.Log("Couldn't get state");
            }
            return(baseValue);
        }
예제 #2
0
        public override void SetProperties()
        {
            ShowDoppleganger             = false;
            DopplegangerProps.PackName   = string.Empty;
            DopplegangerProps.PrefabName = string.Empty;
            DopplegangerMode             = WIMode.Stacked;
            DopplegangerProps.State      = "Default";
            MouseoverHover   = false;
            NormalizedDamage = 0f;
            DisplayMode      = SquareDisplayMode.Empty;

            if (IsEnabled)
            {
                MouseoverHover = true;
                if (mStack.HasTopItem)
                {
                    //Debug.Log("Wearable has top item: " + mStack.TopItem.FileName);
                    DisplayMode = SquareDisplayMode.Enabled;
                    IWIBase topItem = mStack.TopItem;
                    DopplegangerProps.CopyFrom(topItem);
                    ShowDoppleganger = true;
                    //get the damageable properties
                    System.Object damageableStateObject = null;
                    if (topItem.GetStateOf <Damageable>(out damageableStateObject))
                    {
                        DamageableState state = damageableStateObject as DamageableState;
                        NormalizedDamage = state.NormalizedDamage;
                    }
                }
            }
        }
예제 #3
0
 public void FinishCheckingPreviousVisits(IWIBase iwiBase)
 {
     if (iwiBase == null)
     {
         //failure! since it's a Location - which should never return null - put out a warning
         Debug.LogError("WARNING: Location returned null in objective script - this should never happen! looknig for" + LocationReference.FullPath);
     }
     else if (iwiBase.IsWorldItem)
     {
         Visitable visitable = null;
         if (iwiBase.worlditem.Is <Visitable> (out visitable))
         {
             NumTimesVisitedOnActivation = visitable.State.NumTimesVisited;
         }
     }
     else
     {
         object stateData = null;
         if (iwiBase.GetStateOf <Visitable> (out stateData))
         {
             VisitableState visitableState = stateData as VisitableState;
             NumTimesVisitedOnActivation = visitableState.NumTimesVisited;
         }
     }
 }
예제 #4
0
        public bool FillLiquidContainer(IWIBase liquidContainer, IWIBase foodStuff, WIStack foodStuffStack)
        {
            if (!foodStuff.Is <FoodStuff>())
            {
                //nope! can't do it
                return(false);
            }

            System.Object fssObject = null;
            //check the foodstuff first since it has to be liquid
            if (foodStuff.GetStateOf <FoodStuff>(out fssObject))
            {
                FoodStuffState fss = (FoodStuffState)fssObject;
                if (fss.IsLiquid(foodStuff.State))
                {
                    //okay we've confirmed it's a liquid
                    //now see if the liquid container can hold it
                    if (!liquidContainer.Is <LiquidContainer>())
                    {
                        //we're returning true because it'll make the correct noise and the item will disappear
                        GUIManager.PostWarning("The liquid cannot be held by this container. It seeps away.");
                        foodStuff.RemoveFromGame();
                        return(true);
                    }

                    System.Object lcObject = null;
                    if (liquidContainer.GetStateOf <LiquidContainer>(out lcObject))
                    {
                        LiquidContainerState lcs         = (LiquidContainerState)lcObject;
                        string           liquidFillError = string.Empty;
                        int              numFilled       = 0;
                        GenericWorldItem genericLiquid   = new GenericWorldItem(foodStuff);
                        if (lcs.TryToFillWith(genericLiquid, foodStuffStack.NumItems, out numFilled, out liquidFillError))
                        {
                            //hooray, it worked
                            //how we have to pop items off the top of the food stuff stack
                            for (int i = 0; i < numFilled; i++)
                            {
                                Stacks.Pop.AndToss(foodStuffStack);
                            }
                            GUIManager.PostInfo("Filled " + numFilled.ToString());
                            return(true);
                        }
                        else
                        {
                            GUIManager.PostWarning(liquidFillError);
                        }
                    }
                }
            }
            return(false);
        }
예제 #5
0
        public int CalculateLocalValue(int baseValue, IWIBase item)
        {
            if (item == null)
            {
                return(baseValue);
            }

            object flowerPotStateObject = null;

            if (item.GetStateOf <FlowerPot>(out flowerPotStateObject))
            {
                FlowerPotState f = (FlowerPotState)flowerPotStateObject;
                if (f != null)
                {
                    baseValue += Plants.Get.BaseCurrencyValueOfPlant(f.PlantName);
                }
            }
            return(baseValue);
        }
예제 #6
0
        public void FinishChecking(IWIBase iwiBase)
        {
            mLoadingStackItem = false;

            if (iwiBase == null)
            {
                //failure! since it's a Location - which should never return null - put out a warning
                Debug.LogError("WARNING: Location returned null in objective script - this should never happen!");
            }
            else if (iwiBase.IsWorldItem)
            {
                Visitable visitable = null;
                if (iwiBase.worlditem.Is <Visitable> (out visitable))
                {
                    if (IgnorePreviousVisits)
                    {
                        HasCompleted = visitable.State.NumTimesVisited > NumTimesVisitedOnActivation;
                    }
                    else
                    {
                        HasCompleted = visitable.State.NumTimesVisited > 0;
                    }
                }
            }
            else
            {
                object stateData = null;
                if (iwiBase.GetStateOf <Visitable> (out stateData))
                {
                    VisitableState visitableState = stateData as VisitableState;
                    if (IgnorePreviousVisits)
                    {
                        HasCompleted = visitableState.NumTimesVisited > NumTimesVisitedOnActivation;
                    }
                    else
                    {
                        HasCompleted = visitableState.NumTimesVisited > 0;
                    }
                }
            }
            FinishedChecking = true;
        }
예제 #7
0
        public static int CalculateLocalPrice(int basePrice, IWIBase item)
        {
            if (item == null)
            {
                return(basePrice);
            }

            object foodStuffStateObject = null;

            if (item.GetStateOf <FoodStuff>(out foodStuffStateObject))
            {
                FoodStuffState f = (FoodStuffState)foodStuffStateObject;
                if (f != null)
                {
                    basePrice += CalculateFoodStuffLocalPrice(f.PotentialProps, item.State);
                }
            }

            return(basePrice);
        }
예제 #8
0
파일: Purse.cs 프로젝트: yazici/FRONTIERS
        public static int CalculateLocalPrice(int basePrice, IWIBase item)
        {
            if (item == null)
            {
                return(basePrice);
            }

            object purseStateObject = null;

            if (item.GetStateOf <Purse>(out purseStateObject))
            {
                PurseState p = (PurseState)purseStateObject;
                if (p != null)
                {
                    basePrice = basePrice + p.TotalValue;
                }
            }

            return(basePrice);
        }
예제 #9
0
        public static int CalculateLocalPrice(int basePrice, IWIBase item)
        {
            if (item == null)
            {
                return(basePrice);
            }

            object luminiteStateObject = null;

            if (item.GetStateOf <Luminite> (out luminiteStateObject))
            {
                LuminiteState l = (LuminiteState)luminiteStateObject;
                if (l != null)
                {
                    basePrice += Mathf.CeilToInt(l.MaxCharge * Globals.BaseValueLuminite);
                }
            }

            return(basePrice);
        }
예제 #10
0
        public static int CalculateLocalPrice(int basePrice, IWIBase item)
        {
            if (item == null)
            {
                return(basePrice);
            }

            object foodStuffStateObject = null;

            if (item.GetStateOf <BookAvatar>(out foodStuffStateObject))
            {
                BookAvatarState b = (BookAvatarState)foodStuffStateObject;
                if (b != null)
                {
                    basePrice += Books.GetLocalPrice(b.BookName);
                }
            }

            return(basePrice);
        }
예제 #11
0
        public static bool ConsumeRequirement(WIStack itemStack, IWIBase item, GenericWorldItem template, bool requirementsMet)
        {
            if (!requirementsMet)
            {
                return(false);
            }

            bool result = false;

            if (item.Is <LiquidContainer> ())
            {
                //see if the thing inside the liquid container has what we need
                bool foundState                  = false;
                LiquidContainerState state       = null;
                System.Object        stateObject = null;
                if (item.GetStateOf <LiquidContainer> (out stateObject))
                {
                    state      = (LiquidContainerState)stateObject;
                    foundState = state != null;
                }

                if (foundState)
                {
                    //hooray it is a liquid
                    if (!state.IsEmpty)
                    {
                        //and it's not empty so steal one
                        state.Contents.InstanceWeight--;
                        result = true;
                        item.SetStateOf <LiquidContainer> (state);
                    }
                }
            }
            else
            {
                Stacks.Pop.AndToss(itemStack);
                result = true;
            }
            return(result);
        }
예제 #12
0
        public static int CalculateLocalPrice(int baseValue, IWIBase item)
        {
            if (item == null)
            {
                return(baseValue);
            }

            object weaponStateObject = null;

            if (item.GetStateOf <Weapon>(out weaponStateObject))
            {
                WeaponState w = (WeaponState)weaponStateObject;
                if (w != null)
                {
                    //Debug.Log("Adding to base value of weapon, " + baseValue.ToString());
                    float delays = w.BaseSwingDelay + w.BaseWindupDelay + w.BaseEquipInterval + w.BaseHitInterval + w.BaseSwingDuration + w.BaseSwingRate + w.BaseImpactTime;
                    baseValue += Mathf.CeilToInt(Mathf.Clamp(20f - delays, 0f, Mathf.Infinity) * Globals.BaseValueWeaponDelayInterval);
                    baseValue += Mathf.CeilToInt(w.BaseDamagePerHit * Globals.BaseValueWeaponDamagePerHit);
                    baseValue += Mathf.CeilToInt(w.BaseForcePerHit * Globals.BaseValueWeaponForcePerHit);
                    baseValue += Mathf.CeilToInt(0.5f - w.BaseStrengthDrain * Globals.BaseValueWeaponStrengthDrain);
                    if (w.HasBeenImproved)
                    {
                        baseValue = baseValue * w.NumTimesImproved;
                    }
                    baseValue += w.NumTimesUsedSuccessfully;
                    baseValue += w.NumTimesKilledTarget * 10;
                    if (!string.IsNullOrEmpty(w.ProjectileType))
                    {
                        baseValue = Mathf.CeilToInt(baseValue * Globals.BaseValueWeaponProjectileMultiplier);
                    }
                }
            }
            else
            {
                Debug.Log("Couldn't get state");
            }
            return(baseValue);
        }
예제 #13
0
        public void FinishChecking(IWIBase iwiBase)
        {
            mLoadingStackItem = false;

            if (iwiBase == null)
            {
                FinishedChecking = true;
                HasCompleted     = false;
                return;
            }

            System.Object structureStateObject = null;
            if (iwiBase.GetStateOf <Structure> (out structureStateObject))
            {
                StructureState structureState = (StructureState)structureStateObject;
                HasCompleted = Flags.Check((uint)LoadState, (uint)structureState.LoadState, Flags.CheckType.MatchAll);
                if (HasCompleted)
                {
                    Status |= MissionStatus.Completed;
                }
            }
            FinishedChecking = true;
        }
예제 #14
0
        public void AquireLastOffer()
        {
            if (LastOfferItems == null || string.IsNullOrEmpty(LastOfferType))
            {
                return;
            }

            Player.Local.Inventory.InventoryBank.AddBaseCurrencyOfType(LastOfferMade, WICurrencyType.A_Bronze);

            for (int i = 0; i < LastOfferItems.Count; i++)
            {
                mLastOfferItem = LastOfferItems[i];
                //update which items we've aquired
                switch (LastOfferType)
                {
                case "UndatedShard":
                    ActiveMuseum.UndatedShardAquired++;
                    break;

                case "UndatedSmall":
                    ActiveMuseum.UndatedSmallAquired++;
                    break;

                case "DatedShard":
                    if (mLastOfferItem.GetStateOf <ArtifactShard>(out mArtifactStateObject))
                    {
                        mArtifactShardState = (ArtifactShardState)mArtifactStateObject;
                        ActiveMuseum.DatedShardsAquired.Add(mArtifactShardState.Age);
                    }
                    break;

                case "DatedSmall":
                    if (mLastOfferItem.GetStateOf <Artifact>(out mArtifactStateObject))
                    {
                        mArtifactState = (ArtifactState)mArtifactStateObject;
                        ArtifactQuality currentQuality;
                        if (!ActiveMuseum.SmallArtifactsAquired.TryGetValue(mArtifactState.Age, out currentQuality))
                        {
                            //if we haven't alread aquired this age add it now
                            ActiveMuseum.SmallArtifactsAquired.Add(mArtifactState.Age, mArtifactState.Quality);
                        }
                        else if (IsOfHigherQuality(mArtifactState.Quality, currentQuality))
                        {
                            //set the existing entry to the newer level of quality
                            ActiveMuseum.SmallArtifactsAquired[mArtifactState.Age] = mArtifactState.Quality;
                        }
                    }
                    break;

                case "DatedLarge":
                    if (mLastOfferItem.GetStateOf <Artifact>(out mArtifactStateObject))
                    {
                        mArtifactState = (ArtifactState)mArtifactStateObject;
                        ArtifactQuality currentQuality;
                        if (!ActiveMuseum.LargeArtifactsAquired.TryGetValue(mArtifactState.Age, out currentQuality))
                        {
                            //if we haven't alread aquired this age add it now
                            ActiveMuseum.LargeArtifactsAquired.Add(mArtifactState.Age, mArtifactState.Quality);
                        }
                        else if (IsOfHigherQuality(mArtifactState.Quality, currentQuality))
                        {
                            //set the existing entry to the newer level of quality
                            ActiveMuseum.LargeArtifactsAquired[mArtifactState.Age] = mArtifactState.Quality;
                        }
                    }
                    break;

                default:
                    Debug.Log("Couldn't find artifact type " + LastOfferType);
                    break;
                }
                //destroy it - the curator will disply a doppleganger
                mLastOfferItem.RemoveFromGame();
            }

            Mods.Get.Runtime.SaveMod(ActiveMuseum, "Museum", ActiveMuseum.Name);


            LastOfferItems.Clear();
            UndatedShard.Clear();
            UndatedSmall.Clear();
            DatedShard.Clear();
            DatedSmall.Clear();
            DatedLarge.Clear();
            //this will force the containers to update their newly missing items
            GUI.GUIInventoryInterface.Get.RefreshContainers();

            RefreshCuratedItems();
        }
예제 #15
0
        public void RefreshAvailableArtifacts()
        {
            UndatedShard.Clear();
            UndatedSmall.Clear();
            DatedShard.Clear();
            DatedSmall.Clear();
            DatedLarge.Clear();

            mAvailableArtifacts.Clear();
            //this goes through the player's inventory and looks for
            //anything they can sell to the museum
            //this is used by converstions to search the player's inventory once
            //instead of for every exchange
            Player.Local.Inventory.FindItemsOfType("Artifact", mAvailableArtifacts);
            for (int i = 0; i < mAvailableArtifacts.Count; i++)
            {
                mCurrentArtifact = mAvailableArtifacts[i];
                if (mCurrentArtifact.GetStateOf <Artifact>(out mArtifactStateObject))
                {
                    mArtifactState = (ArtifactState)mArtifactStateObject;
                    //check if it's dated or not
                    if (mArtifactState.HasBeenDated)
                    {
                        if (mCurrentArtifact.StackName.Contains("Large"))
                        {
                            DatedLarge.SafeAdd(mCurrentArtifact);
                        }
                        else
                        {
                            DatedSmall.SafeAdd(mCurrentArtifact);
                        }
                    }
                    else
                    {
                        UndatedSmall.SafeAdd(mCurrentArtifact);
                    }
                }
            }

            mAvailableArtifacts.Clear();
            Player.Local.Inventory.FindItemsOfType("ArtifactShard", mAvailableArtifacts);
            for (int i = 0; i < mAvailableArtifacts.Count; i++)
            {
                mCurrentArtifact = mAvailableArtifacts[i];
                if (mCurrentArtifact.GetStateOf <ArtifactShard>(out mArtifactStateObject))
                {
                    mArtifactShardState = (ArtifactShardState)mArtifactStateObject;
                    //check if it's dated or not
                    if (mArtifactState.HasBeenDated)
                    {
                        DatedShard.SafeAdd(mCurrentArtifact);
                    }
                    else
                    {
                        UndatedShard.SafeAdd(mCurrentArtifact);
                    }
                }
            }

            /*
             * Debug.Log("Found " + UndatedShardAvailable.ToString() + " Undated Shard Available");
             * Debug.Log("Found " + UndatedSmallAvailable.ToString() + " Undated Small Available");
             * Debug.Log("Found " + DatedShardAvailable.ToString() + " Dated Shard Available");
             * Debug.Log("Found " + DatedSmallAvailable.ToString() + " Dated Small Available");
             * Debug.Log("Found " + DatedLargeAvailable.ToString() + " Dated Large Available");
             */
        }