Base class for objects and npcs Works hand in hand with ObjectInteraction
Наследование: UWEBase
    //Theory. Untested
    //This is used to change the tile type &  wall/floor texture on all tiles in a level.
    //The From trap defines the criteria
    //and the to trap defines the changes to make.
    //Heading seems to define a  floor texture to match for changing.
    //Nothing seems to define the range of tiles to change so it may be a global change
    //Therefore
    //Use the change_From trap to execute the changes using the values in the to trap.
    //Use the to trap as a placeholder to pass execution along in the link chain.



    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        //return;
        //TileMap curr = GameWorldController.instance.currentTileMap();
        ObjectInteraction ChangeTo = null;

        if (objInt().link != 0)
        {
            ChangeTo = GameWorldController.instance.CurrentObjectList().objInfo[objInt().link].instance;
        }
        if (ChangeTo == null)
        {
            return;
        }

        short NewTileFloorTexture = (short)(ChangeTo.heading | (((ChangeTo.zpos >> 4) & 0x1) << 3));

        short tileFloorCriteria = (short)(objInt().heading | (((objInt().zpos >> 4) & 0x1) << 3));

        for (int x = 0; x <= 63; x++)
        {
            for (int y = 0; y <= 63; y++)
            {
                //	if (ChangeTo.quality<63)
                if (objInt().quality == GameWorldController.instance.currentTileMap().Tiles[x, y].wallTexture)
                {                //This is probably a seperate test to the floor texture test above.
                    GameWorldController.instance.currentTileMap().Tiles[x, y].wallTexture = ChangeTo.quality;

                    if (GameWorldController.instance.currentTileMap().Tiles[x, y].floorTexture == tileFloorCriteria) //==objInt().heading)
                    {                                                                                                //Putting this in this block could be wrong as well.
                        if (GameWorldController.instance.currentTileMap().Tiles[x, y].Render)
                        {
                            for (int v = 0; v < 6; v++)
                            {
                                GameWorldController.instance.currentTileMap().Tiles[x, y].VisibleFaces[v] = true;
                                GameWorldController.instance.currentTileMap().Tiles[x, y].VisibleFaces[v] = true;
                            }
                        }

                        GameWorldController.instance.currentTileMap().Tiles[x, y].floorTexture = NewTileFloorTexture;                       //ChangeTo.heading;
                        if (ChangeTo.owner < 10)
                        {
                            GameWorldController.instance.currentTileMap().Tiles[x, y].tileType = (short)ChangeTo.owner;
                        }
                        if (ChangeTo.zpos < 15)
                        {
                            GameWorldController.instance.currentTileMap().Tiles[x, y].floorHeight = ChangeTo.zpos;
                        }
                    }                    //end floor texture criteria.
                }

                GameWorldController.instance.currentTileMap().SetTileMapWallFacesUW();                //Update neighbour wall faces
            }
        }

        //Re-render the level to see the changes
        //TODO:make this a tile based update rather than a full redraw.
        GameWorldController.WorldReRenderPending = true;      //Request a world redraw at the next lateupdate.
        GameWorldController.FullReRender         = true;
    }
Пример #2
0
 public override void PostActivate(object_base src)
 {
     if (skupSpawned)
     {
         base.PostActivate(src);
     }
 }
Пример #3
0
    /// <summary>
    /// Executes the trap.
    /// </summary>
    /// <param name="src">Source.</param>
    /// <param name="triggerX">Trigger x.</param>
    /// <param name="triggerY">Trigger y.</param>
    /// <param name="State">State.</param>
    /// Toggles the variable controlling which world is available from this facet of the gem.
    /// In the future change the lighting on the gem.
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        //		base.ExecuteTrap (src, triggerX, triggerY, State);

        /*
         *      if (GameWorldController.instance.variables[6] == 0)
         *      {
         * GameWorldController.instance.variables[6] = 8;
         *      }
         *      else
         *      {
         * GameWorldController.instance.variables[6] = 0;
         *      }
         */

        Quest.instance.variables[6]++;
        if (Quest.instance.variables[6] > a_hack_trap_teleport.NoOfWorlds)
        {
            Quest.instance.variables[6] = 0;
        }
        if (prevWorld != Quest.instance.variables[6])
        {
            Debug.Log("Now serving world " + Quest.instance.variables[6]);
        }
        prevWorld = Quest.instance.variables[6];
    }
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        ObjectInteraction forcefieldtoMove = findForceField();

        if (forcefieldtoMove != null)
        {
            if (forcefieldtoMove.zpos == 127)
            {
                forcefieldtoMove.zpos = 0;
                forcefieldtoMove.objectloaderinfo.zpos = 0;
            }
            else
            {
                forcefieldtoMove.zpos = 127;
                forcefieldtoMove.objectloaderinfo.zpos = 127;
            }
            forcefieldtoMove.transform.position = ObjectLoader.CalcObjectXYZ(_RES,
                                                                             GameWorldController.instance.currentTileMap(),
                                                                             GameWorldController.instance.currentTileMap().Tiles,
                                                                             GameWorldController.instance.CurrentObjectList().objInfo,
                                                                             forcefieldtoMove.objectloaderinfo.index,
                                                                             forcefieldtoMove.tileX,
                                                                             forcefieldtoMove.tileY,
                                                                             1
                                                                             );
        }
    }
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        switch (quality)
        {
        case 2:    //guardian laugh
        {
            UWCharacter.Instance.aud.clip = MusicController.instance.SoundEffects[MusicController.SOUND_EFFECT_GUARDIAN_LAUGH_1];
            UWCharacter.Instance.aud.Play();
            break;
        }

        case 4:
            //Call a camera shake effect
            //CameraShake.instance.shakeDuration = owner * 0.2f;
            CameraShake.instance.ShakeEarthQuake(owner * 0.05f);
            break;

        case 5:
            StartCoroutine(Flash("FadeToRed"));
            break;

        default:
            Debug.Log("unimplemented special effect " + this.name + " q=" + quality);
            break;
        }
    }
	/*
	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.
	}
Пример #7
0
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        UpdateTile(25, 32, 0);
        UpdateTile(25, 35, 2);
        UpdateTile(25, 38, 1);
        UpdateTile(25, 41, 2);
        UpdateTile(25, 44, 2);

        UpdateTile(28, 32, 3);
        UpdateTile(28, 35, 1);
        UpdateTile(28, 38, 0);
        UpdateTile(28, 41, 1);
        UpdateTile(28, 44, 3);

        UpdateTile(31, 32, 0);
        UpdateTile(31, 35, 3);
        UpdateTile(31, 38, 1);
        UpdateTile(31, 41, 0);
        UpdateTile(31, 44, 2);

        UpdateTile(34, 32, 3);
        UpdateTile(34, 35, 0);
        UpdateTile(34, 38, 0);
        UpdateTile(34, 41, 0);
        UpdateTile(34, 44, 3);
    }
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        switch (owner)
        {
        case 0:    //Raise tile
            RaiseLowerBullfrog(+1);
            break;

        case 1:    //Lower tile
            RaiseLowerBullfrog(-1);
            break;

        case 2:

            targetX = targetX + 1;
            if (targetX >= 8)
            {
                targetX = 0;
            }
            break;

        case 3:
            targetY = targetY + 1;

            if (targetY >= 8)
            {
                targetY = 0;
            }
            break;

        case 4:    //reset
            ResetBullFrog();
            break;
        }
    }
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        if (platformTile == null)
        {
            platformTile = GameWorldController.FindTile(triggerX, triggerY, TileMap.SURFACE_FLOOR);
        }
        if (platformTile == null)
        {
            return;
        }
        if (GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight / 2 >= objInt().owner)
        {
            objInt().x = 0;
        }
        else if (GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight / 2 <= objInt().quality)
        {
            objInt().x = 1;
        }

        if (objInt().x == 1)
        {        //moving up
            GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight += 2;
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, 0.3f, 0f), 0.1f));
        }
        else
        {        //moving down
            GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight -= 2;
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, -0.3f, 0f), 0.1f));
        }
    }
    public bool Use()
    {                                    //Code to activate objects by type.
        //Objects will return true if they have done everything that needs to be done and false if they expect the calling code to do something instead.
        GameObject  ObjectInHand = null; // = new GameObject();
        object_base item         = null; //Base object class

        ObjectInHand = playerUW.playerInventory.GetGameObjectInHand();
        if (ObjectInHand != null)
        {
            //First do a combineobject test. This will implement object combinatiosn defined by UW1/2
            if (CombineObject(this.gameObject, ObjectInHand))
            {
                return(true);
            }
        }


        item = this.GetComponent <object_base>();
        if (item != null)
        {
            return(item.use());
        }
        else
        {
            return(false);
        }
    }
Пример #11
0
    //A trap that angers nearby npcs if you enter it.
    //TODO:The stealth skill should effect this (see skill trap on lvl2 of prison tower)

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        if (((owner & 0x1f)) != 0)
        {
            SignalTheft(UWCharacter.Instance.transform.position, owner, 7f);
        }
    }
/*
 * Moves a tile up and down.
 *
 * State is controlled by the triggering objects (eg switches)
 *
 * Usage example
 * The platform puzzle on Level 1 leading to the grave of Korianus.
 */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        Debug.Log(this.name);
        GameObject platformTile = GameWorldController.FindTile(triggerX, triggerY, TileMap.SURFACE_FLOOR);//Var.FindTile (Var.triggerX,Var.triggerY,1);

        //Get the height of the tile


        //if (objInt().flags==7)
        if (GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight >= 18)
        {
            //Move the tile to the bottom
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, -0.3f * 7f, 0f), 0.7f));
            objInt().flags = (short)State;
            //state = 1;
            GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight = 2;
        }
        else
        {
            //Go up a step.
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, 0.3f, 0f), 0.1f));
            //objInt().flags=State;
            GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight += 2;
        }
        objInt().flags = (short)State;
    }
Пример #13
0
    //Used on level 42 - scintilus academy terraforming test

    /* MAP OF ROOM
     *           EXIT
     *              X  X  X  X  X
     *
     *              X  X  X  X  X
     *
     *              X  X  X  X  X
     *          ENTRANCE
     */

    //Quality is the height of the tile when set "on"
    //Bit field of the following parameters toggles the tiles as follows (bits go from exit to entrance)
    //eg x=1 will change the bottom left tile on the above map
    //x = controls the first column (left to right)
    //y = controls the second
    //heading = the third column
    //bits 0-2 of zpos = the fourth column
    //bits 3-6 of zpos = the fifth column



    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        //change the x columns first
        if (xpos != 0)
        {
            ChangeColumn(triggerX, triggerY, 0, xpos);
        }

        if (ypos != 0)
        {
            ChangeColumn(triggerX, triggerY, 1, ypos);
        }

        if (heading != 0)
        {
            ChangeColumn(triggerX, triggerY, 2, heading);
        }

        if ((zpos & 0x7) != 0)
        {
            ChangeColumn(triggerX, triggerY, 3, (zpos & 0x7));
        }

        if (((zpos >> 3) & 0x7) != 0)
        {
            ChangeColumn(triggerX, triggerY, 4, ((zpos >> 3) & 0x7));
        }
    }
Пример #14
0
 //0186  a_spelltrap
 //	fields "quality" and "owner" determine spell type.
 public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
 {
     Debug.Log(this.name);
     //int spellindex = ((objInt().quality & 0xf)<<4) | (objInt().owner & 0xf) ;
     //	Debug.Log ("casting spelleffect " + spellindex);
     UWCharacter.Instance.PlayerMagic.CastEnchantment(this.gameObject, null, GetSpellIndex(), Magic.SpellRule_TargetVector);
 }
Пример #15
0
    /*
     * Per uw-formats.txt
     * 0180  a_damage trap
     * player vitality is decreased; number of hit points are in "quality"
     * field; if the "owner" field is != 0, the hit points are added
     * instead. the trap is only set of when a random value [0..10] is >= 7.
     *
     * Examples of usage
     * Ironwits maze on Level2 (rotworm area)
     *
     * //UPDATE
     * It appears the above may be wrong?
     * owner = 0 damage trap
     * owner != 0 poison trap
     */

    //Question to answer. What impact does the flags value have?

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        //Debug.Log (this.name);
        if (owner == 0)
        {
            if (Random.Range(0, 11) >= 7)
            {
                UWCharacter.Instance.CurVIT = UWCharacter.Instance.CurVIT - quality;
            }
        }
        else        //poison version
        {
            if (!UWCharacter.Instance.isPoisonResistant())
            {
                if (UWCharacter.Instance.play_poison == 0)
                {
                    //UWCharacter.Instance.PlayerMagic.CastEnchantment(UWCharacter.Instance.gameObject,null,SpellEffect.UW1_Spell_Effect_Poison,Magic.SpellRule_TargetSelf, Magic.SpellRule_Consumable);
                    UWCharacter.Instance.play_poison = (short)Random.Range(1, 6);
                    if (UWCharacter.Instance.poison_timer == 0)
                    {
                        UWCharacter.Instance.poison_timer = 30f;
                    }
                }
            }
        }
    }
    //public int xpos;

    /*
     * Per uw-formats.txt
     * 018e  a_check variable trap
     * the "value" from the set variable trap (018d) is also used here.
     * the trap checks a range of variables, starting from "zpos" and of
     * length "heading". if "xpos" is not 0, the variable values in range
     * are added; if it is 0, the lower 3 bits of every variable value are
     * shifted into the resulting value. here's some meta-C code to show
     * how the check works:
     *
     * bool check_variable_trap(zpos,heading,value)
     * {
     *  Int16 cmp = 0;
     *  for(Int16 i=zpos; i<zpos+heading; i++)
     *  {
     *     if (xpos != 0)
     *        cmp += game_vars[i];
     *     else
     *     {
     *        cmp <<= 3;
     *        cmp |= game_vars[i] & 7;
     *     }
     *  }
     *
     *  return di != value
     * }
     *
     * The trigger associated with the trap is set off when the resulting
     * value is not equal the "value".
     *
     * Examples of usage
     * the left, right, center button combination on Level3.
     *
     */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        //Debug.Log (this.name);
        if (check_variable_trap())
        {
            TriggerNext(triggerX, triggerY, State);
            PostActivate(src);
        }
        else
        {
            if (_RES == GAME_UW2)
            {            //If linked to a null trap in UW2 the next of the null trap will act as a "false" action.
                ObjectInteraction nullObj = ObjectLoader.getObjectIntAt(objInt().link);
                //if (triggerObj.tileX==TileMap.ObjectStorageTile)
                if (nullObj.GetItemType() == ObjectInteraction.A_NULL_TRAP)
                {
                    ObjectInteraction triggerObj = ObjectLoader.getObjectIntAt(nullObj.next);
                    if (triggerObj != null)
                    {
                        if (triggerObj.GetComponent <trap_base>() != null)
                        {
                            triggerObj.GetComponent <trap_base>().Activate(this, triggerX, triggerY, State);
                            PostActivate(src);
                        }
                    }
                }
            }
        }
    }
Пример #17
0
    //Used on level 42 - scintilus academy terraforming test

    /* MAP OF ROOM
     *           EXIT
     *              X  X  X  X  X
     *
     *              X  X  X  X  X
     *
     *              X  X  X  X  X
     *          ENTRANCE
     */

    //Quality is the height of the tile when set "on"
    //Bit field of the following parameters toggles the tiles as follows (bits go from exit to entrance)
    //eg x=1 will change the bottom left tile on the above map
    //x = controls the first column (left to right)
    //y = controls the second
    //heading = the third column
    //bits 0-2 of zpos = the fourth column
    //bits 3-6 of zpos = the fifth column



    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        //base.ExecuteTrap (src, triggerX, triggerY, State);
        //change the x columns first
        if (objInt().x != 0)
        {
            ChangeColumn(triggerX, triggerY, 0, objInt().x);
        }

        if (objInt().y != 0)
        {
            ChangeColumn(triggerX, triggerY, 1, objInt().y);
        }

        if (objInt().heading != 0)
        {
            ChangeColumn(triggerX, triggerY, 2, objInt().heading);
        }

        if ((objInt().zpos & 0x7) != 0)
        {
            ChangeColumn(triggerX, triggerY, 3, (objInt().zpos & 0x7));
        }

        if (((objInt().zpos >> 3) & 0x7) != 0)
        {
            ChangeColumn(triggerX, triggerY, 4, ((objInt().zpos >> 3) & 0x7));
        }
    }
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        string created = "";
        //if (objInt().quality <= Random.Range(1,41)) //100% chance when quality is zero.
        //{
        ObjectInteraction objToClone = ObjectLoader.getObjectIntAt(objInt().link);

        if (objToClone != null)
        {
            GameObject NewObject = CloneObject(objToClone, triggerX, triggerY, true);
            LastObjectCreated = NewObject.name;
            created           = NewObject.name;
            if (objToClone.GetComponent <Container>() != null)
            {                    //Clone the items on this object
                for (short i = 0; i <= objToClone.GetComponent <Container>().MaxCapacity(); i++)
                {
                    if (objToClone.GetComponent <Container>().GetItemAt(i) != "")
                    {
                        GameObject obj = objToClone.GetComponent <Container>().GetGameObjectAt(i);
                        GameObject CloneContainerItem = CloneObject(obj.GetComponent <ObjectInteraction>(), triggerX, triggerY, false);
                        NewObject.GetComponent <Container>().items[i] = CloneContainerItem.name;
                    }
                }
            }
        }
        //}
        Debug.Log(this.name + " " + created);
    }
    //const int CompletedPyramid=3569;
    //Trap used to control the qbert puzzle in the ethereal void.
    //qual=32

    //Takes a couple of parameters.
    //Owner = 0 //entrance teleport to pyramid from red hell. tells game you need to set a red pyramid.
    //owner = 2 //entrance from the blue zone
    //owner = 3 //entrance from the purple zone (stickman)
    //Owner = 4 //entrance from the green zone (maze)
    //Owner = 11 to 15 //Unknown usage possibly used for  other moongate destinations such as the sigil of binding or the shrine
    //owner = 16 //used in leaving the pyramid area and the sigil
    //Onwer = 32 //randomly takes you to a moongate of the same colour or to the matching zone for this moongate.
    //Owner = 63 //Used in stepping on the pyramid, Most steps point to one of two traps with this owner value.


    //game variables 101 to 108 are used for this trap
    //These variables track the state of the puzzle
    //101 to 105 are the colours. The colour is the texture map index
    //These values start at 0xFF and need to be set accordingly in a new game.
    //0=red
    //1=white (default)?
    //2=blue
    //3=purple
    //4=gold
    //5=orange (final)
    //106 seems to be unused.
    //107 is set to one when you are in the pyramid room.

    //On completion of the pyramid a moongate is spawned at the top of the pyramid and you can teleport to hidden rooms (for each colour)
    //or to the shrine room.
    //After the first 4 pyramids a new final moongate is spawned at the entrance to the void to take you to the
    //final pyramid(orange)

    //when the top pyramid spawns the owner and quality target changes on the teleport trap.
    //The moongate becomes invisible.

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        switch (objInt().owner)
        {
        case 0:                //Exit from zones to pyramid
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
            ExitToPyramid(objInt().owner);
            break;

        case 16:
            LeaveArea();
            break;

        case 32:
            GameWorldController.instance.PositionDetect();
            RandomTeleport(src);
            break;

        case 62:
            BeginQbertPyramid();
            break;

        case 63:
            GameWorldController.instance.PositionDetect();
            StepOnPyramid(TileMap.visitTileX, TileMap.visitTileY);
            break;
        }
    }
Пример #20
0
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        TileXToWatch = triggerX;
        TileYToWatch = triggerY;
        TileVector   = CurrentTileMap().getTileVector(TileXToWatch, TileYToWatch);

        if (platformTile == null)
        {
            platformTile = GameWorldController.FindTile(triggerX, triggerY, TileMap.SURFACE_FLOOR);
        }
        if (platformTile == null)
        {
            return;
        }
        if (CurrentTileMap().Tiles[triggerX, triggerY].floorHeight / 2 >= owner)
        {
            xpos = 0;
        }
        else if (CurrentTileMap().Tiles[triggerX, triggerY].floorHeight / 2 <= quality)
        {
            xpos = 1;
        }

        if (xpos == 1)
        {//moving up
            MoveTileUp(triggerX, triggerY);
        }
        else
        {//moving down
            CurrentTileMap().Tiles[triggerX, triggerY].floorHeight -= 2;
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, -0.3f, 0f), 0.1f));
        }
    }
Пример #21
0
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {//950-954-- not sure yet if this is the correct behaviour to hard code indices
        switch (src.owner)
        {
        case 1:    //moves buttons 1/2
            MoveButton(950);
            MoveButton(951);
            break;

        case 2:    //Moves buttons 2/3
            MoveButton(951);
            MoveButton(952);
            break;

        case 4:     //moves buttons 3/4
            MoveButton(952);
            MoveButton(953);
            break;

        case 8:    // moves buttons 4/5
            MoveButton(953);
            MoveButton(954);
            break;

        case 16:    //moves buttons 5/1
            MoveButton(954);
            MoveButton(950);
            break;

        default:
            Debug.Log("unknown switch to move " + src.owner);
            break;
        }
    }
/*
 * 0181  a_teleport trap
 *      teleports the player to another level and tile; destination level is
 *      given by "zpos" (0 means current level), tile x/y coordinates
 *      are given in "quality" and "owner" fields.
 */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        if (_RES == GAME_UWDEMO)
        {
            if (zpos != 0)
            {
                ExecuteForUWDemo();
                return;
            }
            //Special case for the UW Demo.
        }
        if (EditorMode)
        {
            return;
        }
        if ((_RES == GAME_UW2) && (UWCharacter.Instance.JustTeleported))
        {        //To stop infinite level transitions in UW2
            //UWCharacter.Instance.JustTeleported=false;
            return;
        }

        float targetX = (float)quality * 1.2f + 0.6f;
        float targetY = (float)owner * 1.2f + 0.6f;

        //Heading
        //0=north
        //1=northeast
        //2=east and so on
        UWCharacter.Instance.transform.eulerAngles             = new Vector3(0f, ((float)heading * 45f), 0f);
        UWCharacter.Instance.playerCam.transform.localRotation = Quaternion.identity;

        UWCharacter.Instance.JustTeleported  = true;
        UWCharacter.Instance.teleportedTimer = 0f;

        if (zpos == 0)
        {        //Stay on this level.
            float Height = ((float)(CurrentTileMap().GetFloorHeight(quality, owner))) * 0.15f;
            UWCharacter.Instance.transform.position = new Vector3(targetX, Height + 0.5f, targetY);
            UWCharacter.Instance.TeleportPosition   = UWCharacter.Instance.transform.position;
        }
        else
        {
            UWCharacter.Instance.teleportedTimer = -1f;          //Longer wait period when travelling between levels.
            //Goto to another level
            if (_RES == GAME_UW1)
            {            //Special case for the magic drain effect in UW1
                UWCharacter.ResetTrueMana();
            }
            UWCharacter.Instance.playerMotor.movement.velocity = Vector3.zero;
            if ((xpos & 0x1) == 1)
            {//Teleport above ground and drop down into level
                GameWorldController.instance.SwitchLevel((short)(zpos - 1), quality, owner, 24);
            }
            else
            {
                GameWorldController.instance.SwitchLevel((short)(zpos - 1), quality, owner);
            }
        }
    }
    //A trap that angers nearby npcs if you enter it.
    //TODO:The stealth skill should effect this (see skill trap on lvl2 of prison tower)

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        Debug.Log("A trespass trap " + objInt().owner + " " + this.name);
        if (((objInt().owner & 0x1f)) != 0)
        {
            SignalTheft(UWCharacter.Instance.transform.position, objInt().owner, 7f);
        }
    }
Пример #24
0
    //public int xpos;

    /*
     * Per uw-formats.txt
     * 018e  a_check variable trap
     * the "value" from the set variable trap (018d) is also used here.
     * the trap checks a range of variables, starting from "zpos" and of
     * length "heading". if "xpos" is not 0, the variable values in range
     * are added; if it is 0, the lower 3 bits of every variable value are
     * shifted into the resulting value. here's some meta-C code to show
     * how the check works:
     *
     * bool check_variable_trap(zpos,heading,value)
     * {
     *  Int16 cmp = 0;
     *  for(Int16 i=zpos; i<zpos+heading; i++)
     *  {
     *     if (xpos != 0)
     *        cmp += game_vars[i];
     *     else
     *     {
     *        cmp <<= 3;
     *        cmp |= game_vars[i] & 7;
     *     }
     *  }
     *
     *  return di != value
     * }
     *
     * The trigger associated with the trap is set off when the resulting
     * value is not equal the "value".
     *
     * Examples of usage
     * the left, right, center button combination on Level3.
     *
     */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        //Debug.Log (this.name);
        if (check_variable_trap())
        {
            TriggerNext(triggerX, triggerY, State);
        }
    }
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        Debug.Log(this.name);
        Cutscene_EndGame ce = UWHUD.instance.gameObject.AddComponent <Cutscene_EndGame>();

        UWHUD.instance.CutScenesFull.cs = ce;
        UWHUD.instance.CutScenesFull.Begin();
    }
Пример #26
0
    //Changes the variable controlling the vending machine selection

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        Quest.instance.variables[objInt().owner]++;
        if (Quest.instance.variables[objInt().owner] >= 8)
        {
            Quest.instance.variables[objInt().owner] = 0;
        }
    }
 public override void PostActivate(object_base src)
 {
     if (skupSpawned)
     {
         Debug.Log("Overridden PostActivate to test " + this.name);
         base.PostActivate(src);
     }
 }
Пример #28
0
    public override void PostActivate(object_base src)
    {
        int TriggerRepeat = (objInt().flags >> 1) & 0x1;

        if (TriggerRepeat == 1)
        {
            DestroyTrap(src);
        }
    }
    public override bool Activate(object_base src, int triggerX, int triggerY, int State)
    {
        //Do what it needs to do.
        ExecuteTrap(this, triggerX, triggerY, State);

        //It's link is the object it is creating so no activation of more traps/triggers
        PostActivate(src);
        return(true);
    }
    //Removes the link on the target object.
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        ObjectInteraction objToUnlink = ObjectLoader.getObjectIntAt(link);

        if (objToUnlink != null)
        {
            objToUnlink.link = 0;
        }
    }