CreateNewObject() 공개 정적인 메소드

Creates a new game object at run time.
public static CreateNewObject ( int NewItem_id ) : ObjectInteraction
NewItem_id int New item identifier.
리턴 ObjectInteraction
예제 #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);
    }
예제 #2
0
    private void LeftOvers()
    {
        int LeftOverToCreate = -1;

        switch (item_id)
        {
        case 176:
        case 177:    //meat
            LeftOverToCreate = 197; break;

        case 186:    //honeycomb
            LeftOverToCreate = 210; break;

        case 187:
        case 188:
        case 189:    //bottles.
            LeftOverToCreate = 317; break;
        }

        if (LeftOverToCreate != -1)
        {
            ObjectLoaderInfo newobjt = ObjectLoader.newObject(LeftOverToCreate, 40, 0, 0, 256);
            newobjt.InUseFlag = 1;
            ObjectInteraction created = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, GameWorldController.instance.InventoryMarker.transform.position);
            GameWorldController.MoveToWorld(created.gameObject);
            CurrentObjectInHand = created;
            //UWHUD.instance.CursorIcon = created.GetInventoryDisplay().texture;
            UWCharacter.InteractionMode = UWCharacter.InteractionModePickup;
        }
    }
예제 #3
0
    public void GiveKeyOfTruth()
    {
        if (HasGivenKey == false)
        {
            //Code to spawn key of truth in player hand
            //Debug.Log ("You get the key of truth");
            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_none_of_your_skills_improved_));            //No skills appear
            //inputctrl.text=UWHUD.instance.MessageScroll.text;
            Shrine.HasGivenKey = true;
            //create the key of truth.
            ObjectLoaderInfo newobjt = ObjectLoader.newObject(225, 0, 0, 0, 256);
            GameObject       key     = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject;
            GameWorldController.MoveToInventory(key);
            ObjectInteraction myObjInt = key.GetComponent <ObjectInteraction>();


            /*ObjectInteraction myObjInt = ObjectInteraction.CreateNewObject(225);
             * myObjInt.gameObject.transform.parent=GameWorldController.instance.InventoryMarker.transform;
             * GameWorldController.MoveToInventory(myObjInt.gameObject);*/
            UWCharacter.Instance.playerInventory.ObjectInHand = myObjInt.name;
            UWHUD.instance.CursorIcon        = myObjInt.GetInventoryDisplay().texture;
            UWCharacter.InteractionMode      = UWCharacter.InteractionModePickup;
            InteractionModeControl.UpdateNow = true;
        }
    }
예제 #4
0
 public static GameObject SpawnHitImpact(int Item_ID, Vector3 ImpactPosition, int StartFrame, int EndFrame)
 {
     try
     {
         ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(Item_ID, 40, StartFrame, 1, 256);
         if (newobjt != null)
         {
             ObjectInteraction objInt = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, ImpactPosition);
             //objInt.GetComponent<AnimationOverlay>().Looping = false;
             objInt.GetComponent <AnimationOverlay>().StartFrame       = StartFrame;
             objInt.GetComponent <AnimationOverlay>().NoOfFrames       = EndFrame - StartFrame;
             objInt.GetComponent <AnimationOverlay>().StartingDuration = objInt.GetComponent <AnimationOverlay>().NoOfFrames;
             objInt.gameObject.layer = LayerMask.NameToLayer("Animation");
             return(objInt.gameObject);
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         return(null);
     }
 }
	/*
	An arrow trap is used to fire projectiles (usually at the player).
	The item type created is controlled by the object quality and owner
	target = (currobj.quality << 5) | currobj.owner; //This is set in UWexporter

	The vector is simply the heading of the trap.

	Examples of usage
	The mine collapse on level2
	The skulls launched at the player on level3 -Troll area.
	*/

	public override void ExecuteTrap (object_base src, int triggerX, int triggerY, int State)
	{
		int item_index=  (quality << 5) | owner;

		ObjectLoaderInfo newobjt= ObjectLoader.newWorldObject(item_index,0,0,0,256);
		GameObject myObj = ObjectInteraction.CreateNewObject(CurrentTileMap(),newobjt,CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position).gameObject;
		if (ObjectTileX == TileMap.ObjectStorageTile)
		{
			Vector3 pos = CurrentTileMap().getTileVector(triggerX,triggerY);
			pos = new Vector3(pos.x,this.transform.position.y,pos.z);
			myObj.transform.position=pos;
		}
		else
		{
			myObj.transform.position = this.transform.position;			
		}
		myObj.transform.rotation = this.transform.rotation;	
		if (myObj.GetComponent<Rigidbody>()==null)
		{
			myObj.AddComponent<Rigidbody>();
		}

		UnFreezeMovement(myObj);
		myObj.GetComponent<Rigidbody>().collisionDetectionMode=CollisionDetectionMode.Continuous;
		myObj.GetComponent<Rigidbody>().AddForce(myObj.transform.forward* 20.0f *((float)(owner)));
		
		GameObject myObjChild = new GameObject(myObj.name + "_damage");
		myObjChild.transform.position =myObj.transform.position;
		myObjChild.transform.parent =myObj.transform;
		ProjectileDamage pd= myObjChild.AddComponent<ProjectileDamage>();
		pd.Source=this.gameObject;//Traps don't need to be identified.
		pd.Damage=10;//Dunno what drives damage here?
		pd.AttackCharge=100f;
		pd.AttackScore=15;//down the middle.
	}
예제 #6
0
    protected override void Start()
    {
        base.Start();
        if (_RES == GAME_UW2)
        {
            if (SpellObjectOwnerToCreate == -1)
            {            //This is  wand with infinite charges. Does not use a spell object for it's enchantment.
                //Debug.Log("linking wand " + this.name + " to an existing spell");
                //SpellObjectLink = ObjectLoader.getObjectIntAt(objInt().link).link;
            }
            else
            {
                if (objInt().PickedUp)
                {                //A wand and spell in the inventory loaded from a playerdat file. Need to create it's spell object now
                    ObjectLoaderInfo  newobjt = ObjectLoader.newObject(288, SpellObjectQualityToCreate, SpellObjectOwnerToCreate, SpellObjectLink, 256);
                    ObjectInteraction spell   = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.LevelMarker().gameObject, GameWorldController.instance.LevelMarker().position);
                    objInt().link = newobjt.index;
                }
            }
        }        //UW2 stores enchantments on the player.dat. This is not properly implemented yet


        if (ObjectLoader.getObjectIntAt(objInt().link) != null)
        {
            SpellObjectLink = ObjectLoader.getObjectIntAt(objInt().link).link;
        }
    }
예제 #7
0
    public override bool use()
    {
        if (CurrentObjectInHand == null)
        {
            if ((objInt().PickedUp == true))
            {
                ObjectLoaderInfo newtree = ObjectLoader.newWorldObject(458, 40, 16, 1, 256);
                newtree.is_quant = 1;
                ObjectInteraction.CreateNewObject
                (
                    CurrentTileMap(),
                    newtree,
                    CurrentObjectList().objInfo,
                    GameWorldController.instance.DynamicObjectMarker().gameObject,
                    CurrentTileMap().getTileVector(TileMap.visitTileX, TileMap.visitTileY)
                );

                UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 12));

                //UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault;
                UWCharacter.Instance.ResurrectPosition = UWCharacter.Instance.transform.position;
                UWCharacter.Instance.ResurrectLevel    = (short)(GameWorldController.instance.LevelNo + 1);
                objInt().consumeObject();
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(ActivateByObject(CurrentObjectInHand));
        }
    }
    /// <summary>
    /// Creates bridges in a line
    /// </summary>
    /// <param name="triggerX"></param>
    /// <param name="triggerY"></param>
    void CreateBridges(int triggerX, int triggerY)
    {
        int dirX = 0; int dirY = 0;

        GetDirectionsForBridgeTrap(ref dirX, ref dirY);

        for (int i = 0; i < quality; i++)
        {
            int tileX = triggerX + dirX * i;
            int tileY = triggerY + dirY * i;
            if (TileMap.ValidTile(tileX, tileY))
            {
                //Create a bridge at this tile. Only if no bridge is already there.
                if (ObjectLoader.findObjectByTypeInTile(CurrentObjectList().objInfo, (short)tileX, (short)tileY, ObjectInteraction.BRIDGE) == -1)
                {
                    ObjectLoaderInfo newObj = ObjectLoader.newObject(356, 40, 0, 0, 256);
                    newObj.xpos = 4; newObj.ypos = 4; newObj.zpos = zpos;
                    // bridge texture will be set by  (bridge.enchantment << 3) | bridge.flags & 0x3F;
                    newObj.flags       = (short)(owner & 0x7);
                    newObj.enchantment = (short)((owner >> 3) & 0x1);
                    newObj.heading     = heading;
                    newObj.ObjectTileX = (short)tileX;
                    newObj.ObjectTileY = (short)tileY;
                    Vector3 pos = ObjectLoader.CalcObjectXYZ(newObj.index, 0);
                    ObjectInteraction.CreateNewObject(CurrentTileMap(), newObj, CurrentObjectList().objInfo, GameWorldController.instance.LevelModel, pos);
                }
            }
        }
    }
    private void CreateRuneStone(int ItemID)
    {
        ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(ItemID, 0, 0, 1, 256);
        GameObject       myObj   = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, new Vector3(64.5f, 4.0f, 24.5f)).gameObject;

        UnFreezeMovement(myObj);
    }
예제 #10
0
    public static GameObject SpawnHitImpact(int Item_ID, Vector3 ImpactPosition, int StartFrame, int EndFrame)
    {
        ObjectLoaderInfo  newobjt = ObjectLoader.newObject(Item_ID, 40, StartFrame, 1, 256);
        ObjectInteraction objInt  = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, ImpactPosition);

        objInt.GetComponent <AnimationOverlay>().Looping    = false;
        objInt.GetComponent <AnimationOverlay>().StartFrame = StartFrame;
        objInt.GetComponent <AnimationOverlay>().NoOfFrames = EndFrame - StartFrame;
        return(objInt.gameObject);
    }
예제 #11
0
    /// <summary>
    /// Creates the fish that the player has caught.
    /// </summary>
    /// <returns>The fish.</returns>
    ObjectInteraction CreateFish()
    {
        ObjectLoaderInfo  newobjt = ObjectLoader.newObject(182, 40, 0, 1, 256);
        ObjectInteraction fishy   = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position);

        fishy.gameObject.name = ObjectLoader.UniqueObjectName(newobjt);
        fishy.isquant         = 1;
        GameWorldController.MoveToInventory(fishy.gameObject);
        return(fishy);
    }
예제 #12
0
    /// <summary>
    /// Creates the fish that the player has caught.
    /// </summary>
    /// <returns>The fish.</returns>
    GameObject CreateFish()
    {
        ObjectLoaderInfo newobjt = ObjectLoader.newObject(182, 40, 0, 1, 256);
        GameObject       fishy   = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject;

        fishy.name = ObjectLoader.UniqueObjectName(newobjt);
        GameWorldController.MoveToInventory(fishy);
        //newobjt.index= UWCharacter.Instance.playerInventory.ItemCounter++;

        //fishy.GetComponent<Food>().Nutrition=5;
        return(fishy);       // ObjectInteraction.CreateNewObject(182).gameObject;
    }
    /// <summary>
    /// Handle player choosing how many items to pick up in a stack
    /// </summary>
    /// <param name="quant"></param>
    public void OnSubmitPickup(int quant)
    {
        InputField inputctrl = UWHUD.instance.InputControl;

        inputctrl.text = "";
        inputctrl.gameObject.SetActive(false);
        WindowDetect.WaitingForInput = false;
        ConversationVM.EnteringQty   = false;
        if (ConversationVM.InConversation == false)
        {
            UWHUD.instance.MessageScroll.Clear();
            Time.timeScale = 1.0f;
        }
        else
        {
            UWHUD.instance.ConversationButtonParent.SetActive(true);
            UWHUD.instance.MessageScroll.Set("");
            // UWHUD.instance.MessageScroll.NewUIOUt.text = InventorySlot.TempLookAt;//Restore original text
        }

        if (quant == 0)
        {//cancel
            QuantityObj = null;
        }
        if (QuantityObj != null)
        {//Just do a normal pickup.
            if (quant >= QuantityObj.GetComponent <ObjectInteraction>().link)
            {
                CurrentObjectInHand = QuantityObj;
                if (this.slotIndex >= 11)
                {
                    UWCharacter.Instance.playerInventory.currentContainer.RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11);
                }
                UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex);
            }
            else
            {
                //split the obj.
                ObjectInteraction objI = QuantityObj.GetComponent <ObjectInteraction>();
                objI.link = objI.link - quant;
                ObjectLoaderInfo newObj = ObjectLoader.newWorldObject(objI.item_id, objI.quality, objI.owner, quant, -1);
                newObj.is_quant = 1;
                ObjectInteraction NewObjI = ObjectInteraction.CreateNewObject(CurrentTileMap(), newObj, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker, GameWorldController.instance.InventoryMarker.transform.position);
                GameWorldController.MoveToInventory(NewObjI);
                CurrentObjectInHand = NewObjI;
                ObjectInteraction.Split(objI, NewObjI);
                UWCharacter.Instance.playerInventory.Refresh();
                QuantityObj = null;
            }
        }
    }
예제 #14
0
    /*protected override void Start ()
     *  {
     *          base.Start ();
     *          //this.transform.localScale = new Vector3(4f,4f,4f);
     *  }*/

    public override bool ActivateByObject(ObjectInteraction ObjectUsed)
    {
        if (ObjectUsed.item_id == 296)
        {//Bashed with a rock hammer
         //ObjectInteraction newObj;
            switch (item_id)
            {
            case LargeBoulder1:    //Large Boulders
            case LargeBoulder2:    //Split into two boulders
                for (int i = 0; i < 2; i++)
                {
                    ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(MediumBoulder, 0, 0, 0, 256);
                    ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f)));
                    objInt().BaseObjectData.InUseFlag = 0;
                    Destroy(this.gameObject);
                    ObjectInteraction.DestroyObjectFromUW(this.objInt());
                }
                break;

            case MediumBoulder:    //Boulder. //Split into 2 small boulders
                for (int i = 0; i < 2; i++)
                {
                    ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(342, 0, 0, 0, 256);
                    ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f)));
                    objInt().BaseObjectData.InUseFlag = 0;
                    ObjectInteraction.DestroyObjectFromUW(this.objInt());
                }
                break;

            case SmallBoulder:    //Small boulder
            {
                ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(16, 0, 0, 1, 256);
                newobjt.is_quant = 1;
                newobjt.link     = Random.Range(1, 3);
                ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f)));
                objInt().BaseObjectData.InUseFlag = 0;
                ObjectInteraction.DestroyObjectFromUW(this.objInt());
                break;
            }
            }
            //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault;
            CurrentObjectInHand = null;
            return(true);
        }
        else
        {
            return(base.ActivateByObject(ObjectUsed));
        }
    }
예제 #15
0
    void SpoilPotion(ObjectInteraction obj)
    {
        obj.ChangeType(228);
        obj.isquant = 0;

        ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(384, 40, 1, 0, 256);

        newobjt.InUseFlag = 1;
        ObjectInteraction created = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, GameWorldController.instance.InventoryMarker.transform.position);

        GameWorldController.MoveToInventory(created);
        created.transform.parent           = GameWorldController.instance.InventoryMarker.transform;
        obj.GetComponent <Potion>().linked = created;
        obj.GetComponent <Potion>().SetDisplayEnchantment();
    }
예제 #16
0
    public void OnSubmitPickup(int quant)
    {
        InputField inputctrl = UWHUD.instance.InputControl;       //UWHUD.instance.MessageScroll.gameObject.GetComponent<UIInput>();

        Time.timeScale = 1.0f;
        inputctrl.gameObject.SetActive(false);
        WindowDetectUW.WaitingForInput = false;
        inputctrl.text = "";
        inputctrl.text = "";
        UWHUD.instance.MessageScroll.Clear();
        //int quant= int.Parse(inputctrl.text);
        if (quant == 0)
        {        //cancel
            QuantityObj = null;
        }
        if (QuantityObj != null)
        {
            if (quant >= QuantityObj.link)
            {
                Pickup(QuantityObj, playerInventory);
            }
            else
            {
                //split the obj.


                ObjectLoaderInfo newobjt = ObjectLoader.newObject(QuantityObj.item_id, QuantityObj.quality, QuantityObj.owner, quant, 256);
                newobjt.is_quant    = QuantityObj.isquant;
                newobjt.flags       = QuantityObj.flags;
                newobjt.enchantment = QuantityObj.enchantment;
                newobjt.doordir     = QuantityObj.doordir;
                newobjt.invis       = QuantityObj.invis;
                ObjectInteraction Split = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.LevelMarker().gameObject, QuantityObj.transform.position);
                newobjt.InUseFlag = 1;
                QuantityObj.link -= quant;

                //GameObject Split = Instantiate(QuantityObj.gameObject);//What we are picking up.
                //Split.GetComponent<ObjectInteraction>().link =quant;
                //Split.name = Split.name+"_"+summonCount++;
                //QuantityObj.link=QuantityObj.link-quant;
                Pickup(Split, playerInventory);
                ObjectInteraction.Split(Split, QuantityObj);
                QuantityObj = null;              //Clear out to avoid weirdness.
            }
        }
    }
예제 #17
0
    /// <summary>
    /// Sends the avatar into the ethereal void.
    /// </summary>
    /// Spins the avatar and the slasher (specific object name) towards a newly spawned moongate.
    IEnumerator SuckItAvatar()
    {
        //Spawn a moon gate at the center of the lava
        ObjectInteraction slasher    = GameWorldController.instance.CurrentObjectList().objInfo[129].instance;             //GameObject.Find("slasher_of_veils_32_33_07_0129");//Assumes slasher will be at this index.
        Vector3           slasherPos = Vector3.zero;

        if (slasher != null)
        {
            slasherPos = slasher.transform.position;
        }
        ObjectLoaderInfo newobjt = ObjectLoader.newObject(346, 0, 0, 0, 256);
        GameObject       myObj   = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(),
                                                                     newobjt,
                                                                     GameWorldController.instance.CurrentObjectList().objInfo,
                                                                     GameWorldController.instance.DynamicObjectMarker().gameObject,
                                                                     GameWorldController.instance.InventoryMarker.transform.position).gameObject;

        GameWorldController.MoveToWorld(myObj.GetComponent <ObjectInteraction>());
        myObj.transform.localPosition = this.transform.position + new Vector3(0.0f, 0.5f, 0.0f);

        //GameObject myInstance = Resources.Load("Models/MoonGate") as GameObject;
        //GameObject newObj = (GameObject)GameObject.Instantiate(myInstance);
        //newObj.transform.parent=GameWorldController.instance.DynamicObjectMarker();
        //	GameWorldController.MoveToWorld(newObj);
        //newObj.transform.localPosition=this.transform.position+new Vector3(0.0f,0.5f,0.0f);
        Quaternion playerRot = UWCharacter.Instance.transform.rotation;
        Quaternion EndRot    = new Quaternion(playerRot.x, playerRot.y, playerRot.z + 1.2f, playerRot.w);
        Vector3    StartPos  = UWCharacter.Instance.transform.position;
        Vector3    EndPos    = myObj.transform.localPosition;
        float      rate      = 1.0f / 2.0f;
        float      index     = 0.0f;

        while (index < 1.0f)
        {
            UWCharacter.Instance.transform.position = Vector3.Lerp(StartPos, EndPos, index);
            UWCharacter.Instance.transform.rotation = Quaternion.Lerp(playerRot, EndRot, index);
            if (slasher != null)
            {
                slasher.transform.position = Vector3.Lerp(slasherPos, EndPos, index);
            }
            index += rate * Time.deltaTime;
            yield return(new WaitForSeconds(0.01f));
        }
        UWCharacter.Instance.transform.rotation = playerRot;
        GameWorldController.instance.SwitchLevel(8, 26, 24);              //One way trip.
    }
예제 #18
0
    private void CreateRuneStone(int ItemID)
    {
        //string Item= ItemID.ToString("000");

        ObjectLoaderInfo newobjt = ObjectLoader.newObject(ItemID, 0, 0, 1, 256);
        GameObject       myObj   = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.LevelMarker().gameObject, new Vector3(64.5f, 4.0f, 24.5f)).gameObject;


        //GameObject myObj=  new GameObject("SummonedObject_" + UWCharacter.Instance.PlayerMagic.SummonCount++);
        //myObj.layer=LayerMask.NameToLayer("UWObjects");
        //myObj.transform.parent=GameWorldController.instance.LevelMarker();
        //GameWorldController.MoveToWorld(myObj);
        //ObjectInteraction.CreateObjectGraphics(myObj,_RES +"/Sprites/Objects/Objects_224",true);
        //ObjectInteraction.CreateObjectInteraction(myObj,0.5f,0.5f,0.5f,0.5f, 224, ItemID, ItemID, ObjectInteraction.RUNE, 224, 1, 40, 0, 1, 1, 0, 1, 1, 0, 0, 1);

        //myObj.AddComponent<RuneStone>();

        //myObj.transform.position = new Vector3(64.5f,4.0f,24.5f);
        GameWorldController.UnFreezeMovement(myObj);
    }
    /*
     * An arrow trap is used to fire projectiles (usually at the player).
     * The item type created is controlled by the object quality and owner
     * target = (currobj.quality << 5) | currobj.owner; //This is set in UWexporter
     *
     * The vector is simply the heading of the trap.
     *
     * Examples of usage
     * The mine collapse on level2
     * The skulls launched at the player on level3 -Troll area.
     */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        int item_index = (objInt().quality << 5) | objInt().owner;

        ObjectLoaderInfo newobjt = ObjectLoader.newObject(item_index, 0, 0, 0, 256);
        GameObject       myObj   = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.LevelMarker().gameObject, this.transform.position).gameObject;

        myObj.transform.position = this.transform.position;
        myObj.transform.rotation = this.transform.rotation;

        GameWorldController.UnFreezeMovement(myObj);
        myObj.GetComponent <Rigidbody>().collisionDetectionMode = CollisionDetectionMode.Continuous;
        myObj.GetComponent <Rigidbody>().AddForce(myObj.transform.forward * 50.0f * ((float)(objInt().owner)));
        GameObject myObjChild = new GameObject(myObj.name + "_damage");

        myObjChild.transform.position = myObj.transform.position;
        myObjChild.transform.parent   = myObj.transform;
        ProjectileDamage pd = myObjChild.AddComponent <ProjectileDamage>();

        pd.Source       = this.gameObject; //Traps don't need to be identified.
        pd.Damage       = 10;              //Dunno what drives damage here?
        pd.AttackCharge = 100f;
        pd.AttackScore  = 15;              //down the middle.
    }
예제 #20
0
    private void MusicInstrumentInteaction()
    {
        if (Input.GetKeyDown("1"))
        {
            PlayNote(1);
        }
        if (Input.GetKeyDown("2"))
        {
            PlayNote(2);
        }
        if (Input.GetKeyDown("3"))
        {
            PlayNote(3);
        }
        if (Input.GetKeyDown("4"))
        {
            PlayNote(4);
        }
        if (Input.GetKeyDown("5"))
        {
            PlayNote(5);
        }
        if (Input.GetKeyDown("6"))
        {
            PlayNote(6);
        }
        if (Input.GetKeyDown("7"))
        {
            PlayNote(7);
        }
        if (Input.GetKeyDown("8"))
        {
            PlayNote(8);
        }
        if (Input.GetKeyDown("9"))
        {
            PlayNote(9);
        }
        if (Input.GetKeyDown("0"))
        {
            PlayNote(10);
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            //000~001~251~You put the instrument down.
            PlayingInstrument = false;
            CurrentInstrument = "";
            WindowDetectUW.WaitingForInput           = false;
            UWCharacter.Instance.playerMotor.enabled = true;
            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_put_the_instrument_down_));
            GameWorldController.instance.getMus().Resume();
            //354237875
            if (_RES == GAME_UW1)
            {
                if ((NoteRecord == "354237875") && (objInt().item_id == 292))            //Flute only
                {
                    //UWHUD.instance.MessageScroll.Add ("Eyesnack would be proud of your playing");
                    if ((GameWorldController.instance.LevelNo == 2) && (Quest.instance.isCupFound == false) && (objInt().item_id == 292))
                    {
                        int tileX = TileMap.visitTileX;
                        int tileY = TileMap.visitTileY;
                        if (((tileX >= 23) || (tileX <= 27)) && ((tileY >= 43) || (tileY <= 45)))
                        {
                            //create the cup of wonder.

                            ObjectLoaderInfo newobjt = ObjectLoader.newObject(174, 0, 0, 0, 256);
                            GameObject       cup     = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject;
                            GameWorldController.MoveToInventory(cup);
                            ObjectInteraction myObjInt = cup.GetComponent <ObjectInteraction>();

                            /*	ObjectInteraction myObjInt = ObjectInteraction.CreateNewObject(174);
                             * myObjInt.gameObject.transform.parent=GameWorldController.instance.InventoryMarker.transform;
                             * GameWorldController.MoveToInventory(myObjInt.gameObject);*/
                            UWCharacter.Instance.playerInventory.ObjectInHand = myObjInt.name;
                            UWHUD.instance.CursorIcon        = myObjInt.GetInventoryDisplay().texture;
                            UWCharacter.InteractionMode      = UWCharacter.InteractionModePickup;
                            InteractionModeControl.UpdateNow = true;
                            Quest.instance.isCupFound        = true;
                            //An object appears in the air and falls into your hands
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 136));
                        }
                    }
                }
            }
        }
    }
예제 #21
0
    public override bool ActivateByObject(GameObject ObjectUsed)
    {
        if (ObjectUsed.GetComponent <ObjectInteraction>().item_id == 296)
        {                        //Bashed with a rock hammer
            //ObjectInteraction newObj;
            switch (objInt().item_id)
            {
            case 339:                                    //Large Boulders
            case 340:                                    //Split into two boulders
                for (int i = 0; i < 2; i++)
                {
                    ObjectLoaderInfo newobjt = ObjectLoader.newObject(341, 0, 0, 0, 256);
                    ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.LevelMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f)));


                    /*	newObj= ObjectInteraction.CreateNewObject(341);
                     *                  if (newObj!=null)
                     *                  {
                     *                          newObj.gameObject.transform.position=this.transform.position+new Vector3(Random.Range(-0.6f,0.6f),0.0f,Random.Range(-0.6f,0.6f));
                     *                          newObj.gameObject.transform.parent=GameWorldController.instance.LevelMarker();
                     *                          GameWorldController.MoveToWorld(newObj);
                     *                  }*/
                    objInt().objectloaderinfo.InUseFlag = 0;
                    Destroy(this.gameObject);
                }
                break;

            case 341:                                    //Boulder. //Split into 2 small boulders
                for (int i = 0; i < 2; i++)
                {
                    ObjectLoaderInfo newobjt = ObjectLoader.newObject(342, 0, 0, 0, 256);
                    ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.LevelMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f)));


                    //newObj= ObjectInteraction.CreateNewObject(342);
                    //if (newObj!=null)
                    //{
                    //	newObj.gameObject.transform.position=this.transform.position+new Vector3(Random.Range(-0.6f,0.6f),0.0f,Random.Range(-0.6f,0.6f));
                    //	newObj.gameObject.transform.parent=GameWorldController.instance.LevelMarker();
                    //	GameWorldController.MoveToWorld(newObj);
                    //}
                    objInt().objectloaderinfo.InUseFlag = 0;
                    Destroy(this.gameObject);
                }
                break;

            case 342:                                    //Small boulder
            {
                ObjectLoaderInfo newobjt = ObjectLoader.newObject(341, 0, 0, 1, 256);
                newobjt.is_quant = 1;
                ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.LevelMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f)));


                //Split into random qty of slingstones
                //newObj= ObjectInteraction.CreateNewObject(16);
                //newObj.link= Random.Range(3,10);
                //newObj.isquant=1;
                //newObj.gameObject.transform.position=this.transform.position;
                //newObj.gameObject.transform.parent=GameWorldController.instance.LevelMarker();
                //GameWorldController.MoveToWorld(newObj);
                objInt().objectloaderinfo.InUseFlag = 0;
                Destroy(this.gameObject);
                break;
            }
            }
            return(true);
        }
        else
        {
            return(base.ActivateByObject(ObjectUsed));
        }
    }
예제 #22
0
    public override ActionResult Execute(RAIN.Core.AI ai)
    {
        //Spawn a bloodstain at this spot.
        int bloodstain = -1;

        /*GameObject myObj=new GameObject("SummonedObject_" + GameWorldController.instance.playerUW.PlayerMagic.SummonCount++);
         * myObj.layer=LayerMask.NameToLayer("UWObjects");
         * myObj.transform.position = ai.Body.transform.position;
         * myObj.transform.parent=GameWorldController.instance.LevelMarker();
         * ObjectInteraction.CreateObjectGraphics(myObj,"Sprites/OBJECTS_" + bloodstain,true);
         * ObjectInteraction.CreateObjectInteraction(myObj,0.5f,0.5f,0.5f,0.5f, "Sprites/OBJECTS_" +bloodstain, "Sprites/OBJECTS_" + bloodstain, "Sprites/OBJECTS_" + bloodstain, ObjectInteraction.SCENERY, bloodstain, 1, 40, 0, 0, 0, 0, 1, 0, 0, 0, 1);
         * myObj.AddComponent<object_base>();*/

        //Nothing = 0x00,
        //RotwormCorpse = 0x20,
        //Rubble = 0x40,
        //WoodChips = 0x60,
        //Bones = 0x80,
        //GreenBloodPool = 0xA0,
        //RedBloodPool = 0xC0,
        //RedBloodPoolGiantSpider = 0xE0.
        ObjectInteraction objInt = ai.Body.GetComponent <ObjectInteraction>();

        switch (GameWorldController.instance.critter.Remains[objInt.item_id - 64])
        {
        case 0x20:                        //Rotworm corpse
            bloodstain = 217;
            break;

        case 0x40:                        //Rubble
            bloodstain = 218;
            break;

        case 0x60:                        //Woodchips
            bloodstain = 219;
            break;

        case 0x80:                        //Bones
            bloodstain = 220;
            break;

        case 0xA0:                        //Greenblood
            bloodstain = 221;
            break;

        case 0xC0:                        //Redblood
            bloodstain = 222;
            break;

        case 0xE0:                        //RedBloodPoolGiantSpider
            bloodstain = 223;
            break;

        case 0:                        //Nothing
        default:
            bloodstain = -1;
            break;
        }

        if (bloodstain != -1)
        {
            ObjectInteraction remains = ObjectInteraction.CreateNewObject(bloodstain);
            remains.gameObject.transform.parent = GameWorldController.instance.LevelMarker();
            remains.transform.position          = ai.Body.transform.position;
        }

        GameObject.Destroy(ai.Body);
        return(ActionResult.SUCCESS);
    }
예제 #23
0
    public void ObjectEditorApplyChanges()
    {
        currObj.item_id = ObjectItemIds.value;
        if (ObjectFlagisQuant.isOn)
        {
            currObj.is_quant = 1;
        }
        else
        {
            currObj.is_quant = 0;
        }

        if (ObjectFlaginVis.isOn)
        {
            currObj.invis = 1;
        }
        else
        {
            currObj.invis = 0;
        }

        if (ObjectFlagDoorDir.isOn)
        {
            currObj.doordir = 1;
        }
        else
        {
            currObj.doordir = 0;
        }

        if (ObjectFlagEnchant.isOn)
        {
            currObj.enchantment = 1;
        }
        else
        {
            currObj.enchantment = 0;
        }
        int val = 0;

        if (int.TryParse(ObjectFlagValue.text, out val))
        {
            currObj.flags        = (short)(val & 0x7);
            ObjectFlagValue.text = currObj.flags.ToString();
        }

        if (int.TryParse(ObjectOwner.text, out val))
        {
            currObj.owner    = (short)(val & 0x3F);
            ObjectOwner.text = currObj.owner.ToString();
        }

        if (int.TryParse(ObjectLink.text, out val))
        {
            currObj.link    = (short)(val & 0x3FF);
            ObjectLink.text = currObj.link.ToString();
        }

        if (int.TryParse(ObjectQuality.text, out val))
        {
            currObj.quality    = (short)(val & 0x3F);
            ObjectQuality.text = currObj.quality.ToString();
        }

        if (currObj.index <= 255)
        {                        //A mobile object
            if (int.TryParse(npc_whoami.text, out val))
            {
                currObj.npc_whoami = (short)(val);
                npc_whoami.text    = currObj.npc_whoami.ToString();
            }
            if (int.TryParse(npc_xhome.text, out val))
            {
                currObj.npc_xhome = (short)(val);
                npc_xhome.text    = currObj.npc_xhome.ToString();
            }
            if (int.TryParse(npc_yhome.text, out val))
            {
                currObj.npc_yhome = (short)(val);
                npc_yhome.text    = currObj.npc_yhome.ToString();
            }
            if (int.TryParse(npc_hp.text, out val))
            {
                currObj.npc_hp = (short)(val);
                npc_hp.text    = currObj.npc_hp.ToString();
            }

            currObj.npc_goal = (short)npc_goal.value;

            if (int.TryParse(npc_goaltarget.text, out val))
            {
                currObj.npc_gtarg   = (short)(val);
                npc_goaltarget.text = currObj.npc_gtarg.ToString();
            }


            if (int.TryParse(npc_attitude.text, out val))
            {
                currObj.npc_attitude = (short)(val);
                npc_attitude.text    = currObj.npc_attitude.ToString();
            }
            if (int.TryParse(npc_talkedto.text, out val))
            {
                currObj.npc_talkedto = (short)(val & 0x1);
                npc_talkedto.text    = currObj.npc_talkedto.ToString();
            }
        }

        switch (GameWorldController.instance.objectMaster.type[currObj.item_id])
        {
        case ObjectInteraction.LOCK:
        case ObjectInteraction.A_USE_TRIGGER:
            if (int.TryParse(ObjectNext.text, out val))
            {
                currObj.next    = (short)(val & 0x3Ff);
                ObjectNext.text = currObj.next.ToString();
            }
            break;

        default:
            break;                            //do not allow changing the next of an object. The engine normally handles this.
        }

        if (int.TryParse(ObjectTileX.text, out val))
        {
            if ((val < 0) || (val > TileMap.TileMapSizeX))
            {
                val = TileMap.ObjectStorageTile;
            }
            currObj.tileX    = (short)(val);
            ObjectTileX.text = currObj.tileX.ToString();
        }

        if (int.TryParse(ObjectTileY.text, out val))
        {
            if ((val < 0) || (val > TileMap.TileMapSizeY))
            {
                val = TileMap.ObjectStorageTile;
            }
            currObj.tileY    = (short)(val);
            ObjectTileY.text = currObj.tileY.ToString();
        }


        if (int.TryParse(ObjectXPos.text, out val))
        {
            currObj.x       = (short)(val & 0x7);
            ObjectXPos.text = currObj.x.ToString();
        }
        if (int.TryParse(ObjectYPos.text, out val))
        {
            currObj.y       = (short)(val & 0x7);
            ObjectYPos.text = currObj.y.ToString();
        }
        if (int.TryParse(ObjectZPos.text, out val))
        {
            currObj.zpos    = (short)(val & 0x7F);
            ObjectZPos.text = currObj.zpos.ToString();
        }

        if (currObj.instance != null)
        {
            Destroy(currObj.instance.gameObject);
            Vector3 pos = ObjectLoader.CalcObjectXYZ(_RES,
                                                     GameWorldController.instance.currentTileMap(),
                                                     GameWorldController.instance.currentTileMap().Tiles,
                                                     GameWorldController.instance.CurrentObjectList().objInfo,
                                                     (long)currObj.index, (short)currObj.tileX,
                                                     (short)currObj.tileY, 0);
            ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(),
                                              currObj, GameWorldController.instance.LevelMarker().gameObject,
                                              pos);
        }
        else
        {
            if (currObj.tileX <= TileMap.TileMapSizeX)                  //A object is brought from off map.
            {
                currObj.InUseFlag = 1;
                Vector3 pos = ObjectLoader.CalcObjectXYZ(_RES,
                                                         GameWorldController.instance.currentTileMap(),
                                                         GameWorldController.instance.currentTileMap().Tiles,
                                                         GameWorldController.instance.CurrentObjectList().objInfo,
                                                         (long)currObj.index, (short)currObj.tileX,
                                                         (short)currObj.tileY, 0);
                ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(),
                                                  currObj, GameWorldController.instance.LevelMarker().gameObject,
                                                  pos);
            }
        }
    }
예제 #24
0
    /// <summary>
    /// Launchs the ammo.
    /// </summary>
    /// <returns><c>true</c>, if ammo was launched, <c>false</c> otherwise.</returns>
    bool LaunchAmmo(float charge)
    {
        if (currentAmmo != null)
        {
            Ray ray;
            if (UWCharacter.Instance.MouseLookEnabled == true)
            {
                ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
            }
            else
            {
                ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            }

            RaycastHit hit       = new RaycastHit();
            float      dropRange = 0.5f;
            if (!Physics.Raycast(ray, out hit, dropRange))
            {///Checks No object interferes with the launch
                float      force = 1000.0f * (charge / 100.0f);
                GameObject launchedItem;
                if (currentAmmo.GetQty() == 1)
                {
                    launchedItem = currentAmmo.gameObject;
                    UWCharacter.Instance.playerInventory.RemoveItem(currentAmmo);
                    //launchedItem.transform.parent=GameWorldController.instance.DynamicObjectMarker();
                    GameWorldController.MoveToWorld(launchedItem);
                    launchedItem.transform.position = ray.GetPoint(dropRange - 0.1f);
                }
                else
                {//reduce this quantity by one and create a copy in the world
                    ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(currWeaponRanged.AmmoType(), 40, 0, 1, 256);
                    launchedItem = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, ray.GetPoint(dropRange - 0.1f)).gameObject;
                    currentAmmo.consumeObject();
                }
                launchedItem.GetComponent <ObjectInteraction>().isquant = 1;
                UnFreezeMovement(launchedItem);
                Vector3 ThrowDir = ray.GetPoint(dropRange) - ray.origin;

                ///Apply the force along the direction of the ray that the player has targetted along.
                launchedItem.GetComponent <Rigidbody>().AddForce(ThrowDir * force);
                GameObject myObjChild = new GameObject(launchedItem.name + "_damage");
                myObjChild.transform.position = launchedItem.transform.position;
                myObjChild.transform.parent   = launchedItem.transform;
                ///Appends ProjectileDamage to the projectile to act as the damage delivery method.
                ProjectileDamage pd = myObjChild.AddComponent <ProjectileDamage>();
                pd.Source       = UWCharacter.Instance.gameObject;
                pd.Damage       = (short)currWeaponRanged.Damage(); //   (short)(10.0f*(Charge/100.0f));
                pd.AttackCharge = charge;
                pd.AttackScore  = UWCharacter.Instance.PlayerSkills.GetSkill(Skills.SkillAttack) / 2 + UWCharacter.Instance.PlayerSkills.GetSkill(Skills.SkillMissile);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {//No ammo?? Should not happen
            return(false);
        }
    }
/*
 * A change terrain trap changes a tile from one type to another. It works over a range of tiles that are set by the traps
 * x,y values. In Underworld these are set by the the relative position of the trap within the tile.
 * The tile it acts on is controlled by the trigger.
 *
 * Examples of it's usage
 * The Moonstone room on Level2
 * The path to the sword hilt on Level3
 *
 */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        Debug.Log(this.name);
        int textureQuality = (objInt().quality >> 1) & 0xf;

        for (short x = 0; x <= objInt().x; x++)
        {
            for (short y = 0; y <= objInt().y; y++)
            {
                short      tileXToChange = (short)(x + triggerX);
                short      tileYToChange = (short)(y + triggerY);
                GameObject tile          = GameWorldController.FindTile(tileXToChange, tileYToChange, TileMap.SURFACE_FLOOR);
                if (tile != null)
                {
                    TileInfo tileToChange = GameWorldController.instance.currentTileMap().Tiles[tileXToChange, tileYToChange];
                    //Destroy (tile);

                    switch (_RES)
                    {                            //I will probably have to change this again!
                    //case GAME_UW2:
                    //	tileToChange.floorTexture=textureQuality;
                    //	break;
                    default:
                        if (textureQuality < 10)
                        {
                            tileToChange.floorTexture = (short)textureQuality;                                  //+48;
                            //tileToChange.floorTexture=GameWorldController.instance.currentTileMap().texture_map[textureQuality+48];
                        }
                        break;
                    }

                    //currobj.zpos >> 2
                    //(objList[k].zpos >> 2);
                    tileToChange.Render = true;
                    for (int v = 0; v < 6; v++)
                    {
                        tileToChange.VisibleFaces[v] = true;
                    }
                    short tileTypeToChangeTo = (short)(objInt().quality & 0x01);
                    short newTileHeight      = (short)(objInt().zpos >> 2);
                    short newWallTexture     = tileToChange.wallTexture;
                    if (_RES == GAME_UW2)
                    {                            //Also the owner can be used to change wall texture. This means changing it's neighours.
                        if (objInt().owner < 63)
                        {
                            newWallTexture = objInt().owner;
                        }
                    }

                    //tileToChange.tileType=tileTypeToChangeTo;
                    tileToChange.DimX = 1;
                    tileToChange.DimY = 1;

                    ////tileToChange.floorHeight=newTileHeight;
                    //tileToChange.floorHeight=tileToChange.floorHeight;//DOUBLE CHECK THIS
                    tileToChange.isWater = TileMap.isTextureWater(GameWorldController.instance.currentTileMap().texture_map[tileToChange.floorTexture]);
                    //TileMapRenderer.RenderTile(GameWorldController.instance.LevelModel,tileXToChange,tileYToChange,tileToChange,tileToChange.isWater,false,false,true);
                    tileToChange.TileNeedsUpdate();
                    TileMapRenderer.UpdateTile(tileXToChange, tileYToChange, tileTypeToChangeTo, newTileHeight, tileToChange.floorTexture, newWallTexture, false);
                    Destroy(tile);

                    if (tileToChange.isDoor)
                    {                            //The door may be rendered
                        GameObject door = GameWorldController.findDoor(tileToChange.tileX, tileToChange.tileY);
                        if (door != null)
                        {
                            string doorname = ObjectLoader.UniqueObjectName(door.GetComponent <ObjectInteraction>().objectloaderinfo);
                            DestroyDoorPortion("front_leftside_" + doorname);
                            DestroyDoorPortion("front_over_" + doorname);
                            DestroyDoorPortion("front_rightside_" + doorname);
                            DestroyDoorPortion("side1_filler_" + doorname);
                            DestroyDoorPortion("over_filler_" + doorname);
                            DestroyDoorPortion("side2_filler_" + doorname);
                            DestroyDoorPortion("front_filler_" + doorname);
                            DestroyDoorPortion("rear_leftside_" + doorname);
                            DestroyDoorPortion("rear_over_" + doorname);
                            DestroyDoorPortion("rear_rightside_" + doorname);
                            DestroyDoorPortion(doorname);
                            TileMapRenderer.RenderDoorwayFront(
                                GameWorldController.instance.LevelModel,
                                GameWorldController.instance.currentTileMap(),
                                GameWorldController.instance.CurrentObjectList(),
                                door.GetComponent <ObjectInteraction>().objectloaderinfo
                                );
                            TileMapRenderer.RenderDoorwayRear(
                                GameWorldController.instance.LevelModel,
                                GameWorldController.instance.currentTileMap(),
                                GameWorldController.instance.CurrentObjectList(),
                                door.GetComponent <ObjectInteraction>().objectloaderinfo
                                );
                            Vector3 objPos = door.transform.position;
                            ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(),
                                                              door.GetComponent <ObjectInteraction>().objectloaderinfo,
                                                              GameWorldController.instance.LevelModel, objPos
                                                              );
                        }
                    }
                }
                else
                {
                    Debug.Log(this.name + " Unable to find tile for change terrain trap " + tileXToChange + " " + tileYToChange);
                }
            }
        }

        GameWorldController.WorldReRenderPending = true;

        //	if ((objInt().owner<63) && (_RES==GAME_UW2))
        //	{
        //Now force re-render the tiles and their neighbours
        for (int x = -1; x <= objInt().x + 1; x++)
        {
            for (int y = -1; y <= objInt().y + 1; y++)
            {
                int tileXToChange = x + triggerX;
                int tileYToChange = y + triggerY;

                GameObject tile = GameWorldController.FindTile(tileXToChange, tileYToChange, TileMap.SURFACE_FLOOR);
                if (tile != null)
                {
                    Destroy(tile);
                }
                if ((tileXToChange >= 0) && (tileXToChange <= 63) && (tileYToChange >= 0) && (tileYToChange <= 63))
                {
                    TileInfo tileToChange = GameWorldController.instance.currentTileMap().Tiles[tileXToChange, tileYToChange];
                    tileToChange.Render = true;
                    for (int v = 0; v < 6; v++)
                    {
                        tileToChange.VisibleFaces[v] = true;
                    }
                    tileToChange.isWater = TileMap.isTextureWater(GameWorldController.instance.currentTileMap().texture_map[tileToChange.floorTexture]);
                    //TileMapRenderer.RenderTile(GameWorldController.instance.LevelModel,tileXToChange,tileYToChange,tileToChange,tileToChange.isWater,false,false,true);
                    tileToChange.TileNeedsUpdate();
                }
            }
        }
        //}
    }
예제 #26
0
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        GameObject door = GameWorldController.findDoor(triggerX, triggerY);

        if (door != null)
        {
            DoorControl DC = door.GetComponent <DoorControl>();

            switch (quality)
            {
            case 0:            //Just lock
                //Copy the lock object at the link to use on this door
                if (link != 0)
                {                //link to a lock
                    if (ObjectLoader.GetItemTypeAt(link) == ObjectInteraction.LOCK)
                    {
                        ObjectInteraction lockToCopy = ObjectLoader.getObjectIntAt(link);
                        ObjectLoaderInfo  newobjt    = ObjectLoader.newObject(lockToCopy.item_id, lockToCopy.quality, lockToCopy.owner, lockToCopy.link, 256);
                        newobjt.flags       = lockToCopy.flags;
                        newobjt.doordir     = lockToCopy.doordir;
                        newobjt.invis       = lockToCopy.invis;
                        newobjt.enchantment = lockToCopy.enchantment;
                        newobjt.zpos        = lockToCopy.zpos;
                        newobjt.xpos        = lockToCopy.xpos;
                        newobjt.ypos        = lockToCopy.ypos;
                        newobjt.next        = DC.link;               //To allow proper triggering of traps
                        newobjt.InUseFlag   = 1;
                        GameObject Created = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject;
                        DC.link = newobjt.index;                        //Point the lock at this new lock
                    }
                }
                else
                {                //unlink the lock and tie the locks next back to the door as it's link
                    ObjectInteraction linkedObj = ObjectLoader.getObjectIntAt(DC.link);
                    if (linkedObj != null)
                    {
                        DC.link = linkedObj.next;
                        linkedObj.objectloaderinfo.InUseFlag = 0;
                        Destroy(linkedObj);
                    }
                }
                break;

            case 1:            //try open
                if (TriggerInstantly)
                {
                    DC.UnlockDoor(false);
                    DC.OpenDoor(0f);
                }
                else
                {
                    DC.UnlockDoor(false);
                    DC.OpenDoor(DoorControl.DefaultDoorTravelTime);
                }

                break;

            case 2:            //try close
                if (TriggerInstantly)
                {
                    DC.CloseDoor(0f);
                    DC.LockDoor();
                }
                else
                {
                    DC.CloseDoor(DoorControl.DefaultDoorTravelTime);
                    DC.LockDoor();
                }

                break;

            case 3:            //try toggle
                //TODO:check if toggle respects unlocked status. (door trap 1001 on level 3)
                if (TriggerInstantly)
                {
                    DC.ToggleDoor(0, false);
                }
                else
                {
                    DC.ToggleDoor(DoorControl.DefaultDoorTravelTime, false);
                }
                break;
            }
        }
        else
        {
            Debug.Log("Door not found!");
        }
    }
예제 #27
0
    public override bool Eat()
    {    //TODO:Implement drag and drop feeding.
        if (Nutrition() + UWCharacter.Instance.FoodLevel >= 255)
        {
            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_are_too_full_to_eat_that_now_));
            return(false);
        }
        else
        {
            UWCharacter.Instance.FoodLevel = Nutrition() + UWCharacter.Instance.FoodLevel;
            switch (objInt().item_id)    //TODO:update for UW2
            {
            case 192:                    //plants
            case 207:
            case 212:
                UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_the_plant_is_plain_tasting_but_nourishing_));
                break;

            case 217:                    //Dead rotworm
                UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 234));
                break;

            case 283:                    //Rotworm stew
                UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 235));
                break;

            default:
                UWHUD.instance.MessageScroll.Add("That " + StringController.instance.GetObjectNounUW(objInt()) + foodFlavourText());
                break;
            }
            if (ObjectInteraction.PlaySoundEffects)
            {
                switch (Random.Range(1, 3))
                {
                case 1:
                    UWCharacter.Instance.aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_EAT_1]; break;

                case 2:
                    UWCharacter.Instance.aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_EAT_2]; break;

                default:
                    UWCharacter.Instance.aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_EAT_3]; break;
                }
                UWCharacter.Instance.aud.Play();
            }

            if (_RES == GAME_UW2)
            {            //Some food items leave left overs
                int LeftOverToCreate = -1;
                switch (objInt().item_id)
                {
                case 176:
                case 177:                        //meat
                    LeftOverToCreate = 197; break;

                case 186:                        //honeycomb
                    LeftOverToCreate = 210; break;

                case 187:
                case 188:
                case 189:                        //bottles.
                    LeftOverToCreate = 317; break;
                }

                if (LeftOverToCreate != -1)
                {
                    ObjectLoaderInfo newobjt = ObjectLoader.newObject(LeftOverToCreate, 40, 0, 0, 256);
                    newobjt.InUseFlag = 1;
                    ObjectInteraction created = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, GameWorldController.instance.InventoryMarker.transform.position);
                    GameWorldController.MoveToWorld(created.gameObject);
                    UWCharacter.Instance.playerInventory.ObjectInHand = created.name;
                    UWHUD.instance.CursorIcon   = created.GetInventoryDisplay().texture;
                    UWCharacter.InteractionMode = UWCharacter.InteractionModePickup;
                }
            }
            objInt().consumeObject(); //destroy and remove from inventory/world.

            return(true);             //Food was eaten.
        }
    }
예제 #28
0
    public void OnSubmitPickup(int quant)
    {
        InputField inputctrl = UWHUD.instance.InputControl;

        inputctrl.text = "";
        inputctrl.gameObject.SetActive(false);
        WindowDetect.WaitingForInput = false;
        ConversationVM.EnteringQty   = false;
        if (ConversationVM.InConversation == false)
        {
            UWHUD.instance.MessageScroll.Clear();
            Time.timeScale = 1.0f;
        }
        else
        {
            UWHUD.instance.MessageScroll.NewUIOUt.text = InventorySlot.TempLookAt;            //Restore original text
        }

        if (quant == 0)
        {        //cancel
            QuantityObj = null;
        }
        if (QuantityObj != null)
        {        //Just do a normal pickup.
            if (quant >= QuantityObj.GetComponent <ObjectInteraction>().link)
            {
                UWCharacter.Instance.playerInventory.ObjectInHand = QuantityObj.name;
                UWHUD.instance.CursorIcon = QuantityObj.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
                if (this.slotIndex >= 11)
                {
                    UWCharacter.Instance.playerInventory.GetCurrentContainer().RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11);
                }
                UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex);
            }
            else
            {
                //split the obj.
                ObjectInteraction objI = QuantityObj.GetComponent <ObjectInteraction>();
                objI.link = objI.link - quant;
                ObjectLoaderInfo newObj = ObjectLoader.newObject(objI.item_id, objI.quality, objI.owner, quant, -1);
                newObj.is_quant = 1;
                ObjectInteraction NewObjI = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newObj, GameWorldController.instance.CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker, GameWorldController.instance.InventoryMarker.transform.position);
                GameWorldController.MoveToInventory(NewObjI);
                UWCharacter.Instance.playerInventory.ObjectInHand = NewObjI.name;
                UWHUD.instance.CursorIcon = NewObjI.GetInventoryDisplay().texture;
                ObjectInteraction.Split(objI, NewObjI);
                UWCharacter.Instance.playerInventory.Refresh(slotIndex);
                QuantityObj = null;


                /*	GameObject Split = Instantiate(QuantityObj);//What we are picking up.
                 *      Split.GetComponent<ObjectInteraction>().link =quant;
                 *      Split.name = Split.name+"_"+UWCharacter.Instance.summonCount++;
                 *      Split.transform.parent=UWCharacter.Instance.playerInventory.InventoryMarker.transform;//this.transform.parent;
                 *      QuantityObj.GetComponent<ObjectInteraction>().link=QuantityObj.GetComponent<ObjectInteraction>().link-quant;
                 *      UWCharacter.Instance.playerInventory.ObjectInHand= Split.name;
                 *      UWHUD.instance.CursorIcon= Split.GetComponent<ObjectInteraction>().GetInventoryDisplay().texture;
                 *      ObjectInteraction.Split (Split.GetComponent<ObjectInteraction>(),QuantityObj.GetComponent<ObjectInteraction>());
                 *      UWCharacter.Instance.playerInventory.Refresh (slotIndex);
                 *      QuantityObj=null;//Clear out to avoid weirdness.*/
            }
        }
    }
예제 #29
0
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        Vector3 spawn = CurrentTileMap().getTileVector(ObjectTileX, ObjectTileY);

        spawn = new Vector3(spawn.x, 4.4f, spawn.z);
        int ItemStringIndex = 0;
        int Price           = 0;

        //Pick the item to sell and get its price
        switch (Quest.instance.variables[owner])
        {
        case 0:    //fish
            ItemStringIndex = 182;
            Price           = 3;
            break;

        case 1:    //meat
            ItemStringIndex = 176;
            Price           = 3;
            break;

        case 2:    //ale
            ItemStringIndex = 187;
            Price           = 4;
            break;

        case 3:    //leeches
            ItemStringIndex = 293;
            Price           = 4;
            break;

        case 4:    //water
            ItemStringIndex = 188;
            Price           = 3;
            break;

        case 5:    //dagger
            ItemStringIndex = 3;
            Price           = 11;
            break;

        case 6:    //lockpick
            ItemStringIndex = 257;
            Price           = 6;
            break;

        case 7:    //torch
            ItemStringIndex = 145;
            Price           = 4;
            break;

        default:
            return;
        }

        if (CheckPrice(Price, ObjectTileX, ObjectTileY))
        {//price check
            ObjectLoaderInfo newobjt = ObjectLoader.newObject(ItemStringIndex, 40, 0, 0, 256);
            newobjt.InUseFlag = 1;
            UnFreezeMovement(GameWorldController.MoveToWorld(ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, spawn)).gameObject);
        }
    }