示例#1
0
 private void Key_Up(object sender, KeyRoutedEventArgs e)
 {
     if (_ezb != null)
     {
         if (e.Key.ToString() == "W")
         {
             BotMove.reverse(move_vec, _ezb);
         }
         else if (e.Key.ToString() == "S")
         {
             BotMove.forward(move_vec, _ezb);
         }
         else if (e.Key.ToString() == "A")
         {
             BotMove.right(move_vec, _ezb);
         }
         else if (e.Key.ToString() == "D")
         {
             BotMove.left(move_vec, _ezb);
         }
         else if (e.Key.ToString() == "U")
         {
         }
         else if (e.Key.ToString() == "I")
         {
         }
         else if (e.Key.ToString() == "O")
         {
         }
         else if (e.Key.ToString() == "P")
         {
         }
     }
 }
示例#2
0
        private bool IsMoveValid(TankBlasterBot bot, BotMove move)
        {
            var newLocation = _locationService.GetNewLocation(bot.Location, move.Direction);

            return(_locationService.IsLocationValid(newLocation) && _field.Board[newLocation.X, newLocation.Y] == BoardTile.Empty &&
                   !_field.Bots.Any(blasterBot => blasterBot.Id != bot.Id && blasterBot.Location == newLocation));
        }
示例#3
0
        public BotMove PerformNextMove(SurroundingAreaInfo arenaInfo)
        {
            var nextMove = EnumValueHelper <AvailableActions> .RandomEnumValue();

            var result = new BotMove();

            result.Action = nextMove;
            switch (nextMove)
            {
            case AvailableActions.FireMissile:
            case AvailableActions.Move:
            {
                result.ActionDirection = EnumValueHelper <ActionDirections> .RandomEnumValue();

                break;
            }

            case AvailableActions.Watch:
            {
                result.ActionDirection = null;
                break;
            }
            }

            return(result);
        }
示例#4
0
 /*
  * Handler for Left Button
  */
 private void Left_Btn_Click(object sender, RoutedEventArgs e)
 {
     if (_ezb != null)
     {
         BotMove.left(move_vec, _ezb);
     }
 }
示例#5
0
 /*
  * Handler for Stop Button
  */
 private void Stop_Btn_Click(object sender, RoutedEventArgs e)
 {
     if (_ezb != null)
     {
         BotMove.stop(move_vec, _ezb);
     }
 }
示例#6
0
    void Start()
    {
        botTransform = target.GetComponent <Transform> ();
        botMove      = target.GetComponent <BotMove> ();

        colGenerator = FindObjectOfType <CollectibleGeneration> ();

        pool = PoolManager.instance;
        pool.CreatePool(tile, totalTiles);

        currentVoid = 0;
        maxVoid     = 3;

        pos = Vector3.zero;

        generators = FindObjectsOfType <ObjectGeneration> ();

        posX = botTransform.position.x - 3.0F;
        // create initiale stage
        for (int i = 0; i < totalTiles; i++)
        {
            pos.x = posX;
            // tile generation
            pool.SpawnObject(tile, pos);

            foreach (ObjectGeneration generator in generators)
            {
                generator.Generate(pos);
            }

            posX += 1F;
        }
        tileIndex = totalTiles - 1;
    }
        public BotMove CalculateNextMove(BotArenaInfo arenaInfo)
        {
            _field = arenaInfo;
            var result = new BotMove();

            if (_shouldDropBombs && _rand.Next(_bombDroppingFrequency) == 0)
            {
                result.Action = BotAction.DropBomb;
            }

            if (_shouldFireMissiles && _field.MissileAvailableIn == 0)
            {
                var fireDirections = _allMoveDirections.Where(direction =>
                {
                    var tempLocation = _field.BotLocation;
                    for (int i = 0; i < CurrentMissileBlastRadius + 1; i++)
                    {
                        tempLocation = AddDirectionMove(tempLocation, direction);
                        if (!IsLocationValid(tempLocation) || _field.Board[tempLocation.X, tempLocation.Y] != BoardTile.Empty)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }).ToList();

                if (fireDirections.Any())
                {
                    result.Action        = BotAction.FireMissile;
                    result.FireDirection = fireDirections.ElementAt(_rand.Next(fireDirections.Count()));
                }
            }

            if (IsInDangerZone(_field.BotLocation))
            {
                result.Action = BotAction.None;
            }

            var directions = _allMoveDirections.Where(direction => !IsInDangerZone(AddDirectionMove(_field.BotLocation, direction))).ToList();

            if (!directions.Any())
            {
                directions = _allMoveDirections;
            }
            result.Direction = result.Action == BotAction.FireMissile ? (MoveDirection?)null : directions[_rand.Next(directions.Count)];

            return(result);
        }
示例#8
0
        private RoundPartialHistory PerformMove(TankBlasterBot bot, BotMove move, int roundNumber)
        {
            var actionDescription = move.Direction != null ? "move " + move.Direction.Value : "stay";

            if (move.Action == BotAction.DropBomb)
            {
                _field.Bombs.Add(new Bomb
                {
                    Location            = bot.Location,
                    RoundsUntilExplodes = 5,
                    ExplosionRadius     = CurrentBombBlastRadius(roundNumber)
                });

                actionDescription += " & drop bomb";
            }

            bot.Location      = _locationService.GetNewLocation(bot.Location, move.Direction);
            bot.LastDirection = move.Direction ?? bot.LastDirection;

            if (move.Action == BotAction.FireMissile)
            {
                if (IsMissileAvailable(bot, roundNumber) && _locationService.IsLocationAvailableForMissile(_locationService.GetNewLocation(bot.Location, move.FireDirection)))
                {
                    bot.LastMissileFiredRound = roundNumber;
                    _field.Missiles.Add(new Missile
                    {
                        ExplosionRadius = CurrentMissileBlastRadius(roundNumber),
                        MoveDirection   = move.FireDirection,
                        Location        = _locationService.GetNewLocation(bot.Location, move.FireDirection)
                    });
                    actionDescription += " & fire " + move.FireDirection;
                }
                else
                {
                    actionDescription += " & can't fire " + move.FireDirection;
                }
            }

            return(new RoundPartialHistory
            {
                Caption = string.Format("Round {0} {1}: {2}", roundNumber, bot.Name, actionDescription),
                BoardState = _field.ExportState()
            });
        }
示例#9
0
        public async Task <RoundResult> PlayBotMovesAsync(int delayTime, int roundNumber)
        {
            var result = new RoundResult()
            {
                FinalResult = null,
                IsFinished  = false,
                History     = new List <RoundPartialHistory>()
            };

            int turnNumber = 0;

            foreach (var dynaBlasterBot in _field.Bots.Where(bot => !bot.IsDead))
            {
                BotMove move;
                try
                {
                    turnNumber++;
                    move = await dynaBlasterBot.NextMoveAsync(GetBotBattlefieldInfo(dynaBlasterBot, roundNumber, turnNumber));
                }
                catch (Exception e)
                {
                    move = new BotMove()
                    {
                        Action    = BotAction.None,
                        Direction = null
                    };

                    result.OutputText += string.Format("Bot {0} threw exception:\n{1}\n", dynaBlasterBot.Name, e.Message);
                }

                if (IsMoveValid(dynaBlasterBot, move))
                {
                    result.History.Add(PerformMove(dynaBlasterBot, move, roundNumber));
                    _field.OnArenaChanged();
                }

                await DelayHelper.DelayAsync(delayTime);
            }

            return(result);
        }
示例#10
0
        public static void LoadWiredItem(Item item, Room room, IQueryAdapter dbClient)
        {
            IWired handler = null;

            switch (item.GetBaseItem().InteractionType)
            {
                #region Trigger
            case InteractionType.triggertimer:
                handler = new Timer(item, room.GetWiredHandler(), 2, room.GetGameManager());
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggerroomenter:
                handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), false, string.Empty);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggercollision:
                handler = new Collision(item, room.GetWiredHandler(), room.GetRoomUserManager());
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggergameend:
                HandleItemLoad(new GameEnds(item, room.GetWiredHandler(), room.GetGameManager()), item);
                break;

            case InteractionType.triggergamestart:
                HandleItemLoad(new GameStarts(item, room.GetWiredHandler(), room.GetGameManager()), item);
                break;

            case InteractionType.triggerrepeater:
                handler = new Repeater(room.GetWiredHandler(), item, 0);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggerrepeaterlong:
                handler = new Repeaterlong(room.GetWiredHandler(), item, 0);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggeronusersay:
                handler = new UserSays(item, room.GetWiredHandler(), false, string.Empty, room);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggercommand:
                handler = new UserCommand(item, room.GetWiredHandler(), room);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_trg_bot_reached_avtr:
                handler = new BotReadchedAvatar(item, room.GetWiredHandler(), "");
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggercollisionuser:
                handler = new UserCollision(item, room.GetWiredHandler(), room);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggerscoreachieved:
                handler = new ScoreAchieved(item, room.GetWiredHandler(), 0, room.GetGameManager());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggerstatechanged:
                handler = new SateChanged(room.GetWiredHandler(), item, new List <Item>(), 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggerwalkonfurni:
                handler = new WalksOnFurni(item, room.GetWiredHandler(), new List <Item>(), 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggerwalkofffurni:
                handler = new WalksOffFurni(item, room.GetWiredHandler(), new List <Item>(), 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

                #endregion
                #region Action
            case InteractionType.actiongivescore:
                handler = new GiveScore(0, 0, room.GetGameManager(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_give_score_tm:
                handler = new GiveScoreTeam(0, 0, 0, room.GetGameManager(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionposreset:
                handler = new PositionReset(new List <Item>(), 0, room.GetRoomItemHandler(), room.GetWiredHandler(), item.Id, 0, 0, 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionmoverotate:
                handler = new MoveRotate(MovementState.none, RotationState.none, new List <Item>(), 0, room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionresettimer:
                handler = new TimerReset(room, room.GetWiredHandler(), 1, item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.highscore:
                handler = new HighScore(item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.highscorepoints:
                handler = new HighScorePoints(item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionshowmessage:
                handler = new ShowMessage(string.Empty, room.GetWiredHandler(), item.Id, 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actiongivereward:
                //handlergr = (IWiredTrigger) new GiveReward(string.Empty, room.GetWiredHandler(), item.Id);
                //handlergr.LoadFromDatabase(dbClient, room);
                //WiredLoader.HandleItemLoad(handlergr, item);
                break;

            case InteractionType.superwired:
                handler = new SuperWired(string.Empty, 0, false, false, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionteleportto:
                handler = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), new List <Item>(), 0, item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_endgame_team:
                handler = new TeamGameOver(1, item.Id, room);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actiontogglestate:
                handler = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), new List <Item>(), 0, item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_call_stacks:
                handler = new ExecutePile(new List <Item>(), 0, room.GetWiredHandler(), item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionkickuser:
                handler = new KickUser(string.Empty, room.GetWiredHandler(), item.Id, room);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionflee:
                handler = new Escape(new List <Item>(), room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionchase:
                handler = new Chase(new List <Item>(), room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.collisionteam:
                handler = new CollisionTeam(1, room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.collisioncase:
                handler = new CollisionCase(new List <Item>(), room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionmovetodir:
                handler = new MoveToDir(new List <Item>(), room, room.GetWiredHandler(), item.Id, MovementDirection.up, WhenMovementBlock.none);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_clothes:
                handler = new BotClothes("", "", room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_teleport:
                handler = new BotTeleport("", new List <Item>(), room.GetGameMap(), room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_follow_avatar:
                handler = new BotFollowAvatar("", false, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_give_handitem:
                handler = new BotGiveHanditem("", room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_move:
                handler = new BotMove("", new List <Item>(), room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_user_move:
                handler = new UserMove(new List <Item>(), 0, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_talk_to_avatar:
                handler = new BotTalkToAvatar("", "", false, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_talk:
                handler = new BotTalk("", "", false, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_leave_team:
                handler = new TeamLeave(item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_join_team:
                handler = new TeamJoin(1, item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

                #endregion
                #region Condition
            case InteractionType.superwiredcondition:
                handler = (IWiredCondition) new SuperWiredCondition(item, string.Empty, false);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionfurnishaveusers:
                handler = (IWiredCondition) new FurniHasUser(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionfurnishavenousers:
                handler = (IWiredCondition) new FurniHasNoUser(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionstatepos:
                handler = (IWiredCondition) new FurniStatePosMatch(item, new List <Item>(), 0, 0, 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_cnd_stuff_is:
                handler = (IWiredCondition) new FurniStuffIs(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_cnd_not_stuff_is:
                handler = (IWiredCondition) new FurniNotStuffIs(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionstateposNegative:
                handler = (IWiredCondition) new FurniStatePosMatchNegative(item, new List <Item>(), 0, 0, 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditiontimelessthan:
                handler = (IWiredCondition) new LessThanTimer(0, room, item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditiontimemorethan:
                handler = (IWiredCondition) new MoreThanTimer(0, room, item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditiontriggeronfurni:
                handler = (IWiredCondition) new TriggerUserIsOnFurni(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditiontriggeronfurniNegative:
                handler = (IWiredCondition) new TriggerUserIsOnFurniNegative(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionhasfurnionfurni:
                handler = (IWiredCondition) new HasFurniOnFurni(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionhasfurnionfurniNegative:
                handler = (IWiredCondition) new HasFurniOnFurniNegative(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionactoringroup:
                handler = (IWiredCondition) new HasUserInGroup(item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionnotingroup:
                handler = (IWiredCondition) new HasUserNotInGroup(item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_cnd_actor_in_team:
                handler = (IWiredCondition) new ActorInTeam(item.Id, 1);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_cnd_not_in_team:
                handler = (IWiredCondition) new ActorNotInTeam(item.Id, 1);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.wf_cnd_not_user_count:
                handler = (IWiredCondition) new RoomUserNotCount(item, 1, 1);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.wf_cnd_user_count_in:
                handler = (IWiredCondition) new RoomUserCount(item, 1, 1);
                handler.LoadFromDatabase(dbClient, room);
                break;
                #endregion
            }
            if (handler != null)
            {
                HandleItemLoad(handler, item);
            }
        }
示例#11
0
        internal static void HandleSave(GameClient Session, uint itemID, Room room, ClientMessage clientMessage)
        {
            if (room == null || room.GetRoomItemHandler() == null)
            {
                return;
            }

            var item = room.GetRoomItemHandler().GetItem(itemID);

            if (item == null)
            {
                return;
            }

            if (item.wiredHandler != null)
            {
                item.wiredHandler.Dispose();
                item.wiredHandler = null;
            }

            InteractorGenericSwitch.DoAnimation(item);

            var type = item.GetBaseItem().InteractionType;

            switch (type)
            {
                #region Causantes
            case InteractionType.triggeronusersay:
            {
                var junk        = clientMessage.PopWiredInt32();
                var isOnlyOwner = (clientMessage.PopWiredInt32() == 1);
                var message     = clientMessage.PopFixedString();

                IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), isOnlyOwner, message, room);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggerwalkonfurni:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);

                IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggerwalkofffurni:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);

                IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), items);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggergameend:
            {
                IWiredTrigger handler = new GameEnds(item, room.GetWiredHandler(), room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggergamestart:
            {
                IWiredTrigger handler = new GameStarts(item, room.GetWiredHandler(), room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggertimer:
            {
                var junk   = clientMessage.PopWiredInt32();
                var cycles = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerrepeater:
            {
                var junk       = clientMessage.PopWiredInt32();
                var cycleTimes = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerroomenter:
            {
                var junk  = clientMessage.PopWiredInt32();
                var users = clientMessage.PopFixedString();

                IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(users), users);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggerscoreachieved:
            {
                var junk  = clientMessage.PopWiredInt32();
                var score = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerstatechanged:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk3 = clientMessage.PopWiredBoolean();
                var junk2 = clientMessage.PopWiredBoolean();

                int furniAmount;
                var items = GetItems(clientMessage, room, out furniAmount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, items);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggercollision:
            {
                IWiredTrigger handler = new Collision(item, room.GetWiredHandler(), room.GetRoomUserManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggerlongperiodic:
            {
                var junk       = clientMessage.PopWiredInt32();
                var cycleTimes = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new LongRepeater(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerbotreachedavtr:
            {
                var junk    = clientMessage.PopWiredInt32();
                var botname = clientMessage.PopFixedString();

                IWiredTrigger handler = new BotAlcanzaUsuario(item, room.GetWiredHandler(), room.GetRoomUserManager(), botname);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerbotreachedstf:
            {
                var junk    = clientMessage.PopWiredInt32();
                var botname = clientMessage.PopFixedString();

                int furniAmount;
                var items = GetItems(clientMessage, room, out furniAmount);

                IWiredTrigger handler = new BotAlcanzaFurni(item, room.GetWiredHandler(), room.GetRoomUserManager(), items, botname);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }
                #endregion

                #region Efectos
            case InteractionType.actiongivescore:
            {
                var junk   = clientMessage.PopWiredInt32();
                var points = clientMessage.PopWiredInt32();
                var games  = clientMessage.PopWiredInt32();

                IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionposreset:
            {
                var junk = clientMessage.PopWiredInt32();

                var state     = clientMessage.PopWiredInt32();
                var direction = clientMessage.PopWiredInt32();
                var position  = clientMessage.PopWiredInt32();

                var junk3 = clientMessage.PopFixedString();

                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new PositionReset(items, delay, state + "," + direction + "," + position, new Dictionary <uint, OriginalItemLocation>(), room.GetRoomItemHandler(), room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionresettimer:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk3 = clientMessage.PopWiredBoolean();
                var junk2 = clientMessage.PopWiredBoolean();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionshowmessage:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());

                if (BlackWordsManager.Check(message, BlackWordType.Hotel, Session, "<WiredMensaje>"))
                {
                    message = "Mensaje bloqueado por el filtro bobba.";
                }

                IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionhandiitemcustom:
            {
                var  junk    = clientMessage.PopWiredInt32();
                var  message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());
                int  valorInteiro;
                bool inteiroCustom = int.TryParse(message, out valorInteiro);

                if (inteiroCustom)
                {
                    IWiredTrigger action = new HandiCustom(message, room.GetWiredHandler(), item);
                    HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                }
                else
                {
                    RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                    usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números.");
                }
                break;
            }

            case InteractionType.actioneffectcustom:
            {
                var  junk    = clientMessage.PopWiredInt32();
                var  message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());
                int  valorInteiro;
                bool inteiroCustom = int.TryParse(message, out valorInteiro);

                if (inteiroCustom)
                {
                    IWiredTrigger action = new EffectCustom(message, room.GetWiredHandler(), item);
                    HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                }
                else
                {
                    RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                    usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números.");
                }
                break;
            }

            case InteractionType.actiondiamantescustom:
            {
                var  junk    = clientMessage.PopWiredInt32();
                var  message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());
                int  valorInteiro;
                bool inteiroCustom = int.TryParse(message, out valorInteiro);

                if (inteiroCustom)
                {
                    IWiredTrigger action = new DiamantesCustom(message, room.GetWiredHandler(), item);
                    HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                    break;
                }
                else
                {
                    RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                    usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números e hífen (-).");
                }
                break;
            }

            case InteractionType.actiondancecustom:
            {
                var  junk    = clientMessage.PopWiredInt32();
                var  message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());
                int  valorInteiro;
                bool inteiroCustom = int.TryParse(message, out valorInteiro);

                if (inteiroCustom)
                {
                    IWiredTrigger action = new DanceCustom(message, room.GetWiredHandler(), item);
                    HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                }
                else
                {
                    RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                    usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números.");
                }
                break;
            }

            case InteractionType.actionfastwalk:
            {
                var junk       = clientMessage.PopWiredInt32();
                var cycleTimes = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new FastWalkCustom(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionfreezecustom:
            {
                var junk       = clientMessage.PopWiredInt32();
                var cycleTimes = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new FreezeCustom(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionteleportto:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk2 = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actiontogglestate:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new ToggleItemState(room.GetWiredHandler(), items, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionmoverotate:
            {
                var junk     = clientMessage.PopWiredInt32();
                var movement = (MovementState)clientMessage.PopWiredInt32();
                var rotation = (RotationState)clientMessage.PopWiredInt32();

                var junk3 = clientMessage.PopWiredBoolean();
                var junk2 = clientMessage.PopWiredBoolean();
                var items = GetItems(clientMessage, room, out int furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), item);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actiongivereward:
            {
                if (!Session.GetHabbo().HasFuse("fuse_wired_rewards"))
                {
                    Session.SendNotif("No tienes permitido usar este Wired.");
                    break;
                }

                var junk      = clientMessage.PopWiredInt32();
                var often     = clientMessage.PopWiredInt32();
                var unique    = clientMessage.PopWiredInt32();
                var limite    = clientMessage.PopWiredInt32();
                var nInt      = clientMessage.PopWiredInt32();
                var extrainfo = clientMessage.PopFixedString();

                #region Posible Bug?
                if (extrainfo.Contains(";"))
                {
                    foreach (var s in extrainfo.Split(';'))
                    {
                        if (s.StartsWith("1"))
                        {
                            string value = s.Split(',')[1];
                            if (!value.StartsWith("diamonds:") && !value.StartsWith("alert:"))
                            {
                                try { int.Parse(value); }
                                catch { Session.SendNotif("Has intentado poner un item inválido. Recuerda que debes poner el item_id."); return; }
                            }
                        }
                    }
                }
                else
                {
                    if (extrainfo.StartsWith("1"))
                    {
                        string value = extrainfo.Split(',')[1];
                        if (!value.StartsWith("diamonds:") && !value.StartsWith("alert:"))
                        {
                            try { int.Parse(value); }
                            catch { Session.SendNotif("Has intentado poner un item inválido. Recuerda que debes poner el item_id."); return; }
                        }
                    }
                }
                #endregion

                OtanixEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Username, "", "WiredReward", "Wired Id: " + item.Id + ", RoomId: " + item.RoomId + ".");

                IWiredTrigger action = new GiveReward(extrainfo, limite, often, unique, nInt, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionchase:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk2 = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new Chase(items, delay, room, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionkickuser:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();

                IWiredTrigger action = new KickUser(message, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionescape:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk2 = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new Escape(items, delay, room, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionjointoteam:
            {
                var junk   = clientMessage.PopWiredInt32();
                var teamid = (Team)clientMessage.PopWiredInt32();

                IWiredTrigger action = new JoinToTeam(room.GetWiredHandler(), item, teamid);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionleaveteam:
            {
                IWiredTrigger action = new LeaveTeam(room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actiongiveteamscore:
            {
                var junk   = clientMessage.PopWiredInt32();
                var points = clientMessage.PopWiredInt32();
                var games  = clientMessage.PopWiredInt32();
                var teamid = (Team)clientMessage.PopWiredInt32();

                IWiredTrigger action = new GiveTeamScore(games, points, teamid, room.GetGameManager(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actioncallstacks:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk2 = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new CallStacks(items, room, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionmovetodir:
            {
                var junk     = clientMessage.PopWiredInt32();
                var movement = (MovementDirection)clientMessage.PopWiredInt32();
                var rotation = (WhenMovementBlock)clientMessage.PopWiredInt32();

                var junk3 = clientMessage.PopWiredBoolean();
                var junk2 = clientMessage.PopWiredBoolean();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new MoveToDir(items, movement, rotation, room, room.GetWiredHandler(), item);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotmove:
            {
                var junk    = clientMessage.PopWiredInt32();
                var botName = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotMove(item.Id, room, room.GetWiredHandler(), botName, items, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotwhisper:
            {
                var    junk          = clientMessage.PopWiredInt32();
                bool   talkorwhisper = clientMessage.PopWiredInt32() == 1;
                string message       = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);

                IWiredTrigger action = new BotTalkToUser(item.Id, room, room.GetWiredHandler(), message, talkorwhisper);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotteleport:
            {
                var junk    = clientMessage.PopWiredInt32();
                var botName = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotTeleport(item.Id, room, room.GetWiredHandler(), botName, items, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotclothes:
            {
                int    junk    = clientMessage.PopWiredInt32();
                string message = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotChangeLook(item.Id, room, room.GetWiredHandler(), message, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbottalk:
            {
                var    junk        = clientMessage.PopWiredInt32();
                bool   talkorshout = clientMessage.PopWiredInt32() == 1;
                string message     = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotTalkToAll(item.Id, room, room.GetWiredHandler(), message, talkorshout, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbothanditem:
            {
                var    junk     = clientMessage.PopWiredInt32();
                int    handitem = clientMessage.PopWiredInt32();
                string botname  = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotGiveHandItem(item.Id, room, room.GetWiredHandler(), botname, handitem, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotfollowavt:
            {
                var    junk         = clientMessage.PopWiredInt32();
                bool   followorstop = clientMessage.PopWiredInt32() == 1;
                string botname      = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotFollowUser(item.Id, room, room.GetWiredHandler(), botname, followorstop, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionmutetriggerer:
            {
                var    junk      = clientMessage.PopWiredInt32();
                uint   mutetimer = clientMessage.PopWiredUInt();
                string botname   = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new MuteTriggerer(room.GetWiredHandler(), botname, mutetimer, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionmovetofurni:
            {
                var junk      = clientMessage.PopWiredInt32();
                int direction = clientMessage.PopWiredInt32();
                int length    = clientMessage.PopWiredInt32();
                clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new MoveToFurni(room.GetWiredHandler(), items, length, direction, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }
                #endregion
            }
            Session.SendMessage(new ServerMessage(Outgoing.SaveWired));
        }
示例#12
0
        internal static void LoadWiredItem(RoomItem item, Room room, IQueryAdapter dbClient)
        {
            WiredLoaderSQL wired = new WiredLoaderSQL(item, room, dbClient);

            switch (item.GetBaseItem().InteractionType)
            {
                #region Cargar Causantes
            case InteractionType.triggerroomenter:
            {
                IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(wired.StringSettings[0]), wired.StringSettings[0]);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerwalkonfurni:
            {
                IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), wired.wiredItems);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerwalkofffurni:
            {
                IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), wired.wiredItems);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggergameend:
            {
                IWiredTrigger handler = new GameEnds(item, room.GetWiredHandler(), room.GetGameManager());
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggergamestart:
            {
                IWiredTrigger handler = new GameStarts(item, room.GetWiredHandler(), room.GetGameManager());
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggertimer:
            {
                int time = 50;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), time, room.GetGameManager());
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerrepeater:
            {
                int time = 50;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, time);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggeronusersay:
            {
                IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), ((wired.StringSettings[2] == "true") ? true : false), wired.StringSettings[0], room);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerscoreachieved:
            {
                int score = 0;
                int.TryParse(wired.StringSettings[0], out score);

                IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerstatechanged:
            {
                IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, wired.wiredItems);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggercollision:
            {
                IWiredTrigger handler = new Collision(item, room.GetWiredHandler(), room.GetRoomUserManager());
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerlongperiodic:
            {
                int time = 10;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger handler = new LongRepeater(room.GetWiredHandler(), item, time);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerbotreachedavtr:
            {
                IWiredTrigger handler = new BotAlcanzaUsuario(item, room.GetWiredHandler(), room.GetRoomUserManager(), wired.StringSettings[0]);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerbotreachedstf:
            {
                IWiredTrigger handler = new BotAlcanzaFurni(item, room.GetWiredHandler(), room.GetRoomUserManager(), wired.wiredItems, wired.StringSettings[0]);
                HandleItemLoad(handler, item);
                break;
            }
                #endregion

                #region Cargar Efectos
            case InteractionType.actiongivescore:
            {
                int maxCountPerGame = 1;
                int.TryParse(wired.StringSettings[1], out maxCountPerGame);
                int scoreToGive = 10;
                int.TryParse(wired.StringSettings[0], out scoreToGive);

                IWiredTrigger action = new GiveScore(maxCountPerGame, scoreToGive, room.GetGameManager(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionposreset:
            {
                int time = 5;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new PositionReset(wired.wiredItems, time, wired.StringSettings[1], wired.originalPositionList, room.GetRoomItemHandler(), room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionresettimer:
            {
                int time = 5;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), time, item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionshowmessage:
            {
                IWiredTrigger action = new ShowMessage(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionhandiitemcustom:
            {
                IWiredTrigger action = new HandiCustom(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actioneffectcustom:
            {
                IWiredTrigger action = new EffectCustom(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiondiamantescustom:
            {
                IWiredTrigger action = new DiamantesCustom(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiondancecustom:
            {
                IWiredTrigger action = new DanceCustom(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionfastwalk:
            {
                int time = 2;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new FastWalkCustom(room.GetWiredHandler(), item, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionfreezecustom:
            {
                int time = 2;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new FreezeCustom(room.GetWiredHandler(), item, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionteleportto:
            {
                IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), wired.wiredItems, 0, item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiontogglestate:
            {
                int time = 5;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new ToggleItemState(room.GetWiredHandler(), wired.wiredItems, time, item);

                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionmoverotate:
            {
                int time = 5;
                int.TryParse(wired.StringSettings[0], out time);

                Console.WriteLine(wired.StringSettings[0]);
                Console.WriteLine(wired.StringSettings[1]);
                int movementInt = 0;
                int rotationInt = 0;
                if (wired.StringSettings[1].Length > 0 && wired.StringSettings[1].Contains(","))
                {
                    int.TryParse(wired.StringSettings[1].Split(',')[0], out movementInt);
                    int.TryParse(wired.StringSettings[1].Split(',')[1], out rotationInt);
                }

                IWiredTrigger action = new MoveRotate((MovementState)Convert.ToInt32(movementInt), (RotationState)Convert.ToInt32(rotationInt), wired.wiredItems, time, room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiongivereward:
            {
                int Amount   = 0;
                int Type     = 0;
                int AllUsers = 0;
                int nInt     = 1;

                if (wired.StringSettings[1].Length > 0 && wired.StringSettings[1].Contains(",") && wired.StringSettings[1].Split(',').Length >= 4)
                {
                    int.TryParse(wired.StringSettings[1].Split(',')[0], out Amount);
                    int.TryParse(wired.StringSettings[1].Split(',')[1], out Type);
                    int.TryParse(wired.StringSettings[1].Split(',')[2], out AllUsers);
                    int.TryParse(wired.StringSettings[1].Split(',')[3], out nInt);
                }

                IWiredTrigger action = new GiveReward(wired.StringSettings[0], Amount, Type, AllUsers, nInt, item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionchase:
            {
                IWiredTrigger action = new Chase(wired.wiredItems, 0, room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionkickuser:
            {
                IWiredTrigger action = new KickUser(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionescape:
            {
                IWiredTrigger action = new Escape(wired.wiredItems, 0, room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionjointoteam:
            {
                int teamid = 1;
                int.TryParse(wired.StringSettings[0], out teamid);

                IWiredTrigger action = new JoinToTeam(room.GetWiredHandler(), item, (Team)teamid);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionleaveteam:
            {
                IWiredTrigger action = new LeaveTeam(room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiongiveteamscore:
            {
                int maxCountPerGame = 1;
                int scoreToGive     = 10;
                if (wired.StringSettings[0].Contains(","))
                {
                    int.TryParse(wired.StringSettings[0].Split(',')[1], out maxCountPerGame);
                    int.TryParse(wired.StringSettings[0].Split(',')[0], out scoreToGive);
                }

                int teamid = 1;
                int.TryParse(wired.StringSettings[1], out teamid);

                IWiredTrigger action = new GiveTeamScore(maxCountPerGame, scoreToGive, (Team)teamid, room.GetGameManager(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actioncallstacks:
            {
                IWiredTrigger action = new CallStacks(wired.wiredItems, room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionmovetodir:
            {
                int movementInt = 0;
                int rotationInt = 0;
                int.TryParse(wired.StringSettings[0], out movementInt);
                int.TryParse(wired.StringSettings[1], out rotationInt);

                IWiredTrigger action = new MoveToDir(wired.wiredItems, (MovementDirection)Convert.ToInt32(movementInt), (WhenMovementBlock)Convert.ToInt32(rotationInt), room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotmove:
            {
                string botName = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[1], out time);

                IWiredTrigger action = new BotMove(item.Id, room, room.GetWiredHandler(), botName, wired.wiredItems, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotwhisper:
            {
                string message = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[1], out time);

                bool talkorwhisper = wired.StringSettings[2].ToLower() == "true";

                IWiredTrigger action = new BotTalkToUser(item.Id, room, room.GetWiredHandler(), message, talkorwhisper);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotteleport:
            {
                string message = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[1], out time);

                IWiredTrigger action = new BotTeleport(item.Id, room, room.GetWiredHandler(), message, wired.wiredItems, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotclothes:
            {
                string message = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[2], out time);

                IWiredTrigger action = new BotChangeLook(item.Id, room, room.GetWiredHandler(), message, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbottalk:
            {
                string message = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[1], out time);

                bool talkorwhisper = wired.StringSettings[2].ToLower() == "true";

                IWiredTrigger action = new BotTalkToAll(item.Id, room, room.GetWiredHandler(), message, talkorwhisper, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbothanditem:
            {
                string message = wired.StringSettings[0];

                int handitem = 0;
                int.TryParse(wired.StringSettings[1], out handitem);

                uint time = 5;
                uint.TryParse(wired.StringSettings[2], out time);

                IWiredTrigger action = new BotGiveHandItem(item.Id, room, room.GetWiredHandler(), message, handitem, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotfollowavt:
            {
                string botname = wired.StringSettings[0];

                uint time = 0;
                uint.TryParse(wired.StringSettings[1], out time);

                bool followorstop = wired.StringSettings[2].ToLower() == "true";

                IWiredTrigger action = new BotFollowUser(item.Id, room, room.GetWiredHandler(), botname, followorstop, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionmutetriggerer:
            {
                string botname = wired.StringSettings[0];

                uint mutetimer = 0;
                uint.TryParse(wired.StringSettings[1], out mutetimer);

                uint time = 0;
                uint.TryParse(wired.StringSettings[2], out time);

                IWiredTrigger action = new MuteTriggerer(room.GetWiredHandler(), botname, mutetimer, time, item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionmovetofurni:
            {
                int length = 0;
                int.TryParse(wired.StringSettings[0], out length);

                int direction = 0;
                int.TryParse(wired.StringSettings[1], out direction);

                int time = 0;
                int.TryParse(wired.StringSettings[2], out time);

                IWiredTrigger action = new MoveToFurni(room.GetWiredHandler(), wired.wiredItems, length, direction, time, item);
                HandleItemLoad(action, item);
                break;
            }
                #endregion

                #region Condiciones
            case InteractionType.conditionfurnishaveusers:
            {
                IWiredCondition furniHasUsers = new FurniHasUsers(item, wired.wiredItems);
                HandleConditionLoad(furniHasUsers, item, room);
                break;
            }

            case InteractionType.conditionhasfurnion:
            {
                int hasfurni = 0;
                int.TryParse(wired.StringSettings[0], out hasfurni);

                IWiredCondition furniHasFurni = new FurniHasFurni(item, wired.wiredItems, hasfurni);
                HandleConditionLoad(furniHasFurni, item, room);
                break;
            }

            case InteractionType.conditiontriggeronfurni:
            {
                IWiredCondition triggerUserIsOnFurni = new TriggerUserIsOnFurni(item, wired.wiredItems);
                HandleConditionLoad(triggerUserIsOnFurni, item, room);
                break;
            }

            case InteractionType.conditionstatepos:
            {
                IWiredCondition furnistatepos = new FurniStatePosMatch(item, wired.wiredItems, wired.StringSettings[0], wired.originalPositionList);
                HandleConditionLoad(furnistatepos, item, room);
                break;
            }

            case InteractionType.conditiontimelessthan:
            {
                int time = 18;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredCondition timeLessThan = new LessThanTimer(time, room, item);
                HandleConditionLoad(timeLessThan, item, room);
                break;
            }

            case InteractionType.conditiontimemorethan:
            {
                int time = 18;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredCondition timeMoreThan = new MoreThanTimer(time, room, item);
                HandleConditionLoad(timeMoreThan, item, room);
                break;
            }

            case InteractionType.conditionactoringroup:
            {
                IWiredCondition actionInGroup = new ActorInGroup(room.RoomData.GroupId, item);
                HandleConditionLoad(actionInGroup, item, room);
                break;
            }

            case InteractionType.conditionactorinteam:
            {
                int teamid = 1;
                int.TryParse(wired.StringSettings[0], out teamid);

                IWiredCondition actionInGroup = new ActorInTeam((Team)teamid, item);
                HandleConditionLoad(actionInGroup, item, room);
                break;
            }

            case InteractionType.conditionusercountin:
            {
                uint minUsers = 1;
                uint.TryParse(wired.StringSettings[0], out minUsers);

                uint maxUsers = 50;
                uint.TryParse(wired.StringSettings[1], out maxUsers);

                IWiredCondition userCountIn = new UserCountIn(minUsers, maxUsers, item);
                HandleConditionLoad(userCountIn, item, room);
                break;
            }

            case InteractionType.conditionstuffis:
            {
                IWiredCondition struffIn = new StuffIs(item, wired.wiredItems);
                HandleConditionLoad(struffIn, item, room);
                break;
            }

            case InteractionType.conditionhandleitemid:
            {
                int handleId = 18;
                int.TryParse(wired.StringSettings[0], out handleId);

                IWiredCondition handleItem = new HandleItemUser(handleId, item);
                HandleConditionLoad(handleItem, item, room);
                break;
            }

            case InteractionType.conditionnotfurnishaveusers:
            {
                IWiredCondition furniHasUsers = new NotFurniHasUsers(item, wired.wiredItems);
                HandleConditionLoad(furniHasUsers, item, room);
                break;
            }

            case InteractionType.conditionnotfurnion:
            {
                int hasfurni = 0;
                int.TryParse(wired.StringSettings[0], out hasfurni);

                IWiredCondition furniHasFurni = new NotFurniHasFurni(item, wired.wiredItems, hasfurni);
                HandleConditionLoad(furniHasFurni, item, room);
                break;
            }

            case InteractionType.conditionnottriggeronfurni:
            {
                IWiredCondition triggerUserIsOnFurni = new NotTriggerUserIsOnFurni(item, wired.wiredItems);
                HandleConditionLoad(triggerUserIsOnFurni, item, room);
                break;
            }

            case InteractionType.conditionnotstatepos:
            {
                IWiredCondition furnistatepos = new NotFurniStatePosMatch(item, wired.wiredItems, wired.StringSettings[0], wired.originalPositionList);
                HandleConditionLoad(furnistatepos, item, room);
                break;
            }

            case InteractionType.conditionnotingroup:
            {
                IWiredCondition actionInGroup = new NotActorInGroup(room.RoomData.GroupId, item);
                HandleConditionLoad(actionInGroup, item, room);
                break;
            }

            case InteractionType.conditionnotinteam:
            {
                int teamid = 1;
                int.TryParse(wired.StringSettings[0], out teamid);

                IWiredCondition actionInGroup = new NotActorInTeam((Team)teamid, item);
                HandleConditionLoad(actionInGroup, item, room);
                break;
            }

            case InteractionType.conditionnotusercount:
            {
                uint minUsers = 1;
                uint.TryParse(wired.StringSettings[0], out minUsers);

                uint maxUsers = 50;
                uint.TryParse(wired.StringSettings[1], out maxUsers);

                IWiredCondition userCountIn = new NotUserCountIn(minUsers, maxUsers, item);
                HandleConditionLoad(userCountIn, item, room);
                break;
            }

            case InteractionType.conditionnotstuffis:
            {
                IWiredCondition struffIn = new NotStuffIs(item, wired.wiredItems);
                HandleConditionLoad(struffIn, item, room);
                break;
            }

            case InteractionType.conditionwearingeffect:
            {
                uint effect = 0;
                uint.TryParse(wired.StringSettings[0], out effect);

                IWiredCondition wearingEffect = new UserWearingEffect(effect, item);
                HandleConditionLoad(wearingEffect, item, room);
                break;
            }

            case InteractionType.conditionnotwearingeffect:
            {
                uint effect = 0;
                uint.TryParse(wired.StringSettings[0], out effect);

                IWiredCondition notWearingEffect = new UserNotWearingEffect(effect, item);
                HandleConditionLoad(notWearingEffect, item, room);
                break;
            }

            case InteractionType.conditionwearingbadge:
            {
                string badge = wired.StringSettings[0];

                IWiredCondition wearingBadge = new UserWearingBadge(badge, item);
                HandleConditionLoad(wearingBadge, item, room);
                break;
            }

            case InteractionType.conditionnotwearingbadge:
            {
                string badge = wired.StringSettings[0];

                IWiredCondition notWearingBadge = new UserNotWearingBadge(badge, item);
                HandleConditionLoad(notWearingBadge, item, room);
                break;
            }

            case InteractionType.conditiondaterange:
            {
                int startDate = 0;
                int.TryParse(wired.StringSettings[0], out startDate);

                int endDate = 0;
                int.TryParse(wired.StringSettings[1], out endDate);

                IWiredCondition dateRangeActive = new DateRangeActive(startDate, endDate, item);
                HandleConditionLoad(dateRangeActive, item, room);
                break;
            }
                #endregion
            }
        }
示例#13
0
 void Start()
 {
     GameObject.FindGameObjectWithTag(managerTag).GetComponentInChildren <BotPlayerManager>().AddToTeam(this);
     BotMove = GetComponent <BotMove>();
 }
示例#14
0
        private async void Key_Down(object sender, KeyRoutedEventArgs e)
        {
            int servo_speed = 5;

            if (_ezb != null)
            {
                if (e.Key.ToString() == "W")
                {
                    BotMove.forward(move_vec, _ezb);
                }
                else if (e.Key.ToString() == "S")
                {
                    BotMove.reverse(move_vec, _ezb);
                }
                else if (e.Key.ToString() == "A")
                {
                    BotMove.left(move_vec, _ezb);
                }
                else if (e.Key.ToString() == "D")
                {
                    BotMove.right(move_vec, _ezb);
                }
                else if (e.Key.ToString() == "U") //open LEFT
                {
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D12, EZ_B.Servo.SERVO_MIN, 0);
                }
                else if (e.Key.ToString() == "I")  //close LEFT
                {
                    //left claw
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D12, EZ_B.Servo.SERVO_CENTER, 0);
                }
                else if (e.Key.ToString() == "O") //close RIGHT
                {
                    //right claw
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D16, EZ_B.Servo.SERVO_CENTER, 0);
                }
                else if (e.Key.ToString() == "P")  //open RIGHT
                {
                    //grab using right hand
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D16, EZ_B.Servo.SERVO_MIN, 0);
                }

                // neck nod movement
                else if (e.Key.ToString() == "J") //move neck to top pos
                {
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D9, 150, 3);
                }

                else if (e.Key.ToString() == "K") //move neck to center
                {
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D9, EZ_B.Servo.SERVO_CENTER, 3);
                }
                else if (e.Key.ToString() == "L") //move neck to down pos
                {
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D9, 30, 3);
                }

                //neck swivel movement
                else if (e.Key.ToString() == "Z") // move neck swivel left
                {
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D10, 150, servo_speed);
                }
                else if (e.Key.ToString() == "X") // move neck swivel center
                {
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D10, EZ_B.Servo.SERVO_CENTER, servo_speed);
                }
                else if (e.Key.ToString() == "C") // move neck swivel right
                {
                    await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D10, 30, servo_speed);
                }
            }
        }