Ejemplo n.º 1
0
        public override void ActivateContent(LogicTile t)
        {
            foreach (var gate in t.Gates)
            {
                switch (BitAction)
                {
                    case ActionState.Clear:
                        gate[BitIndex] = false;
                        break;
                    case ActionState.Set:
                        gate[BitIndex] = true;
                        break;
                    case ActionState.Toggle:
                        gate[BitIndex] ^= true;
                        break;
                    case ActionState.Hold:
                        throw new InvalidOperationException();
                }
            }

            foreach (var counter in t.Counters)
            {
                switch (BitAction)
                {
                    case ActionState.Set:
                        counter.Increase();
                        break;
                    case ActionState.Clear:
                    case ActionState.Toggle:
                        counter.Decrease();
                        break;
                    case ActionState.Hold:
                        throw new InvalidOperationException();
                }
            }
        }
Ejemplo n.º 2
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 ? 
            }
        }