Exemple #1
0
 /// <summary>
 ///     Добавить объект на карту и поменять его координаты
 /// </summary>
 /// <param name="gameObject"></param>
 /// <param name="point"></param>
 /// <param name="enableObject"></param>
 public void Add(GameObject gameObject, int x, int y, bool enableObject = true)
 {
     gameObject.X = x;
     gameObject.Y = y;
     this[x, y].Add(gameObject);
     gameObject.IsEnabled = enableObject;
 }
        protected override void SetClone(GameObject obj)
        {
            base.SetClone(obj);
            var creature = (Creature) obj;
            creature.Playable = Playable;
            creature.Hp = Hp;
            creature.MaxHp = MaxHp;
            creature.Map = Map;

            creature.Modificators = Modificators.Select(m => m.Clone()).ToList();
            creature.Attributes = Attributes.Select(a => a.Clone()).ToList();
            creature.Inventory = Inventory.Select(i => i.Clone()).ToList();
        }
Exemple #3
0
        private void Initialize()
        {
            var floor = new DrawableGameObject(this)
            {
                Tile = '.',
                Name = "Floor",
                Key = "floor1",
                Color = ConsoleColor.DarkGreen
            };
            ObjectsDictionary.Add(floor);

            _currentMap = new Map(this, 50, 50);

            for (int x = 0; x < 50; x++)
            {
                for (int y = 0; y < 50; y++)
                {
                    _currentMap.Add(ObjectsDictionary["floor1"], x, y);
                }
            }

            _player = new Creature(this)
            {
                X = 2,
                Y = 2,
                IsPlayer = true,
                Tile = '@',
                Map = _currentMap,
                Color = ConsoleColor.Red
            };
            _camera = _player;
            _currentMap.Add(_player);
        }
 protected override void SetClone(GameObject obj)
 {
     base.SetClone(obj);
     var drawable = (DrawableGameObject) obj;
     drawable.Frames = (char[]) Frames.Clone();
     drawable.IsAnimationStopped = IsAnimationStopped;
     drawable.IsAnimuted = IsAnimuted;
     drawable.IsVisible = IsVisible;
     drawable.Offset = Offset;
     drawable.Color = Color;
 }
Exemple #5
0
 private bool HasCollision(GameObject gameObject, Vector point)
 {
     return false; //todo
 }
Exemple #6
0
 public bool CanMoveObject(GameObject gameObject, Vector point)
 {
     return point.X >= 0 && point.Y >= 0 && point.X < Width && point.Y < Height
         && !HasCollision(gameObject, point); //todo
 }
Exemple #7
0
 public void Add(GameObject gameObject)
 {
     var count = GetPointCount(gameObject.X, gameObject.Y);
     if(gameObject.Z != -1 )
     GameObjects.Add(gameObject);
 }
Exemple #8
0
 /// <summary>
 ///     Добавить объект на карту и поменять его координаты
 /// </summary>
 /// <param name="gameObject"></param>
 /// <param name="point"></param>
 /// <param name="enableObject"></param>
 public void Add(GameObject gameObject, Vector point, bool enableObject = true)
 {
     Add(gameObject, point.X, point.Y, enableObject);
 }
Exemple #9
0
 private void ResetUpdate(GameObject gameObject)
 {
     gameObject.ResetUpdate();
 }
Exemple #10
0
 private bool CanMoveObject(GameObject gameObject, Vector point)
 {
     return point.X >= 0 && point.Y >= 0 && point.X < _map.GetLength(0) && point.Y < _map.GetLength(1); //todo
 }
Exemple #11
0
        public bool MoveObject(GameObject gameObject, Vector point)
        {
            if (!CanMoveObject(gameObject, point))
                return false;

            this[gameObject.Position].Remove(gameObject);
            this[point].Add(gameObject);
            return true;
        }
Exemple #12
0
 /// <summary>
 ///     Добавить объект на координаты, указанные в самом объекте
 /// </summary>
 /// <param name="gameObject"></param>
 /// <param name="enableObject"></param>
 public void Add(GameObject gameObject, bool enableObject = true)
 {
     Add(gameObject, gameObject.Position, enableObject);
 }
 public void Add(GameObject obj, string key)
 {
     obj.Key = key;
     _objects.Add(key, obj); //todo exc catch
 }
 public void Add(GameObject obj)
 {
     _objects.Add(obj.Key, obj); //todo exc catch
 }