예제 #1
0
        private void LogAvatarStatus(IAtlas atlas, float temperatureAround)
        {
            string areaName = atlas.AreasCarrier.AreaName(Position);

            if (areaName != null)
            {
                Log.Instance.Debug("Name of current Avatar's location is " + areaName + ".");
            }
            else
            {
                Log.Instance.Debug("Avatar is in unknown location.");
            }

            string roomName = atlas.AreasCarrier.RoomName(Position);

            if (roomName != null)
            {
                Log.Instance.Debug("Avatar is in room " + roomName + ".");
            }
            else
            {
                Log.Instance.Debug("Avatar is in no room.");
            }
            Log.Instance.Debug("Energy of avatar {" + Id + "} is " + Energy);

            Log.Instance.Debug("Temperature around avatar " + temperatureAround + ".");
            Log.Instance.Debug("Temperature of avatar " + Temperature + ".");
        }
예제 #2
0
 public void PickUp(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable = null)
 {
     if (gameAction is PickUp || gameAction is LayDown)
     {
         gameAction.Resolve(new GameActorPosition(this, position, LayerType.Object), atlas, tilesetTable);
     }
 }
예제 #3
0
 public ISwitchableGameActor SwitchOff(GameActorPosition gameActorPosition, IAtlas atlas)
 {
     TilesetId = AlternativeTextures.Id("Open");
     atlas.MoveToOtherLayer(new GameActorPosition(this, new Vector2(Position), LayerType.OnGroundInteractable), LayerType.ObstacleInteractable);
     m_closed = false;
     return(this);
 }
예제 #4
0
        private bool PerformPickup(IAtlas atlas, ITilesetTable tilesetTable)
        {
            // check tile in front of
            List <GameActorPosition> targets = GetInteractableTilesInFrontOf(atlas);

            // if no tile, check objects
            if (targets.Count == 0)
            {
                targets = GetInteractableObjectsInFrontOf(atlas);
            }
            if (targets.Count == 0)
            {
                return(false);
            }

            foreach (GameActorPosition target in targets)
            {
                IPickableGameActor interactableTarget = target.Actor as IPickableGameActor;
                if (interactableTarget == null)
                {
                    continue;
                }
                GameAction pickUpAction = new PickUp(this);
                interactableTarget.PickUp(atlas, pickUpAction, target.Position, tilesetTable);

                RemoveSpeed(target);
                return(true);
            }
            return(false);
        }
예제 #5
0
 public void PickUp(IAtlas atlas, GameAction gameAction, Vector2 position)
 {
     if (gameAction is PickUp || gameAction is LayDown)
     {
         gameAction.Resolve(new GameActorPosition(this, position, LayerType.Object), atlas);
     }
 }
예제 #6
0
        static void Main(string[] args)
        {
            // configure our dependency injection
            var serviceProvider = new ServiceCollection()
                                  .AddLogging(config =>
            {
                config.ClearProviders().AddConsole();
            })
                                  .AddScoped <IDefaultValidators, DefaultValidators>()
                                  .AddScoped <IAtlasConsoleOutputService, AtlasConsoleOutputService>()
                                  .AddTransient <ISolverService, SolverService>()
                                  .BuildServiceProvider();

            // get our solver service
            var solverService = serviceProvider.GetService <ISolverService>();
            var logger        = serviceProvider.GetService <ILoggerFactory>().CreateLogger <Program>();

            // generate a test atlas to generate
            IAtlas <TextItem> atlasOutput = null;
            var result = solverService.Solve(50, 100, new List <TextItem>
            {
                new TextItem {
                    Width = 25, Height = 25, Character = 'a'
                },
                new TextItem {
                    Width = 25, Height = 50, Character = 'B'
                },
                new TextItem {
                    Width = 5, Height = 5, Character = 'c'
                },
                new TextItem {
                    Width = 9, Height = 14, Character = 'D'
                },
                new TextItem {
                    Width = 25, Height = 3, Character = 'e'
                }
            }, out atlasOutput);

            if (result)
            {
                // generate our output
                var outputService = serviceProvider.GetService <IAtlasConsoleOutputService>();
                var output        = outputService.GenerateConsoleOutput <TextItem>(atlasOutput);

                // print it to screen
                foreach (var line in output)
                {
                    Console.WriteLine(line);
                }
            }
            else
            {
                Console.WriteLine("Unable to generate atlas.");
            }

            serviceProvider.Dispose();
            Console.WriteLine("");
            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
        }
예제 #7
0
 public void Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table)
 {
     var leverOn = new LeverSwitchOn(table, Position);
     atlas.ReplaceWith(new GameActorPosition(this, (Vector2)Position, LayerType.ObstacleInteractable), leverOn);
     if (Switchable == null) return;
     leverOn.Switchable = Switchable.Switch(null, atlas, table);
 }
예제 #8
0
        private void Ignite(IAtlas atlas, ITilesetTable tilesetTable)
        {
            var fireplaceBurning = new FireplaceBurning(tilesetTable, Position);

            atlas.ReplaceWith(ThisGameActorPosition(LayerType.OnGroundInteractable), fireplaceBurning);
            atlas.RegisterToAutoupdate(fireplaceBurning);
        }
예제 #9
0
        public void Update(IAtlas atlas)
        {
            List <Vector2I> free = atlas.FreePositionsAround(Position, LayerType.Obstacle | LayerType.Object).ToList();

            if (free.Count == 0)
            {
                return;
            }

            // filter out position with PathTiles
            free = free.Where(x => atlas.ActorsAt((Vector2)x, LayerType.Background).First().Actor.GetType() != typeof(PathTile)).ToList();
            if (free.Count == 0)
            {
                return;
            }

            Vector2I targetPosition = free[m_rng.Next(free.Count)];

            object[]          args          = { targetPosition };
            Fruit             fruit         = (Fruit)Activator.CreateInstance(typeof(T), args);
            GameActorPosition fruitPosition = new GameActorPosition(fruit, new Vector2(targetPosition), LayerType.ObstacleInteractable);

            atlas.Add(fruitPosition);

            NextUpdateAfter = m_updatePeriod;
        }
예제 #10
0
 public void Update(IAtlas atlas, ITilesetTable table)
 {
     List<IGameObject> stayingOnTile = atlas.StayingOnTile(Position);
     if (stayingOnTile.Count != 0) return;
     atlas.ReplaceWith(new GameActorPosition(this, new Vector2(Position), LayerType.OnGroundInteractable),
         new TrapCharged(table, Position));
     NextUpdateAfter = 0;
 }
예제 #11
0
        private bool PerformLayDown(IAtlas atlas, ITilesetTable tilesetTable)
        {
            Vector2    positionInFrontOf = atlas.PositionInFrontOf(this, 1);
            GameAction layDownAction     = new LayDown(this);

            Tool.PickUp(atlas, layDownAction, positionInFrontOf, tilesetTable);
            return(true);
        }
예제 #12
0
 public ISwitchableGameActor Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table)
 {
     RcDoorClosed closedDoor = new RcDoorClosed(table, Position);
     bool added = atlas.Add(new GameActorPosition(closedDoor, (Vector2)Position, LayerType.ObstacleInteractable), true);
     if (!added) return this;
     atlas.Remove(new GameActorPosition(this, (Vector2)Position, LayerType.OnGroundInteractable));
     return closedDoor;
 }
예제 #13
0
 public LuaExecutor(IAtlas atlas, LuaConsole luaConsole = null)
 {
     m_atlas      = atlas;
     DoWorkSync   = new AutoResetEvent(false);
     WorkDoneSync = new AutoResetEvent(false);
     m_luaConsole = luaConsole;
     SetInitialState();
 }
예제 #14
0
        public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position)
        {
            var interact = gameAction as Interact;

            if (interact != null)
            {
                Ignite(atlas);
            }
        }
예제 #15
0
 public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable)
 {
     var doorOpened = new SimpleDoorOpened(tilesetTable);
     bool added = atlas.Add(new GameActorPosition(doorOpened, position, LayerType.OnGroundInteractable));
     if (added)
     {
         atlas.Remove(new GameActorPosition(this, position, LayerType.ObstacleInteractable));
     }
 }
예제 #16
0
        public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable)
        {
            var interact = gameAction as Interact;

            if (interact != null)
            {
                Ignite(atlas, tilesetTable);
            }
        }
예제 #17
0
        public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable)
        {
            var interact = gameAction as Interact;

            if (interact != null)
            {
                Ignite(atlas, tilesetTable);
            }
        }
예제 #18
0
 public void ObjectDetected(IGameObject gameObject, IAtlas atlas)
 {
     if (SomeoneOnTile)
     {
         return;
     }
     NextUpdateAfter = 60;
     atlas.RegisterToAutoupdate(this);
 }
예제 #19
0
        private List <GameActorPosition> GetInteractableObjectsInFrontOf(IAtlas atlas)
        {
            // check circle in front of avatar
            float radius = ((CircleShape)PhysicalEntity.Shape).Radius;
            List <GameActorPosition> actorsInFrontOf = atlas.ActorsInFrontOf(this, LayerType.Object,
                                                                             0.2f + radius, radius).ToList();

            return(actorsInFrontOf);
        }
예제 #20
0
 public void Use(GameActorPosition senderPosition, IAtlas atlas, ITilesetTable tilesetTable)
 {
     IEnumerable<GameActorPosition> actorsInFrontOf =
         atlas.ActorsInFrontOf(senderPosition.Actor as ICharacter).ToList();
     if (actorsInFrontOf.Select(x => x.Actor).Contains(Switchable as GameActor))
     {
         GameActorPosition switchable = actorsInFrontOf.First(x => x.Actor == Switchable);
         Switch(switchable, atlas, tilesetTable);
     }
 }
예제 #21
0
        public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable)
        {
            var  doorOpened = new SimpleDoorOpened(tilesetTable);
            bool added      = atlas.Add(new GameActorPosition(doorOpened, position, LayerType.OnGroundInteractable));

            if (added)
            {
                atlas.Remove(new GameActorPosition(this, position, LayerType.ObstacleInteractable));
            }
        }
예제 #22
0
        public override void Resolve(GameActorPosition target, IAtlas atlas, ITilesetTable table)
        {
            ICanPickGameObject picker = Sender as ICanPickGameObject;
            IPickableGameActor pickItem = target.Actor as IPickableGameActor;

            if (picker == null || pickItem == null) return;

            if (picker.AddToInventory(pickItem))
                atlas.Remove(target);
        }
예제 #23
0
        public AvatarCommander(LuaExecutor ex, IAtlas atlas)
        {
            m_atlas = atlas;

            ex.State.RegisterFunction("Vector", typeof(AtlasManipulator).GetMethod("Vector"));

            m_currentAvatar    = atlas.Avatars.Values.First();
            ex.State["avatar"] = m_currentAvatar;

            m_le = ex;
        }
예제 #24
0
        public void Use(GameActorPosition senderPosition, IAtlas atlas)
        {
            IEnumerable <GameActorPosition> actorsInFrontOf =
                atlas.ActorsInFrontOf(senderPosition.Actor as ICharacter).ToList();

            if (actorsInFrontOf.Select(x => x.Actor).Contains(Switchable as GameActor))
            {
                GameActorPosition switchable = actorsInFrontOf.First(x => x.Actor == Switchable);
                Switch(switchable, atlas);
            }
        }
예제 #25
0
 public void ObjectDetected(IGameObject gameObject, IAtlas atlas)
 {
     if (m_wasActive)
     {
         m_isActive = true;
         return;
     }
     m_isActive      = true;
     NextUpdateAfter = 1;
     atlas.RegisterToAutoupdate(this);
 }
예제 #26
0
        public void Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table)
        {
            var leverOff = new LeverSwitchOff(table, Position);

            atlas.ReplaceWith(new GameActorPosition(this, (Vector2)Position, LayerType.ObstacleInteractable), leverOff);
            if (Switchable == null)
            {
                return;
            }
            leverOff.Switchable = Switchable.Switch(null, atlas, table) as ISwitchableGameActor;
        }
예제 #27
0
        public AtlasTests()
        {
            Stream tmxStream = FileStreams.SmallPickupTmx();
            StreamReader tilesetTableStreamReader = new StreamReader(FileStreams.TilesetTableStream());

            TmxSerializer serializer = new TmxSerializer();
            Map map = serializer.Deserialize(tmxStream);
            ToyWorld world = new ToyWorld(map, tilesetTableStreamReader);

            m_atlas = world.Atlas;
        }
예제 #28
0
        public AtlasTests()
        {
            Stream       tmxStream = FileStreams.SmallPickupTmx();
            StreamReader tilesetTableStreamReader = new StreamReader(FileStreams.TilesetTableStream());

            TmxSerializer serializer = new TmxSerializer();
            Map           map        = serializer.Deserialize(tmxStream);
            ToyWorld      world      = new ToyWorld(map, tilesetTableStreamReader);

            m_atlas = world.Atlas;
        }
예제 #29
0
 public void Switch(GameActorPosition gameActorPosition, IAtlas atlas)
 {
     if (m_On)
     {
         SwitchOff(gameActorPosition, atlas);
     }
     else
     {
         SwitchOn(gameActorPosition, atlas);
     }
 }
예제 #30
0
        public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable = null)
        {
            UsePickaxe action = gameAction as UsePickaxe;
            if (action != null)
            {
                UsePickaxe usePickaxe = action;
                Health -= usePickaxe.Damage;
            }

            if (Health <= 0f)
                atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DestroyedWall(tilesetTable));
        }
예제 #31
0
        public void Update(IAtlas atlas, ITilesetTable table)
        {
            List <IGameObject> stayingOnTile = atlas.StayingOnTile(Position);

            if (stayingOnTile.Count != 0)
            {
                return;
            }
            atlas.ReplaceWith(new GameActorPosition(this, new Vector2(Position), LayerType.OnGroundInteractable),
                              new TrapCharged(table, Position));
            NextUpdateAfter = 0;
        }
예제 #32
0
 public ISwitchableGameActor Switch(GameActorPosition gameActorPosition, IAtlas atlas)
 {
     if (m_closed)
     {
         SwitchOff(gameActorPosition, atlas);
     }
     else
     {
         SwitchOn(gameActorPosition, atlas);
     }
     return(this);
 }
예제 #33
0
        public ISwitchableGameActor Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table)
        {
            RcDoorClosed closedDoor = new RcDoorClosed(table, Position);
            bool         added      = atlas.Add(new GameActorPosition(closedDoor, (Vector2)Position, LayerType.ObstacleInteractable), true);

            if (!added)
            {
                return(this);
            }
            atlas.Remove(new GameActorPosition(this, (Vector2)Position, LayerType.OnGroundInteractable));
            return(closedDoor);
        }
예제 #34
0
        public LuaConsole(ToyWorld toyWorld, IAtlas atlas)
        {
            InitializeComponent();

            toyWorld.ToyWorldDisposed += CloseConsole;

            outputListBox.DataSource = m_inputOutputList;

            m_lex = new LuaExecutor(atlas, this);

            m_inputOutputList.Add(INVITATION_MESSAGE);
            ResetBox();
        }
예제 #35
0
        public void Update(IAtlas atlas, ITilesetTable table)
        {
            List<IGameObject> gameActorPositions = atlas.StayingOnTile(Position);

            SomeoneOnTile = gameActorPositions.Any();

            foreach (IGameObject gameActor in gameActorPositions)
            {
                IAvatar avatar = gameActor as IAvatar;
                if (avatar != null)
                    avatar.Rested += TWConfig.Instance.BedRechargeRate;
            }
        }
예제 #36
0
 public CollisionChecker(IAtlas atlas)
 {
     m_atlas       = atlas;
     m_objectLayer = atlas.GetLayer(LayerType.Object) as SimpleObjectLayer;
     if (m_objectLayer != null)
     {
         m_physicalEntities = m_objectLayer.GetPhysicalEntities();
     }
     else
     {
         throw new ArgumentException("ObjectLayer not found.");
     }
 }
예제 #37
0
 public CollisionChecker(IAtlas atlas)
 {
     m_atlas = atlas;
     m_objectLayer = atlas.GetLayer(LayerType.Object) as SimpleObjectLayer;
     if (m_objectLayer != null)
     {
         m_physicalEntities = m_objectLayer.GetPhysicalEntities();
     }
     else
     {
         throw new ArgumentException("ObjectLayer not found.");
     }
 }
예제 #38
0
 public void Update(IAtlas atlas)
 {
     if (m_isActive)
     {
         Switchable?.SwitchOn(null, atlas);
         m_isActive      = false;
         m_wasActive     = true;
         NextUpdateAfter = DELAY;
         return;
     }
     Switchable?.SwitchOff(null, atlas);
     NextUpdateAfter = 0;
     m_wasActive     = false;
 }
예제 #39
0
        private static void FillNamedAreas(IAtlas atlas, Map map)
        {
            ObjectGroup foregroundObjects = map.ObjectGroups.First(x => x.Name == "ForegroundObject");

            List <TmxObject> tmxMapObjects = foregroundObjects.TmxMapObjects;
            List <TmxObject> areaLabels    = tmxMapObjects.Where(x => x.Type.Trim() == "AreaLabel").ToList();

            IEnumerable <Vector2I>           positions      = areaLabels.Select(x => new Vector2I((int)Math.Floor(x.X), (int)Math.Floor(x.Y)));
            IEnumerable <string>             names          = areaLabels.Select(x => x.Name);
            List <Tuple <Vector2I, string> > namesPositions = positions.Zip(names, (x, y) => new Tuple <Vector2I, string>(x, y)).ToList();

            atlas.AreasCarrier = new AreasCarrier((ITileLayer)atlas.GetLayer(LayerType.Background),
                                                  (ITileLayer)atlas.GetLayer(LayerType.Area), namesPositions);
        }
예제 #40
0
 public void Update(IAtlas atlas)
 {
     List<IGameObject> stayingOnTile = atlas.StayingOnTile(Position);
     if (stayingOnTile.Count == 0)
     {
         Charged = true;
     }
     if (Charged)
     {
         var avatars = stayingOnTile.OfType<IAvatar>();
         avatars.ForEach(x => x.Energy -= ENERGY_FOR_STEP_ON_TRAP);
         Charged = false;
     }
 }
예제 #41
0
 public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position)
 {
     if (m_closed)
     {
         TilesetId = AlternativeTextures.Id("Open");
         atlas.MoveToOtherLayer(new GameActorPosition(this, position, LayerType.ObstacleInteractable), LayerType.OnGroundInteractable);
     }
     else
     {
         TilesetId = AlternativeTextures.Id("Closed");
         atlas.MoveToOtherLayer(new GameActorPosition(this, position, LayerType.OnGroundInteractable), LayerType.ObstacleInteractable);
     }
     m_closed = !m_closed;
 }
예제 #42
0
        public override void Resolve(GameActorPosition target, IAtlas atlas, ITilesetTable table)
        {
            if (target.Actor is Apple || target.Actor is Pear)
            {
                atlas.Remove(target);
            }

            var switcher = target.Actor as ISwitcherGameActor;

            if (switcher != null)
            {
                switcher.Switch(target, atlas, table);
            }
        }
예제 #43
0
        public void Update(IAtlas atlas, ITilesetTable table)
        {
            List<IGameObject> gameActorPositions = atlas.StayingOnTile(Position);

            SomeoneOnTile = gameActorPositions.Any();

            foreach (IGameObject gameActor in gameActorPositions)
            {
                var avatar = gameActor as IAvatar;
                if (avatar != null)
                {
                    avatar.Energy += ENERGY_RECHARGED;
                }
            }
        }
예제 #44
0
        public void Update(IAtlas atlas, ITilesetTable table)
        {
            List<IGameObject> gameActorPositions = atlas.StayingOnTile(Position);

            SomeoneOnTile = gameActorPositions.Any();

            foreach (IGameObject gameActor in gameActorPositions)
            {
                var avatar = gameActor as IAvatar;
                if (avatar != null)
                {
                    avatar.Energy -= ENERGY_FOR_STEP_OR_WAIT_A_SECOND_ON_POISON;
                }
            }
        }
예제 #45
0
        public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable = null)
        {
            UsePickaxe action = gameAction as UsePickaxe;

            if (action != null)
            {
                UsePickaxe usePickaxe = action;
                Health -= usePickaxe.Damage;
            }

            if (Health <= 0f)
            {
                atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DestroyedWall(tilesetTable));
            }
        }
예제 #46
0
 public void UpdateItems(IAtlas atlas, TilesetTable table)
 {
     if (atlas.NewAutoupdateables != null)
     {
         CurrentUpdateRequests.AddRange(atlas.NewAutoupdateables);
         atlas.NewAutoupdateables.Clear();
     }
     foreach (IAutoupdateableGameActor actor in CurrentUpdateRequests)
     {
         actor.Update(atlas, table);
         if (actor.NextUpdateAfter > 0)
             Register(actor, actor.NextUpdateAfter);
     }
     CurrentUpdateRequests.Clear();
 }
예제 #47
0
        public MapLoaderTests()
        {
            // initiate streamReaders
            var tmxMemoryStream = FileStreams.SmallTmx();
            var tilesetTableMemoryStream = FileStreams.TilesetTableStream();

            var tilesetTableStreamReader = new StreamReader(tilesetTableMemoryStream);

            var serializer = new TmxSerializer();
            Map map = serializer.Deserialize(tmxMemoryStream);

            var tilesetTable = new TilesetTable(map, tilesetTableStreamReader);

            // create atlas
            m_atlas = MapLoader.LoadMap(map, tilesetTable, (GameActor actor) => { });
        }
예제 #48
0
        public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable = null)
        {
            if (!(gameAction is UsePickaxe))
                return;

            UsePickaxe usePickaxe = (UsePickaxe)gameAction;
            if (Math.Abs(usePickaxe.Damage) < 0.00001f)
                return;

            if (usePickaxe.Damage >= 1.0f)
            {
                atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DestroyedWall(tilesetTable));
                return;
            }
            atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DamagedWall(usePickaxe.Damage, tilesetTable, Vector2I.Zero));
        }
예제 #49
0
        public void ObjectDetected(IGameObject gameObject, IAtlas atlas, ITilesetTable tilesetTable)
        {
            var avatar = gameObject as IAvatar;
            if (avatar != null)
            {
                avatar.Energy -= ENERGY_FOR_STEP_ON_TRAP;
            }

            var forwardMovable = gameObject as IForwardMovable;
            if (forwardMovable != null)
            {
                forwardMovable.ForwardSpeed = 0;
            }

            gameObject.Position = Vector2.Floor(gameObject.Position) + Vector2.One/2;

            var trapDischarged = new TrapDischarged(tilesetTable, Position);
            atlas.RegisterToAutoupdate(trapDischarged);
            atlas.ReplaceWith(new GameActorPosition(this, new Vector2(Position), LayerType.OnGroundInteractable),
                trapDischarged);
        }
예제 #50
0
 public void Update(IAtlas atlas, ITilesetTable table)
 {
     if (Heat < 0)
     {
         // first update - fire starts
         Heat = 0.2f;
         atlas.RegisterHeatSource(this);
         NextUpdateAfter = 60;
     }
     if (Heat >= MAX_HEAT && m_counter > 1000)
     {
         // fourth update - fire is extinguished.
         Heat = 0;
         NextUpdateAfter = 0;
         var fireplace = new Fireplace(table, Position);
         atlas.UnregisterHeatSource(this);
         atlas.ReplaceWith(ThisGameActorPosition(LayerType.OnGroundInteractable), fireplace);
         return;
     }
     if (Heat < MAX_HEAT)
     {
         // second update - fire is growing
         Heat += 0.4f;
     }
     if(Heat >= MAX_HEAT)
     {
         // third update - fire is stable
         IEnumerable<GameActorPosition> gameActorPositions = atlas.ActorsAt((Vector2) Position, LayerType.All);
         foreach (GameActorPosition gameActorPosition in gameActorPositions)
         {
             ICombustibleGameActor combustible = gameActorPosition.Actor as ICombustibleGameActor;
             if (combustible != null)
             {
                 combustible.Burn(gameActorPosition, atlas, table);
             }
         }
         m_counter++;
     }
 }
        public UnpredictableAtmosphere(IAtlas atlas)
        {
            m_atlas = atlas;
            m_heatSources = new List<IHeatSource>();
            m_oldTemperature = 1f;
            

            DateTime time = atlas.RealTime;
            bool getCold = time.Hour < 6 || time.Hour >= 18;
            if (getCold)
            {
                m_newDiff = -0.1f;
            }
            else
            {
                m_newDiff = 0.1f;
            }

            long cycles = time.Ticks / TICKS_IN_12_HOURS;
            m_prevCycleStart = new DateTime(cycles * TICKS_IN_12_HOURS - TICKS_IN_12_HOURS / 2);

        }
예제 #52
0
        public override void Resolve(GameActorPosition target, IAtlas atlas, ITilesetTable table)
        {
            ICanPickGameObject picker = Sender as ICanPickGameObject;
            ICharacter character = Sender as ICharacter;
            if (picker == null || character == null) return;
            Vector2 positionInFrontOf = target.Position;

            // solving case when positions where character should place tile collides with character's position
            if (target.Actor is Tile)
            {
                Tile tile = (target.Actor as Tile);
                IPhysicalEntity physicalEntity = tile.GetPhysicalEntity(new Vector2I(positionInFrontOf));
                bool collidesWithSource = physicalEntity.CollidesWith(character.PhysicalEntity);
                if (collidesWithSource)
                {
                    /*  <- change to //* to switch
                    // to the center of current tile
                    character.Position = Vector2.Floor(character.Position) + Vector2.One/2;
                    
                    /*/
                    // back WRT his direction
                    do
                    {
                        character.Position = Physics.Utils.Move(character.Position, character.Direction, -0.01f);
                    } while (physicalEntity.CollidesWith(character.PhysicalEntity));
                    // */
                }
            }

            GameActorPosition toLayDown = new GameActorPosition(target.Actor, positionInFrontOf, target.Layer);

            bool added = atlas.Add(toLayDown, true);
            if (added)
            {
                picker.RemoveFromInventory();
            }
        }
예제 #53
0
 public void Update(IAtlas atlas, ITilesetTable table)
 {
     atlas.Remove(new GameActorPosition(this, (Vector2)Position, LayerType.ObstacleInteractable));
 }
예제 #54
0
 public void Burn(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table)
 {
     atlas.Remove(gameActorPosition);
 }
예제 #55
0
 public void Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table)
 {
     Switchable = Switchable.Switch(null, atlas, table);
 }
예제 #56
0
 public void PickUp(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable)
 {
     gameAction.Resolve(new GameActorPosition(this, position, LayerType.OnGroundInteractable), atlas, tilesetTable);
 }
예제 #57
0
 public void ObjectDetected(IGameObject gameObject, IAtlas atlas, ITilesetTable tilesetTable)
 {
     if(SomeoneOnTile) return;
     NextUpdateAfter = 60;
     atlas.RegisterToAutoupdate(this);
 }
예제 #58
0
 public SimpleAtmosphere(IAtlas atlas)
 {
     m_atlas = atlas;
     m_heatSources = new List<IHeatSource>();
 }
예제 #59
0
 public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable)
 {
     gameAction.Resolve(new GameActorPosition(this, position, LayerType.ObstacleInteractable), atlas, tilesetTable);
 }