/// <summary>
        ///     Add the actor to the appropriate list based on actor transparency
        /// </summary>
        /// <param name="actor"></param>
        public void Add(OurDrawnActor3D actor)
        {
            if (actor.EffectParameters.GetAlpha() < 1)
            {
                TransparentList.Add(actor);
            }
            else
            {
                OpaqueList.Add(actor);
            }

            isDirty = true;
        }
Esempio n. 2
0
        //debug method to draw collision skins for collidable objects and zone objects
        private void ProcessAllDrawnObjects()
        {
            for (int i = 0; i < objectManager.OpaqueList.Count; i++)
            {
                actor = objectManager.OpaqueList[i];
                if (actor is Tile tile && tile.TileType != ETileType.Static)
                {
                    AddCollisionSkinVertexData(actor as OurCollidableObject);
                }
            }

            for (int i = 0; i < objectManager.TransparentList.Count; i++)
            {
                actor = objectManager.TransparentList[i];
                if (actor is OurCollidableObject)
                {
                    AddCollisionSkinVertexData(actor as OurCollidableObject);
                }
            }
        }
        private void HandleObjectCategoryEvent(EventData eventData)
        {
            switch (eventData.EventActionType)
            {
            case EventActionType.OnRemoveActor:
            {
                OurDrawnActor3D removeObject = eventData.Parameters[0] as OurDrawnActor3D;
                OpaqueList.Remove(removeObject);
                break;
            }

            case EventActionType.OnAddActor:
            {
                if (eventData.Parameters[0] is OurModelObject modelObject)
                {
                    Add(modelObject);
                }
                break;
            }
            }
        }
Esempio n. 4
0
        protected override void Update(GameTime gameTime)
        {
            game?.Update();

            //The game has its own "global timer" that runs out periodically and is defined in the GameConstants.
            //Lots of temporal elements use this as a reference on how long a "turn" in the game is, its to give the player a sense of rhythm
            if (currentMovementCoolDown <= 0)
            {
                currentMovementCoolDown = GameConstants.MovementCooldown;
                EventManager.FireEvent(new MovingTilesEventInfo());
            }

            currentMovementCoolDown -= (float)gameTime.ElapsedGameTime.TotalSeconds;

            //Fetch the Player and set the camera to target him is we don't have a reference to him.
            if (player == null)
            {
                OurDrawnActor3D drawnActor3D =
                    ObjectManager.OpaqueList.Find(actor3D =>
                                                  actor3D is Tile tile && tile.ActorType == ActorType.Player);
                if (CameraManager.ActiveCamera.ControllerList[0] is RotationAroundActor cam &&
                    drawnActor3D != null)
                {
                    cam.Target = drawnActor3D;
                    player     = drawnActor3D as PlayerTile;
                    drawnActor3D.StatusType = StatusType.Drawn | StatusType.Update;
                }
            }

            //Don't update the Player if using wrong cam
            if (player != null)
            {
                player.StatusType = CameraManager.ActiveCameraIndex switch
                {
                    0 => StatusType.Drawn | StatusType.Update,
                    1 => StatusType.Drawn,
                    2 => StatusType.Drawn,
                    _ => player.StatusType
                }
            }
            ;

            if (KeyboardManager.IsFirstKeyPress(Keys.Escape))
            {
                EventDispatcher.Publish(MenuManager.StatusType == StatusType.Off
                    ? new EventData(EventCategoryType.Menu, EventActionType.OnPause, null)
                    : new EventData(EventCategoryType.Menu, EventActionType.OnPlay, null));
            }

            if (KeyboardManager.IsFirstKeyPress(Keys.C))
            {
                CameraManager.CycleActiveCamera();
            }

            //Cycle Through Audio
            if (KeyboardManager.IsFirstKeyPress(Keys.N))
            {
                EventManager.FireEvent(new SoundEventInfo {
                    soundEventType = SoundEventType.PlayNextMusic
                });
            }
            //Mute All Sounds
            if (KeyboardManager.IsFirstKeyPress(Keys.M))
            {
                EventManager.FireEvent(new SoundEventInfo {
                    soundEventType = SoundEventType.ToggleMute
                });
            }
            //Volume Changes
            if (KeyboardManager.IsFirstKeyPress(Keys.L))
            {
                EventManager.FireEvent(new SoundEventInfo
                {
                    soundEventType = SoundEventType.IncreaseVolume, soundVolumeType = SoundVolumeType.Master
                });
            }
            else if (KeyboardManager.IsFirstKeyPress(Keys.K))
            {
                EventManager.FireEvent(new SoundEventInfo
                {
                    soundEventType = SoundEventType.DecreaseVolume, soundVolumeType = SoundVolumeType.Master
                });
            }
            //Pause/resume music
            if (KeyboardManager.IsFirstKeyPress(Keys.P))
            {
                EventManager.FireEvent(new SoundEventInfo
                {
                    soundEventType = SoundEventType.ToggleMusicPlayback, soundVolumeType = SoundVolumeType.Master
                });
            }

            //if (KeyboardManager.IsFirstKeyPress(Keys.Escape))
            //    Exit();

            base.Update(gameTime);
        }