示例#1
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            WIListResult dialogResult = secondaryResult as WIListResult;

            switch (dialogResult.SecondaryResult)
            {
            case "Pluck":
                WIStackError error            = WIStackError.None;
                WorldItem    pluckedWorldItem = null;
                if (WorldItems.CloneWorldItem(PluckedItem, STransform.zero, false, WIGroups.GetCurrent(), out pluckedWorldItem))
                {
                    pluckedWorldItem.Initialize();
                }
                Player.Local.Inventory.AddItems(pluckedWorldItem, ref error);
                creature.OnTakeDamage();
                creature.FleeFromThing(Player.Local);
                break;

            default:
                break;
            }
        }
示例#2
0
        public void OnClickSquare()
        {
            Debug.Log("Clicking result square");
            WIStackError error = WIStackError.None;

            if (ReadyForRetrieval)
            {
                Debug.Log("Is ready for retrieval");
                while (NumItemsCrafted > 0)
                {
                    StackItem craftedItem = CraftedItemTemplate.ToStackItem();
                    craftedItem.Group = WIGroups.Get.Player;
                    if (craftedItem.CanEnterInventory)
                    {
                        if (Player.Local.Inventory.AddItems(craftedItem, ref error))
                        {
                            Debug.Log("Added item to inventory");
                            NumItemsCrafted--;
                        }
                        else
                        {
                            Debug.Log("Couldn't add to inventory, what now?");
                            break;
                        }
                    }
                    else
                    {
                        Debug.Log("We have to carry the item");
                        if (Player.Local.ItemPlacement.IsCarryingSomething)
                        {
                            Player.Local.ItemPlacement.PlaceOrDropCarriedItem();
                        }
                        //turn it into a worlditem and have the player carry it
                        WorldItem craftedWorldItem = null;
                        if (WorldItems.CloneFromStackItem(craftedItem, WIGroups.GetCurrent(), out craftedWorldItem))
                        {
                            craftedWorldItem.Props.Local.CraftedByPlayer = true;
                            craftedWorldItem.Initialize();
                            craftedWorldItem.ActiveState = WIActiveState.Active;
                            craftedWorldItem.Props.Local.FreezeOnStartup = false;
                            craftedWorldItem.tr.rotation = Quaternion.identity;
                            craftedWorldItem.SetMode(WIMode.World);
                            craftedWorldItem.tr.position = Player.Local.ItemPlacement.GrabberIdealPosition;
                            craftedWorldItem.LastActiveDistanceToPlayer = 0f;
                            //if we have an interface open, close it now
                            GUIInventoryInterface.Get.Minimize();
                            //then force the player to carry the item
                            if (Player.Local.ItemPlacement.ItemCarry(craftedWorldItem, true))
                            {
                                NumItemsCrafted--;
                            }
                            else
                            {
                                GUIManager.PostWarning("You have to drop what you're carrying first");
                            }
                            //set placement mode to true immediately
                            Player.Local.ItemPlacement.PlacementModeEnabled = true;
                        }
                        break;
                    }
                }
            }
            else
            {
                Debug.Log("Not ready for retrieval");
            }

            RefreshRequest();
        }
示例#3
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            WIListResult dialogResult = secondaryResult as WIListResult;

            switch (dialogResult.SecondaryResult)
            {
            case "Shear":
                State.LastTimeSheared = WorldClock.AdjustedRealTime;
                //spawn a random number of wool items
                //make it pop off the chest body part, upwards
                WorldItem shearedWorldItem = null;
                BodyPart  chestBodyPart    = null;
                creature.Body.GetBodyPart(BodyPartType.Chest, out chestBodyPart);
                Bounds        colliderBounds = chestBodyPart.PartCollider.bounds;
                Vector3       popPosition;
                Vector3       popDirection;
                System.Random random          = new System.Random(Profile.Get.CurrentGame.Seed);
                int           numShearedItems = random.Next(MinShearedItems, MaxShearedItems);
                Debug.Log("Shearing " + numShearedItems.ToString() + " Items in " + name);
                for (int i = 0; i < numShearedItems; i++)
                {
                    popPosition = (UnityEngine.Random.onUnitSphere * 5f) + chestBodyPart.tr.position;
                    popPosition = chestBodyPart.PartCollider.ClosestPointOnBounds(popPosition);
                    //give it a push in a direction away from the body
                    popDirection = Vector3.Normalize(chestBodyPart.tr.position - popPosition);

                    if (WorldItems.CloneWorldItem(ShearedItem, STransform.zero, false, WIGroups.GetCurrent(), out shearedWorldItem))
                    {
                        shearedWorldItem.Initialize();
                        shearedWorldItem.SetMode(WIMode.World);
                        shearedWorldItem.tr.position = popPosition;
                        shearedWorldItem.ApplyForce(popDirection, popPosition);
                    }
                    //let them all fall away
                }
                //the creature freaks out but doesn't actually take damage
                creature.OnTakeDamage();
                break;

            default:
                break;
            }
        }