Ejemplo n.º 1
0
        /// <summary>
        /// human player do some action
        /// </summary>
        /// <param name="action">action from input</param>
        /// <param name="dir">direction where is player looking</param>
        internal void Spell(Input.Action action, Microsoft.DirectX.Vector3 dir)
        {
            switch (action)
            {
            case Input.Action.Action1:
                //at action button send fireball
                this.fireballInfo.startPosition  = this.camera.GetVector3Position();
                this.fireballInfo.targetPosition = this.camera.GetVector3Position() + dir;
                CharacterNPC playerChar = this.ai.GetPlayerInfo().Character;

                ActionInfo info = this.fireballInfo;
                info.action.enemyHpTaken += playerChar.level * playerChar.power;

                if (ai.AcceptPlayerAction(info))
                {
                    CreateFireball(info);
                }
                break;

            case Input.Action.Action2:
                break;

            case Input.Action.Action3:
                break;

            case Input.Action.Wheel:
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Funkce se stara o zpracovani udalosti z DXInput vstupu
        /// </summary>
        /// <param name="actions">Vycet akci, ktere se maji provest</param>
        void ProcessActions(List <Input.Action> actions)
        {
            #region Actions from keyboard and mouse
            while (actions.Count > 0)
            {
                switch (actions[0])
                {
                case Input.Action.Action1:
                    if (game != null)
                    {
                        if (action1Stoper > 0)
                        {
                            break;
                        }

                        WRG.Camera cam = WRG.Camera.GetCameraInstance();
                        Vector3    dir = cam.GetDirectionVector2(graphic.GetCursorPosition());

                        Input.Action action = actions[0];
                        game.Logic.Spell(action, dir);

                        //WiccanRede.Objects.Fireball f = new WiccanRede.Objects.Fireball("Hrac", Graphics.GraphicCore.GetInitializator().GetDevice(), cam.GetVector3Position(), dir, new AI.ActionInfo(), null);
                        //Graphics.GraphicCore.GetCurrentSceneManager().AddObject(f.GetFireName(), f, null as Microsoft.DirectX.Direct3D.Effect);

                        action1Stoper = 50f;
                    }
                    break;

                case Input.Action.Action2:
                    if (game != null)
                    {
                        if (action2Stoper > 0)
                        {
                            break;
                        }

                        Vector2 pos = graphic.GetCursorPosition();
                        List <Graphics.Scene.SceneManager.SceneObject> selectedObjects = Graphics.GraphicCore.GetCurrentSceneManager().GetAllObjects((int)pos.X, (int)pos.Y);

                        if (selectedObjects.Count > 0)
                        {
                            int t = 0;

                            while (t < selectedObjects.Count && selectedObjects[t].name.StartsWith("Hrac") || selectedObjects[t].generalObject.isEquiped())
                            {
                                t++;
                            }

                            if (t >= selectedObjects.Count)
                            {
                                break;
                            }

                            float distance = selectedObjects[t].generalObject.GetDistanceFromCamera();

                            if (distance > selectedObjects[t].generalObject.GetSphereRadius() + 100)
                            {
                                break;
                            }

                            WiccanRede.Graphics.HUD.DrawText("Byl označen objekt " + selectedObjects[t].name, "System", System.Drawing.Color.Red, false);
                            Logger.AddInfo("Oznacen objekt: " + selectedObjects[t].name);

                            if (!(selectedObjects[t].generalObject is WiccanRede.Objects.PickupObject))
                            {
                                game.FireGameEventUp(selectedObjects[t].name, "click");
                            }
                            else
                            {
                                game.PickupObject(selectedObjects[t].name);
                                (selectedObjects[t].generalObject as PickupObject).Pickup();
                            }

                            action2Stoper = 300f;
                        }
                    }
                    break;

                case Input.Action.MoveForwardStart:
                    direction.X += 1;
                    break;

                case Input.Action.MoveForwardStop:
                    direction.X -= 1;
                    break;

                case Input.Action.MoveRightStart:
                    direction.Y += 1;
                    break;

                case Input.Action.MoveRightStop:
                    direction.Y -= 1;
                    break;

                case Input.Action.MoveBackwardStart:
                    direction.X += -1;
                    break;

                case Input.Action.MoveBackwardStop:
                    direction.X -= -1;
                    break;

                case Input.Action.MoveLeftStart:
                    direction.Y += -1;
                    break;

                case Input.Action.MoveLeftStop:
                    direction.Y -= -1;
                    break;

                case Input.Action.LookAround:
                    WRG.CameraDriver.LookAround(input.MouseRelativeMove.X, input.MouseRelativeMove.Y);
                    break;

                case Input.Action.Exit:
                    drawMenu = true;
                    this.menu.CurrentMenuResult = MenuResult.None;
                    break;
                }

                actions.RemoveAt(0);
            }
            #endregion

            #region Moving by Camera
            if (direction.Length() != 0 && !WRG.Console.ConsoleIsShowed())
            {
                float angle = 0f;

                if (direction.X == 1 && direction.Y == 1)
                {
                    angle = (float)Math.PI / 4f;
                }
                else if (direction.X == 1 && direction.Y == -1)
                {
                    angle = -(float)Math.PI / 4f;
                }
                else if (direction.X == -1 && direction.Y == -1)
                {
                    angle = -3f * (float)Math.PI / 4f;
                }
                else if (direction.X == -1 && direction.Y == 1)
                {
                    angle = 3f * (float)Math.PI / 4f;
                }
                else if (direction.X == 1)
                {
                    angle = 0;
                }
                else if (direction.X == -1)
                {
                    angle = (float)Math.PI;
                }
                else if (direction.Y == 1)
                {
                    angle = (float)Math.PI / 2f;
                }
                else if (direction.Y == -1)
                {
                    angle = -(float)Math.PI / 2f;
                }

                game.Logic.PlayerMove(angle);
            }

            #endregion

            #region Actions from Console
            List <string> commands = WRG.Console.ConsoleGetCommands();

            if (commands.Count > 0)
            {
                int    firstspace = commands[0].IndexOf(" ");
                string command    = commands[0];
                string parameters = String.Empty;

                if (firstspace != -1)
                {
                    command    = command.Substring(0, firstspace);
                    parameters = commands[0].Substring(firstspace + 1);
                }

                switch (command)
                {
                case "exit":
                case "quit": exit = true;
                    break;

                case "sensitivity":
                    float sensitivity = WRG.CameraDriver.GetSensitivity();

                    if (parameters == String.Empty)
                    {
                        WRG.Console.ConsoleWriteLine("Citlivost mysi je: " + sensitivity.ToString());
                    }
                    else if (!Single.TryParse(parameters, out sensitivity))
                    {
                        WRG.Console.ConsoleWriteLine("Je nutno zadat cislo, urcujici citlivost mysi");
                    }
                    else
                    {
                        WRG.CameraDriver.SetSensitivity(sensitivity);
                    }
                    break;

                case "fly":
                    WRG.CameraDriver.EnableFreeLook();
                    break;

                case "walk":
                    WRG.CameraDriver.DisableFreeLook();
                    break;

                case "help":
                    WRG.Console.ConsoleWriteLine("do konzole je mozne zadat prikazy:");
                    WRG.Console.ConsoleWriteLine("help");
                    WRG.Console.ConsoleWriteLine("exit");
                    WRG.Console.ConsoleWriteLine("quit");
                    WRG.Console.ConsoleWriteLine("sensitivity [t]");
                    WRG.Console.ConsoleWriteLine("fly");
                    WRG.Console.ConsoleWriteLine("walk");
                    WRG.Console.ConsoleWriteLine("shadowsoff");
                    WRG.Console.ConsoleWriteLine("shadowson");
                    WRG.Console.ConsoleWriteLine("wire");
                    WRG.Console.ConsoleWriteLine("solid");
                    WRG.Console.ConsoleWriteLine("quadtree");
                    WRG.Console.ConsoleWriteLine("occ");
                    WRG.Console.ConsoleWriteLine("lights");
                    WRG.Console.ConsoleWriteLine("bspheres");
                    break;

                case "shadowson":
                    WRG.GraphicCore.enableshadows = true;
                    break;

                case "shadowsoff":
                    WRG.GraphicCore.enableshadows = false;
                    break;

                case "wire":
                    WRG.GraphicCore.GetInitializator().GetDevice().RenderState.FillMode = Microsoft.DirectX.Direct3D.FillMode.WireFrame;
                    break;

                case "solid":
                    WRG.GraphicCore.GetInitializator().GetDevice().RenderState.FillMode = Microsoft.DirectX.Direct3D.FillMode.Solid;
                    break;

                case "quadtree":
                    WRG.GraphicCore.usedoptimize = WRG.GraphicCore.OptimizeType.QuadTree;
                    break;

                case "occ":
                    WRG.GraphicCore.usedoptimize = WRG.GraphicCore.OptimizeType.OcclussionCulling;
                    break;

                case "bspheres":
                    WRG.GraphicCore.showBoundingSpheres = !WRG.GraphicCore.showBoundingSpheres;
                    break;

                case "low":
                    graphic.InitDetails(Details.Low);
                    break;

                case "medium":
                    graphic.InitDetails(Details.Medium);
                    break;

                case "high":
                    graphic.InitDetails(Details.High);
                    break;

                case "ultra":
                    graphic.InitDetails(Details.UltraHigh);
                    break;

                case "lights":
                    WRG.GraphicCore.enableLights = !WRG.GraphicCore.enableLights;
                    WRG.GraphicCore.GetCurrentSceneManager().EnableLights(WRG.GraphicCore.enableLights);
                    break;

                case "restart":
                    Restart();
                    break;

                default: WRG.Console.ConsoleWriteLine("Zadany prikaz neexistuje");
                    break;
                }

                commands.RemoveAt(0);
            }
            #endregion
        }