示例#1
0
文件: Bot.cs 项目: shengaevdf/DFBot
        public int ServerSelection(string message)
        {
            if (message.StartsWith(PrefixMessage.ServerSelection.ServersInfo))
            {
                SelectServer();
            }
            else if (message.StartsWith(PrefixMessage.ServerSelection.SelectServer))
            {
                var ip = SeverIPDecrypt.Decrypt(message);
                //Switch socket
                Socket.ReconnectTo(ip);

                //Store in the cache the value for the next step
                Cache.Add(PrefixMessage.ServerSelection.SelectServer, message.Substring(14, 7));
            }
            else if (message.StartsWith(PrefixMessage.ServerSelection.SwitchSocketOk))
            {
                Socket.Send(PrefixMessage.ServerSelection.ServerIdentification + Cache[PrefixMessage.ServerSelection.SelectServer] + CharNewLine + CharNull);
            }
            else if (message.StartsWith(PrefixMessage.ServerSelection.ServerIdentification))
            {
                Socket.Send("Ai07ZMr3g5oEkTN0" + CharNewLine + CharNull + "AL" + CharNewLine + CharNull + "Af" + CharNewLine + CharNull);
            }
            else if (message.StartsWith(PrefixMessage.ServerSelection.PlaceQueue))
            {
                string place = message.Remove(0, PrefixMessage.ServerSelection.PlaceQueue.Length);
                Program.log.Info("Place in the queue: " + place);

                //If pace in the queue change
                if (!Cache.ContainsKey("place") || Cache["place"] != place)
                {
                    Cache["delay"] = ((Int32)1000).ToString();
                    //Caching the place
                    Cache["place"] = place;
                }
                else
                {
                    Cache["delay"] = (Int32.Parse(Cache["delay"]) * 2).ToString();
                }


                Thread.Sleep(Int32.Parse(Cache["delay"]));

                Socket.Send("Af" + CharNewLine + CharNull);
            }
            else if (message.StartsWith(PrefixMessage.CharacterSelection.PersoInfo))
            {
                State = new CharacterSelectionState(this);
                PersoSelection(message);
            }
            return(0);
        }
示例#2
0
    public void ClickOnField(Vector3 hit)
    {
        if(isCharacterSelected)
        {
            Cell cell = board.GetCellByLocation (hit);
            if (board.IsInsideHighlighted (cell))
            {
                switch(selectionState)
                {
                case CharacterSelectionState.None:
                break;
                case CharacterSelectionState.Moving:
                    MainGameInstance.SetPlayerAction(new PlayerAction(PlayerAction.Actions.Move, CurrentSelectedChar, cell, CurrentSelectedChar.LastTargetCell));
                    if ((CurrentSelectedChar.targetCount == 1 && CurrentSelectedChar.IsSprinting))
                    {
                        board.HighlightAdjacent (x=> !x.bOccupied && x !=null && x.type!=Cell.CellType.OutOfBounds, cell.Location, CurrentSelectedChar.MoveDistance);

                    }
                    else {
                        board.TurnOffHiglightedAdjacent();
                        selectionState = CharacterSelectionState.None;
                    }
                break;
                case CharacterSelectionState.Passing:
                    CreatePlayerMeter (cell.Location, PlayerAction.Actions.Pass);
                break;
                case CharacterSelectionState.Shooting:
                    CreatePlayerMeter (cell.Location, PlayerAction.Actions.Shoot);
                break;
                case CharacterSelectionState.Tackling:
                    ActionClick(cell, PlayerAction.Actions.Tackle);
                break;
                }
        //				if (isPassing)
        //				{
        //					CreatePlayerMeter (cell.Location, PlayerAction.Actions.Pass);
        //				} else if (isMoving)
        //				{
        //					MovementClick (cell);
        //				} else if (isShooting)
        //				{
        //					CreatePlayerMeter (cell.Location, PlayerAction.Actions.Shoot);
        //				}
        //				else if (isTackling)
        //				{
        //					ActionClick (cell, PlayerAction.Actions.Tackle);
        //				}
            }
        }
    }
示例#3
0
        protected override void LoadContent()
        {
            Library.Player tempPlayer = new Library.Player
            {
                Type = Library.Player.ClassType.Wizard
            };
            networkManager = new NetworkManager(tempPlayer);
            playerManager  = new PlayerManager(networkManager);

            spriteBatch = new SpriteBatch(GraphicsDevice);
            AssetManager.LoadTextures(Content);


            mainMenu           = new MainMenuState(Window);
            characterSelection = new CharacterSelectionState(Window, networkManager);
            lobby    = new LobbyState(Window, networkManager, ref player, playerManager);
            gameOver = new WinState(Window);
        }
示例#4
0
    void CreateButtonPanel(Vector3 cellLocation)
    {
        Vector3 loc = Camera.main.WorldToScreenPoint(cellLocation);
        loc += new Vector3(offsetX,offsetY,0f);
        pc.ShowPanel(loc);
        Vector3 CharacterPosition = CurrentSelectedChar.LastTargetCell.Location;

        if(CurrentSelectedChar.actionCount > 0|| CurrentSelectedChar.targetCount > 0 || CurrentSelectedChar.IsSprinting)
        {
            pc.AddButton("Clear", false).onClick.AddListener (() =>
            {
                CurrentSelectedChar.ClearActions();
                MainGameInstance.RemovePlayerActions(CurrentSelectedChar);
                board.TurnOffHiglightedAdjacent();
                pc.HidePanel();
            });
        }
        if (MainGameInstance.ActionsLeft > 0)
        {
            if ((CurrentSelectedChar.maxActions - CurrentSelectedChar.actionCount > 0))
            {
                if(CurrentSelectedChar.CanSprint  && !CurrentSelectedChar.IsSprinting)
                {
                    pc.AddButton ("Sprint", false).onClick.AddListener (() =>
                        {
                            selectionState = CharacterSelectionState.Moving;
                            board.HighlightAdjacent (x=> x !=null  && !x.bOccupied && x.type!=Cell.CellType.OutOfBounds,CharacterPosition, CurrentSelectedChar.MoveDistance);
                            CurrentSelectedChar.StartSprinting();
                            pc.HidePanel();
                        });
                }
                if (CurrentSelectedChar.targetCount == 0 || (CurrentSelectedChar.targetCount == 1 && CurrentSelectedChar.IsSprinting))
                {
                    pc.AddButton ("Move", false).onClick.AddListener (() =>
                    {
                        selectionState = CharacterSelectionState.Moving;
                        board.HighlightAdjacent (x=> x !=null  && !x.bOccupied && x.type!=Cell.CellType.OutOfBounds,CharacterPosition, CurrentSelectedChar.MoveDistance);
                        pc.HidePanel();//GameObject.Destroy (panel.gameObject);
                    });
                }
                if (CurrentSelectedChar.targetCount == 0  && !CurrentSelectedChar.IsSprinting)
                {
                    pc.AddButton ("Tackle", false).onClick.AddListener (() =>
                    {
                        selectionState = CharacterSelectionState.Tackling;
                        board.HighlightAdjacent (x=> x !=null  && x.bOccupied && x.UnitOccupier.team!=CurrentSelectedChar.team && x.type!=Cell.CellType.OutOfBounds,CharacterPosition, CurrentSelectedChar.MoveDistance);
                        pc.HidePanel();
                    });
                }

                if (CurrentSelectedChar.hasBall || CurrentSelectedChar.LastTargetCell.HasBall)
                {
                    pc.AddButton("Pass", false).onClick.AddListener (() =>
                    {
                        selectionState = CharacterSelectionState.Passing;
                        int shotDistanceSqrd = (int)CurrentSelectedChar.charData.Strength*(int)CurrentSelectedChar.charData.Strength;
                        board.HighlightAdjacent (x=> x !=null && x.type!=Cell.CellType.OutOfBounds&& (x.Location-CharacterPosition).sqrMagnitude<shotDistanceSqrd, CharacterPosition, (int)CurrentSelectedChar.charData.Strength);
                        pc.HidePanel();
                    });
                    pc.AddButton("Shoot", false).onClick.AddListener (() =>
                    {
                        selectionState = CharacterSelectionState.Shooting;
                        int shotDistanceSqrd = (int)CurrentSelectedChar.charData.Strength*(int)CurrentSelectedChar.charData.Strength;
                        board.HighlightAdjacent (x=> x !=null && x.type!=Cell.CellType.OutOfBounds && (x.Location-CharacterPosition).sqrMagnitude<shotDistanceSqrd, CharacterPosition, (int)CurrentSelectedChar.charData.Strength);
                        pc.HidePanel();
                    });
                }
            }
        }else pc.HidePanel();
    }
示例#5
0
 //    void MovementClick(Cell tCell)
 //    {
 //        MainGameInstance.SetPlayerAction(new PlayerAction(PlayerAction.Actions.Move, CurrentSelectedChar, tCell, CurrentSelectedChar.LastTargetCell));
 //        if ((CurrentSelectedChar.targetCount == 1 && CurrentSelectedChar.IsSprinting))
 //        {
 //            board.HighlightAdjacent (x=> !x.bOccupied && x !=null && x.type!=Cell.CellType.OutOfBounds,tCell.Location, CurrentSelectedChar.MoveDistance);
 //
 //        }
 //        else {
 //            board.TurnOffHiglightedAdjacent();
 //            selectionState = CharacterSelectionState.None;
 //        }
 //    }
 void ActionClick(Cell tCell, PlayerAction.Actions act)
 {
     //if (CurrentSelectedChar.maxActions -CurrentSelectedChar.actionCount > 0)
     {
         MainGameInstance.SetPlayerAction(new PlayerAction (act, CurrentSelectedChar,tCell, CurrentSelectedChar.LastTargetCell));
         board.TurnOffHiglightedAdjacent();
         selectionState = CharacterSelectionState.None;
     }
 }
示例#6
0
    public void DeselectCharacter()
    {
        if(currentID!=-1)
        {
            selectionState = CharacterSelectionState.None;
            pc.HidePanel();//GameObject.Destroy(panel.gameObject);

            if (meter!=null)
            {
                GameObject.Destroy(meter.gameObject);
            }
            CurrentSelectedChar.Highlight(false);
            board.TurnOffHiglightedAdjacent();
            currentID = -1;
        }
    }