コード例 #1
0
        private void ClearMoveArray(PlaybackItem item, int size)
        {
            item.moveEvents = new PlaybackMoveEvent[size];

            for (int k = 0; k < item.moveEvents.Length; k++)
            {
                item.moveEvents[k] = new PlaybackMoveEvent();
            }
        }
コード例 #2
0
        private bool DrawStar(PlaybackItem item, Color explosionColor)
        {
            float sizeScale = playbackTime - item.moveEvents[0].timeStamp;

            sizeScale *= 0.001f;

            if (sizeScale > 1 || sizeScale < 0)
            {
                return(false);
            }

            explosionColor = Color.Lerp(explosionColor, Helpers.transColor(explosionColor), sizeScale);

            float explosionSize = MathHelper.Lerp(4, 1, sizeScale);

            FrameworkCore.lineRenderer.Draw(
                item.position + Matrix.Identity.Up * explosionSize,
                item.position + Matrix.Identity.Up * -explosionSize,
                explosionColor);

            FrameworkCore.lineRenderer.Draw(
                item.position + Matrix.Identity.Left * explosionSize,
                item.position + Matrix.Identity.Left * -explosionSize,
                explosionColor);

            FrameworkCore.lineRenderer.Draw(
                item.position + Matrix.Identity.Forward * explosionSize,
                item.position + Matrix.Identity.Forward * -explosionSize,
                explosionColor);

            explosionSize = MathHelper.Lerp(2, 0.5f, sizeScale);

            FrameworkCore.lineRenderer.Draw(
                item.position + (Matrix.Identity.Forward * explosionSize) + (Matrix.Identity.Up * explosionSize) + (Matrix.Identity.Left * explosionSize),
                item.position + (Matrix.Identity.Forward * -explosionSize) + (Matrix.Identity.Up * -explosionSize) + (Matrix.Identity.Left * -explosionSize),
                explosionColor);

            FrameworkCore.lineRenderer.Draw(
                item.position + (Matrix.Identity.Forward * -explosionSize) + (Matrix.Identity.Up * explosionSize) + (Matrix.Identity.Left * explosionSize),
                item.position + (Matrix.Identity.Forward * explosionSize) + (Matrix.Identity.Up * -explosionSize) + (Matrix.Identity.Left * -explosionSize),
                explosionColor);


            FrameworkCore.lineRenderer.Draw(
                item.position + (Matrix.Identity.Forward * explosionSize) + (Matrix.Identity.Up * explosionSize) + (Matrix.Identity.Left * -explosionSize),
                item.position + (Matrix.Identity.Forward * -explosionSize) + (Matrix.Identity.Up * -explosionSize) + (Matrix.Identity.Left * explosionSize),
                explosionColor);

            FrameworkCore.lineRenderer.Draw(
                item.position + (Matrix.Identity.Forward * -explosionSize) + (Matrix.Identity.Up * explosionSize) + (Matrix.Identity.Left * -explosionSize),
                item.position + (Matrix.Identity.Forward * explosionSize) + (Matrix.Identity.Up * -explosionSize) + (Matrix.Identity.Left * explosionSize),
                explosionColor);

            return(true);
        }
コード例 #3
0
        public PlaybackSystem()
        {
            //pre allocate a giant array for every item that this level will ever create.
            playbackItems = new PlaybackItem[TOTALPLAYBACKITEMS];

            for (int i = 0; i < playbackItems.Length; i++)
            {
                int amount = MOVEARRAYDEFAULT;

                playbackItems[i] = new PlaybackItem(amount);

                ClearMoveArray(playbackItems[i], MOVEARRAYDEFAULT);
            }
        }
コード例 #4
0
        public void DrawShips(GameTime gameTime)
        {
            if (!HasFocus)
            {
                return;
            }

            for (int k = 0; k < FrameworkCore.playbackSystem.ItemIndex; k++)
            {
                PlaybackItem item = FrameworkCore.playbackSystem.PlaybackItems[k];

                if (!item.ShouldDraw(playbackTime))
                {
                    continue;
                }

                Matrix worldMatrix = Matrix.CreateFromQuaternion(item.rotation);
                worldMatrix.Translation = item.position;

                if (item.ObjectType == objectType.ship)
                {
                    FrameworkCore.meshRenderer.Draw(item.modelType, worldMatrix, owner.lockCamera, item.color);
                }


                if (item.ObjectType == objectType.deflection)
                {
                    DrawStar(item, Color.Gray);
                    continue;
                }


                if (item.ObjectType == objectType.explosion)
                {
                    DrawStar(item, Color.Orange);
                    continue;
                }

                if (item.ObjectType == objectType.beamHit)
                {
                    FrameworkCore.lineRenderer.Draw(
                        item.spawnPos,
                        item.position,
                        item.color);

                    DrawStar(item, Color.Orange);
                    continue;
                }


                if (item.ObjectType == objectType.hulk)
                {
                    FrameworkCore.meshRenderer.Draw(item.modelType, worldMatrix, owner.lockCamera);

                    //only draw diamond for the ship hulks
                    if (item.modelType == ModelType.debrisHulk1 || item.modelType == ModelType.debrisHulk2)
                    {
                        int diamondSize = 2;
                        FrameworkCore.lineRenderer.Draw(
                            item.position + worldMatrix.Left * diamondSize,
                            item.position + worldMatrix.Forward * diamondSize,
                            item.color);

                        FrameworkCore.lineRenderer.Draw(
                            item.position + worldMatrix.Left * -diamondSize,
                            item.position + worldMatrix.Forward * diamondSize,
                            item.color);

                        FrameworkCore.lineRenderer.Draw(
                            item.position + worldMatrix.Left * diamondSize,
                            item.position + worldMatrix.Forward * -diamondSize,
                            item.color);

                        FrameworkCore.lineRenderer.Draw(
                            item.position + worldMatrix.Left * -diamondSize,
                            item.position + worldMatrix.Forward * -diamondSize,
                            item.color);
                    }

                    continue;
                }


                if (item.ObjectType == objectType.bolt)
                {
                    FrameworkCore.meshRenderer.Draw(item.modelType, worldMatrix, owner.lockCamera, Color.White);

                    Color orangeColor = new Color(255, 128, 0);

                    Vector3 boltDir = item.spawnPos - item.position;
                    boltDir.Normalize();

                    FrameworkCore.pointRenderer.Draw(item.position, 4, item.color);

                    FrameworkCore.lineRenderer.Draw(
                        item.position + boltDir * 3,
                        item.position,
                        item.color);

                    continue;
                }


                if (item.ObjectType == objectType.ship)
                {
                    //Rods.
                    Color   rodColor = new Color(128, 128, 128);
                    Vector3 planePos = item.position;
                    planePos.Y = owner.GridAltitude;
                    FrameworkCore.lineRenderer.Draw(item.position, planePos, rodColor);

                    FrameworkCore.pointRenderer.Draw(planePos, 4, rodColor);
                }

                //BoundingSphere s = new BoundingSphere(ship.entityScratch.Position, 3);
                //FrameworkCore.sphereRenderer.Draw(s, Matrix.Identity, Color.LimeGreen);
            }
        }
コード例 #5
0
        private void UpdateShips(GameTime gameTime)
        {
            if (!HasFocus)
            {
                return;
            }

            for (int i = 0; i < FrameworkCore.playbackSystem.ItemIndex; i++)
            {
                PlaybackItem ship = FrameworkCore.playbackSystem.PlaybackItems[i];

                if (ship.isStatic)
                {
                    if (ship.moveEvents[0] != null)
                    {
                        ship.position = ship.moveEvents[0].position;
                        ship.rotation = ship.moveEvents[0].rotation;
                    }

                    continue;
                }


                for (int k = 0; k < ship.moveArrayIndex; k++)
                {
                    PlaybackMoveEvent moveEvent = ship.moveEvents[k];

                    if (moveEvent.timeStamp == playbackTime)
                    {
                        ship.position = moveEvent.position;
                        ship.rotation = moveEvent.rotation;
                        continue;
                    }

                    if (k < ship.moveArrayIndex - 1)  //NOT the last node.
                    {
                        if (moveEvent.timeStamp < playbackTime && ship.moveEvents[k + 1].timeStamp > playbackTime)
                        {
                            //this is the interval we are interested in.

                            float adjustedPlaybackTime = playbackTime - moveEvent.timeStamp;

                            float intervalTransition = adjustedPlaybackTime /
                                                       (ship.moveEvents[k + 1].timeStamp - moveEvent.timeStamp);

                            ship.position = Vector3.Lerp(
                                moveEvent.position,
                                ship.moveEvents[k + 1].position,
                                intervalTransition);

                            ship.rotation = Quaternion.Lerp(
                                moveEvent.rotation,
                                ship.moveEvents[k + 1].rotation,
                                intervalTransition);

                            continue;
                        }
                    }
                }
            }
        }