Esempio n. 1
0
    private void MoveTick()
    {
        if (!_target.HasValue)
        {
            return;
        }

        var now = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

        if (transform.position == _target && _movingToDirection != Direction.NONE && now > _shouldArriveAt)
        {
            _movingToDirection = Direction.NONE;

            SpriteSheets.ForEach(e => e.Moving = false);

            if (_lastMovement)
            {
                _lastMovement = false;
                if (UnityClient.Player.FollowingPath == null)
                {
                    Selectors.HideSelector();
                }
                _target = null;
            }
        }
        else
        {
            t += Time.deltaTime;
            transform.position = Vector3.Lerp(startPosition, new Vector2(_target.Value.x, _target.Value.y), t / timeToReachTarget);
        }
    }
Esempio n. 2
0
        public static void PlayerSetTarget(GameObject target)
        {
            var livingEntityBhv = target.GetComponent <LivingEntityBehaviour>();

            if (livingEntityBhv == null)
            {
                return;
            }
            Selectors.RemoveSelector(SelectorType.TARGET);
            var targetEntity = livingEntityBhv.Entity;
            var entityType   = targetEntity.EntityType;

            if (entityType == EntityType.MONSTER)
            {
                UnityClient.Player.Target = targetEntity;
                UnityClient.TcpClient.Send(new EntityTargetPacket()
                {
                    WhoUuid    = UnityClient.Player.UID,
                    TargetUuid = UnityClient.Player.Target.UID
                });
                Selectors.AddSelector(target, SelectorType.TARGET, Color.red);
                var path = UnityClient.Map.FindPath(UnityClient.Player.Position, target.GetMapPosition());
                if (path != null)
                {
                    UnityClient.Player.Behaviour.Route = path;
                    Selectors.HideSelector();
                }
            }
        }
Esempio n. 3
0
    private void MoveTick()
    {
        if (!_target.HasValue)
        {
            return;
        }
        t += Time.deltaTime / timeToReachTarget;
        transform.position = Vector3.Lerp(startPosition, _target.Value, t);

        if (transform.position == _target && _movingToDirection != Direction.NONE)
        {
            _movingToDirection = Direction.NONE;

            _spriteSheets.ForEach(e => e.Moving = false);

            if (_lastMovement)
            {
                _lastMovement = false;
                if (UnityClient.Player.FollowingPath == null)
                {
                    Selectors.HideSelector();
                }
                _target = null;
            }
        }
    }
Esempio n. 4
0
 public override void OnFinishRoute()
 {
     // Hide the green square on the ground when i finish moving
     if (this.Route.Count == 0)
     {
         Selectors.HideSelector();
     }
 }
Esempio n. 5
0
        public static void PlayerSetTarget(GameObject target)
        {
            Selectors.RemoveSelector("targeted");
            var objType = FactoryMethods.GetType(target);

            if (objType == FactoryObjectTypes.MONSTER)
            {
                UnityClient.Player.Target = target;
                Selectors.AddSelector(target, "targeted", Color.red);
                var path = UnityClient.Map.FindPath(UnityClient.Player.Position, target.GetMapPosition());
                if (path != null)
                {
                    UnityClient.Player.FollowingPath = path;
                    Selectors.HideSelector();
                }
            }
        }