示例#1
0
 /// <summary>
 /// Renders the parts of the level map that the character sees or remembers.
 /// </summary>
 /// <param name="fieldOfVision"></param>
 public virtual void RenderMap(AbstractFieldOfVision fieldOfVision)
 {
     for (int i = 0; i < Width; ++i)
     {
         for (int j = 0; j < Height; ++j)
         {
             if (isInFieldOfVision(i, j, fieldOfVision))
             {
                 console.ForegroundColor = GetDisplayColor(i, j);
                 Write(this[i, j], i, j);
                 Memorize(i, j);
             }
             else if (getMemAt(i, j) != Map.UNKNOWN)
             {
                 if (Shade)
                 {
                     console.ForegroundColor = ShadeColor;
                 }
                 else
                 {
                     console.ForegroundColor = GetDisplayColor(i, j);
                 }
                 Write(getDisplayMemAt(i, j), i, j);
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// Indicates whether a square of coordinates (x, y) is inside of fov.
 /// x and y are in ViewPort coordinates (not IConsole ol Level coordinates)
 /// </summary>
 /// <param name="i"></param>
 /// <param name="j"></param>
 /// <param name="fieldOfVision"></param>
 /// <returns></returns>
 private bool isInFieldOfVision(int i, int j, AbstractFieldOfVision fieldOfVision)
 {
     i += Position.X;
     j += Position.Y;
     i -= fieldOfVision.Observer.X;
     j -= fieldOfVision.Observer.Y;
     return(fieldOfVision[i, j]);
 }
示例#3
0
        public void Display(AbstractEntity entity, AbstractFieldOfVision fov, Position observer)
        {
            int x = entity.Position.X - observer.X;
            int y = entity.Position.Y - observer.Y;

            if (fov[x, y])
            {
                Display(entity);
            }
        }
        private string getTargetString(AbstractEntity target)
        {
            AbstractFieldOfVision fieldOfVision = GameController.Instance.FieldOfVision;

            if (target != null && (fieldOfVision.IsInFieldOfVision(target.Position) || target.Person == Person.Second))
            {
                return(target.Accusativ);
            }
            else
            {
                return("coś");
            }
        }
        public override void FromXml(XmlElement element)
        {
            base.FromXml(element);
            gametimeTicks = GetIntAttribute("gametime-ticks"); // TODO convert XML element and attribute names to constants
            pc            = GetElement("pc") as Pc;
            LevelPersistencyHelper helper = new LevelPersistencyHelper();

            helper.FromXml(element.SelectSingleNode("levels") as XmlElement); // TODO probably wrong
            level         = helper.StartingLevel;
            fieldOfVision = GetElement("field-of-vision") as AbstractFieldOfVision;
            viewPort      = GetElement("viewport") as ViewPort;
            //console = new SystemConsole();
            viewPort.Console = console;
            viewPort.Map     = Level.Map;
        }
        public void ShowMessage(string key, AbstractEntity performer, AbstractEntity target, bool force)
        {
            AbstractFieldOfVision fieldOfVision = GameController.Instance.FieldOfVision;

            if (fieldOfVision.IsInFieldOfVision(performer.Position) || force || performer.Person == Person.Second)
            {
                string targetString = getTargetString(target);
                string message      = getMessage(performer.Person, key, performer.Identity,
                                                 target != null ? targetString : "");
                window.ShowMessage(message);
                logMessage(message);
            }
            if (!fieldOfVision.IsInFieldOfVision(performer.Position) &&
                performer.Person == Person.Third && target != null && target.Person == Person.Second)
            {
                string message = getMessage(performer.Person, key, "coś", target.Accusativ);
                window.ShowMessage(message);
                logMessage(message);
            }
        }