Ejemplo n.º 1
0
        public Vector3 GetWallPosition(TilePosition tilePosition, Tile currentTile)
        {
            Vector3     offset       = Vector3.Zero;
            const float scalarOffset = 0.25f;

            switch (tilePosition)
            {
            case TilePosition.North_TopLeft:
                offset = new Vector3(scalarOffset, scalarOffset, 1 - scalarOffset);
                break;

            case TilePosition.East_TopRight:
                offset = new Vector3(0, scalarOffset, 1 - scalarOffset);
                break;

            case TilePosition.South_BottomLeft:
                offset = new Vector3(scalarOffset, scalarOffset, 0);
                break;

            case TilePosition.West_BottomRight:
                offset = new Vector3(1 - scalarOffset, scalarOffset, scalarOffset);
                break;
            }

            return(currentTile.Position + offset);
        }
Ejemplo n.º 2
0
        private LogicGate InitLogicGates(ActuatorItemData gateActuator, Tile gateActuatorTile)
        {
            //if nextTarget tile is current tile do not call recurese
            Tile nextTargetTile = gateActuatorTile.GridPosition == ((RemoteTarget)gateActuator.ActionLocation).Position.Position.ToAbsolutePosition(CurrentMap) ? gateActuatorTile : GetTargetTile(gateActuator);

            return(new LogicGate(nextTargetTile, gateActuator.GetActionStateX(), gateActuatorTile.Position, (gateActuator.Data & 0x10) == 0x10, (gateActuator.Data & 0x20) == 0x20, (gateActuator.Data & 0x40) == 0x40, (gateActuator.Data & 0x80) == 0x80));
        }
Ejemplo n.º 3
0
        private CounterActuator InitCounters(ActuatorItemData gateActuator, Tile gateActuatorTile)
        {
            //if nextTarget tile is current tile do not call recurese
            Tile nextTargetTile = gateActuatorTile.GridPosition == ((RemoteTarget)gateActuator.ActionLocation).Position.Position.ToAbsolutePosition(CurrentMap) ? gateActuatorTile : GetTargetTile(gateActuator);

            return(new CounterActuator(nextTargetTile, gateActuator.GetActionStateX(), gateActuator.Data, gateActuatorTile.Position));
        }
Ejemplo n.º 4
0
        private void SetupFloorItems(Tile tile)
        {
            FloorActuatorCreator.CreateSetupActuators(tile);

            var itemCreator = new LegacyItemCreator(this);
            var tileData    = CurrentMap[tile.GridPosition.X, tile.GridPosition.Y];

            tileData.GrabableItems.ForEach(x => tile.SubItems.Add(itemCreator.CreateItem(x, tile)));

            //TODO creatures
            var creatureCreator = new CreatureCreator(this);

            foreach (var creatre in tileData.Creatures.Where(i => !i.Processed))
            {
                creatures.AddRange(creatureCreator.AddCreature(creatre, tile));
            }
        }
Ejemplo n.º 5
0
        public Tile GetTargetTile(ActuatorItemData callingActuator)
        {
            var targetPos = ((RemoteTarget)callingActuator.ActionLocation).Position.Position.ToAbsolutePosition(CurrentMap);

            Tile targetTile = null;

            if (TilesPositions.TryGetValue(targetPos, out targetTile))
            {
                return(targetTile);
            }
            else
            {
                //try find tile in raw data, and than actuator, add it to Tiles Positions
                var virtualTileData = CurrentMap[targetPos.X, targetPos.Y];
                if (virtualTileData.Actuators.Any()) //virtual tile will be proccessed at the and so any checking shouldnt be necessary
                {
                    var newTile = new LogicTile(targetPos.ToGridVector3(CurrentLevel));
                    newTile.Gates    = virtualTileData.Actuators.Where(x => x.ActuatorType == 5).Select(y => InitLogicGates(y, newTile)).ToArray(); //recurse
                    newTile.Counters = virtualTileData.Actuators.Where(x => x.ActuatorType == 6).Select(y => InitCounters(y, newTile)).ToArray();   //recurse

                    TilesPositions.Add(targetPos, targetTile = newTile);                                                                            //subitems will be processed
                }
                else if (virtualTileData.TextTags.Any())
                {
                    var textTag = virtualTileData.TextTags.Single();
                    textTag.HasTargetingActuator = true;
                    targetTile = TilesPositions[textTag.GetParentPosition(targetPos)];

                    if (textTag.Processed)
                    {
                        targetTile.SubItems.Single(x => x is TextTag).AcceptMessages = true;
                    }
                }

                return(targetTile); //TODO (if null)  think out what to do
                //Acutor at the begining references wall near by with tag only ... what to do ?
            }
        }
Ejemplo n.º 6
0
        public bool PrepareActuatorData(ActuatorItemData i, out Tile targetTile, out IConstrain constrain, out Texture2D decoration, bool putOnWall)
        {
            targetTile = GetTargetTile(i);
            constrain  = null;
            decoration = null;


            if (i.Data > 0)
            {
                constrain = new GrabableItemConstrain(GetItemFactory(i.Data), i.IsRevertable);
            }
            else
            {
                constrain = new NoConstrain();
            }

            if (i.IsLocal)
            {
                throw new NotSupportedException("yet");
            }
            decoration = GetTexture(i, putOnWall);

            return(true);
        }
Ejemplo n.º 7
0
        public bool PrepareActuatorData(ActuatorItemData i, out Tile targetTile, out IConstrain constrain, out Texture2D decoration, bool putOnWall)
        {
            targetTile = GetTargetTile(i);
            constrain = null;
            decoration = null;


            if (i.Data > 0)
                constrain = new GrabableItemConstrain(GetItemFactory(i.Data), i.IsRevertable);
            else
                constrain = new NoConstrain();

            if (i.IsLocal)
                throw new NotSupportedException("yet");
            decoration = GetTexture(i, putOnWall);

            return true;
        }
Ejemplo n.º 8
0
        public Vector3 GetWallPosition(TilePosition tilePosition, Tile currentTile)
        {
            Vector3 offset = Vector3.Zero;
            const float scalarOffset = 0.25f;
            switch (tilePosition)
            {
                case TilePosition.North_TopLeft:
                    offset = new Vector3(scalarOffset, scalarOffset, 1 - scalarOffset);
                    break;
                case TilePosition.East_TopRight:
                    offset = new Vector3(0, scalarOffset, 1 - scalarOffset);
                    break;
                case TilePosition.South_BottomLeft:
                    offset = new Vector3(scalarOffset, scalarOffset, 0);
                    break;
                case TilePosition.West_BottomRight:
                    offset = new Vector3(1 - scalarOffset, scalarOffset, scalarOffset);
                    break;
            }

            return currentTile.Position + offset;
        }
Ejemplo n.º 9
0
        private LogicGate InitLogicGates(ActuatorItemData gateActuator, Tile gateActuatorTile)
        {
            //if nextTarget tile is current tile do not call recurese
            Tile nextTargetTile = gateActuatorTile.GridPosition == ((RemoteTarget)gateActuator.ActionLocation).Position.Position.ToAbsolutePosition(CurrentMap) ? gateActuatorTile : GetTargetTile(gateActuator);

            return new LogicGate(nextTargetTile, gateActuator.GetActionStateX(), gateActuatorTile.Position, (gateActuator.Data & 0x10) == 0x10, (gateActuator.Data & 0x20) == 0x20, (gateActuator.Data & 0x40) == 0x40, (gateActuator.Data & 0x80) == 0x80);
        }
Ejemplo n.º 10
0
        private CounterActuator InitCounters(ActuatorItemData gateActuator, Tile gateActuatorTile)
        {
            //if nextTarget tile is current tile do not call recurese
            Tile nextTargetTile = gateActuatorTile.GridPosition == ((RemoteTarget)gateActuator.ActionLocation).Position.Position.ToAbsolutePosition(CurrentMap) ? gateActuatorTile : GetTargetTile(gateActuator);

            return new CounterActuator(nextTargetTile, gateActuator.GetActionStateX(), gateActuator.Data, gateActuatorTile.Position);
        }
Ejemplo n.º 11
0
        private void SetupFloorItems(Tile tile)
        {
            FloorActuatorCreator.CreateSetupActuators(tile);

            var itemCreator = new LegacyItemCreator(this);
            var tileData = CurrentMap[tile.GridPosition.X, tile.GridPosition.Y];
            tileData.GrabableItems.ForEach(x => tile.SubItems.Add(itemCreator.CreateItem(x, tile)));

            //TODO creatures
            var creatureCreator = new CreatureCreator(this);
            foreach (var creatre in tileData.Creatures.Where(i => !i.Processed))
                creatures.AddRange(creatureCreator.AddCreature(creatre, tile));
        }