/// <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);
                }
            }
        }
    }
    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
                                                                             );
        }
    }
示例#3
0
    /// <summary>
    /// Move the button to the new z position
    /// </summary>
    /// <param name="NewZpos"></param>
    /// <param name="buttonToMove"></param>
    void MoveButton(short NewZpos, ObjectInteraction buttonToMove)
    {
        buttonToMove.zpos = NewZpos;
        buttonToMove.BaseObjectData.zpos = NewZpos;
        Vector3 newPos = ObjectLoader.CalcObjectXYZ(buttonToMove.BaseObjectData.index, 0);

        buttonToMove.transform.position = newPos;
    }
    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(forcefieldtoMove.objectloaderinfo.index, 1);
        }
    }
示例#5
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);
            }
        }
    }
    public void SpillContents()
    {
        TileMap tm = GameWorldController.instance.currentTileMap();                        //GameObject.Find("Tilemap").GetComponent<TileMap>();

        GameWorldController.FreezeMovement(this.gameObject);
        ObjectInteraction objInt = this.gameObject.GetComponent <ObjectInteraction>();

        objInt.UpdatePosition();
        objInt.SetWorldDisplay(objInt.GetEquipDisplay());
        for (short i = 0; i <= MaxCapacity(); i++)
        {
            GameObject Spilled = GetGameObjectAt(i);                                    //GameObject.Find (GetItemAt (i));
            if (Spilled != null)
            {
                if (Spilled.GetComponent <trigger_base>() != null)
                {
                    Spilled.GetComponent <trigger_base>().Activate(this.gameObject);
                }
                else
                {
                    ObjectInteraction objSpilled = Spilled.GetComponent <ObjectInteraction>();
                    Spilled.transform.position = this.transform.position;
                    objSpilled.UpdatePosition();
                    switch (tm.Tiles[objInt.tileX, objInt.tileY].tileType)
                    {
                    case TileMap.TILE_OPEN:
                    case TileMap.TILE_SLOPE_N:
                    case TileMap.TILE_SLOPE_S:
                    case TileMap.TILE_SLOPE_E:
                    case TileMap.TILE_SLOPE_W:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(1, 7);
                        break;

                    case TileMap.TILE_DIAG_SE:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(0, objSpilled.x);
                        break;

                    case TileMap.TILE_DIAG_SW:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(1, 7 - objSpilled.x);
                        break;

                    case TileMap.TILE_DIAG_NE:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(8 - objSpilled.x, 8);
                        break;

                    case TileMap.TILE_DIAG_NW:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(objSpilled.x, 8);
                        break;
                    }
                    objSpilled.zpos = (short)(tm.Tiles[objInt.tileX, objInt.tileY].floorHeight * 4);
                    objSpilled.objectloaderinfo.x    = objSpilled.x;
                    objSpilled.objectloaderinfo.y    = objSpilled.y;
                    objSpilled.objectloaderinfo.zpos = objSpilled.zpos;
                    objSpilled.transform.position    = ObjectLoader.CalcObjectXYZ(_RES, tm, tm.Tiles, GameWorldController.instance.CurrentObjectList().objInfo, objSpilled.objectloaderinfo.index, this.objInt().objectloaderinfo.tileX, this.objInt().objectloaderinfo.tileY, 0);
                    RemoveItemFromContainer(i);
                    Spilled.GetComponent <ObjectInteraction>().PickedUp = false;
                    GameWorldController.UnFreezeMovement(Spilled);
                }
            }
        }
    }
    public void SpillContents()
    {
        TileMap tm = CurrentTileMap(); //GameObject.Find("Tilemap").GetComponent<TileMap>();

        FreezeMovement(this.gameObject);
        ObjectInteraction objInt = this.gameObject.GetComponent <ObjectInteraction>();

        objInt.UpdatePosition();
        objInt.SetWorldDisplay(objInt.GetEquipDisplay());
        objInt.link = 0; //So items in world will not create infinitly lopping references
        for (short i = 0; i <= MaxCapacity(); i++)
        {
            ObjectInteraction objSpilled = GetItemAt(i);
            if (objSpilled != null)
            {
                if (objSpilled.GetComponent <trigger_base>() != null)
                {
                    objSpilled.GetComponent <trigger_base>().Activate(this.gameObject);
                }
                else
                {
                    //ObjectInteraction objSpilled = Spilled.GetComponent<ObjectInteraction>();
                    objSpilled.transform.position = this.transform.position;
                    objSpilled.UpdatePosition();
                    switch (tm.Tiles[objInt.ObjectTileX, objInt.ObjectTileY].tileType)
                    {
                    case TileMap.TILE_OPEN:
                    case TileMap.TILE_SLOPE_N:
                    case TileMap.TILE_SLOPE_S:
                    case TileMap.TILE_SLOPE_E:
                    case TileMap.TILE_SLOPE_W:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(1, 7);
                        break;

                    case TileMap.TILE_DIAG_SE:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(0, objSpilled.xpos);
                        break;

                    case TileMap.TILE_DIAG_SW:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(1, 7 - objSpilled.xpos);
                        break;

                    case TileMap.TILE_DIAG_NE:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(8 - objSpilled.xpos, 8);
                        break;

                    case TileMap.TILE_DIAG_NW:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(objSpilled.xpos, 8);
                        break;
                    }
                    objSpilled.zpos = (short)(tm.Tiles[objInt.ObjectTileX, objInt.ObjectTileY].floorHeight * 4);
                    objSpilled.objectloaderinfo.xpos = objSpilled.xpos;
                    objSpilled.objectloaderinfo.ypos = objSpilled.ypos;
                    objSpilled.objectloaderinfo.zpos = objSpilled.zpos;
                    objSpilled.transform.position    = ObjectLoader.CalcObjectXYZ(objSpilled.objectloaderinfo.index, 0);
                    RemoveItemFromContainer(i);
                    //FIELD PICKUP Spilled.GetComponent<ObjectInteraction>().PickedUp=false;
                    UnFreezeMovement(objSpilled);
                }
            }
        }
    }