Esempio n. 1
0
 public static void F2()
 {
     WorldRendering.drawWorld(-1);
     WorldRendering.drawUnits(-1);
     _DEBUG.AddDebugMessage("clairvoyance... Press any key");
     Console.ReadKey(true);
 }
Esempio n. 2
0
 void ContinuePeep(ConsoleKeyInfo keyPressed)
 {
     Log.AddLine("You continue peeping...");
     WorldRendering.drawInCircleFOV(lastPeepX, lastPeepY, visibilityRadius);
     WorldRendering.drawUnitsInCircle(lastPeepX, lastPeepY, visibilityRadius);
     this.Draw();
     if (keyPressed.Key == ConsoleKey.Spacebar || keyPressed.Key == ConsoleKey.Escape)
     {
         isPeeping = false;
         Log.ReplaceLastLine("You recoiled and looked around.");
     }
 }
Esempio n. 3
0
        void peepDialogue()
        {
            Log.AddLine("Peep in which direction?");
            ConsoleKeyInfo keyPressed = Console.ReadKey(true);

            KeyToVector.ProcessInput(keyPressed);
            int peepX = CoordX + KeyToVector.x, peepY = CoordY + KeyToVector.y;

            if (peepX == CoordX && peepY == CoordY)
            {
                int randomMessageNumber = MyRandom.getRandomInt(3);
                switch (randomMessageNumber)
                {
                case 0:
                    Log.AddLine("You feel SO introversive for a moment");
                    break;

                case 1:
                    Log.AddLine("You peep yourself. So interesting");
                    break;

                case 2:
                    Log.AddLine("If you wanna, hm, look at yourself, get a room, please.");
                    break;
                }
                return;
            }
            //don't peep through walls anymore! :D
            if (World.IsPassable(peepX, peepY) || World.IsDoorPresent(peepX, peepY))
            {
                isPeeping = true;
                lastPeepX = peepX;
                lastPeepY = peepY;
                WorldRendering.drawInCircleFOV(peepX, peepY, visibilityRadius);
                WorldRendering.drawUnitsInCircle(peepX, peepY, visibilityRadius);
                this.Draw();
                Console.ForegroundColor = ConsoleColor.Gray;
                Timing.AddActionTime(TimeCost.CloseDoorCost(this));
                Log.ReplaceLastLine("You carefully peep in that direction... Press space or esc to stop");
                keyPressed = Console.ReadKey(true);
                if (keyPressed.Key == ConsoleKey.Spacebar || keyPressed.Key == ConsoleKey.Escape)
                {
                    isPeeping = false;
                    Log.ReplaceLastLine("You carefully peep in that direction...");
                }
            }
            else
            {
                Log.ReplaceLastLine("You try to peep through this, but in vain.");
            }
        }
Esempio n. 4
0
        void shootDialogue()
        {
            if (Inv.Wielded.Range == 1)
            {
                Log.AddLine("You can't shoot with the " + Inv.Wielded.DisplayName + "!");
                return;
            }
            Log.AddLine("Which target? (tab - next, f - fire, esc - cancel)");
            bool nextTargetPlease = true;

            while (nextTargetPlease)
            {
                nextTargetPlease = false;
                foreach (Actor currTarget in World.AllActors)
                {
                    if (WorldLOS.VisibleLineExist(CoordX, CoordY, currTarget.CoordX, currTarget.CoordY))
                    {
                        WorldRendering.drawInCircleFOV(CoordX, CoordY, visibilityRadius);
                        WorldRendering.drawUnitsInCircle(CoordX, CoordY, visibilityRadius);
                        this.Draw();
                        currTarget.DrawHighlighted();
                        Console.ForegroundColor = ConsoleColor.Red;
                        WorldRendering.DrawLineNotInclusive(CoordX, CoordY, currTarget.CoordX, currTarget.CoordY, '*');
                        ConsoleKeyInfo keyPressed = Console.ReadKey(true);
                        if (keyPressed.Key == ConsoleKey.Tab)
                        {
                            nextTargetPlease = true;
                            continue;
                        }
                        if (keyPressed.Key == ConsoleKey.Escape)
                        {
                            Log.AddOneFromList(StringFactory.CancelStrings());
                            return;
                        }
                        if (keyPressed.Key == ConsoleKey.F)
                        {
                            Attack.RangedAttack(this, currTarget);
                            return;
                        }
                    }
                }
            }
            Log.ReplaceLastLine("No targets in range!");
        }
Esempio n. 5
0
        public static void RangedAttack(Unit attacker, Unit victim)
        {
            Weapon attackerWeapon = attacker.Inv.Wielded;

            if (attackerWeapon.Range > 1)
            {
                attacker.Timing.AddActionTime(TimeCost.RangedAttackCost(attacker));
                if (!attackerWeapon.TryConsumeAmmo())
                {
                    if (attacker is Player)
                    {
                        Log.ReplaceLastLine("Click!");
                    }
                    else
                    {
                        Log.AddLine(attacker.Name + "'s " + attackerWeapon.DisplayName + " clicks!");
                    }
                    return;
                }
                int damage = CalculateRangedDamage(attacker, victim);
                victim.Hitpoints -= damage;
                if (attacker is Player)
                {
                    Log.AddLine("You shot the " + victim.Name + " with your " + attacker.Inv.Wielded.DisplayName + "!");
                }
                else
                {
                    Log.AddLine(attacker.Name + " shoots at " + victim.Name + " with the " + attacker.Inv.Wielded.DisplayName + "!");
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                WorldRendering.DrawTraversingBullet(attacker.CoordX, attacker.CoordY, victim.CoordX, victim.CoordY, '*');
            }
            else
            {
                _DEBUG.AddDebugMessage("ERROR: attempt to shoot from non-ranged weapon!");
            }
        }
Esempio n. 6
0
        public void Loop()
        {
            ConsoleKeyInfo keyPressed;

            //drawWorld();
            while (true)
            {
                if (player.Timing.IsTimeToAct())
                {
                    if (player.seesAsUsual())
                    {
                        WorldRendering.drawWorld(0);
                    }
                    player.DrawStatusbar();
                    keyPressed = Console.ReadKey(true);
                    if (keyPressed.Key == ConsoleKey.Escape)
                    {
                        break;
                    }
                    if (keyPressed.Key == ConsoleKey.F1)
                    {
                        HelpScreen.DrawHelpScreen();
                        Log.DrawMiniLog();
                        continue;
                    }

                    if (_DEBUG.DebugKey(keyPressed)) //DEBUG-ONLY
                    {
                        continue;
                    }

                    player.handleKeys(keyPressed);

                    if (player.Timing.IsTimeToAct()) //don't do anything if player did nothing at all
                    {
                        continue;
                    }
                }
                for (int i = 0; i < AllActors.Count; i++)
                {
                    Actor currActor = AllActors[i];
                    if (currActor.Hitpoints <= 0)
                    {
                        AllItemsOnFloor.Add(new Corpse(currActor));
                        Log.AddLine(currActor.Name + " drops dead!");
                        AllActors.Remove(currActor);
                        i--;
                        continue;
                    }
                    if (currActor.KnockedOutTime > 0)
                    {
                        AllItemsOnFloor.Add(new UnconsciousBody(currActor));
                        Log.AddLine(currActor.Name + " falls unconscious!");
                        AllActors.Remove(currActor);
                        i--;
                        continue;
                    }
                    if (currActor.Timing.IsTimeToAct())
                    {
                        currActor.DoSomething();
                    }
                }
                if (player.Hitpoints <= 0) //GAME OVER
                {
                    Gameover.ShowGameoverScreen();
                    break;
                }
                for (int i = 0; i < AllItemsOnFloor.Count; i++)
                {
                    if (AllItemsOnFloor[i] is UnconsciousBody)
                    {
                        UnconsciousBody curr = ((UnconsciousBody)AllItemsOnFloor[i]);
                        if (curr.TimeToWakeUp())
                        {
                            AllActors.Add((Actor)curr.Knocked);
                            Log.AddLine(((Actor)curr.Knocked).Name + " wakes up!");
                            AllItemsOnFloor.Remove(curr);
                            i--;
                            continue;
                        }
                    }
                }
                TurnTiming.Tick();
            }
        }