Example #1
0
        public void StopBeThrowed(bool isEnd = false)
        {
            if (isEnd)
            {
                if (this.unitBeThrowedInfo != null)
                {
                    this.unitBeThrowedInfo.remainDuration = 0.02f;
                    this.__UpdateBeThrowed(0.02f);
                }

                return;
            }

            if (this.unitBeThrowedInfo != null && !this.unitBeThrowedInfo.isNotStopAnimation &&
                this.unitBeThrowedInfo.IsHasAnimationName())
            {
                this.unit.StopAnimation(this.unitBeThrowedInfo.animationName, 0.2f);
            }

            var isBackToGround = unitBeThrowedInfo?.isBackToGround ?? false;

            this.unitBeThrowedInfo = null;
            this.moveType          = null;
            this.unit.UpdateMixedStates();

            if (isBackToGround)
            {
                var unitBeThrowedInfo = new UnitBeThrowedInfo();
                unitBeThrowedInfo.endPos         = Client.instance.combat.pathManager.GetGroundPos(this.unit.GetPosition());
                unitBeThrowedInfo.duration       = 0.1f;
                unitBeThrowedInfo.height         = 0f;
                unitBeThrowedInfo.isBackToGround = false;
                this.BeThrowed(unitBeThrowedInfo);
            }
        }
Example #2
0
 public void BeThrowed(UnitBeThrowedInfo unitBeThrowedInfo)
 {
     if (this.IsDead() || this.IsImmuneControl())
     {
         return;
     }
     this.unitMoveComp.BeThrowed(unitBeThrowedInfo);
 }
Example #3
0
        public void BeThrowed(UnitBeThrowedInfo unitBeThrowedInfo)
        {
            Vector3 endPos         = unitBeThrowedInfo.endPos;
            float   duration       = unitBeThrowedInfo.duration;
            float   height         = unitBeThrowedInfo.height;
            var     endRotation    = unitBeThrowedInfo.endRotation;
            var     rotateDuration = unitBeThrowedInfo.rotateDuration;

            if ("be_throwed".Equals(this.moveType))
            {
                return;
            }
            var unit = this.unit;

            this.moveType = "be_throwed";
            if (unitBeThrowedInfo.IsHasAnimationName() && unit.animation != null)
            {
                this.unit.PlayAnimation(unitBeThrowedInfo.animationName);
            }
            this.unitBeThrowedInfo = unitBeThrowedInfo;
            this.unit.UpdateMixedStates();
            this.unitBeThrowedInfo.orgHeight      = unit.GetPosition().y;
            this.unitBeThrowedInfo.startPos       = unit.GetPosition();
            this.unitBeThrowedInfo.remainDuration = duration;
            float deltaHeight = endPos.y - unit.GetPosition().y;
            // 起点和落点,取最高的,加上height,为真正的最高高度
            var maxHeight = deltaHeight > 0 ? Math.Max((deltaHeight + height), 0) : height;

            this.unitBeThrowedInfo.maxHeight = maxHeight;
            if (maxHeight == 0)
            {
                this.unitBeThrowedInfo.heightAccelerate = deltaHeight * 2 / (duration * duration);
                this.unitBeThrowedInfo.height_speed     = 0;
            }
            else
            {
                float hTime = duration / ((float)Math.Sqrt(1 - deltaHeight / maxHeight) + 1);
                this.unitBeThrowedInfo.heightAccelerate = -2 * maxHeight / (hTime * hTime);
                this.unitBeThrowedInfo.height_speed     = -this.unitBeThrowedInfo.heightAccelerate * hTime;
            }

            if (endRotation != null && rotateDuration != null)
            {
                this.unitBeThrowedInfo.rotateRemainDuration = rotateDuration.Value;
                this.unitBeThrowedInfo.startRotation        = unit.GetRotation();
            }
        }