예제 #1
0
        public void CalcSlowStun()
        {
            var el  = DemoEffectModel();
            var val = StatusCalculator.GetSpeedValueByStatus(new MobData {
                Speed = 100
            }, el);

            Assert.Equal(0, val);
            el.Remove(el[4]);
            val = StatusCalculator.GetSpeedValueByStatus(new MobData {
                Speed = 100
            }, el);
            Assert.Equal(60, val);
        }
        public void Update(double delta)
        {
            if (IsDead || IsOnGoal)
            {
                WaitBeforeRemoved -= delta;
                if (WaitBeforeRemoved <= 0)
                {
                    RemoveMob();
                }
                return;
            }
            StatusEffect = StatusCalculator.GetCleardEffectList(StatusEffect);
            StatusCalculator.CalculateLeftTime(StatusEffect, delta);
            StatusCalculator.CalculateHot(MobData, StatusEffect, delta);
            StatusCalculator.CalculateDot(MobData, StatusEffect, delta, towerInstanceId =>
            {
                Killed(_session.GameTower.SingleOrDefault(x => x.InstanceId == towerInstanceId));
            });
            if (IsTowerCollision(delta))
            {
                return;
            }
            var transformedSpeed = (float)StatusCalculator.GetSpeedValueByStatus(MobData, StatusEffect);

            if (CurrentGoal.X > TilePosX)
            {
                TilePosX += transformedSpeed / GConfig.D.GameSimulationTime * (float)delta;
            }
            if (CurrentGoal.X < TilePosX)
            {
                TilePosX -= transformedSpeed / GConfig.D.GameSimulationTime * (float)delta;
            }
            if (CurrentGoal.Y > TilePosY)
            {
                TilePosY += transformedSpeed / GConfig.D.GameSimulationTime * (float)delta;
            }
            if (CurrentGoal.Y < TilePosY)
            {
                TilePosY -= transformedSpeed / GConfig.D.GameSimulationTime * (float)delta;
            }
            if (!IsMobNearPoint(this))
            {
                return;
            }

            X = CurrentGoal.X;
            Y = CurrentGoal.Y;
            CurrentPathPos++;
            if (Path == null)
            {
                return;
            }
            if (CurrentPathPos >= Path.Count)
            {
                if (VisitedWayPoint)
                {
                    ReachGoal();
                }
                else
                {
                    VisitedWayPoint = true;
                    UpdatePath();
                }
                return;
            }

            CurrentGoal = Path[CurrentPathPos];
        }