Beispiel #1
0
        public InjectedAutoPlayer(TypeViewers typeViewers, Structures Camera, TypePlayer tp = TypePlayer.SD) : this()
        {
            this.Camera = Camera;
            Viever      = typeViewers;
            Player      = tp;

            if (typeViewers == TypeViewers.ImageV)
            {
                ImageVPlayer play = new ImageVPlayer
                {
                    ImageURL = Camera.GetPhotoStream,
                    FPS      = (byte)Settings.StaticMembers.ImageSettings.FPS,
                    Dock     = DockStyle.Fill,
                };
                Controls.Add(play);
            }
            else if (typeViewers == TypeViewers.FFPLAY)
            {
                ffplayer ffplayer1 = new ffplayer();
                ffplayer1.Dock      = DockStyle.Fill;
                ffplayer1.Disposed += (o, q) => { Dispose(); };
                ffplayer1.FilePath  = Player == TypePlayer.SD ? Camera.GetRTSPSecondONVIF : Camera.GetRTSPFirstONVIF;
                ffplayer1.StartFFPLAY();
                Controls.Add(ffplayer1);
            }
            else if (typeViewers == TypeViewers.MPlayer)
            {
                mplayer mplayer1 = new mplayer();
                mplayer1.Dock      = DockStyle.Fill;
                mplayer1.Disposed += (o, q) => { Dispose(); };
                mplayer1.FilePath  = Player == TypePlayer.SD ? Camera.GetRTSPSecondONVIF : Camera.GetRTSPFirstONVIF;
                mplayer1.Startmplayer();
                Controls.Add(mplayer1);
            }
        }
 public Player(string nom, string ip, int port, TypePlayer tipusJugador)
 {
     this.nom          = nom;
     this.ip           = ip;
     this.port         = port;
     this.tipusJugador = tipusJugador;
 }
Beispiel #3
0
        /// <summary>
        /// Установка дефолтных значений
        /// </summary>
        public Player(string playerName, TypePlayer type, IStartParams gameParams)
        {
            this.playerName = playerName;
            this.type       = type;

            PlayerParams = new Dictionary <Attributes, int>(gameParams.DefaultParams);
            Cards        = new List <Card>();
        }
Beispiel #4
0
    public void SetupdataHp(TypePlayer type, float dmg)
    {
        Debug.Log("va cham");
        switch (type)
        {
        case TypePlayer.Blue:
            player1.transform.GetComponent <HeavyBandit>().hp.UpdateHp(dmg);
            break;

        case TypePlayer.Red:
            Player2.transform.GetComponent <HeavyBandit>().hp.UpdateHp(dmg);
            break;
        }
    }
        public static string ToString(TypePlayer typePlayer)
        {
            switch (typePlayer)
            {
            case TypePlayer tp when tp == TypePlayer.O:
                return("O");

            case TypePlayer tp when tp == TypePlayer.X:
                return("X");

            default:
                return(null);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Afegeix un jugador al Controlador del Joc
        /// </summary>
        /// <param name="nom">Nom del jugador</param>
        /// <param name="ip">IP del Jugador</param>
        /// <param name="port">Port del Jugador</param>
        /// <param name="tipusJugador">Tipus de jugador Amic/Enemic</param>
        public void afegirPlayer(string nom, string ip, int port, TypePlayer tipusJugador)
        {
            if (players == null)
            {
                players = new List <Player>();
            }

            players.Add(new Player(nom, ip, port, tipusJugador));
            if (tipusJugador == TypePlayer.Amic)
            {
                pAmic = true;
            }
            numPlayers++;
        }
Beispiel #7
0
        private bool AnyCheckCanMove(TypePlayer typePlayer)
        {
            var chessMen = GetOtherAliveChessMen(typePlayer).Where(c => c.GetType() != typeof(King)).ToArray();

            foreach (var chessMan in chessMen)
            {
                if (!HasCanMoveVariants(chessMan.Piece))
                {
                    return(false);
                }
            }

            return(false);
        }
    public UnitContainer AddUnit(Player player, TypePlayer typePlayer, GameObject unitObject)
    {
        var pl = GetPlayerControl(player.ID);

        if (pl != null)
        {
            return(pl.Unit);
        }
        var control = Create(player, typePlayer, unitObject.GetComponent <UnitContainer>());

        m_PlayerControls.Add(control);
        //unit.Init();
        ExternInit(control);
        return(control.Unit);
    }
Beispiel #9
0
 public static PersistentDataUnitUI GetPersistentDataUI(TypePlayer type)
 {
     if (!Can)
     {
         return(null);
     }
     for (int i = 0; i < m_I.m_PersistentUnitUI.Length; i++)
     {
         if (m_I.m_PersistentUnitUI[i].Type == type)
         {
             return(m_I.m_PersistentUnitUI[i]);
         }
     }
     return(null);
 }
        public IPlayer Create(int hp, TypePlayer typePlayer)
        {
            switch (typePlayer)
            {
            case TypePlayer.Mag:
                return(new Mag());

            case TypePlayer.Player:
                return(new Player(hp, _weaponFactory.Create()));

            case TypePlayer.None:
            default:
                throw new ArgumentOutOfRangeException(nameof(typePlayer), typePlayer, null);
            }
        }
Beispiel #11
0
    public void CheckCollider(TypePlayer type, int dmg)
    {
        var x1 = player1.transform.localPosition.x;
        var x2 = Player2.transform.localPosition.x;

        if (x1 > x2)
        {
            if (Mathf.Abs(x1 - x2) <= 0.35f)
            {
                SetupdataHp(type, dmg);
            }
        }
        else
        {
            if (Mathf.Abs(x2 - x1) <= 0.35f)
            {
                SetupdataHp(type, dmg);
            }
        }
    }
    void Awake()
    {
        playFabManager = GameObject.Find("PlayFabManager").GetComponent <PlayFabManager>();

        //Playfab Manager

        if (playFabManager.Player_Car == "rouge")
        {
            myTypePlayer = TypePlayer.rouge;
        }
        else if (playFabManager.Player_Car == "vert")
        {
            myTypePlayer = TypePlayer.vert;
        }
        else
        {
            myTypePlayer = TypePlayer.orange;
        }


        switch (myTypePlayer)
        {
        case TypePlayer.orange:
            currentSpeed = normalSpeed;
            canJump      = false;
            GetComponent <MeshRenderer>().material.mainTexture = orangeTex;
            break;

        case TypePlayer.vert:
            currentSpeed = normalSpeed * 2;
            canJump      = false;
            GetComponent <MeshRenderer>().material.mainTexture = vertText;
            break;

        case TypePlayer.rouge:
            currentSpeed = normalSpeed * 2;
            canJump      = true;
            GetComponent <MeshRenderer>().material.mainTexture = rougeTex;
            break;
        }
    }
        public void AddPlayer(TypePlayer tp, string name, IStartParams startParams = null)
        {
            if (Status == CurrentAction.StartGame)
            {
                log.Error("Невозможно добавить игроков во время игры");
                return;
            }

            if (players.Count == 2)
            {
                log.Error("Достигнуто максимальное количество игроков");
                return;
            }

            if (startParams == null)
            {
                startParams = new GameStartParams();
            }

            players.Add(new Player(name, tp, startParams));
        }
Beispiel #14
0
        // Непосредственно разрыв
        private void DisableConnect()
        {
            ChannelServices.UnregisterChannel(ChannelServices.RegisteredChannels[0]);
            try
            {
                if (m_RefFromClient != null)
                {
                    RemotingServices.Unmarshal(m_RefFromClient);
                    RemotingServices.Disconnect(m_FromClient);
                }
            }
// ReSharper disable EmptyGeneralCatchClause
            catch { }
// ReSharper restore EmptyGeneralCatchClause

            try
            {
                if (m_RefFromServer != null)
                {
                    RemotingServices.Unmarshal(m_RefFromServer);
                    RemotingServices.Disconnect(m_FromServer);
                }
            }
// ReSharper disable EmptyGeneralCatchClause
            catch { }
// ReSharper restore EmptyGeneralCatchClause

            m_TypePlayer             = TypePlayer.Local;
            serverButton.Visible     = connectButton.Visible = true;
            disconnectButton.Visible = false;
            m_FromClient             = null;
            m_FromServer             = null;
            startGameButton.Enabled  = true;
            m_WhoStep            = ObjectType.Empty;
            m_ClientReady        = m_ServerReady = false;
            textBoxNetInfo.Text += "Соединение разорвано.";
        }
Beispiel #15
0
 public PlayerIndex(string[] data)
 {
     this.id = int.Parse(data[0]);
     this.type = data[1];
     this.typePlay = GetPlayerTypeByString(type);
     this.level = int.Parse(data[2]);
     this.hp = float.Parse(data[3]);
     this.damge = float.Parse(data[4]);
 }
Beispiel #16
0
 public Player(TypePlayer typePlayer, bool positiveYMovement)
 {
     _typePlayer        = typePlayer;
     _positiveYMovement = positiveYMovement ? 1 : -1;
 }
Beispiel #17
0
        internal const int MAX_FLAG_COUNT     = 5; // Максимальное число активных флагов

        public Player(Lobby lobby, int index, string name, TypePlayer typePlayer) : base()
        {
            Lobby            = lobby;
            Name             = name;
            TypePlayer       = typePlayer;
            Wins             = 0;
            Loses            = 0;
            PlayerIndex      = index;
            ImageIndexAvatar = (typePlayer == TypePlayer.Computer ? PlayerIndex : Program.formMain.Settings.IndexInternalAvatar) + Program.formMain.ImageIndexFirstAvatar;
            ResultLastBattle = ResultBattle.None;

            // Создаем справочик количества приоритетов флагов
            foreach (PriorityExecution pe in Enum.GetValues(typeof(PriorityExecution)))
            {
                QuantityFlags.Add(pe, 0);
            }

            // Настраиваем игрока согласно настройкам лобби
            DurabilityCastle           = Lobby.TypeLobby.DurabilityCastle;
            PointConstructionGuild     = lobby.TypeLobby.StartPointConstructionGuild;
            PointConstructionEconomic  = lobby.TypeLobby.StartPointConstructionEconomic;
            PointConstructionTemple    = 0;
            PointConstructionTradePost = 0;
            SetQuantityFlags(lobby.TypeLobby.StartQuantityFlags);

            // Инициализация зданий
            foreach (TypeConstruction tck in FormMain.Config.TypeConstructionsOfKingdom)
            {
                Buildings.Add(new PlayerBuilding(this, tck));
            }

            // Инициализация логов
            Lairs = new PlayerLair[lobby.TypeLobby.LairsLayers, lobby.TypeLobby.LairsHeight, lobby.TypeLobby.LairsWidth];

            GenerateLairs();

            Castle = GetPlayerBuilding(FormMain.Config.FindTypeEconomicConstruction(FormMain.Config.IDBuildingCastle));

            Gold = Lobby.TypeLobby.Gold;
            if (TypePlayer == TypePlayer.Computer)
            {
                Gold = 100_000;
            }

            LevelGreatness             = 1;
            PointGreatnessForNextLevel = 100;

            PlayerHero king      = Castle.HireHero(FormMain.Config.FindTypeHero("King"));
            PlayerHero advisor   = Castle.HireHero(FormMain.Config.FindTypeHero("Advisor"));
            PlayerHero captain   = Castle.HireHero(FormMain.Config.FindTypeHero("Captain"));
            PlayerHero treasurer = Castle.HireHero(FormMain.Config.FindTypeHero("Treasurer"));

            //
            AddItem(new PlayerItem(FormMain.Config.FindItem("PotionOfHealth"), 10, true));
            AddItem(new PlayerItem(FormMain.Config.FindItem("PotionOfHealth"), 10, true));
            AddItem(new PlayerItem(FormMain.Config.FindItem("PotionOfMana"), 10, true));
            AddItem(new PlayerItem(FormMain.Config.FindItem("Regeneration"), 1, true));
            AddItem(new PlayerItem(FormMain.Config.FindItem("Protection"), 1, true));
            AddItem(new PlayerItem(FormMain.Config.FindItem("ImpProtection"), 2, true));

            ValidateHeroes();
        }
Beispiel #18
0
        // Установить сервер
        private void serverButton_Click(object sender, EventArgs e)
        {
            try
            {
                textBoxNetInfo.Text = "";
                m_ClientReady       = m_ServerReady = false;
                ChannelServices.RegisterChannel(new TcpChannel(8080), false);

                m_FromClient    = new FromClientTransmittor();
                m_RefFromClient = RemotingServices.Marshal(m_FromClient, "FromClientTransmittor");

                // Обработка события на запрос о ничьей
                m_FromClient.ToServerRemiEvent += ToServerRemiEvent;

                // Обработка события на сообщение о начале игры
                m_FromClient.StartGameEvent += StartGameEvent;

                // Обработка нового хода клиента
                m_FromClient.ToServerStepEvent += ToServerStepEvent;

                // Обработка события на сообщение о ничьей
                m_FromClient.ToServerDeliverEvent += ToServerDeliverEvent;

                // Обработка события на готовность клиента играть
                m_FromClient.ToServerReadyEvent += ToServerReadyEvent;

                // Обработка события на отключение клиента
                m_FromClient.ToServerDisableEvent += ToServerDisableEvent;

                m_WhoStep    = ObjectType.Cross;
                m_TypePlayer = TypePlayer.Server;
                IPAddress ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList[Dns.GetHostEntry(Dns.GetHostName()).AddressList.Length - 1];
                textBoxNetInfo.Text += "Сервер установлен\r\nIP-адрес: " + ip + "\r\n";
                textBoxNetInfo.Text += "Ожидаем подсоединения клиента\r\n";

                serverButton.Visible     = connectButton.Visible = startGameButton.Enabled = false;
                disconnectButton.Visible = true;
            }
            catch
            {
                MessageBox.Show("Сервер не установлен.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                try
                {
                    ChannelServices.UnregisterChannel(ChannelServices.RegisteredChannels[0]);
                }
// ReSharper disable EmptyGeneralCatchClause
                catch { }
// ReSharper restore EmptyGeneralCatchClause

                try
                {
                    if (m_RefFromClient != null)
                    {
                        RemotingServices.Unmarshal(m_RefFromClient);
                        RemotingServices.Disconnect(m_FromClient);
                    }
                }
// ReSharper disable EmptyGeneralCatchClause
                catch { }
// ReSharper restore EmptyGeneralCatchClause

                try
                {
                    if (m_RefFromServer != null)
                    {
                        RemotingServices.Unmarshal(m_RefFromServer);
                        RemotingServices.Disconnect(m_FromServer);
                    }
                }
// ReSharper disable EmptyGeneralCatchClause
                catch { }
// ReSharper restore EmptyGeneralCatchClause
            }
        }
Beispiel #19
0
        // Подключиться к серверу
        private void connectButton_Click(object sender, EventArgs e)
        {
            try
            {
                m_ClientReady = m_ServerReady = false;
                new ServerConnectForm(this).ShowDialog();
                if (IpConnect != "")
                {
                    ChannelServices.RegisterChannel(new TcpChannel(8081), false);

                    m_FromClient = (FromClientTransmittor)Activator.GetObject(typeof(FromClientTransmittor), "tcp://" + IpConnect + ":8080/FromClientTransmittor");

                    // Установить свой сервер для получения ответа от сервера
                    m_FromServer    = new FromServerTransmittor();
                    m_RefFromServer = RemotingServices.Marshal(m_FromServer, "FromServerTransmittor");

                    // Обработка события на запрос о ничьей
                    m_FromServer.ToClientRemiEvent += ToClientRemiEvent;

                    // Обработка события на сообщение о сдаче сервера
                    m_FromServer.ToClientDeliverEvent += ToClientDeliverEvent;

                    // Обработка очередного хода сервера
                    m_FromServer.ToClientStepEvent += ToClientStepEvent;

                    // Обработка события на готовность клиента играть
                    m_FromServer.ToClientReadyEvent += ToClientReadyEvent;

                    // Обработка события на отключение клиента
                    m_FromServer.ToClientDisableEvent += ToClientDisableEvent;

                    // Получение сетевого адреса клиента (вида tcp://xxx.xxx.xxx.xxx:8081)
                    IPAddress ip   = Dns.GetHostEntry(Dns.GetHostName()).AddressList[Dns.GetHostEntry(Dns.GetHostName()).AddressList.Length - 1];
                    string    addr = "tcp://" + ip + ":8081";

                    var cb = new AsyncCallback(StartGameQuery);
                    var d  = new StartGameDelegate(m_FromClient.StartGame);
                    d.BeginInvoke(addr, cb, null);

                    m_WhoStep                = ObjectType.Cross;
                    m_TypePlayer             = TypePlayer.Client;
                    serverButton.Visible     = connectButton.Visible = false;
                    disconnectButton.Visible = true;
                    textBoxNetInfo.Text      = "Соединение с сервером установлено\r\n";
                }
            }
            catch
            {
                MessageBox.Show("Подключение к серверу не установлено.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ChannelServices.UnregisterChannel(ChannelServices.RegisteredChannels[0]);
                try
                {
                    if (m_RefFromClient != null)
                    {
                        RemotingServices.Unmarshal(m_RefFromClient);
                        RemotingServices.Disconnect(m_FromClient);
                    }
                }
// ReSharper disable EmptyGeneralCatchClause
                catch { }
// ReSharper restore EmptyGeneralCatchClause

                try
                {
                    if (m_RefFromServer != null)
                    {
                        RemotingServices.Unmarshal(m_RefFromServer);
                        RemotingServices.Disconnect(m_FromServer);
                    }
                }
// ReSharper disable EmptyGeneralCatchClause
                catch { }
// ReSharper restore EmptyGeneralCatchClause
            }
        }
 public UnitContainer AddUnit(Player player, TypePlayer typePlayer, TypeUnit typeUnit)
 {
     return(AddUnit(player, typePlayer, ManagerUnits.CreateUnit(typeUnit)));
 }
 PlayerMainControl Create(Player player, TypePlayer type, UnitContainer unit)
 {
     return(new PlayerMainControl(player, unit, ManagerUnitUI.GetUnitUI(), ManagerUnitUI.GetPersistentDataUI(type)));
 }
 public UnitContainer AddUnit(Player player, TypePlayer typePlayer)
 {
     return(AddUnit(player, typePlayer, ManagerUnits.CreateRandom()));
 }
Beispiel #23
0
 public IEnumerable <ChessMan> GetOtherAliveChessMen(TypePlayer typePlayer)
 {
     return(_pieces.OfType <Piece>().Where(p => p.GetChessMan() != null && p.GetChessMan().GetPlayer().GetTypePlayer() != typePlayer)
            .Select(p => p.GetChessMan()));
 }