public void TeleportTo(TeleportDestination destination)
        {
            scroll.TeleportTo(destination);

            UpdateChargesCount();
            CloseTab();             // TODO: does not close clientside.
        }
        public void TeleportTo(TeleportDestination destination)
        {
            ConnectedPlayer teleportingPlayer = GetLastReader();

            if (!HasChargesRemaining(teleportingPlayer.GameObject))
            {
                return;
            }

            if (teleport.IsBusy)
            {
                Chat.AddExamineMsgFromServer(teleportingPlayer.GameObject, $"You are already teleporting!");
                return;
            }

            Transform spawnTransform = PlayerSpawn.GetSpawnForJob((JobType)destination);

            teleport.ServerTeleportWizard(teleportingPlayer.GameObject, spawnTransform.position.CutToInt());

            SpellData teleportSpell = SpellList.Instance.Spells.Find(spell => spell.Name == "Teleport");

            SoundManager.PlayNetworkedAtPos(
                teleportSpell.CastSound, teleportingPlayer.Script.WorldPos, sourceObj: teleportingPlayer.GameObject);

            var incantation = $"{teleportSpell.InvocationMessage.Trim('!')} {destination.ToString().ToUpper()}!";

            Chat.AddChatMsgToChat(teleportingPlayer, incantation, ChatChannel.Local);

            ChargesRemaining--;
        }
        public void TeleportTo(TeleportDestination destination)
        {
            scroll.TeleportTo(destination);

            UpdateChargesCount();
            ServerCloseTabFor(scroll.GetLastReader());
        }
Esempio n. 4
0
 /// <summary>
 /// Recycle the destination object. In the basic implementation, this just destroys the object however if there
 /// is an object pooling system then the TeleportDestinationRecycler should be overridden to use it.
 /// </summary>
 /// <param name="oldDestination"></param>
 public void RecycleTeleportDestination(TeleportDestination oldDestination)
 {
     if (oldDestination == _teleportDestination)
     {
         _teleportDestination = TeleportDestinationFactory();
     }
     TeleportDestinationRecycler(oldDestination);
 }
Esempio n. 5
0
 public void RecycleTeleportDestination(TeleportDestination oldDestination)
 {
     if (oldDestination == _teleportDestination)
     {
         CreateNewTeleportDestination();
     }
     GameObject.Destroy(oldDestination.gameObject);
 }
Esempio n. 6
0
    /// <summary>
    /// This is called whenever a new teleport destination is required. This might occur when rapidly switching
    /// between targets, or when teleporting multiple times in quick succession when the teleport destination
    /// requires additional time to complete any animations that are triggered by these actions.
    /// </summary>
    protected void CreateNewTeleportDestination()
    {
        TeleportDestinationPrefab.gameObject.SetActive(false);         // ensure the prefab isn't active in order to delay event handler setup until after it has been configured with a reference to this object.
        TeleportDestination td = GameObject.Instantiate(TeleportDestinationPrefab);

        td.LocomotionTeleport = this;
        _teleportDestination  = td;
        _teleportDestination.LocomotionTeleport = this;
    }
Esempio n. 7
0
        public override void Deserialize(IDataReader reader)
        {
            Type = reader.ReadSByte();
            var DestinationsCount = reader.ReadShort();

            Destinations = new List <TeleportDestination>();
            for (var i = 0; i < DestinationsCount; i++)
            {
                var objectToAdd = new TeleportDestination();
                objectToAdd.Deserialize(reader);
                Destinations.Add(objectToAdd);
            }
        }
Esempio n. 8
0
        public override void Deserialize(ICustomDataInput reader)
        {
            Type = reader.ReadByte();
            var countDestinations = reader.ReadShort();

            Destinations = new List <TeleportDestination>();
            for (short i = 0; i < countDestinations; i++)
            {
                TeleportDestination type = new TeleportDestination();
                type.Deserialize(reader);
                Destinations.Add(type);
            }
        }
Esempio n. 9
0
    void OnTriggerEnter2D(Collider2D other)
    {
        PlayerController pc = other.GetComponent <PlayerController>();

        if (!!pc)
        {
            TeleportDestination td = GetComponentInChildren <TeleportDestination>();
            if (!!td)
            {
                pc.teleportToLocation(td.teleportToMe(teleportID));
            }
        }
    }
Esempio n. 10
0
        public void LocationToPointerTableEntry2()
        {
            var test = new TeleportDestination
            {
                NameTextOffset = "0421",
                Song           = 0x86,
                X            = 0xCA,
                MinitileCode = 8,
                Direction    = "southeast",
                Y            = 0x4B
            };

            Assert.AreEqual(location2, test.TableEntry);
        }
Esempio n. 11
0
        public void LocationToPointerTableEntry()
        {
            var test = new TeleportDestination
            {
                NameTextOffset = "03E3",
                Song           = 0x86,
                X            = 0x33,
                MinitileCode = 4,
                Direction    = "west",
                Y            = 0x51
            };

            var testBytes = test.TableEntry;

            Assert.AreEqual(location1, testBytes);
        }
Esempio n. 12
0
        public override void Deserialize(IDataReader reader)
        {
            this.type = (uint)reader.ReadByte();
            if (this.type < 0U)
            {
                throw new Exception("Forbidden value (" + (object)this.type + ") on element of TeleportDestinationsMessage.type.");
            }
            uint num = (uint)reader.ReadUShort();

            for (int index = 0; (long)index < (long)num; ++index)
            {
                TeleportDestination teleportDestination = new TeleportDestination();
                teleportDestination.Deserialize(reader);
                this.destinations.Add(teleportDestination);
            }
        }
Esempio n. 13
0
        public void HexToLocation2()
        {
            var expectedLocation = new TeleportDestination
            {
                NameTextOffset = "0421",
                Song           = 0x86,
                X            = 0xCA,
                MinitileCode = 8,
                Direction    = "west",
                Y            = 0x4B
            };

            var test = TeleportDestination.ParseHex(location3);

            Assert.AreEqual(expectedLocation.NameTextOffset, test.NameTextOffset);
            Assert.AreEqual(expectedLocation.Song, test.Song);
            Assert.AreEqual(expectedLocation.X, test.X);
            Assert.AreEqual(expectedLocation.Direction, test.Direction);
            Assert.AreEqual(expectedLocation.MinitileCode, test.MinitileCode);
            Assert.AreEqual(expectedLocation.Y, test.Y);
        }
        public void TeleportTo(TeleportDestination destination)
        {
            var teleportingPlayer = netTab.LastInteractedPlayer();

            if (!HasChargesRemaining(teleportingPlayer))
            {
                return;
            }

            if (teleport.IsBusy)
            {
                Chat.AddExamineMsgFromServer(teleportingPlayer, $"You are already teleporting!");
                return;
            }

            Transform spawnTransform = PlayerSpawn.GetSpawnForJob((JobType)destination);

            teleport.ServerTeleportWizard(teleportingPlayer, spawnTransform.position.CutToInt());
            Chat.AddChatMsgToChat(teleportingPlayer.Player(), $"SCYAR NILA {destination.ToString().ToUpper()}!", ChatChannel.Local);

            ChargesRemaining--;
        }
Esempio n. 15
0
 /// <summary>
 /// This is called whenever a new teleport destination is required. This might occur when rapidly switching
 /// between targets, or when teleporting multiple times in quick succession when the teleport destination
 /// requires additional time to complete any animations that are triggered by these actions.
 /// </summary>
 protected void CreateNewTeleportDestination()
 {
     _teleportDestination = TeleportDestinationFactory();
     _teleportDestination.LocomotionTeleport = this;
 }
Esempio n. 16
0
 /// <summary>
 /// Override the TeleportDestinationRecycler with your own pool manager if necessary.
 /// </summary>
 /// <param name="obj"></param>
 protected virtual void TeleportDestinationRecycler(TeleportDestination obj)
 {
     GameObject.DestroyImmediate(obj.gameObject);
 }
Esempio n. 17
0
 public void Init(GUI_TeleportScroll scrollGUI, TeleportDestination destination)
 {
     this.scrollGUI   = scrollGUI;
     this.destination = destination;
     destinationLabel.SetValueServer(destination.ToString());
 }