ObjectInteraction.CreateNewObject C# (CSharp) Method

CreateNewObject() public static method

Creates a new game object at run time.
public static CreateNewObject ( int NewItem_id ) : ObjectInteraction
NewItem_id int New item identifier.
return ObjectInteraction
    public static ObjectInteraction CreateNewObject(int NewItem_id)
    {
        //Create the new object
                GameObject myObj = new GameObject ("SummonedObject_" + GameWorldController.instance.playerUW.PlayerMagic.SummonCount++);
                myObj.layer = LayerMask.NameToLayer ("UWObjects");
                myObj.transform.position = GameWorldController.instance.playerUW.playerInventory.InventoryMarker.transform.position;
                myObj.transform.parent = GameWorldController.instance.playerUW.playerInventory.InventoryMarker.transform;
                GameObject SpriteObj = ObjectInteraction.CreateObjectGraphics (myObj, _RES + "/Sprites/Objects/Objects_" + NewItem_id, true);
                ObjectMasters objM = GameWorldController.instance.objectMaster;
                ObjectInteraction objInt = ObjectInteraction.CreateObjectInteraction (myObj, 0.5f, 0.5f, 0.5f, 0.5f, objM.particle [NewItem_id], objM.InvIcon [NewItem_id], objM.InvIcon [NewItem_id], objM.type [NewItem_id], NewItem_id, 1, 40, 0, objM.isMoveable [NewItem_id], 1, 0, 1, 1, 0, 0, 1);
                //Some known examples that occur
                switch (NewItem_id) {
                case 10://Sword of justice
                        myObj.AddComponent<WeaponMelee>();
                        break;
                case 47://Dragonskin boots
                        myObj.AddComponent<Boots>();
                        objInt.Link=  SpellEffect.UW1_Spell_Effect_Flameproof_alt01+256-16;
                        objInt.isEnchanted=true;
                        break;
                case 276://Exploding book
                        myObj.AddComponent<ReadableTrap>();
                        break;
                case 299:
                        //Fishing pole
                        myObj.AddComponent<FishingPole> ();
                        break;
                case 182://fish
                case 183://Popcorn
                case 217://Rotworm corpse
                        Food fd = myObj.AddComponent<Food> ();
                        fd.Nutrition = 5;
                        break;
                case 314://Scroll given by biden?
                        myObj.AddComponent<Readable>();//Scroll given by Biden
                        break;
                case 339://Boulders
                case 340:
                case 341:
                case 342:
                        myObj.AddComponent<Boulder>();
                        break;
                default:
                        myObj.AddComponent<object_base> ();
                        break;
                }
                //GameWorldController.instance.playerUW.playerInventory.ObjectInHand = myObj.name;
                myObj.AddComponent<StoreInformation>();
                SpriteObj.AddComponent<StoreInformation>();
                return objInt;//myObj.GetComponent<ObjectInteraction> ();
    }

Usage Example

Ejemplo n.º 1
0
    private bool PickUpSeed()
    {
        ObjectLoaderInfo newseed = ObjectLoader.newObject(290, 40, 16, 1, 256);

        newseed.is_quant = 1;
        ObjectInteraction newseedobj = ObjectInteraction.CreateNewObject
                                       (
            CurrentTileMap(),
            newseed,
            CurrentObjectList().objInfo,
            GameWorldController.instance.InventoryMarker.gameObject,
            CurrentTileMap().getTileVector(TileMap.ObjectStorageTile, TileMap.ObjectStorageTile)
                                       );

        GameWorldController.MoveToInventory(newseedobj.gameObject);
        UWCharacter.Instance.ResurrectPosition = Vector3.zero;
        UWCharacter.Instance.ResurrectLevel    = 0;
        UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 9));
        CurrentObjectInHand = newseedobj;
        //newseedobj.UpdateAnimation();
        //UWHUD.instance.CursorIcon = newseedobj.GetWorldDisplay().texture;
        UWCharacter.InteractionMode      = UWCharacter.InteractionModePickup;
        InteractionModeControl.UpdateNow = true;

        objInt().consumeObject();
        return(true);
    }
All Usage Examples Of ObjectInteraction::CreateNewObject