Exemplo n.º 1
0
        private static void OnUnitTeleport(Obj_AI_Base sender, Obj_AI_BaseTeleportEventArgs e)
        {
            var eventArgs = new TeleportEventArgs
            {
                Status = TeleportStatus.Unknown,
                Type   = TeleportType.Unknown
            };

            if (sender == null)
            {
                return;
            }

            if (!TeleportDataNetId.ContainsKey(sender.NetworkId))
            {
                TeleportDataNetId[sender.NetworkId] = eventArgs;
            }

            if (!string.IsNullOrEmpty(e.DisplayName))
            {
                eventArgs.Status   = TeleportStatus.Start;
                eventArgs.Duration = GetDuration(e);
                eventArgs.Type     = GetType(e);
                eventArgs.Start    = Game.TickCount;

                TeleportDataNetId[sender.NetworkId] = eventArgs;
            }
            else
            {
                eventArgs        = TeleportDataNetId[sender.NetworkId];
                eventArgs.Status = Game.TickCount - eventArgs.Start < eventArgs.Duration - 250 ? TeleportStatus.Abort : TeleportStatus.Finish;
            }

            OnTeleport?.Invoke(sender, eventArgs);
        }
    public void SetPosition(Vector2 newPos)
    {
        Vector2 old = transform.position;

        transform.position = newPos;
        OnTeleport?.Invoke(old, newPos);
    }
Exemplo n.º 3
0
 private void Teleport()
 {
     _destination = _destination - _direction.normalized * _bodyRadious;
     _transform.DOMove(_destination, _duration)
     .SetEase(Ease.OutCubic);
     OnTeleport?.Invoke();
 }
Exemplo n.º 4
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         OnTeleport?.Invoke(new Vector3(-2, 5, 0));
     }
 }
Exemplo n.º 5
0
 void TriggerEventsAfterTeleport(GameObject player)
 {
     OnTeleport?.Invoke(teleportEnter, teleportExit, player);
     OnAnyTeleport?.Invoke(teleportEnter, teleportExit, player);
     OnTeleportSimple?.Invoke();
     OnAnyTeleportSimple?.Invoke();
 }
Exemplo n.º 6
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("TeleportTrigger") && canTeleport)
        {
            linkedMirror.canTeleport = false;
            canTeleport = false;
            Vector3 positionHolder1 = player.transform.parent.position;
            Vector3 positionHolder2 = player.transform.position;

            player.transform.parent.parent   = player.transform.parent.parent == livingWorld ? deadWorld : livingWorld;
            player.transform.parent.position = linkedMirror.player.transform.parent.position;
            player.transform.position        = linkedMirror.player.transform.position;

            if (player.GetComponent <PlayerController>())
            {
                player.GetComponent <PlayerController>().currentWorld = player.GetComponent <PlayerController>().currentWorld == World.Living ? World.Dead : World.Living;
            }
            else if (player.GetComponent <MirrorManController>())
            {
                player.GetComponent <MirrorManController>().currentWorld = player.GetComponent <MirrorManController>().currentWorld == World.Dead ? World.Living : World.Dead;
            }

            linkedMirror.player.transform.parent.parent   = linkedMirror.player.transform.parent.parent == deadWorld ? livingWorld : deadWorld;
            linkedMirror.player.transform.parent.position = positionHolder1;
            linkedMirror.player.transform.position        = positionHolder2;
            linkedMirror.isBlockingCamera = true;
            MirrorHandler.UsedPortal();
            OnTeleport?.Invoke();
        }
    }
Exemplo n.º 7
0
    public void TeleportCollider(Collider2D collision, Vector3 location)
    {
        Teleportable teleportable = collision.GetComponent <Teleportable>();

        if (teleportable && canTeleport)
        {
            OnTeleport?.Invoke();
            teleportable.Teleport(location);
            ClearSelection();
        }
    }
Exemplo n.º 8
0
 private void Awake()
 {
     onTeleport += StartTeleport;
     if (instance == null)
     {
         instance = this;
     }
     else
     if (instance == this)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Allows the controller to be teleporter to
        /// any position in world space
        /// </summary>
        /// <param name="resetVelocity">Set velocity to 0.</param>
        public void TeleportTo(Vector3 worldPosition, Quaternion rotation, bool resetVelocity = true)
        {
            FixedPosition       = worldPosition;
            _rigidbody.velocity = rotation * Quaternion.Inverse(_rigidbody.rotation) * _rigidbody.velocity;
            _rigidbody.position = FixedPosition;
            _rigidbody.rotation = rotation;
            if (resetVelocity)
            {
                Velocity = Vector3.zero;
            }

            OnTeleport?.Invoke(worldPosition, rotation);
        }
Exemplo n.º 10
0
        public void Teleport(Portal source, Portal destination)
        {
            if (OnTeleport != null)
            {
                OnTeleport.Invoke(source, destination);
            }

            foreach (var t in TeleportableScripts)
            {
                if (!t)
                {
                    continue;
                }
                t.OnTeleport();
            }

            UpdateBounds();
            StartCoroutine(FlashFix());
        }
Exemplo n.º 11
0
        static EntityEvents()
        {
            var fragment = Platform.CoreFragment?.GetEntityEventsFragment() ?? throw Platform.FragmentException();

            fragment.Notify                      = args => OnNotify.SafeInvoke(args);
            fragment.PlayAnimation               = args => OnPlayAnimation.SafeInvoke(args);
            fragment.ProcessSpellCast            = args => OnProcessSpellCast.SafeInvoke(args);
            fragment.DoCast                      = args => OnDoCast.SafeInvoke(args);
            fragment.NewPath                     = args => OnNewPath.SafeInvoke(args);
            fragment.IssueOrder                  = args => OnIssueOrder.SafeInvoke(args);
            fragment.Teleport                    = args => OnTeleport.SafeInvoke(args);
            fragment.Aggro                       = args => OnAggro.SafeInvoke(args);
            fragment.BuffAdd                     = args => OnBuffAdd.SafeInvoke(args);
            fragment.BuffRemove                  = args => OnBuffRemove.SafeInvoke(args);
            fragment.LevelUp                     = args => OnLevelUp.SafeInvoke(args);
            fragment.SpellbookCastSpell          = args => OnSpellbookCastSpell.SafeInvoke(args);
            fragment.SpellbookStopCast           = args => OnSpellbookStopCast.SafeInvoke(args);
            fragment.SpellbookUpdateChargedSpell = args => OnSpellbookUpdateChargedSpell.SafeInvoke(args);
            fragment.OnIntegerPropertyChange     = args => OnIntegerPropertyChange.SafeInvoke(args);
            fragment.OnFloatPropertyChange       = args => OnFloatPropertyChange.SafeInvoke(args);
        }
Exemplo n.º 12
0
 /// <summary>
 ///     Fires the event.
 /// </summary>
 /// <param name="args">
 ///     The event data
 /// </param>
 private static void FireEvent(TeleportEventArgs args)
 {
     OnTeleport?.Invoke(MethodBase.GetCurrentMethod().DeclaringType, args);
 }
Exemplo n.º 13
0
 /// <summary>
 ///     Fires the event.
 /// </summary>
 /// <param name="sender">
 ///     The sender
 /// </param>
 /// <param name="args">
 ///     The event data
 /// </param>
 private static void FireEvent(Obj_AI_Base sender, TeleportEventArgs args)
 {
     OnTeleport?.Invoke(sender, args);
 }
Exemplo n.º 14
0
 public void Teleport(Point location)
 {
     Location = location;
     OnTeleport?.Invoke(this);
 }
Exemplo n.º 15
0
 public virtual void Teleport(Vector3 newPos)
 {
     Teleport_Internal(newPos);
     OnTeleport.Invoke(newPos);
 }