コード例 #1
0
ファイル: BaseSerpent.cs プロジェクト: danbystrom/VisionQuest
        public override void Update(Camera camera, GameTime gameTime)
        {
            switch (SerpentStatus)
            {
                case SerpentStatus.Ghost:
                    _ascendToHeaven += (float) gameTime.ElapsedGameTime.TotalSeconds;
                    if (_ascendToHeaven > 4)
                        SerpentStatus = SerpentStatus.Finished;
                    return;
                case SerpentStatus.Finished:
                    return;
            }

            var lengthSpeed = Math.Max(0.001f, (11 - _serpentLength)/10f);
            var speed = (float) gameTime.ElapsedGameTime.TotalSeconds*5.0f*lengthSpeed*ModifySpeed();

            if (_whereabouts.Direction != Direction.None)
            {
                _fractionAngle += speed;
                if (_fractionAngle >= 1)
                {
                    _fractionAngle = 0;
                    _whereabouts.Location = _whereabouts.NextLocation;
                    takeDirection(false);
                } else if (_fractionAngle < 0.7f)
                    takeDirection(true);
                _whereabouts.Fraction = (float) Math.Sin(_fractionAngle*MathUtil.PiOverTwo);
            }
            else
                takeDirection(false);

            if (_tail != null)
                _tail.Update(speed, _whereabouts);

            if (_whereabouts.Direction != Direction.None)
                HeadDirection = _whereabouts.Direction;

            if (_layingEgg >= 0)
                _layingEgg += (float) gameTime.ElapsedGameTime.TotalSeconds;
        }
コード例 #2
0
ファイル: BaseSerpent.cs プロジェクト: danbystrom/VisionQuest
        public Egg TimeToLayEgg()
        {
            if (_layingEgg < TimeForLayingEggProcess)
                return null;
            _layingEgg = -1;

            var segment = _tail;
            while (segment.Next != null)
                segment = segment.Next;
            if (segment != _tail)
                removeTail(segment);
            else
                SerpentStatus = SerpentStatus.Ghost;
            return this is PlayerSerpent
                ? new Egg(_textureEffect, _sphere, _eggSkin, TintColor(), _eggWorld, segment.Whereabouts, float.MaxValue)
                : new Egg(_textureEffect, _sphere, _eggSkin, EnemySerpent.ColorWhenLonger, _eggWorld, segment.Whereabouts, 20);
        }