Example #1
0
        public bool FlushWorldItems()
        {
            bool flushedLimit = RecentlyCreatedWorldItems.Count > 10;

            mIsFlushingWorldItems = true;
            for (int i = RecentlyCreatedWorldItems.LastIndex(); i >= 0; i--)
            {
                WorldItem recentlyCreatedWorldItem = RecentlyCreatedWorldItems [i];
                if (recentlyCreatedWorldItem != null)
                {
                    if (!recentlyCreatedWorldItem.gameObject.activeSelf)
                    {
                        recentlyCreatedWorldItem.gameObject.SetActive(true);
                    }
                    recentlyCreatedWorldItem.Initialize();
                    //after calling intialize it will have been added to its group
                    //and its position will have been updated
                    //so we can safely predict its active state here
                }
            }
            RecentlyCreatedWorldItems.Clear();
            mIsFlushingWorldItems = false;

            RecentlyCreatedWorldItems.AddRange(WorldItemsCreatedWhileFlushing);
            WorldItemsCreatedWhileFlushing.Clear();

            return(flushedLimit);
        }
Example #2
0
        public virtual bool TakeDamage(WIMaterialType materialType, Vector3 damagePoint, float attemptedDamage, Vector3 attemptedForce, string damageSource, out float actualDamage, out bool isDead)
        {
            actualDamage       = attemptedDamage;
            isDead             = false;
            State.TotalDamage += actualDamage;

            if (HasPlayerFocus)
            {
                GUIHud.Get.ShowProgressBar(Colors.Get.GeneralHighlightColor, Colors.Darken(Colors.Get.GenericNeutralValue), NormalizedDamage);
            }

            if (State.SpawnOnDamaage && State.TotalDamage >= State.SpawnDamageMinimum)                                          //reset
            {
                State.TotalDamage = 0f;
                //spawn a thing
                WorldItem worlditem = null;
                if (WorldItems.CloneRandomFromCategory(State.SpawnCategory, ParentChunk.AboveGroundGroup, out worlditem))
                {
                    //spit it out at the player
                    Vector3 direction = (Player.Local.Position - damagePoint).normalized * 5f;
                    worlditem.tr.parent   = ParentChunk.AboveGroundGroup.transform;
                    worlditem.tr.position = damagePoint;
                    worlditem.Props.Local.FreezeOnStartup = false;
                    worlditem.Props.Local.Transform.CopyFrom(worlditem.tr);
                    worlditem.Initialize();
                    worlditem.SetMode(WIMode.World);
                    worlditem.ApplyForce(direction, damagePoint);
                    FXManager.Get.SpawnFX(worlditem.tr, "DrawAttentionToItem");
                    worlditem.GetOrAdd <DespawnOnPlayerLeave>();
                }
            }
            return(true);
        }
Example #3
0
        // = new GenericWorldItem ();
        public void CreateDarkrotSpawner(Vector3 spawnerPosition, Vector3 spawnerRotation, WIGroup group, int numDarkrotReleaesd, float releaseDelay, float releaseInterval)
        {
            StackItem spawnerStackItem = gDarkrotSpawner.ToStackItem();

            spawnerStackItem.Transform.Position          = spawnerPosition;
            spawnerStackItem.Transform.Rotation          = spawnerRotation;
            spawnerStackItem.Props.Local.FreezeOnStartup = true;
            spawnerStackItem.Props.Local.Mode            = WIMode.Frozen;
            WorldItem newSpawner = null;

            if (WorldItems.CloneFromStackItem(spawnerStackItem, group, out newSpawner))
            {
                newSpawner.Initialize();
                DarkrotSpawner ds = newSpawner.Get <DarkrotSpawner> ();
                ds.State.MaxDarkrotAtOneTime = numDarkrotReleaesd;
                ds.State.SpawnDelay          = releaseDelay;
                ds.State.SpawnInterval       = releaseInterval;
            }
            Debug.Log("Created spawner");
        }
Example #4
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            WIListResult dialogResult = secondaryResult as WIListResult;

            switch (dialogResult.SecondaryResult)
            {
            case "Drink":
                if (!CanBuyDrink)
                {
                    if (gBartenderSpeech == null)
                    {
                        gBartenderSpeech = new Speech();
                    }
                    gBartenderSpeech.Text = "That's enough for one night, {lad/lass}.";
                    worlditem.Get <Talkative>().SayDTS(gBartenderSpeech);
                }
                else
                {
                    if (Player.Local.Inventory.InventoryBank.TryToRemove(PricePerDrink))
                    {
                        Profile.Get.CurrentGame.Character.Rep.GainGlobalReputation(1);
                        //spawn a cup and put some mead in it
                        WorldItem cup = null;
                        if (WorldItems.CloneRandomFromCategory("BartenderCups", WIGroups.Get.World, out cup))
                        {
                            cup.Initialize();
                            LiquidContainer container = null;
                            if (cup.Is <LiquidContainer>(out container))
                            {
                                container.State.Contents.CopyFrom(BartenderDrinkContents);
                                container.State.Contents.InstanceWeight = container.State.Capacity;
                            }
                            //try to equip it in the player's hands
                            Player.Local.Inventory.TryToEquip(cup);
                        }
                        State.NumTimesBoughtDrink++;
                        State.NumTimesBoughtDrinkTonight++;
                        State.LastTimeBoughtDrink = WorldClock.AdjustedRealTime;
                    }
                }
                break;

            case "Round":
                if (Player.Local.Inventory.InventoryBank.TryToRemove(PricePerRound))
                {
                    if (gBartenderSpeech == null)
                    {
                        gBartenderSpeech = new Speech();
                    }
                    gBartenderSpeech.Text = "Looks like this round's on {PlayerFirstName}!";
                    worlditem.Get <Talkative>().SayDTS(gBartenderSpeech);
                    Profile.Get.CurrentGame.Character.Rep.GainGlobalReputation(5);
                    State.NumTimesBoughtRound++;
                    State.LastTimeBoughtRound = WorldClock.AdjustedRealTime;
                }
                break;

            default:
                break;
            }
        }