예제 #1
0
        internal void RequestStackHandle(Point coordinate, RoomItem item, RoomUser user, Team team)
        {
            List <RoomItem> items = null;

            if (actionStacks.ContainsKey(coordinate) && conditionHandler.AllowsHandling(coordinate, user))
            {
                items = (List <RoomItem>)actionStacks[coordinate];

                foreach (RoomItem stackItem in items)
                {
                    if (stackItem.wiredHandler is IWiredEffect)
                    {
                        ((IWiredEffect)stackItem.wiredHandler).Handle(user, team, item);
                    }
                }

                bool shouldBeHandled = false;

                CheckHandlingState(ref shouldBeHandled, new Point(coordinate.X, coordinate.Y + 1));
                CheckHandlingState(ref shouldBeHandled, new Point(coordinate.X + 1, coordinate.Y));
                CheckHandlingState(ref shouldBeHandled, new Point(coordinate.X, coordinate.Y - 1));
                CheckHandlingState(ref shouldBeHandled, new Point(coordinate.X - 1, coordinate.Y));

                if (shouldBeHandled)
                {
                    room.GetWiredHandler().TriggerOnWire(coordinate);
                }
            }
        }
예제 #2
0
        internal bool RequestStackHandle(RoomItem trigger, RoomItem item, RoomUser user, Team team)
        {
            try
            {
                bool ExecutedTrigger = false;
                if (!room.IsRoomLoaded) // así evitamos que cuando iniciamos la sala, el condición tarda 1 cyclo más en iniciarse, y por lo tanto no funcionan en 0.5 s.
                {
                    return(false);
                }

                Point coordinate = trigger.Coordinate;

                if (MultipleTriggersOnTile(trigger))
                {
                    return(false);
                }

                if (actionStacks.ContainsKey(coordinate) && conditionHandler.AllowsHandling(coordinate, user))
                {
                    List <RoomItem> items = (List <RoomItem>)actionStacks[coordinate];
                    if (complementItems.ContainsKey(coordinate) && items.Count > 0)
                    {
                        List <RoomItem> complements = (List <RoomItem>)complementItems[coordinate];
                        foreach (RoomItem complement in complements)
                        {
                            if (complement.GetBaseItem().InteractionType == InteractionType.specialrandom)
                            {
Refaz:
                                RoomItem stackItem = items[new Random().Next(0, items.Count)];
                                var effect = stackItem.wiredHandler as IWiredEffect;
                                if (effect != null)
                                {
                                    effect.Handle(user, team, item);
                                    ExecutedTrigger = true;
                                }
                                else
                                {
                                    goto Refaz;
                                }
                            }
                            else if (complement.GetBaseItem().InteractionType == InteractionType.specialunseen)
                            {
                                IWiredEffect effect = getUnseenedItem(coordinate);
                                if (effect != null)
                                {
                                    effect.Handle(user, team, item);
                                    ExecutedTrigger = true;
                                }
                            }
                        }
                    }
                    else if (items.Count > 0)
                    {
                        foreach (var stackItem in items)
                        {
                            if (!AreWiredsCompatible(trigger.GetBaseItem().InteractionType, stackItem.GetBaseItem().InteractionType))
                            {
                                continue;
                            }

                            if (stackItem.GetBaseItem().InteractionType == InteractionType.actionteleportto)
                            {
                                IWiredEffect effect2 = getRandomTeleport(coordinate);
                                if (effect2 != null)
                                {
                                    effect2.Handle(user, team, item);
                                    ExecutedTrigger = true;
                                }
                            }
                            else
                            {
                                var effect = stackItem.wiredHandler as IWiredEffect;
                                if (effect != null)
                                {
                                    effect.Handle(user, team, item);
                                    ExecutedTrigger = true;
                                }
                            }
                        }
                    }
                }

                return(ExecutedTrigger);
            }
            catch { return(false); }
        }