Esempio n. 1
0
        public void UpdateBulletData(float time, ref WorldMovement Movement)
        {
            if (Movement != default)
            {
                Vector3 currentPos   = Movement.Position;
                Vector3 nextFramePos = Movement.Position + (Movement.MoveDirection * MuzzleVelocity * time);
                RayDistance = Vector3.Magnitude(nextFramePos - currentPos);

                if (RayDistance > 0)
                {
                    if (IsHit)
                    {
                        Movement.SetPosition(HitPosition);
                    }
                    else
                    {
                        NextFramePos = nextFramePos;
                        Movement.SetPosition(nextFramePos);
                    }
                }
                else
                {
                    "Log: Bullet is hit, position is ({0})".Log(HitPosition.ToString());
                }
            }
        }
Esempio n. 2
0
        public override void Execute(int time, ref IShipDockEntitas target)
        {
            base.Execute(time, ref target);

            mMovement = GetMovmentData(ref target);

            CheckWorldItemCaches(ref target);
            if (ShouldWorldGroupable)
            {
                SetClusteringPosition(ref target);
                CheckClustering(ref target);
            }
            CheckAround(ref target);
            CheckWorldEvents();
        }
Esempio n. 3
0
        public void CheckRaycast(ref Transform transform, ref WorldMovement Movement, ref IBulletBehaviour bulletBehaviour)
        {
            OutOfRange = false;

            if ((RayDistance > 0f) && !IsHit && !IsShowHit)
            {
                transform.position = Movement.Position;
                OutOfRange         = Vector3.Distance(Movement.Position, InitPosition) > ShotRange;
            }

            if (IsHit || OutOfRange || IsShowHit)
            {
                bulletBehaviour.BulletFinish();
            }
            else
            {
                mRay    = bulletBehaviour.Ray;
                mRayHit = bulletBehaviour.RayHit;
                bool isHit = Utils.Raycast(Movement.Position, Movement.MoveDirection, out mRay, out mRayHit, RayDistance, RayMask);
                if (isHit)
                {
                    bulletBehaviour.HitTarget = mRayHit.transform.gameObject;
                    GameObject hitTarget = bulletBehaviour.HitTarget;

                    int hitLayer = hitTarget.layer;
                    int id       = hitTarget.GetInstanceID();
                    DoHit(hitLayer, id, mRayHit.point, Movement.MoveDirection);
                    bulletBehaviour?.AfterDoHit(this);
                    if (!IsShowHit)
                    {
                        IsShowHit = true;
                        CommonBulletChecker?.CacheBulletData(this);//处理命中后的操作
                    }
                }
            }
        }
Esempio n. 4
0
 protected abstract bool CheckingAround(ref IShipDockEntitas target, int aroundID, AroundsCheckedInfo aroundInfo, ref WorldMovement movement);