/// <summary> /// Associate the Teleporter to the one passed in argument /// </summary> /// <param name="t"> the teleporter that must be associated to this one.</param> public bool Associate(Teleporter t) { if (AssociatedTeleporter == null){ AssociatedTeleporter=t; return true; } return false; }
// Use this for initialization void Start() { if(teleporter == null) { teleporter = GameObject.FindGameObjectWithTag("Doorway").GetComponent<Teleporter>(); } teleporter.ActivateForcefield(); }
void OnTriggerEnter2D(Collider2D other) { if (OnOff) { other.transform.position = otherTeleporter.transform.position; tele = otherTeleporter.GetComponent<Teleporter> (); tele.OnOff = false; } }
/// <summary> /// Associates the Teleporter to a free Teleporter, or make it the free teleporter if there isn't one /// </summary> public void AssociateToFree() { if (FreeTeleporter!=null && FreeTeleporter.Associate(this)){ AssociatedTeleporter=FreeTeleporter; FreeTeleporter=null; } else { FreeTeleporter=this; } }
// Use this for initialization void Start() { if (OtherEnd == null) { Debug.LogError("The teleporter needs another end teleport to."); } else { OtherEndTeleporter = OtherEnd.GetComponent<Teleporter>(); if (OtherEndTeleporter == null) { Debug.LogError("The other end is NOT a Teleporter!"); } } }
void Teleport( Teleporter iTP ) { GameObject destinationDoor = iTP.DestinationDoor; MiddleVRTools.Log("Head entered trigger to teleport to door '" + GetGameObjectPath(destinationDoor.transform) + "'."); GameObject destinationRoom = destinationDoor.transform.parent.gameObject; m_JustTeleported = true; MiddleVRTools.Log("Teleporting to '" + destinationRoom + "'"); TPToRoom(destinationRoom); // Disable this TP on all conneted clients MiddleVR.VRKernel.ExecuteCommand("DisableTP", destinationDoor.name); }
public override void Paint(Level level) { var old = Painter.Clip; Painter.Clip = null; Painter.Fill(level, this, Tile.WallA); Painter.Clip = old; var doors = Connected.Values.ToArray(); var rooms = Connected.Keys.ToArray(); var spot = doorZero ? doors[0] : doors[1]; var dot = new Dot(spot.X, spot.Y); if (dot.X == Left) { dot.X += 4; } else if (dot.Y == Top) { dot.Y += 4; } else if (dot.X == Right) { dot.X -= 4; } else if (dot.Y == Bottom) { dot.Y -= 4; } Painter.Fill(level, dot.X - 2, dot.Y - 2, 5, 5, Tiles.RandomFloor()); PaintTunnel(level, Tiles.RandomFloor(), GetCenterRect()); Painter.Set(level, dot.X, dot.Y, Tile.FloorD); var t = new Teleporter { Id = "a" }; level.Area.Add(t); t.Position = dot * 16; }
private static void ReceiveKillTeleporter(BinaryReader reader, int whoAmI) { Teleporter killed = (Teleporter)TileEntity.ByPosition[reader.ReadPoint16()]; if (Main.netMode == NetmodeID.Server) { SendKillTeleporter(killed, whoAmI); } else { foreach (TileEntity tileEntity in TileEntity.ByPosition.Values) { if (tileEntity is Teleporter teleporter && teleporter.Destination == killed) { teleporter.Destination = null; } } } }
public (Teleporter, int) GetTeleporterFromSelection(int id, bool shouldGetOther = false) { System.Predicate <Teleporter> predicate; if (shouldGetOther) { predicate = tele => tele.id != id; } else { predicate = tele => tele.id == id; } Teleporter teleporter = selections.Find(predicate); int index = selections.FindIndex(predicate); return(teleporter, index); }
// Use this for initialization void Start() { controller = GetComponent <Controller2D>(); lightSaber = GetComponentInChildren <LightSaber>(); aim = GetComponent <AimingController>(); teleporte = GetComponent <Teleporter>(); playerMaterial = GetComponent <Renderer>().sharedMaterial; netTrans = GetComponent <NetworkTransform>(); if (gameObject.layer == LayerMask.NameToLayer("Player")) { lightSaber.collisionlayerMask = LayerMask.GetMask("Enemy"); } else { lightSaber.collisionlayerMask = LayerMask.GetMask("Player"); } lightSaber.collisionTest = isServer; EventSwingSaberEvent += lightSaber.Swing; initialMoveSpeed = moveSpeed; gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2); jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; print("Gravity: " + gravity + " Jump Velocity: " + jumpVelocity); targetVelocityX = 0; accelerationTimeAirorne = 0; accelerationTimeGrounded = 0; isAttacking = false; isDodging = false; controller.horizontalRayCount = (int)(controller.horizontalRayCount * transform.localScale.x); controller.verticalRayCount = (int)(controller.verticalRayCount * transform.localScale.y); jumpHeight *= transform.localScale.y; moveSpeed *= transform.localScale.x; wallJumpClimb.x *= transform.localScale.x; wallJumpClimb.y *= transform.localScale.y; wallJumpOff.x *= transform.localScale.x; wallJumpOff.y *= transform.localScale.y; wallLeap.x *= transform.localScale.x; wallLeap.y *= transform.localScale.y; }
public ISlot GetSlot(char slot, int x, int y) { switch (slot) { case '@': return(new Slot(x, y)); case '#': return(new Wall(x, y)); case 'X': return(new Obstacle(x, y)); case 'I': return(new Inverter(x, y)); case 'B': return(new Beer(x, y)); case 'S': return(new Modifier(Direction.SOUTH, x, y)); case 'E': return(new Modifier(Direction.EAST, x, y)); case 'N': return(new Modifier(Direction.NORTH, x, y)); case 'W': return(new Modifier(Direction.WEST, x, y)); case 'T': { if (first == null) { first = new Teleporter(x, y); return(first); } else { Teleporter second = new Teleporter(x, y); second.Destination = first; first.Destination = second; return(second); } } case '$': return(new End(x, y)); } return(new Slot(x, y)); }
// Start is called before the first frame update void Start() { if (_item.MyTitle == "Iron Ingot") { IngotIron ironIngot = (IngotIron)Instantiate(_item); } else if (_item.MyTitle == "Silver Ingot") { IngotSilver silverIngot = (IngotSilver)Instantiate(_item); } else if (_item.MyTitle == "Gold Ingot") { IngotGold goldIngot = (IngotGold)Instantiate(_item); } else if (_item.MyTitle == "Mithril Ingot") { IngotMithril mithrilIngot = (IngotMithril)Instantiate(_item); } else if (_item.MyTitle == "Iron Pickaxe") { IronPickAxe ironPickaxe = ( IronPickAxe )Instantiate(_item); } else if (_item.MyTitle == "Silver Pickaxe") { SilverPickAxe silverPickaxe = ( SilverPickAxe )Instantiate(_item); } else if (_item.MyTitle == "Gold Pickaxe") { GoldPickAxe goldPickaxe = ( GoldPickAxe )Instantiate(_item); } else if (_item.MyTitle == "Mithril Pickaxe") { DiamondPickAxe diamondPickaxe = ( DiamondPickAxe )Instantiate(_item); } else if (_item.MyTitle == "Rune of Teleportation") { Teleporter teleporter = (Teleporter)Instantiate(_item); } nameLabel.text = _item.MyTitle; iconImage.sprite = _item.MyIcon; craftingRecipe.text = _item.MyRecipe; }
public void FinishLoad() { // check to see if all the teleporters have names and if not fix any links foreach (BasicObject obj in Objects) { Teleporter tp = obj as Teleporter; if (tp == null) { continue; } TeleporterCache.Add(tp); if (tp.Name == string.Empty) { tp.Name = "teleporter_" + tp.Index.ToString(); } } }
public static Teleporter DeserializeTeleporter(this LevelDeserializeContext context) { var teleporter = new Teleporter(); teleporter.TargetLevel = context.br.ReadNullableString(); if (teleporter.TargetLevel != null) { teleporter.TargetLevel = teleporter.TargetLevel.ToLowerInvariant(); } teleporter.targetSpawn = context.br.ReadNullableString(); if (context.Version >= 18) { teleporter.neverSelectAtRandom = context.br.ReadBoolean(); } DeserializeRegion(context, teleporter); return(teleporter); }
public void CreateTeleporter(Point3D pointLocation, Point3D pointDestination, Map mapLocation, Map mapDestination, bool back) { if (!FindTeleporter(mapLocation, pointLocation)) { m_Count++; Teleporter tel = new Teleporter(pointDestination, mapDestination); tel.MoveToWorld(pointLocation, mapLocation); } if (back && !FindTeleporter(mapDestination, pointDestination)) { m_Count++; Teleporter telBack = new Teleporter(pointLocation, mapLocation); telBack.MoveToWorld(pointDestination, mapDestination); } }
private void button3_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count <= 0) { return; } if (Teleporter.Destination != null) { return; } var row = dataGridView1.SelectedRows[0]; if (row.DataBoundItem != null) { var bookitem = (BookItem)row.DataBoundItem; Teleporter.SetDestination(new Location(bookitem.X, bookitem.Y, bookitem.Z)); } }
private void HandleSecretRoom(RoomEntrances entrances) { List <Exit> activeExits = entrances.Exits.FindAll((exit) => { return(exit.gameObject.activeSelf); }); if (activeExits.Count > 1) { Debug.LogWarning("For some reason secret room has more than one exit!"); } Teleporter exitTP = activeExits[0].Teleporter; var room = exitTP.Destination.CurrentRoom; Exit destinationExit = exitTP.Destination.GetComponent <Exit>(); Debug.Log($"{entrances.gameObject.name} has exit to room {exitTP.Destination.CurrentRoom.gameObject.name}"); var health = destinationExit.gameObject.AddComponent <SecretDoor>(); }
void OnTriggerEnter(Collider other) { if (other.tag.Equals("Teleporter")) { Teleporter tp = other.GetComponent <Teleporter>(); transform.position = tp.target; if (tp.applyRotation) { transform.rotation = tp.targetRotation; } if (tp.cancelVelocity) { rigidbody.velocity = Vector3.zero; } } else if (other.tag.Equals("Kill")) { respawnPlayer(true); } }
void Update() { if (startCount == true) { float oldTimer = timer; timer -= Time.deltaTime; if (oldTimer < timer) { teleAudio.clip = teleClips[2]; teleAudio.Play(); } if (timer <= 0) { int selectedTeleporterIndicator = Random.Range(0, OtherTeleporters.Length); Teleporter DestTele = OtherTeleporters[selectedTeleporterIndicator]; Vector3 teleLocation = DestTele.TeleportingLocation.transform.position; canUse = false; startCount = false; player.transform.position = teleLocation; coolDownTime = 10;// renderer.material = teleporterMaterials[0]; teleAudio.clip = teleClips[3]; teleAudio.Play(); usesLeft--; } } if (canUse == false && usesLeft > 0) { coolDownTime -= Time.deltaTime; if (coolDownTime <= 0) { teleAudio.clip = teleClips[4]; teleAudio.Play(); canUse = true; renderer.material = teleporterMaterials[usesLeft]; } } }
protected Teleporter UnpackTeleporter() { Teleporter o = new Teleporter(); o.Name = ReadULongPascalString(); o.Position = ReadVector3F(); o.Rotation = ReadFloat(); o.Size = ReadVector3F(); o.Border = ReadFloat(); o.Horizontal = ReadByte() != 0; byte state = ReadByte(); o.DriveThrough = (state & Constants.DRIVE_THRU) != 0; o.ShootThrough = (state & Constants.SHOOT_THRU) != 0; o.Ricochet = (state & Constants.RICOCHET) != 0; return(o); }
/// <summary> /// Constructor. /// </summary> /// <param name="x">x coordinate.</param> /// <param name="y">y coordinate.</param> /// <param name="parent">Parent game object.</param> /// <param name="o">Connected teleporter.</param> public Teleporter(int x, int y, Grid g, GameObject parent, Teleporter o = null) { location = new IntVector.IntVector2(x, y); grid = g; other = o; // size pulser settings float r = UnityEngine.Random.Range(0.1f, 0.9f); Vector2 small = new Vector2(1.0f, 0.95f); Vector2 big = new Vector2(1.0f, 1.05f); // create the teleporter ColourPicker.Colour col = (ColourPicker.Colour)((count / 2) % ColourPicker.ColourCount); GameObject teleObject = ResourceLoader.GetSpriteGameObject(col + "Teleporter", parent, (float)x, (float)y, "Tools", 1, "Sprites/Tools/Teleporter", col); pulse = teleObject.AddComponent <SizePulser>(); pulse.SetParams(true, r, small, big); // increment count count += 1; }
void OnTriggerEnter(Collider target) { if (target.gameObject.tag == "Player" && active && !locked) { if (other == null) { TargetRoomTheme = Random.Range(0, 3); Room = rooms [TargetRoomTheme]; GameObject newFloorRoom = Instantiate(Room, new Vector3(Random.Range(-10000, 10000) + 0.5f, 0, Random.Range(-10000, 10000) + 0.5f), Quaternion.identity); newFloorRoom.GetComponent <LayoutGen> ().count = 0; newFloorRoom.GetComponent <LayoutGen> ().tier = tier + 1; if (newFloorRoom.GetComponent <LayoutGen> ().tier + 1 > 5) { finalfloor = true; } newFloorRoom.name = rooms [TargetRoomTheme].name; GameObject child = Instantiate(teleporter, newFloorRoom.gameObject.transform.position + new Vector3(0, 3, 0), Quaternion.identity); other = child; otherScript = other.GetComponentInChildren <Teleporter> (); child.GetComponentInChildren <Teleporter> ().other = transform.parent.gameObject; child.GetComponentInChildren <Teleporter> ().otherScript = GetComponent <Teleporter> (); child.GetComponentInChildren <Teleporter> ().SourceRoomTheme = TargetRoomTheme; child.GetComponentInChildren <Teleporter> ().TargetRoomTheme = SourceRoomTheme; GameObject.Find("Controller").GetComponent <Doorstopper> ().Fill(); } if (!finalfloor) { Camera.main.GetComponent <AudioSource> ().clip = music [TargetRoomTheme]; Camera.main.GetComponent <AudioSource> ().Play(); otherScript.active = false; target.gameObject.transform.position = other.transform.position; } else { target.gameObject.transform.position = finalplayerpos; Camera.main.GetComponent <AudioSource> ().clip = finalMusic; Camera.main.GetComponent <AudioSource> ().Play(); } } }
/// <summary> /// Constructor /// </summary> /// <param name="teleporter">Teleporter handle</param> /// <param name="dungeon">Dungeon handle</param> public TeleporterControl(Teleporter teleporter, Dungeon dungeon) { InitializeComponent(); targetControl1.Dungeon = dungeon; TeamBox.Checked = teleporter.TeleportTeam; ItemsBox.Checked = teleporter.TeleportItems; MonsterBox.Checked = teleporter.TeleportMonsters; VisibleBox.Checked = teleporter.IsVisible; ReusableBox.Checked = teleporter.Reusable; ActiveBox.Checked = teleporter.IsActivated; UseSoundBox.Checked = teleporter.UseSound; SoundNameBox.Text = teleporter.SoundName; if (teleporter != null) { targetControl1.SetTarget(teleporter.Target); } Teleporter = teleporter; }
public void Check() { if (IsComplete()) { if (ProgressionObject) { ProgressionObject.SetActive(SetActive); //PortalTurnedOn.SetActive(true); //make this a corutine instead } if (UseHud) { PlayerHud.Instance.TurnOnPortalText(); } Teleporter teleporter = FindObjectOfType <Teleporter>(); if (teleporter) { teleporter.PlaySound(); } } }
public override void Setup(GameMode gameMode) { base.Setup(gameMode); IsTopDown = false; var levelGrid = new Engine.ObjectGrid("levelGrid", this, 3, 3, 1920, 960); levelGrid.CanCollide = true; AddGridToLevelGrid(0, 0, levelGrid, new string[] { "96" }); AddGridToLevelGrid(1, 0, levelGrid, new string[] { "97" }); AddGridToLevelGrid(2, 0, levelGrid, new string[] { "98" }); AddGridToLevelGrid(2, 1, levelGrid, new string[] { "46" }); AddGridToLevelGrid(0, 1, levelGrid, new string[] { "26" }); AddGridToLevelGrid(0, 2, levelGrid, new string[] { "100" }); AddGridToLevelGrid(1, 1, levelGrid, new string[] { "99" }); AddGridToLevelGrid(1, 2, levelGrid, new string[] { "110" }); Add(levelGrid); var teleporterback = new Teleporter("teleporter", this, "MainWorld", new Microsoft.Xna.Framework.Vector2(4416, 5184)); teleporterback.Position = new Microsoft.Xna.Framework.Vector2(3456, 2688); teleporterback.BoundingBox = new Rectangle(0, 0, 96, 96); Add(teleporterback); var MinidungeonItem = new UpgradePickup("Alles100", this, new SpriteSheet("Textures/Items/Alles100"), "Increases all stats by 100!"); MinidungeonItem.Position = new Vector2(3360, 2688); MinidungeonItem.Health = 100; MinidungeonItem.Damage = 100; MinidungeonItem.AttackSpeed = 100; MinidungeonItem.Speed = 100; var MinidungeonItem2 = new UpgradePickup("Health100", this, new SpriteSheet("Textures/Items/Health100"), "Increases Health by 100!"); MinidungeonItem2.Position = new Vector2(1536, 400); MinidungeonItem2.Health = 100; Add(MinidungeonItem); Add(MinidungeonItem2); }
void OnGUIButtonClick(int id) { if (correctButton == id) { if (GUIController.Instance != null) { for (int i = 0; i < LevelController.NumOfButtons; i++) { GUIController.Instance.SetButtonEnable(i, false); } } Teleporter.StartTeleporter(); Instance.StartCoroutine(DelayLevelEnd()); } else { LevelController lvl = FindObjectOfType <LevelController>(); lvl.FailLevel(); lvl.GenerateWordRiddles(); UpdateButtonsForLevel(lvl); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject == finishCollider) { reachedFinish = true; } else if (other.tag == "Teleporter") { Teleporter teleport = other.gameObject.GetComponent <Teleporter>(); transform.position = teleport.TelePos.position; } else if (other.tag == "MovingPlatform") { transform.parent = other.transform; } else if (other.tag == "Lever") { Lever lever = other.gameObject.GetComponent <Lever>(); lever.Trigger(); } else if (other.tag == "LeverDoor") { LeverDoor lever = other.gameObject.GetComponent <LeverDoor>(); lever.Trigger(); } else if (other.tag == "Turret") { Turret turret = other.gameObject.GetComponent <Turret>(); turret.targetAcquired = true; } else if (other.tag == "PowerUp") { PowerUp powerUp = other.gameObject.GetComponent <PowerUp>(); powerUpJumpForce = powerUp.jumpForce; powerUpSpeed = powerUp.speed; powerUpTimer = powerUp.timer; powerUp.Use(); } }
public void CreateTeleporter(Point3D pointLocation, Point3D pointDestination, Map mapLocation, Map mapDestination, bool back) { if (!FindTeleporter(mapLocation, pointLocation)) { this.m_Count++; Teleporter tel = new Teleporter(pointDestination, mapDestination); WeakEntityCollection.Add("tel", tel); tel.MoveToWorld(pointLocation, mapLocation); } if (back && !FindTeleporter(mapDestination, pointDestination)) { this.m_Count++; Teleporter telBack = new Teleporter(pointLocation, mapLocation); WeakEntityCollection.Add("tel", telBack); telBack.MoveToWorld(pointDestination, mapDestination); } }
public PvpWarningGump(Teleporter teleporter) : base(150, 50) { m_Owner = teleporter; AddPage(0); AddImage(0, 0, 0xE10); AddImageTiled(0, 14, 15, 200, 0xE13); AddImageTiled(380, 14, 14, 200, 0xE15); AddImage(0, 201, 0xE16); AddImageTiled(15, 201, 370, 16, 0xE17); AddImageTiled(15, 0, 370, 16, 0xE11); AddImage(380, 0, 0xE12); AddImage(380, 201, 0xE18); AddImageTiled(15, 15, 365, 190, 0xA40); AddHtmlLocalized(30, 20, 330, 20, 1060635, 0x4040FE, false, false); // <CENTER>WARNING</CENTER> AddHtmlLocalized(30, 50, 330, 60, 1113792, 0xFFFFFF, false, false); // You are about to enter a PvP area, where you can be attacked and stolen from by other players. Do you wish to proceed? AddHtmlLocalized(65, 125, 300, 25, 1113794, 0xFFFFFF, false, false); // Yes, I wish to proceed AddButton(30, 125, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(65, 150, 300, 25, 1113795, 0xFFFFFF, false, false); // Yes, and do not ask me again AddButton(30, 150, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(65, 175, 300, 25, 1113793, 0xFFFFFF, false, false); // No, I do not wish to proceed AddButton(30, 175, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); AddImageTiled(15, 14, 365, 1, 0x2393); AddImageTiled(380, 14, 1, 190, 0x2391); AddImageTiled(15, 205, 365, 1, 0x2393); AddImageTiled(15, 14, 1, 190, 0x2391); AddImageTiled(0, 0, 395, 1, 0x23C5); AddImageTiled(394, 0, 1, 217, 0x23C3); AddImageTiled(0, 216, 395, 1, 0x23C5); AddImageTiled(0, 0, 1, 217, 0x23C3); }
public void PostCreated(bool loaded) { Button button; //TeleportZombie button button = Owner.MainControl.Controls["TeleportZombie"] as Button; if (button != null) { button.Click += delegate(Button sender) { Teleporter teleporter = (Teleporter)Entities.Instance.GetByName("Teleporter_InsideMap1"); if (teleporter != null) { MapObject unit = (MapObject)Entities.Instance.Create("Zombie", Map.Instance); unit.Position = new Vec3(1000, 1000, 0); unit.PostCreate(); teleporter.ReceiveObject(unit, null); } }; } //TeleportBug button button = Owner.MainControl.Controls["TeleportBug"] as Button; if (button != null) { button.Click += delegate(Button sender) { Teleporter teleporter = (Teleporter)Entities.Instance.GetByName("Teleporter_InsideMap1"); if (teleporter != null) { MapObject unit = (MapObject)Entities.Instance.Create("Bug", Map.Instance); unit.Position = new Vec3(1000, 1000, 0); unit.PostCreate(); teleporter.ReceiveObject(unit, null); } }; } }
void Start() { rb = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); if (isLevel30) { teleporterScript = FindObjectOfType <Teleporter>(); } dashTime = startDashTime; dashCooldownTime = 0f; if (GameObject.FindWithTag("DoubleJump")) { gotDoubleJumpItem = true; } if (GameObject.FindWithTag("Dash")) { gotDashItem = true; } }
public UITeleporterItem(Teleporter teleporter, TeleporterPanel panel) { this.panel = panel; this.teleporter = teleporter; UIIcon icon = new UIIcon(teleporter) { Height = { Percent = 100 } //SubstituteWidth = true }; Add(icon); UIText textDisplayName = new UIText(teleporter.DisplayName) { X = { Pixels = 48 } }; Add(textDisplayName); buttomShowOnMap = new UIButton(Main.mapIconTexture[0]) { Size = new Vector2(20), X = { Percent = 100 }, HoverText = Language.GetText("Mods.Teleportation.UI.ShowOnMap") }; Add(buttomShowOnMap); textureConnection = new UITexture(null, ScaleMode.Stretch) { Size = new Vector2(20), X = { Percent = 100 }, Y = { Percent = 100 } }; //textureConnection.GetHoverText += () => Outbound ? Language.GetTextValue("Mods.Teleportation.UI.OutboundConnection") : Inbound ? Language.GetTextValue("Mods.Teleportation.UI.InboundConnection") : ""; Add(textureConnection); }
void OnTriggerEnter2D(Collider2D c) { if (c.gameObject.GetComponent <PlayerController>() != null) { if (GlobalProperties.IS_NETWORKED) { if (PhotonNetwork.player.ID == c.gameObject.GetComponent <PhotonView>().ownerId&& !justTP) { Teleporter next = GetTeleporterWithID(TeleID, c.gameObject.GetComponent <PlayerController>()); c.gameObject.transform.position = next.transform.position; c.gameObject.GetComponent <PhotonView>().RPC("Teleported", PhotonTargets.All, this.transform.position, next.transform.position); } } else { if (!justTP) { Teleporter next = GetTeleporterWithID(TeleID, c.gameObject.GetComponent <PlayerController>()); c.gameObject.transform.position = next.transform.position; c.gameObject.GetComponent <PlayerController>().LOCAL_Teleported(this.transform.position, next.transform.position); } } } }
public TeleporterDTO Insert(TeleporterDTO teleporter) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { Teleporter entity = new Teleporter(); Mapper.Mapper.Instance.TeleporterMapper.ToTeleporter(teleporter, entity); context.Teleporter.Add(entity); context.SaveChanges(); if (Mapper.Mapper.Instance.TeleporterMapper.ToTeleporterDTO(entity, teleporter)) { return(teleporter); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
IEnumerator Teleport() { //Gets components needed DissolveEffect dissolveEffect = Player.GetComponent <DissolveEffect>(); PlayerMovement playerMovement = Player.GetComponent <PlayerMovement>(); Teleporter teleport = otherTeleporter.GetComponent <Teleporter>(); dissolveEffect.StartDissolve(2f); yield return(new WaitForSeconds(1f)); //Teleports the player PlayerController.isGamePaused = true; Player.transform.position = new Vector2(otherDestination.transform.position.x, otherDestination.transform.position.y); teleport.allowTeleport = false; dissolveEffect.StopDissolve(2f); yield return(new WaitForSeconds(0.35f)); PlayerController.isGamePaused = false; yield return(new WaitForSeconds(0.2f)); teleport.allowTeleport = true; }
public Item Construct() { Item item; try { if (m_Type == typeofStatic) { item = new Static(m_ItemID); } else if (m_Type == typeofLocalizedStatic) { int labelNumber = 0; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("LabelNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { labelNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); break; } } } item = new LocalizedStatic(m_ItemID, labelNumber); } else if (m_Type == typeofLocalizedSign) { int labelNumber = 0; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("LabelNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { labelNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); break; } } } item = new LocalizedSign(m_ItemID, labelNumber); } else if (m_Type == typeofAnkhWest || m_Type == typeofAnkhNorth) { bool bloodied = false; for (int i = 0; !bloodied && i < m_Params.Length; ++i) { bloodied = (m_Params[i] == "Bloodied"); } if (m_Type == typeofAnkhWest) { item = new AnkhWest(bloodied); } else { item = new AnkhNorth(bloodied); } } else if (m_Type == typeofMarkContainer) { bool bone = false; bool locked = false; Map map = Map.Malas; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i] == "Bone") { bone = true; } else if (m_Params[i] == "Locked") { locked = true; } else if (m_Params[i].StartsWith("TargetMap")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { map = Map.Parse(m_Params[i].Substring(++indexOf)); } } } MarkContainer mc = new MarkContainer(bone, locked); mc.TargetMap = map; mc.Description = "strange location"; item = mc; } else if (m_Type == typeofHintItem) { int range = 0; int messageNumber = 0; string messageString = null; int hintNumber = 0; string hintString = null; TimeSpan resetDelay = TimeSpan.Zero; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Range")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("WarningString")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { messageString = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("WarningNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("HintString")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { hintString = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("HintNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { hintNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("ResetDelay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } HintItem hi = new HintItem(m_ItemID, range, messageNumber, hintNumber); hi.WarningString = messageString; hi.HintString = hintString; hi.ResetDelay = resetDelay; item = hi; } else if (m_Type == typeofWarningItem) { int range = 0; int messageNumber = 0; string messageString = null; TimeSpan resetDelay = TimeSpan.Zero; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Range")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("WarningString")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { messageString = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("WarningNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("ResetDelay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } WarningItem wi = new WarningItem(m_ItemID, range, messageNumber); wi.WarningString = messageString; wi.ResetDelay = resetDelay; item = wi; } else if (m_Type == typeofCannon) { CannonDirection direction = CannonDirection.North; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("CannonDirection")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { direction = (CannonDirection)Enum.Parse(typeof(CannonDirection), m_Params[i].Substring(++indexOf), true); } } } item = new Cannon(direction); } else if (m_Type == typeofSerpentPillar) { string word = null; Rectangle2D destination = new Rectangle2D(); for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Word")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { word = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("DestStart")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { destination.Start = Point2D.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("DestEnd")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { destination.End = Point2D.Parse(m_Params[i].Substring(++indexOf)); } } } item = new SerpentPillar(word, destination); } else if (m_Type.IsSubclassOf(typeofBeverage)) { BeverageType content = BeverageType.Liquor; bool fill = false; for (int i = 0; !fill && i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Content")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { content = (BeverageType)Enum.Parse(typeof(BeverageType), m_Params[i].Substring(++indexOf), true); fill = true; } } } if (fill) { item = (Item)Activator.CreateInstance(m_Type, new object[] { content }); } else { item = (Item)Activator.CreateInstance(m_Type); } } else if (m_Type.IsSubclassOf(typeofBaseDoor)) { DoorFacing facing = DoorFacing.WestCW; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Facing")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { facing = (DoorFacing)Enum.Parse(typeof(DoorFacing), m_Params[i].Substring(++indexOf), true); break; } } } item = (Item)Activator.CreateInstance(m_Type, new object[] { facing }); } else { item = (Item)Activator.CreateInstance(m_Type); } } catch (Exception e) { throw new Exception(String.Format("Bad type: {0}", m_Type), e); } if (item is BaseAddon) { if (item is MaabusCoffin) { MaabusCoffin coffin = (MaabusCoffin)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("SpawnLocation")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { coffin.SpawnLocation = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } } } else if (m_ItemID > 0) { List <AddonComponent> comps = ((BaseAddon)item).Components; for (int i = 0; i < comps.Count; ++i) { AddonComponent comp = (AddonComponent)comps[i]; if (comp.Offset == Point3D.Zero) { comp.ItemID = m_ItemID; } } } } else if (item is BaseLight) { bool unlit = false, unprotected = false; for (int i = 0; i < m_Params.Length; ++i) { if (!unlit && m_Params[i] == "Unlit") { unlit = true; } else if (!unprotected && m_Params[i] == "Unprotected") { unprotected = true; } if (unlit && unprotected) { break; } } if (!unlit) { ((BaseLight)item).Ignite(); } if (!unprotected) { ((BaseLight)item).Protected = true; } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (item is Server.Mobiles.Spawner) { Server.Mobiles.Spawner sp = (Server.Mobiles.Spawner)item; sp.NextSpawn = TimeSpan.Zero; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Spawn")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.CreaturesName.Add(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MinDelay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.MinDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MaxDelay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.MaxDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("NextSpawn")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.NextSpawn = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Count")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.Count = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Team")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.Team = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("HomeRange")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.HomeRange = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Running")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.Running = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Group")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.Group = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } } } else if (item is RecallRune) { RecallRune rune = (RecallRune)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Description")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { rune.Description = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("Marked")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { rune.Marked = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("TargetMap")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { rune.TargetMap = Map.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Target")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { rune.Target = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } } } else if (item is SkillTeleporter) { SkillTeleporter tp = (SkillTeleporter)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Skill")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Skill = (SkillName)Enum.Parse(typeof(SkillName), m_Params[i].Substring(++indexOf), true); } } else if (m_Params[i].StartsWith("RequiredFixedPoint")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Required = Utility.ToInt32(m_Params[i].Substring(++indexOf)) * 0.01; } } else if (m_Params[i].StartsWith("Required")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Required = Utility.ToDouble(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MessageString")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MessageString = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("MessageNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MessageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("PointDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MapDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Creatures")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SourceEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("DestEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SoundID")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Delay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (item is KeywordTeleporter) { KeywordTeleporter tp = (KeywordTeleporter)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Substring")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Substring = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("Keyword")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Keyword = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Range")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("PointDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MapDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Creatures")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SourceEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("DestEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SoundID")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Delay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (item is Teleporter) { Teleporter tp = (Teleporter)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("PointDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MapDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Creatures")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SourceEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("DestEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SoundID")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Delay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (item is FillableContainer) { FillableContainer cont = (FillableContainer)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("ContentType")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { cont.ContentType = (FillableContentType)Enum.Parse(typeof(FillableContentType), m_Params[i].Substring(++indexOf), true); } } } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (m_ItemID > 0) { item.ItemID = m_ItemID; } item.Movable = false; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Light")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { item.Light = (LightType)Enum.Parse(typeof(LightType), m_Params[i].Substring(++indexOf), true); } } else if (m_Params[i].StartsWith("Hue")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { int hue = Utility.ToInt32(m_Params[i].Substring(++indexOf)); if (item is DyeTub) { ((DyeTub)item).DyedHue = hue; } else { item.Hue = hue; } } } else if (m_Params[i].StartsWith("Name")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { item.Name = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("Amount")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { // Must supress stackable warnings bool wasStackable = item.Stackable; item.Stackable = true; item.Amount = Utility.ToInt32(m_Params[i].Substring(++indexOf)); item.Stackable = wasStackable; } } } return(item); }
public void CreateLevel(int _world, int _level) { GetComponent<EnemyBulletManager>().DeactivateAllBullets(); foreach(Transform tr in Trees) { tr.gameObject.SetActive(false); } foreach(Transform tr in Tiles) { tr.gameObject.SetActive(false); } //MyBGImage.sprite = WorldBG[_world - 1]; Time.timeScale = 1.0f; World = WorldToLoad; Level = LevelToLoad; foreach(Transform tr in LevelContainer) { Destroy(tr.gameObject); } TextAsset myTextAsset; string filename = "LevelFiles/World" + World.ToString() + "/" + Level.ToString(); myTextAsset = Resources.Load(filename) as TextAsset; if(!myTextAsset) return; string[] lines = myTextAsset.text.Split("\n"[0]); string Season = "Spring"; switch(_world) { case 2: Season = "Summer"; break; case 3: Season = "Autumn"; break; case 4: Season = "Winter"; break; } int CurColumn = 0; int MaxColumn = 0; Vector2 playerpos = new Vector2(); int CurObstacle = 0; int CurTile = 0; for(int i = 0; i < lines.Length; i++) { CurColumn = 0; for(int character = 0; character < lines[i].Length; character++) { switch(lines[i][character]) { case '0': { GameObject tree = Trees.GetChild(CurObstacle).gameObject; //GameObject tile = Instantiate(Resources.Load("Prefabs/" + Season + "/Obstacles/Obstacle")) as GameObject; tree.transform.position = new Vector3(CurColumn * Separation, -i * Separation); //tree.transform.parent = LevelContainer; tree.SetActive(true); CurObstacle++; } break; case '1': { GameObject tile = Tiles.GetChild(CurTile).gameObject; //GameObject tile = Instantiate(Resources.Load("Prefabs/" + Season + "/Tiles/Tile" + (Random.Range(0,11)).ToString())) as GameObject; tile.transform.position = new Vector3(CurColumn * Separation, -i * Separation); //tile.transform.parent = LevelContainer; tile.SetActive(true); CurTile++; } break; case '2': { //Spawn player GameObject.FindObjectOfType<PlayerManager>().transform.position = new Vector3(CurColumn * Separation, -i * Separation); playerpos = new Vector2(CurColumn * Separation, -i * Separation); goto case '1'; } case '3': { //Spawn portal GameObject teleporter = Instantiate(Resources.Load("Prefabs/Teleporter")) as GameObject; teleporter.transform.position = new Vector3(CurColumn * Separation, -i * Separation); teleporter.transform.parent = LevelContainer; MyTeleporter = teleporter.GetComponent<Teleporter>(); MyTeleporter.MyLevelBuilder = this; MyTeleporter.SetGem(_world); TargetObj = teleporter.transform; goto case '1'; } case '4': { //Spawn boss GameObject boss = Instantiate(Resources.Load("Prefabs/Enemies/World" + _world + "/Boss")) as GameObject; boss.transform.position = new Vector3(CurColumn * Separation, -i * Separation); boss.transform.parent = LevelContainer; boss.GetComponent<Enemy>().MyLevelBuilder = this; TargetObj = boss.transform; goto case '1'; } default: CurColumn--; break; } CurColumn++; if(MaxColumn < CurColumn) { MaxColumn = CurColumn; } } } //Spawn enemies randomly, a bit away from the player int numenemies = (_world + 2) * 5 + _level; numenemies *= 3; List<Vector2> usedpositions = new List<Vector2>(); for(int i = 0; i < numenemies; i++) { //Get a random row and column, if it's available (i.e. it's a 1), then spawn an enemy there. //Make sure it's at least 5 x and 5 y away from the player bool FoundPosition = false; while(!FoundPosition) { int randomrow = Random.Range(0, lines.Length-2); int randomcolumn = Random.Range(0, MaxColumn); Vector2 tempvec = new Vector2(randomcolumn * Separation, -randomrow * Separation); if(lines[randomrow][randomcolumn] == '1') { //Check that no enemy has spawned there bool bEmptyFlag = true; foreach(Vector2 vec in usedpositions) { if(vec.x == randomcolumn && vec.y == randomrow) { bEmptyFlag = false; break; } } if(bEmptyFlag) { //Check the distance from the player if(Vector2.SqrMagnitude( tempvec - playerpos ) > 25.0f) { FoundPosition = true; usedpositions.Add(new Vector2(randomcolumn, randomrow)); //Now spawn randomly a ranged or melee if((randomrow & 1) == 0) { GameObject enemy = Instantiate(Resources.Load("Prefabs/Enemies/World" + _world + "/Ranged")) as GameObject; enemy.transform.position = new Vector3(randomcolumn * Separation, -randomrow * Separation); enemy.transform.parent = LevelContainer; } else { GameObject enemy = Instantiate(Resources.Load("Prefabs/Enemies/World" + _world + "/Melee")) as GameObject; enemy.transform.position = new Vector3(randomcolumn * Separation, -randomrow * Separation); enemy.transform.parent = LevelContainer; } } } } } } m_LoadingPanel.SetActive(false); }
public ChangeMapInformation GetChangeMapInformation(Teleporter teleporter) { ChangeMapInformation information = new ChangeMapInformation(); information.position = new Vec3(0, 0, OldPosition.Z - teleporter.Position.Z); information.health = Health; information.weapons = weapons; information.activeWeaponIndex = GetWeaponIndex( (activeWeapon != null) ? activeWeapon.Type : null); return information; }
private int number; //nomor Tile #endregion Fields #region Constructors /// <summary> /// Constructor kelas Tile /// </summary> /// <param name="num">Indeks petak</param> public Tile(int num) { this.number = num; this.isSnake = this.isLadder = null; }
/// <summary> /// Method untuk mengganti teleporter ular yang ada pada petak /// </summary> /// <param name="isSnake">Teleporter ular yang baru</param> public void SetIsSnake(Teleporter isSnake) { this.isSnake = isSnake; }
public void ReceiveObject(MapObject obj, Teleporter source) { if (!string.IsNullOrEmpty(Type.ReceiveParticleName)) Map.Instance.CreateAutoDeleteParticleSystem(Type.ReceiveParticleName, Position); if (source == null) { float offset = obj.Position.Z - obj.PhysicsModel.GetGlobalBounds().Minimum.Z; obj.Position = Position + new Vec3(0, 0, offset); obj.Rotation = Rotation; obj.SetOldTransform(obj.Position, obj.Rotation, obj.Scale); } else { Quat destRotation = Rotation * Mat3.FromRotateByZ(new Degree(180).InRadians()).ToQuat(); foreach (Body body in obj.PhysicsModel.Bodies) { body.Rotation = body.Rotation * source.Rotation.GetInverse() * destRotation; Vec3 localPosOffset = (body.Position - source.Position) * source.Rotation.GetInverse(); body.Position = Position + localPosOffset * destRotation; body.OldPosition = body.Position; body.OldRotation = body.Rotation; body.LinearVelocity = body.LinearVelocity * source.Rotation.GetInverse() * destRotation; body.AngularVelocity = body.AngularVelocity * source.Rotation.GetInverse() * destRotation; } obj.UpdatePositionAndRotationByPhysics(true); obj.SetOldTransform(obj.Position, obj.Rotation, obj.Scale); Unit unit = obj as Unit; if (unit != null) { PlayerIntellect playerIntellect = unit.Intellect as PlayerIntellect; if (playerIntellect != null) { Vec3 vec = playerIntellect.LookDirection.GetVector(); Vec3 v = vec * source.Rotation.GetInverse() * destRotation; playerIntellect.LookDirection = SphereDir.FromVector(v); } } } //add object to the list of processed objects. object can't activate teleportation. processedObjectsInActiveArea.AddWithCheckAlreadyContained(obj); //skip ticks to wait for update physics body of transfered object after teleportation. skipTicks += 2; }
/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnDeleteSubscribedToDeletionEvent(Entity)"/></summary> protected override void OnDeleteSubscribedToDeletionEvent(Entity entity) { base.OnDeleteSubscribedToDeletionEvent(entity); if (entity == destination) destination = null; }
/// <summary> /// Method untuk mengganti teleporter tangga yang ada pada petak /// </summary> /// <param name="isLadder">Teleporter tangga yang baru</param> public void SetIsLadder(Teleporter isLadder) { this.isLadder = isLadder; }