Exemplo n.º 1
0
 protected override void OnEnergyEnter(EnergyBehavior energyBehavior)
 {
     base.OnEnergyEnter(energyBehavior);
     if (Energy == GameData.Constants.FillNodeFillRequirement)
     {
         ParentBoard.RemoveNode(this);
         Behavior.gameObject.SetActive(false);
     }
 }
Exemplo n.º 2
0
 public virtual bool CanSee(Entity other)
 {
     foreach (var point in Toolkit.Line(XPosition, YPosition, other.XPosition, other.YPosition))
     {
         //if ((ParentBoard.IsSolid(point.Y, point.X) && !ParentBoard.IsWater(point.Y, point.X)) && ParentBoard.IsLit(point.Y, point.X))
         if (ParentBoard.IsSolid(point.Y, point.X, SolidityCheck.Projectile) && ParentBoard.IsLit(point.Y, point.X))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 3
0
        public void CheckWarps()
        {
            var warp = ParentBoard.Warps.Find(w => /* !String.IsNullOrEmpty(w.TargetBoard) && */ w.XPosition == XPosition && w.YPosition == YPosition);

            if (warp != null)
            {
                if (warp.TargetBoard == -1)                 //ungenerated dungeon
                {
                    DungeonGenerator.DungeonGeneratorEntranceBoardNum = ParentBoard.BoardNum;
                    DungeonGenerator.DungeonGeneratorEntranceWarpID   = warp.ID;
                    DungeonGenerator.DungeonGeneratorBiome            = (int)ParentBoard.GetToken("biome").Value;
                    DungeonGenerator.CreateDungeon();
                    return;
                }
                else if (warp.TargetBoard == -2)                 //unconnected dungeon
                {
                    Travel.Open();
                    return;
                }

                var game        = NoxicoGame.Me;
                var targetBoard = game.GetBoard(warp.TargetBoard);                 //game.Boards[warp.TargetBoard]; //.Find(b => b.ID == warp.TargetBoard);

                var sourceBoard = ParentBoard;

                ParentBoard.EntitiesToRemove.Add(this);
                game.CurrentBoard = targetBoard;
                ParentBoard       = targetBoard;
                ParentBoard.Entities.Add(this);
                var twarp = targetBoard.Warps.Find(w => w.ID == warp.TargetWarpID);
                if (twarp == null)
                {
                    XPosition = 0;
                    YPosition = 0;
                }
                else
                {
                    XPosition = twarp.XPosition;
                    YPosition = twarp.YPosition;
                }
                ParentBoard.AimCamera();
                ParentBoard.UpdateLightmap(this, true);
                ParentBoard.Redraw();
                ParentBoard.PlayMusic();
                NoxicoGame.Immediate = true;

                //Going from a dungeon to a wild board?
                if (targetBoard.GetToken("type").Value == 0 && sourceBoard.GetToken("type").Value == 2)
                {
                    game.FlushDungeons();
                }
            }
        }
Exemplo n.º 4
0
 private void RestoreImages(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && !Defused && !Opened)
     {
         Image = CellImagesProvider.Default;
     }
     else if (e.Button == MouseButtons.Middle && !Defused && Opened)
     {
         IEnumerable <MineCell> neighbours = ParentBoard.GetNeighbours(FieldLocation).ConvertTo <IMineSquare, MineCell>();
         neighbours.ForEach(OnButtonUp);
     }
 }
Exemplo n.º 5
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (e.Button == MouseButtons.Left && !Opened && !Defused)
     {
         OnButtonDown(this);
     }
     else if (e.Button == MouseButtons.Middle && Opened && !Defused)
     {
         IEnumerable <MineCell> neighbours = ParentBoard.GetNeighbours(FieldLocation).ConvertTo <IMineSquare, MineCell>();
         neighbours.ForEach(OnButtonDown);
     }
 }
Exemplo n.º 6
0
    protected override void OnEnergyEnter(EnergyBehavior energyBehavior)
    {
        base.OnEnergyEnter(energyBehavior);

        if (Energy == MaxEnergy)
        {
            // Create Basic Node
            var data = new BoardNodeData();
            data.Affiliation    = Affiliation;
            data.Type           = BoardNodeType.Basic;
            data.Position       = Position;
            data.StartingEnergy = MaxEnergy;
            ParentBoard.ReplaceNode(this, data);
            Behavior.gameObject.SetActive(false);
        }
    }
Exemplo n.º 7
0
        public virtual void Draw()
        {
            var localX = this.XPosition - NoxicoGame.CameraX;
            var localY = this.YPosition - NoxicoGame.CameraY;

            if (localX >= Program.Cols || localY >= Program.Rows || localX < 0 || localY < 0)
            {
                return;
            }
            var b = ((MainForm)NoxicoGame.HostForm).IsMultiColor ? TileDefinition.Find(this.ParentBoard.Tilemap[this.XPosition, this.YPosition].Index, true).Background : this.BackgroundColor;

            if (ParentBoard.IsLit(this.YPosition, this.XPosition))
            {
                NoxicoGame.HostForm.SetCell(localY, localX, this.Glyph, this.ForegroundColor, b);
            }
            //else
            //	NoxicoGame.HostForm.SetCell(localY, localX, this.Glyph, this.ForegroundColor.Night(), b.Night());
        }
Exemplo n.º 8
0
 public override void Update()
 {
     base.Update();
     if (CanBurn && ParentBoard.IsBurning(YPosition, XPosition))
     {
         ParentBoard.EntitiesToRemove.Add(this);
         return;
     }
     if (Life > 0)
     {
         Life--;
         if (Life == 0)
         {
             ParentBoard.EntitiesToRemove.Add(this);
             return;
         }
     }
 }
Exemplo n.º 9
0
        public void OpenBoard(int index)
        {
            if (this.ParentBoard != null)
            {
                this.ParentBoard.EntitiesToRemove.Add(this);
                this.ParentBoard.SaveToFile(this.ParentBoard.BoardNum);
            }
            var n = NoxicoGame.Me;

            this.ParentBoard = n.GetBoard(index);
            n.CurrentBoard   = this.ParentBoard;
            this.ParentBoard.Entities.Add(this);
            ParentBoard.CheckCombatStart();
            ParentBoard.CheckCombatFinish();
            ParentBoard.UpdateLightmap(this, true);
            ParentBoard.Redraw();
            ParentBoard.PlayMusic();
            NoxicoGame.Immediate = true;

            if (ParentBoard.BoardType == BoardType.Town)
            {
                var boardName = ParentBoard.Name;
                var known     = NoxicoGame.TravelTargets.ContainsValue(boardName);
                if (!known)
                {
                    NoxicoGame.TravelTargets.Add(index, boardName);
                    Program.WriteLine("Registered {0} as a fast-travel target.", boardName);
                }
            }

            this.ParentBoard.AimCamera(XPosition, YPosition);

            if (this.DijkstraMap != null)
            {
                this.DijkstraMap.UpdateWalls(ParentBoard, !Character.IsSlime);
                this.DijkstraMap.Update();
            }
            if (this.AutoTravelMap == null)
            {
                this.AutoTravelMap = new Dijkstra(this.ParentBoard);
                this.AutoTravelMap.Hotspots.Add(new Point(this.XPosition, this.YPosition));
            }
            this.AutoTravelMap.UpdateWalls(ParentBoard, !Character.IsSlime);
        }
Exemplo n.º 10
0
        public void EndTurn()
        {
            var nrg = Energy;

            Energy = 5000;
            var r = Lua.Environment.EachBoardCharTurn(this, this.Character);

            Energy = nrg;

            NoxicoGame.PlayerReady = false;

            if (Character.HasToken("flying"))
            {
                var f = Character.GetToken("flying");
                f.Value--;
                if (!Character.HasToken("wings") || Character.GetToken("wings").HasToken("small"))
                {
                    NoxicoGame.AddMessage(i18n.GetString("losewings"));
                    f.Value = -10;
                }
                if (f.Value <= 0)
                {
                    LandFromFlight(true);
                }
            }

            if (ParentBoard == null)
            {
                return;
            }
            ParentBoard.Update(true);
            if (ParentBoard.IsBurning(YPosition, XPosition))
            {
                Hurt(10, "death_burned", null, false, false);
            }
            //Leave EntitiesToAdd/Remove to Board.Update next passive cycle.
        }
Exemplo n.º 11
0
        public override void Update()
        {
            base.Update();
            NoxicoGame.ContextMessage = i18n.GetString("context_interactmode");
            if (this.ParentBoard == null)
            {
                NoxicoGame.Mode = UserMode.Walkabout;
                return;
            }
            //this.ParentBoard.Draw(true);

            if (NoxicoGame.IsKeyDown(KeyBinding.Interact) || NoxicoGame.IsKeyDown(KeyBinding.Back) || Vista.Triggers == XInputButtons.B)
            {
                NoxicoGame.Mode = UserMode.Walkabout;
                NoxicoGame.ClearKeys();
                NoxicoGame.ContextMessage = string.Empty;
                Hide();
                return;
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.TabFocus) || Vista.Triggers == XInputButtons.RightShoulder)
            {
                NoxicoGame.ClearKeys();
                Tabstop++;
                if (Tabstop >= Tabstops.Count)
                {
                    Tabstop = 0;
                }
                XPosition = Tabstops[Tabstop].X;
                YPosition = Tabstops[Tabstop].Y;
                Point();
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.Accept) || Vista.Triggers == XInputButtons.A)
            {
                Subscreens.PreviousScreen.Clear();
                NoxicoGame.ClearKeys();
                var player = NoxicoGame.Me.Player;
#if DEBUG
                if (PointingAt == null)
                {
                    ActionList.Show("Debug?", this.XPosition - NoxicoGame.CameraX, this.YPosition - NoxicoGame.CameraY,
                                    new Dictionary <object, string>()
                    {
                        { "teleport", "Teleport" },
                        { "spawn", "Spawn character" },
                    },
                                    () =>
                    {
                        Hide();
                        if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                        {
                            NoxicoGame.Mode = UserMode.Walkabout;
                            Hide();
                            return;
                        }
                        switch (ActionList.Answer as string)
                        {
                        case "teleport":
                            player.XPosition = this.XPosition;
                            player.YPosition = this.YPosition;
                            ParentBoard.AimCamera();
                            ParentBoard.Redraw();
                            NoxicoGame.Mode = UserMode.Aiming;
                            Point();
                            return;

                        case "spawn":
                            var spawnOptions = new Dictionary <object, string>();
                            foreach (var bp in Character.Bodyplans)
                            {
                                spawnOptions[bp.Text] = bp.Text;
                            }
                            var uniques = Mix.GetTokenTree("uniques.tml", true);
                            foreach (var bp in uniques)
                            {
                                spawnOptions['!' + bp.Text] = bp.Text;
                            }
                            ActionList.Show("Debug?", this.XPosition - NoxicoGame.CameraX, this.YPosition - NoxicoGame.CameraY, spawnOptions,
                                            () =>
                            {
                                if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                                {
                                    NoxicoGame.Mode = UserMode.Aiming;
                                    Point();
                                    return;
                                }
                                Character newChar = null;
                                if (ActionList.Answer is string && ((string)ActionList.Answer).StartsWith('!'))
                                {
                                    newChar = Character.GetUnique(((string)ActionList.Answer).Substring(1));
                                }
                                else
                                {
                                    newChar = Character.Generate((string)ActionList.Answer, Gender.RollDice);
                                }
                                var newBoardChar = new BoardChar(newChar)
                                {
                                    XPosition   = this.XPosition,
                                    YPosition   = this.YPosition,
                                    ParentBoard = this.ParentBoard
                                };
                                newBoardChar.AdjustView();
                                ParentBoard.EntitiesToAdd.Add(newBoardChar);
                                ParentBoard.Redraw();
                                NoxicoGame.Mode = UserMode.Walkabout;
                                Hide();
                                return;
                            }
                                            );
                            break;
                        }
                    }
                                    );
                }
#endif
                if (PointingAt != null)
                {
                    LastTarget = PointingAt;
                    var distance = player.DistanceFrom(PointingAt);
                    var canSee   = player.CanSee(PointingAt);

                    var options     = new Dictionary <object, string>();
                    var description = "something";

                    options["look"] = i18n.GetString("action_lookatit");

                    if (PointingAt is Player)
                    {
                        description     = i18n.Format("action_descyou", player.Character.Name);
                        options["look"] = i18n.GetString("action_lookatyou");
                        if (player.Character.GetStat("excitement") >= 30)
                        {
                            options["f**k"] = i18n.GetString("action_masturbate");
                        }

                        if (player.Character.HasToken("copier") && player.Character.GetToken("copier").Value == 1)
                        {
                            if (player.Character.Path("copier/backup") != null || player.Character.Path("copier/full") == null)
                            {
                                options["revert"] = i18n.GetString("action_revert");
                            }
                        }
                    }
                    else if (PointingAt is DroppedItem)
                    {
                        var drop  = PointingAt as DroppedItem;
                        var item  = drop.Item;
                        var token = drop.Token;
                        description = item.ToString(token);
                        if (distance <= 1)
                        {
                            options["take"] = i18n.GetString("action_pickup");
                        }
                    }
                    else if (PointingAt is Container)
                    {
                        var container = PointingAt as Container;
                        description = container.Name ?? "container";
                    }
                    else if (PointingAt is Clutter)
                    {
                        var clutter = PointingAt as Clutter;
                        description = clutter.Name ?? "something";
                        if (clutter.ID == "craftstation")
                        {
                            options["craft"] = i18n.GetString("action_craft");
                        }
                    }
                    else if (PointingAt is BoardChar)
                    {
                        var boardChar = PointingAt as BoardChar;
                        description     = boardChar.Character.GetKnownName(true);
                        options["look"] = i18n.Format("action_lookathim", boardChar.Character.HimHerIt(true));

                        if (canSee && distance <= 2 && !boardChar.Character.HasToken("beast") && !boardChar.Character.HasToken("sleeping"))
                        {
                            options["talk"] = i18n.Format("action_talktohim", boardChar.Character.HimHerIt(true));
                            if (boardChar.Character.Path("role/vendor") != null && boardChar.Character.Path("role/vendor/class").Text != "carpenter")
                            {
                                options["trade"] = i18n.Format("action_trade", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && player.Character.GetStat("excitement") >= 30 && distance <= 1)
                        {
                            var mayFuck  = boardChar.Character.HasToken("willing");
                            var willRape = boardChar.Character.HasToken("helpless");

                            if (!IniFile.GetValue("misc", "allowrape", false) && willRape)
                            {
                                mayFuck = false;
                            }
                            //but DO allow it if they're helpless but willing
                            if (boardChar.Character.HasToken("willing") && willRape)
                            {
                                mayFuck  = true;
                                willRape = false;
                            }
                            if (boardChar.Character.HasToken("beast"))
                            {
                                mayFuck = false;
                            }

                            if (mayFuck)
                            {
                                options["f**k"] = i18n.Format(willRape ? "action_rapehim" : "action_fuckhim", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && !boardChar.Character.HasToken("beast") && player.Character.HasToken("copier") && player.Character.Path("copier/timeout") == null)
                        {
                            //if (player.Character.UpdateCopier())
                            if (player.Character.HasToken("fullCopy") || player.Character.HasToken("sexCopy"))
                            {
                                options["copy"] = i18n.Format("action_copyhim", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && player.Character.CanShoot() != null && player.ParentBoard.HasToken("combat"))
                        {
                            options["shoot"] = i18n.Format("action_shoothim", boardChar.Character.HimHerIt(true));
                        }
                    }

#if DEBUG
                    if (PointingAt is BoardChar)
                    {
                        options["mutate"] = "(debug) Random mutate";
                    }
                    if (PointingAt is BoardChar)
                    {
                        options["turbomutate"] = "(debug) Apply LOTS of mutations!";
                    }
#endif

                    ActionList.Show(description, PointingAt.XPosition - NoxicoGame.CameraX, PointingAt.YPosition - NoxicoGame.CameraY, options,
                                    () =>
                    {
                        Hide();
                        if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                        {
                            //NoxicoGame.Messages.Add("[Aim message]");
                            NoxicoGame.Mode = UserMode.Aiming;
                            Point();
                            return;
                        }
                        switch (ActionList.Answer as string)
                        {
                        case "look":
                            if (PointingAt is DroppedItem)
                            {
                                var drop  = PointingAt as DroppedItem;
                                var item  = drop.Item;
                                var token = drop.Token;
                                var text  = (item.HasToken("description") && !token.HasToken("unidentified") ? item.GetToken("description").Text : i18n.Format("thisis_x", item.ToString(token))).Trim();
                                MessageBox.Notice(text, true);
                            }
                            else if (PointingAt is Clutter && !((Clutter)PointingAt).Description.IsBlank())
                            {
                                MessageBox.Notice(((Clutter)PointingAt).Description.Trim(), true, ((Clutter)PointingAt).Name ?? "something");
                            }
                            else if (PointingAt is Container)
                            {
                                MessageBox.Notice(((Container)PointingAt).Description.Trim(), true, ((Container)PointingAt).Name ?? "container");
                            }
                            else if (PointingAt is BoardChar)
                            {
                                if (((BoardChar)PointingAt).Character.HasToken("beast"))
                                {
                                    MessageBox.Notice(((BoardChar)PointingAt).Character.LookAt(PointingAt), true, ((BoardChar)PointingAt).Character.GetKnownName(true));
                                }
                                else
                                {
                                    TextScroller.LookAt((BoardChar)PointingAt);
                                }
                            }
                            break;

                        case "talk":
                            if (PointingAt is Player)
                            {
                                //if (Culture.CheckSummoningDay()) return;
                                if (player.Character.Path("mind").Value >= 10)
                                {
                                    MessageBox.Notice(i18n.GetString("talkingotyourself"), true);
                                }
                                else
                                {
                                    MessageBox.Notice(i18n.GetString("talkingtoyourself_nutso"), true);
                                }
                            }
                            else if (PointingAt is BoardChar)
                            {
                                var boardChar = PointingAt as BoardChar;
                                if (boardChar.Character.HasToken("hostile") && !boardChar.Character.HasToken("helpless"))
                                {
                                    MessageBox.Notice(i18n.Format("nothingtosay", boardChar.Character.GetKnownName(false, false, true, true)), true);
                                }
                                else
                                {
                                    SceneSystem.Engage(player.Character, boardChar.Character);
                                }
                            }
                            break;

                        case "trade":
                            ContainerMan.Setup(((BoardChar)PointingAt).Character);
                            break;

                        case "f**k":
                            if (PointingAt is BoardChar)
                            {
                                SexManager.Engage(player.Character, ((BoardChar)PointingAt).Character);
                            }
                            break;

                        case "shoot":
                            player.AimShot(PointingAt);
                            break;

                        case "copy":
                            player.Character.Copy(((BoardChar)PointingAt).Character);
                            player.AdjustView();
                            //NoxicoGame.AddMessage(i18n.Format((player.Character.Path("copier/full") == null) ? "youimitate_x" : "become_x", ((BoardChar)PointingAt).Character.GetKnownName(false, false, true)));
                            NoxicoGame.AddMessage(i18n.Format(player.Character.HasToken("fullCopy") ? "x_becomes_y" : "x_imitates_y").Viewpoint(player.Character, ((BoardChar)PointingAt).Character));
                            player.Energy -= 2000;
                            break;

                        case "revert":
                            player.Character.Copy(null);
                            player.AdjustView();
                            NoxicoGame.AddMessage(i18n.GetString((player.Character.HasToken("fullCopy")) ? "youmelt" : "yourevert"));
                            player.Energy -= 1000;
                            break;

                        case "take":
                            if (PointingAt is DroppedItem)
                            {
                                var drop  = PointingAt as DroppedItem;
                                var item  = drop.Item;
                                var token = drop.Token;
                                drop.Take(player.Character, ParentBoard);
                                player.Energy -= 1000;
                                NoxicoGame.AddMessage(i18n.Format("youpickup_x", item.ToString(token, true)), drop.ForegroundColor);
                                NoxicoGame.Sound.PlaySound("set://GetItem");
                                ParentBoard.Redraw();
                            }
                            break;

                        case "craft":
                            Crafting.Open(player.Character);
                            break;

#if DEBUG
                        case "edit":
                            TokenCarrier tc = null;
                            if (PointingAt is DroppedItem)
                            {
                                tc = ((DroppedItem)PointingAt).Token;
                            }
                            else if (PointingAt is BoardChar)
                            {
                                tc = ((BoardChar)PointingAt).Character;
                            }

                            NoxicoGame.HostForm.Write("TOKEN EDIT ENGAGED. Waiting for editor process to exit.", Color.Black, Color.White, 0, 0);
                            NoxicoGame.HostForm.Draw();
                            ((MainForm)NoxicoGame.HostForm).timer.Enabled = false;
                            var dump = "-- WARNING! Many things may cause strange behavior or crashes. WATCH YOUR F*****G STEP.\r\n" + tc.DumpTokens(tc.Tokens, 0);
                            var temp = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString() + ".txt");
                            File.WriteAllText(temp, dump);
                            var process = System.Diagnostics.Process.Start(temp);
                            process.WaitForExit();
                            var newDump = File.ReadAllText(temp);
                            File.Delete(temp);
                            ((MainForm)NoxicoGame.HostForm).timer.Enabled = true;
                            ParentBoard.Redraw();
                            if (newDump == dump)
                            {
                                break;
                            }
                            tc.Tokenize(newDump);
                            ((BoardChar)PointingAt).AdjustView();
                            ((BoardChar)PointingAt).Character.RecalculateStatBonuses();
                            ((BoardChar)PointingAt).Character.CheckHasteSlow();
                            break;

                        case "mutate":
                            var result = ((BoardChar)PointingAt).Character.Mutate(1, 30);
                            NoxicoGame.AddMessage(result);
                            break;

                        case "turbomutate":
                            result = ((BoardChar)PointingAt).Character.Mutate(2500, 30);
                            NoxicoGame.AddMessage(result);
                            break;
#endif

                        default:
                            MessageBox.Notice("Unknown action handler \"" + ActionList.Answer.ToString() + "\".", true);
                            break;
                        }
                    }
                                    );             //	true, true);
                    return;
                }
                else
                {
                    /*
                     * var tSD = this.ParentBoard.GetDescription(YPosition, XPosition);
                     * if (!string.IsNullOrWhiteSpace(tSD))
                     * {
                     *      PointingAt = null;
                     *      MessageBox.ScriptPauseHandler = () =>
                     *      {
                     *              NoxicoGame.Mode = UserMode.Aiming;
                     *              Point();
                     *      };
                     *      MessageBox.Notice(tSD, true);
                     *      return;
                     * }
                     */
                }
            }

#if DEBUG
            if (NoxicoGame.KeyMap[Keys.D])
            {
                NoxicoGame.ClearKeys();
                if (PointingAt != null && PointingAt is BoardChar)
                {
                    ((BoardChar)PointingAt).Character.CreateInfoDump();
                    NoxicoGame.AddMessage("Info for " + ((BoardChar)PointingAt).Character.GetKnownName(true, true, true) + " dumped.", Color.Red);
                }
            }
#endif

            if (NoxicoGame.IsKeyDown(KeyBinding.Left) || Vista.DPad == XInputButtons.Left)
            {
                this.Move(Direction.West);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Right) || Vista.DPad == XInputButtons.Right)
            {
                this.Move(Direction.East);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Up) || Vista.DPad == XInputButtons.Up)
            {
                this.Move(Direction.North);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Down) || Vista.DPad == XInputButtons.Down)
            {
                this.Move(Direction.South);
            }
        }
Exemplo n.º 12
0
 private void FindDirection()
 {
     horizontal = ParentBoard.IsSolid(YPosition, XPosition - 1) && ParentBoard.IsSolid(YPosition, XPosition + 1);
     dirInited  = true;
 }
Exemplo n.º 13
0
        public override void Update()
        {
            //base.Update();
            if (NoxicoGame.Mode != UserMode.Walkabout)
            {
                return;
            }

            //START
            if (NoxicoGame.IsKeyDown(KeyBinding.Pause) || Vista.Triggers == XInputButtons.Start)
            {
                NoxicoGame.ClearKeys();
                Pause.Open();
                return;
            }

            var increase = 200 + (int)Character.GetStat("speed");

            if (Character.HasToken("haste"))
            {
                increase *= 2;
            }
            else if (Character.HasToken("slow"))
            {
                increase /= 2;
            }
            Energy += increase;
            if (Energy < 5000)
            {
                var wasNight = Toolkit.IsNight();

                NoxicoGame.InGameTime = NoxicoGame.InGameTime.AddMilliseconds(increase);

                if (wasNight && !Toolkit.IsNight())
                {
                    ParentBoard.UpdateLightmap(this, true);
                    ParentBoard.Redraw();
                }
                EndTurn();
                return;
            }
            else
            {
                if (!NoxicoGame.PlayerReady)
                {
                    NoxicoGame.AgeMessages();
                }
                NoxicoGame.PlayerReady = true;
                Energy = 5000;
            }

            CheckForTimedItems();
            CheckForCopiers();
            if (Character.UpdateSex())
            {
                return;
            }

            var sleeping = Character.Path("sleeping");

            if (sleeping != null)
            {
                Character.Heal(2);
                sleeping.Value--;
                if (sleeping.Value <= 0)
                {
                    Character.RemoveToken("sleeping");
                    Character.RemoveToken("helpless");
                    NoxicoGame.AddMessage(i18n.GetString("yougetup"));
                }
                NoxicoGame.InGameTime = NoxicoGame.InGameTime.AddMinutes(5);
                EndTurn();
                return;                 //07-04-13 no more sleepwalking
            }

            var helpless = Character.HasToken("helpless");

            if (helpless)
            {
                if (Random.NextDouble() < 0.05)
                {
                    Character.Heal(2);
                    NoxicoGame.AddMessage(i18n.GetString("yougetup"));
                    Character.RemoveToken("helpless");
                    helpless = false;
                }
            }
            var flying = Character.HasToken("flying");

#if DEBUG
            if (NoxicoGame.KeyMap[Keys.Z])
            {
                NoxicoGame.ClearKeys();
                NoxicoGame.InGameTime = NoxicoGame.InGameTime.AddMinutes(30);
            }
#endif
            //Pause menu moved up so you can pause while <5000.

            //RIGHT
            if ((NoxicoGame.IsKeyDown(KeyBinding.Travel) || Vista.Triggers == XInputButtons.RightShoulder))
            {
                NoxicoGame.ClearKeys();
                if (!this.ParentBoard.AllowTravel)
                {
                    if (this.ParentBoard.BoardType == BoardType.Dungeon)
                    {
                        NoxicoGame.AddMessage(i18n.GetString("travel_notfromdungeon"));
                    }
                    else
                    {
                        NoxicoGame.AddMessage(i18n.GetString("travel_notfromwilds"));
                    }
                    return;
                }
                Travel.Open();
                return;
            }

            //LEFT
            if (NoxicoGame.IsKeyDown(KeyBinding.Rest) || Vista.Triggers == XInputButtons.LeftShoulder)
            {
                NoxicoGame.ClearKeys();
                Energy -= 1000;
                EndTurn();
                return;
            }

            //GREEN
            if (NoxicoGame.IsKeyDown(KeyBinding.Interact) || Vista.Triggers == XInputButtons.A)
            {
                NoxicoGame.ClearKeys();
                //NoxicoGame.Messages.Add("[Aim message]");
                NoxicoGame.Mode = UserMode.Aiming;
                NoxicoGame.Cursor.ParentBoard = this.ParentBoard;
                NoxicoGame.Cursor.XPosition   = this.XPosition;
                NoxicoGame.Cursor.YPosition   = this.YPosition;
                NoxicoGame.Cursor.PopulateTabstops();
                NoxicoGame.Cursor.Point();
                if (Character.HasToken("tutorial") && !Character.GetToken("tutorial").HasToken("interactmode"))
                {
                    Character.GetToken("tutorial").AddToken("dointeractmode");
                    NoxicoGame.CheckForTutorialStuff();
                }
                return;
            }

            //BLUE
            if (NoxicoGame.IsKeyDown(KeyBinding.Items) || Vista.Triggers == XInputButtons.X)
            {
                NoxicoGame.ClearKeys();
                NoxicoGame.Mode      = UserMode.Subscreen;
                NoxicoGame.Subscreen = Inventory.Handler;
                Subscreens.FirstDraw = true;
                return;
            }

            //YELLOW
            if ((NoxicoGame.IsKeyDown(KeyBinding.Fly) || Vista.Triggers == XInputButtons.Y) && !helpless)
            {
                NoxicoGame.ClearKeys();
                if (Character.HasToken("flying"))
                {
                    LandFromFlight();
                }
                else
                {
                    if (Character.HasToken("wings"))
                    {
                        if (Character.GetToken("wings").HasToken("small"))
                        {
                            NoxicoGame.AddMessage(i18n.GetString("wingsaretoosmall"));
                            return;
                        }
                        var tile = ParentBoard.Tilemap[XPosition, YPosition];
                        if (tile.Definition.Ceiling)
                        {
                            if (Character.GetStat("mind") < 10 ||
                                (Character.GetStat("mind") < 20 && Random.NextDouble() < 0.5))
                            {
                                Hurt(2, "death_crackedagainstceiling", null, false);
                                NoxicoGame.AddMessage(i18n.GetString("hittheceiling"));
                            }
                            else
                            {
                                NoxicoGame.AddMessage(i18n.GetString("cantflyinside"));
                            }
                            return;
                        }
                        //Take off
                        Character.AddToken("flying").Value = 100;
                        NoxicoGame.AddMessage(i18n.GetString("youfly"));
                        return;
                    }
                    NoxicoGame.AddMessage(i18n.GetString("flyneedswings"));
                }
                return;
            }

            //RED
            if ((NoxicoGame.IsKeyDown(KeyBinding.Activate) || Vista.Triggers == XInputButtons.B) && !helpless && !flying)
            {
                NoxicoGame.ClearKeys();

                if (OnWarp())
                {
                    CheckWarps();
                }

                var container = ParentBoard.Entities.OfType <Container>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition);
                if (container != null)
                {
                    NoxicoGame.ClearKeys();
                    ContainerMan.Setup(container);
                    return;
                }

                //Find dropped items
                var itemsHere = DroppedItem.GetItemsAt(ParentBoard, XPosition, YPosition);
                if (itemsHere.Count == 1)
                {
                    var drop = itemsHere[0];
                    if (drop != null)
                    {
                        drop.Take(this.Character, ParentBoard);
                        NoxicoGame.Me.Player.Energy -= 1000;
                        NoxicoGame.AddMessage(i18n.Format("youpickup_x", drop.Item.ToString(drop.Token, true)));
                        NoxicoGame.Sound.PlaySound("set://GetItem");
                        ParentBoard.Redraw();
                        return;
                    }
                }
                else if (itemsHere.Count > 1)
                {
                    DroppedItem.PickItemsFrom(itemsHere);
                    return;
                }

                //Find bed
                //var bed = ParentBoard.Entities.OfType<Clutter>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition && c.Glyph == 0x147);
                var bed = ParentBoard.Entities.OfType <Clutter>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition && c.DBRole == "bed");
                if (bed != null)
                {
                    var prompt  = "It's " + NoxicoGame.InGameTime.ToShortTimeString() + ", " + NoxicoGame.InGameTime.ToLongDateString() + ". Sleep for how long?";
                    var options = new Dictionary <object, string>();
                    foreach (var interval in new[] { 1, 2, 4, 8, 12 })
                    {
                        options[interval] = Toolkit.Count(interval).Titlecase() + (interval == 1 ? " hour" : " hours");
                    }
                    options[-1] = "Cancel";
                    MessageBox.List(prompt, options, () =>
                    {
                        if ((int)MessageBox.Answer != -1)
                        {
                            Character.AddToken("helpless");
                            Character.AddToken("sleeping").Value = (int)MessageBox.Answer * 12;
                        }
                    }, true, true, i18n.GetString("Bed"));
                }
                return;
            }

#if DEBUG
            if (NoxicoGame.KeyMap[Keys.F3])
            {
                NoxicoGame.ClearKeys();
                ParentBoard.DumpToHtml(string.Empty);
                NoxicoGame.AddMessage("Board dumped.");
                return;
            }
#endif
            if (helpless)
            {
                EndTurn();
                return;
            }

            if (!AutoTravelling)
            {
                if (NoxicoGame.IsKeyDown(KeyBinding.Left) || Vista.DPad == XInputButtons.Left)
                {
                    this.Move(Direction.West);
                }
                else if (NoxicoGame.IsKeyDown(KeyBinding.Right) || Vista.DPad == XInputButtons.Right)
                {
                    this.Move(Direction.East);
                }
                else if (NoxicoGame.IsKeyDown(KeyBinding.Up) || Vista.DPad == XInputButtons.Up)
                {
                    this.Move(Direction.North);
                }
                else if (NoxicoGame.IsKeyDown(KeyBinding.Down) || Vista.DPad == XInputButtons.Down)
                {
                    this.Move(Direction.South);
                }
                //And now, attempting to fire a long range weapon in a cardinal.
                else if (NoxicoGame.IsKeyDown(KeyBinding.ShootLeft))
                {
                    this.QuickFire(Direction.West);
                }
                else if (NoxicoGame.IsKeyDown(KeyBinding.ShootRight))
                {
                    this.QuickFire(Direction.East);
                }
                else if (NoxicoGame.IsKeyDown(KeyBinding.ShootUp))
                {
                    this.QuickFire(Direction.North);
                }
                else if (NoxicoGame.IsKeyDown(KeyBinding.ShootDown))
                {
                    this.QuickFire(Direction.South);
                }
            }
            else
            {
                if (NoxicoGame.IsKeyDown(KeyBinding.Left) || NoxicoGame.IsKeyDown(KeyBinding.Right) || NoxicoGame.IsKeyDown(KeyBinding.Up) || NoxicoGame.IsKeyDown(KeyBinding.Down))                //(NoxicoGame.KeyMap[(int)Keys.Left] || NoxicoGame.KeyMap[(int)Keys.Right] || NoxicoGame.KeyMap[(int)Keys.Up] || NoxicoGame.KeyMap[(int)Keys.Down])
                {
                    AutoTravelling = false;
                    return;
                }
                var x   = XPosition;
                var y   = YPosition;
                var dir = Direction.North;
                if (AutoTravelMap.RollDown(y, x, ref dir))
                {
                    Move(dir);
                }
                else
                {
                    AutoTravelling = false;
                    if ((int)AutoTravelLeave > -1)
                    {
                        this.Move(AutoTravelLeave);
                    }
                }
            }
        }
Exemplo n.º 14
0
        public override void Move(Direction targetDirection, SolidityCheck check = SolidityCheck.Walker)
        {
            var lx = XPosition;
            var ly = YPosition;

            check = SolidityCheck.Walker;
            if (Character.IsSlime)
            {
                check = SolidityCheck.DryWalker;
            }
            if (Character.HasToken("flying"))
            {
                check = SolidityCheck.Flyer;
            }

            #region Inter-board travel
            var   n          = NoxicoGame.Me;
            Board otherBoard = null;
            if (ly == 0 && targetDirection == Direction.North && this.ParentBoard.ToNorth > -1)
            {
                otherBoard = n.GetBoard(this.ParentBoard.ToNorth);
                if (this.CanMove(otherBoard, lx, otherBoard.Height - 1, check) != null)
                {
                    return;
                }
                this.YPosition = otherBoard.Height;
                OpenBoard(this.ParentBoard.ToNorth);
            }
            else if (ly == ParentBoard.Height - 1 && targetDirection == Direction.South && this.ParentBoard.ToSouth > -1)
            {
                otherBoard = n.GetBoard(this.ParentBoard.ToSouth);
                if (this.CanMove(otherBoard, lx, 0, check) != null)
                {
                    return;
                }
                this.YPosition = -1;
                OpenBoard(this.ParentBoard.ToSouth);
            }
            else if (lx == 0 && targetDirection == Direction.West && this.ParentBoard.ToWest > -1)
            {
                otherBoard = n.GetBoard(this.ParentBoard.ToWest);
                if (this.CanMove(otherBoard, otherBoard.Width - 1, ly, check) != null)
                {
                    return;
                }
                this.XPosition = otherBoard.Width;
                OpenBoard(this.ParentBoard.ToWest);
            }
            else if (lx == ParentBoard.Width - 1 && targetDirection == Direction.East && this.ParentBoard.ToEast > -1)
            {
                otherBoard = n.GetBoard(this.ParentBoard.ToEast);
                if (this.CanMove(otherBoard, 0, ly, check) != null)
                {
                    return;
                }
                this.XPosition = -1;
                OpenBoard(this.ParentBoard.ToEast);
            }
            #endregion

            if (Character.HasToken("tutorial"))
            {
                Character.GetToken("tutorial").Value++;
            }

            var newX = this.XPosition;
            var newY = this.YPosition;
            Toolkit.PredictLocation(newX, newY, targetDirection, ref newX, ref newY);
            foreach (var entity in ParentBoard.Entities.Where(x => x.XPosition == newX && x.YPosition == newY))
            {
                if (entity.Blocking)
                {
                    NoxicoGame.ClearKeys();
                    if (entity is BoardChar)
                    {
                        var bc = (BoardChar)entity;
                        if (bc.Character.HasToken("hostile") || (bc.Character.HasToken("teambehavior") && bc.Character.DecideTeamBehavior(Character, TeamBehaviorClass.Attacking) != TeamBehaviorAction.Nothing))
                        {
                            //Strike at your foes!
                            AutoTravelling = false;
                            MeleeAttack(bc);
                            EndTurn();
                            return;
                        }
                        if (!bc.OnPlayerBump.IsBlank())
                        {
                            bc.RunScript(bc.OnPlayerBump);
                            return;
                        }
                        //Displace!
                        NoxicoGame.AddMessage(i18n.Format("youdisplacex", bc.Character.GetKnownName(false, false, true)), bc.GetEffectiveColor());
                        bc.XPosition = this.XPosition;
                        bc.YPosition = this.YPosition;
                    }
                }
            }
            base.Move(targetDirection, check);
            ParentBoard.AimCamera(XPosition, YPosition);

            EndTurn();

            if (Character.HasToken("squishy") || (Character.Path("skin/type") != null && Character.Path("skin/type").Text == "slime"))
            {
                NoxicoGame.Sound.PlaySound("set://Squish");
            }
            else
            {
                NoxicoGame.Sound.PlaySound("set://Step");
            }

            if (lx != XPosition || ly != YPosition)
            {
                ParentBoard.UpdateLightmap(this, true);
                this.DijkstraMap.Hotspots[0] = new Point(XPosition, YPosition);
                this.DijkstraMap.Update();
            }
            else if (AutoTravelling)
            {
                AutoTravelling = false;
#if DEBUG
                NoxicoGame.AddMessage("* TEST: couldn't go any further. *");
#endif
            }

            NoxicoGame.ContextMessage = null;
            if (OnWarp())
            {
                NoxicoGame.ContextMessage = i18n.GetString("context_warp");
            }
            else if (ParentBoard.Entities.OfType <DroppedItem>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition) != null)
            {
                NoxicoGame.ContextMessage = i18n.GetString("context_droppeditem");
            }
            else if (ParentBoard.Entities.OfType <Container>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition) != null)
            {
                if (ParentBoard.Entities.OfType <Container>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition).Token.HasToken("corpse"))
                {
                    NoxicoGame.ContextMessage = i18n.GetString("context_corpse");
                }
                else
                {
                    NoxicoGame.ContextMessage = i18n.GetString("context_container");
                }
            }
            //else if (ParentBoard.Entities.OfType<Clutter>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition && c.Glyph == 0x147) != null)
            else if (ParentBoard.Entities.OfType <Clutter>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition && c.DBRole == "bed") != null)
            {
                NoxicoGame.ContextMessage = i18n.GetString("context_bed");
            }
            if (NoxicoGame.ContextMessage != null)
            {
                NoxicoGame.ContextMessage = Toolkit.TranslateKey(KeyBinding.Activate, false, false) + " - " + NoxicoGame.ContextMessage;
            }
        }