Esempio n. 1
0
 private void OnError(object sender, Beetle.ChannelErrorEventArgs e)
 {
     Invoke(new Action<Beetle.ChannelErrorEventArgs>(r =>
     {
         txtStatus.Text = r.Exception.Message;
     }), e);
 }
Esempio n. 2
0
 private void OnDisposed(object sender, Beetle.ChannelEventArgs e)
 {
     Invoke(new Action<Beetle.ChannelEventArgs>(s =>
     {
         txtStatus.Text = "disconnect!";
     }), e);
 }
 public static void Send(Beetle.TcpChannel channel, object msg)
 {
     ProtobufAdapter adapter = new ProtobufAdapter();
     adapter.Message = msg;
     channel.Send(adapter);
     //Beetle.ProtoBufAdapter.MessageAdapter.Send(channel, msg);
 }
Esempio n. 4
0
 private void OnDisposed(object sender, Beetle.ChannelDisposedEventArgs e)
 {
     Invoke(new Action<object>(o => {
         cmdSend.Enabled = false;
         cmdConnect.Enabled = true;
     }),  new object());
 }
Esempio n. 5
0
 public void ClientDisposed(Beetle.NetPackage.NetClient client)
 {
     Invoke(new Action<NetClient>(c =>
     {
         txtStatus.Text = "close!";
     }), client);
 }
Esempio n. 6
0
 public void Connected(Beetle.NetPackage.NetClient client)
 {
     Invoke(new Action<NetClient>(c =>
     {
         txtStatus.Text = "connected!";
     }), client);
 }
Esempio n. 7
0
 private void OnDisposed(object sender, Beetle.ChannelDisposedEventArgs e)
 {
     Invoke(new Action<Register>(o =>
     {
         cmdRegister.Enabled = !(cmdConnect.Enabled = true);
     }), null);
 }
Esempio n. 8
0
 public void ClientError(Beetle.NetPackage.NetClient client, Exception e)
 {
     Invoke(new Action<Exception>(err =>
     {
         txtError.Text = err.Message;
     }),e);
 }
Esempio n. 9
0
 public void Connected(Beetle.NetPackage.NetClient client)
 {
     this.Dispatcher.BeginInvoke(() =>
     {
         txtStatus.Text = "connected!";
     });
 }
Esempio n. 10
0
        public static void Main()
        {
            var chatRoom = new ChatRoom();

            Participant george = new Beetle("George"); // new Beetle("George", chatRoom);
            chatRoom.Register(george);

            Participant paul = new Beetle("Paul");
            chatRoom.Register(paul);

            Participant ringo = new Beetle("Ringo");
            chatRoom.Register(ringo);

            Participant john = new Beetle("John");
            chatRoom.Register(john);

            Participant yoko = new NonBeetle("Yoko");
            chatRoom.Register(yoko);

            yoko.Send("John", "Hi John!");
            paul.Send("Ringo", "All you need is love");
            ringo.Send("George", "My sweet Lord");
            paul.Send("John", "Can't buy me love");
            john.Send("Yoko", "My sweet love");

            yoko.SendToAll("Hi, all!");
        }
Esempio n. 11
0
 public void Save(Beetle.NetPackage.IDataWriter writer)
 {
     writer.WriteUTF(Name);
     writer.WriteUTF(EMail);
     writer.WriteUTF(City);
     writer.WriteUTF(Country);
     writer.WriteUTF(RegTime.ToString("yyyy-MM-dd HH:mm:ss"));
 }
Esempio n. 12
0
 public void ClientReceive(Beetle.NetPackage.NetClient client, object message)
 {
     if (message is Register)
     {
         Invoke(new Action<Register>(msg => {
             txtRegTime.Text = msg.RegTime.ToString();
         }), message as Register);
     }
 }
Esempio n. 13
0
 public void OnLogin(Beetle.Express.IChannel channel, string id, string command, JToken token)
 {
     channel.Name = token["name"].ToString();
     User user = new User();
     user.Name = channel.Name;
     user.ID = channel.ID;
     user.Host = channel.EndPoint.ToString();
     SendAll(id, command, user);
 }   
Esempio n. 14
0
 protected override void OnReceive(object sender, Beetle.ChannelReceiveEventArgs e)
 {
     System.Threading.Interlocked.Increment(ref Count);
     string value = e.Channel.Coding.GetString(e.Data.Array, e.Data.Offset, e.Data.Count);
     C.WriteLine(value);
     Beetle.StringMessage msg = new Beetle.StringMessage();
     msg.Value = value;
     e.Channel.Send(msg);
 }
Esempio n. 15
0
 public void OnTalk(Beetle.Express.IChannel channel, string id, string command, JToken token)
 {
     string content = token["content"].ToString();
     Talk talk = new Talk();
     talk.Content = content;
     talk.From = channel.Name;
     talk.Host = channel.EndPoint.ToString();
     SendAll(id, command, talk);
 }
Esempio n. 16
0
 public override void Disposed(Beetle.Express.IServer server, Beetle.Express.ChannelEventArgs e)
 {         
     base.Disposed(server, e);
     User user = new User();
     user.Name = e.Channel.Name;
     user.ID = e.Channel.ID;
     user.Host = e.Channel.EndPoint.ToString();
     SendAll(null, "exit", user);
 }
Esempio n. 17
0
 private void OnReceive(Beetle.PacketRecieveMessagerArgs e)
 {
     Register reg = (Register)e.Message;
     Invoke(new Action<Register>(r => {
         txtREMail.Text = r.EMail;
         txtRName.Text = r.Name;
         txtResponseTime.Text = r.ResponseTime.ToString();
     }), reg);
 }
Esempio n. 18
0
 protected override Beetle.NetPackage.IMessage GetMessage(Beetle.NetPackage.IDataReader reader)
 {
     string Name = reader.ReadUTF();
     switch (Name)
     {
         case "Register":
             return new Register();
     }
     return null;
 }
Esempio n. 19
0
 public void Load(Beetle.BufferReader reader)
 {
     string type = reader.ReadString();
     //Beetle.ByteArraySegment segment = mArrayPool.Pop();
     byte[] data = reader.ReadByteArray();
     using (System.IO.Stream stream = new System.IO.MemoryStream(data, 0, data.Length))
     {
         Message = ProtoBuf.Meta.RuntimeTypeModel.Default.Deserialize(stream, null, Type.GetType(type));
     }
 }
Esempio n. 20
0
        private  void OnReceive(object sender, Beetle.ChannelReceiveEventArgs e)
        {

            string value = e.Channel.Coding.GetString(e.Data.Array, e.Data.Offset, e.Data.Count);
            this.Invoke(new Action<string>(s =>
            {
                richTextBox2.AppendText(value + "\r\n");
            }), value);

        }
Esempio n. 21
0
 public void Load(Beetle.IDataReader reader)
 {
     Name = reader.ReadUTF();
     EMail = reader.ReadUTF();
     City = reader.ReadUTF();
     Country = reader.ReadUTF();
     string date = reader.ReadUTF();
     Console.WriteLine(date);
     RegTime = DateTime.ParseExact(date, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
 }
Esempio n. 22
0
 protected override Beetle.IMessage ReadMessageByType(Beetle.IDataReader reader, Beetle.ReadObjectInfo typeTag)
 {
     typeTag.TypeofString = reader.ReadUTF();
     switch (typeTag.TypeofString)
     {
         case "Register":
             return new Register();
     }
     return null;
 }
Esempio n. 23
0
 public void Load(Beetle.BufferReader reader)
 {
     string type = reader.ReadString();
     Beetle.ByteArraySegment segment = mArrayPool.Pop();
     reader.ReadByteArray(segment);
     using (System.IO.Stream stream = new System.IO.MemoryStream(segment.Array,0,segment.Count))
     {
         Message = ProtoBuf.Meta.RuntimeTypeModel.Default.Deserialize(stream, null, Type.GetType(type));
     }
     mArrayPool.Push(segment);
 }
Esempio n. 24
0
 public void OnList(Beetle.Express.IChannel channel, string id, string command, JToken token)
 {
     List<User> users = new List<User>();
     Server.GetOnlines(Onlines);
     for (int i = 0; i < Onlines.Count; i++)
     {
         Beetle.Express.IChannel client = Onlines.Channels[i];
         users.Add(new User { Host = client.EndPoint.ToString(), ID = client.ID, Name = client.Name });
     }
     SendAll(id, command, users);
 }
Esempio n. 25
0
        // 用于生成本地化 ApplicationBar 的示例代码
        //private void BuildLocalizedApplicationBar()
        //{
        //    // 将页面的 ApplicationBar 设置为 ApplicationBar 的新实例。
        //    ApplicationBar = new ApplicationBar();

        //    // 创建新按钮并将文本值设置为 AppResources 中的本地化字符串。
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // 使用 AppResources 中的本地化字符串创建新菜单项。
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}

        public void ClientReceive(Beetle.NetPackage.NetClient client, object message)
        {
            if (message is Register)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    Register reg = (Register)message;
                    txtRegtime.Text = reg.RegTime.ToString();
                });
            }
        }
Esempio n. 26
0
 public void Save(Beetle.BufferWriter writer)
 {
     writer.Write(Message.GetType().FullName);
     byte[] data;
     using (System.IO.Stream stream = new System.IO.MemoryStream())
     {
         ProtoBuf.Meta.RuntimeTypeModel.Default.Serialize(stream, Message);
         data = new byte[stream.Length];
         stream.Position = 0;
         stream.Read(data, 0, data.Length);
     }
     writer.Write(data);
 }
Esempio n. 27
0
        public override void Error(Beetle.Express.IServer server, Beetle.Express.ErrorEventArgs e)
        {
            if (e.Channel != null)
            {
                Console.WriteLine("{3}:{0}[{2}] channel error {1}", e.Channel.EndPoint, e.Error.Message, e.Channel.Name,GetType().Name);
            }
            else
            {
                Console.WriteLine("{1}: error {0}", e.Error.Message, GetType().Name);
            }

            base.Error(server, e);
        }
Esempio n. 28
0
        public void Error(Beetle.Express.IServer server, Beetle.Express.ErrorEventArgs e)
        {
            if (e.Channel != null)
            {
                "{0} channel error".Log4Error(e.Error, e.Channel.EndPoint);
            }
            else
            {
                "ec application error ".Log4Error(e.Error);
            }
            mApplication.OnError(new Events.EventApplicationErrorArgs { Application=mApplication,Info=e });

        }
Esempio n. 29
0
        public void Save(Beetle.BufferWriter writer)
        {
            writer.Write(Message.GetType().Name);
            Beetle.ByteArraySegment segment = mArrayPool.Pop();
            using(System.IO.Stream stream = new System.IO.MemoryStream(segment.Array))
            {
                ProtoBuf.Meta.RuntimeTypeModel.Default.Serialize(stream, Message);
                segment.SetInfo(0, (int)stream.Position);

            }
            writer.Write(segment);
            mArrayPool.Push(segment);
        }
Esempio n. 30
0
 public void Receive(Beetle.Express.IServer server, Beetle.Express.ChannelReceiveEventArgs e)
 {
     if (Encoding.UTF8.GetString(e.Data.Array, e.Data.Offset, e.Data.Count) == "GETSN")
     {
         byte[] sn = mCreate.GetValueData();
         Beetle.Express.Data data = new Beetle.Express.Data();
         data.SetBuffer(sn, 0, 8);
         e.Channel.Server.Send(data, e.Channel);
     }
     else
     {
         e.Channel.Dispose();
     }
 }
Esempio n. 31
0
        public void CheckBeetleStackCloning()
        {
            Ant         ant     = new Ant(PieceColor.Black, 1);
            Beetle      beetle  = new Beetle(PieceColor.Black, 1);
            Beetle      beetle2 = new Beetle(PieceColor.Black, 2);
            Beetle      beetle3 = new Beetle(PieceColor.White, 1);
            Beetle      beetle4 = new Beetle(PieceColor.White, 2);
            BeetleStack bs      = new BeetleStack(beetle3, new BeetleStack(ant, beetle));
            BeetleStack bs2     = new BeetleStack(beetle4, bs);

            Assert.IsFalse(bs.Equals(bs2));
            Assert.IsTrue(bs.Contains(beetle3));
            Assert.IsTrue(bs2.Contains(beetle3));
        }
Esempio n. 32
0
        public static void Run()
        {
            var chatRoom = new ChatRoom();

            Participant george = new Beetle("George"); // new Beetle("George", chatRoom);

            chatRoom.Register(george);

            Participant paul = new Beetle("Paul");

            chatRoom.Register(paul);

            Participant ringo = new Beetle("Ringo");

            chatRoom.Register(ringo);

            Participant john = new Beetle("John");

            chatRoom.Register(john);

            Participant yoko = new NonBeetle("Yoko");

            chatRoom.Register(yoko);

            yoko.Send("John", "Hi John!");
            paul.Send("Ringo", "All you need is love");
            ringo.Send("George", "My sweet Lord");
            paul.Send("John", "Can't buy me love");
            john.Send("Yoko", "My sweet love");

            yoko.SendToAll("Hi, all!");


            /*
             * Alternative:
             * Meet Paul with George and vice-versa
             * Meet Ringo with Paul and vice-versa
             * Meet Ringo with George and vice-versa
             * Meet John with Paul and vice-versa
             * Meet John with George and vice-versa
             * Meet John with Ringo and vice-versa
             * Meet Yoko with Paul and vice-versa
             * Meet Yoko with George and vice-versa
             * Meet Yoko with Ringo and vice-versa
             * Meet Yoko with John and vice-versa
             */
        }
Esempio n. 33
0
        public void CheckBeetleStackEquality()
        {
            Ant         ant     = new Ant(PieceColor.Black, 1);
            Beetle      beetle  = new Beetle(PieceColor.Black, 1);
            Beetle      beetle2 = new Beetle(PieceColor.Black, 2);
            Beetle      beetle3 = new Beetle(PieceColor.White, 1);
            Beetle      beetle4 = new Beetle(PieceColor.White, 2);
            BeetleStack bs      = new BeetleStack(beetle3, new BeetleStack(ant, beetle));

            BeetleStack bs2 = new BeetleStack(beetle3, new BeetleStack(ant, beetle));

            BeetleStack bs3 = new BeetleStack(ant, beetle4);

            Assert.IsTrue(bs.Equals(bs2));
            Assert.IsFalse(bs3.Equals(bs2));
            Assert.IsFalse(bs2.Equals(beetle3));
        }
Esempio n. 34
0
    private void OnReadyToFight(Beetle p1, Beetle p2)
    {
        Color p1Dom = p1.GetDominantColor();
        Color p2Dom = p2.GetDominantColor();

        Color outcome = DecideOutcome(p1Dom, p2Dom);

        bool p1wins = outcome == p1Dom;

        if (outcome == Color.None)
        {
            p1wins = true;
        }

        OnMatchOutcomeDecided?.Invoke(p1wins);
        return;
    }
Esempio n. 35
0
        private void HandleBeetleToStackMove(Beetle movingPiece, Piece referencePiece, Hex from, Hex to)
        {
            // beetle climbing
            BeetleStack newStack;

            if (referencePiece is BeetleStack)
            {
                newStack = new BeetleStack(movingPiece, (BeetleStack)referencePiece);
            }
            else
            {
                // new beetle stack
                newStack = new BeetleStack(referencePiece, movingPiece);
            }
            _playedPieces.Remove(referencePiece);
            _boardPieceArray[to.column, to.row] = newStack;
            _playedPieces.Add(newStack, to);
        }
Esempio n. 36
0
    void SpawnBeetles(int count, Vector2 JackPos)
    {
        int spawnCount = 0;

        while (spawnCount < count)
        {
            Vector2 randPos = GetRandomPointOnStreet();
            if ((randPos - JackPos).magnitude < Beetle.NearJackThreshold)
            {
                continue;
            }
            Beetle b = new Beetle(this);
            b.SpawnAt(randPos);
            //Debug.Log("spawning beetle at " + randPos);
            Beetles.Add(b);
            spawnCount += 1;
        }
    }
Esempio n. 37
0
        public static void Main()
        {
            var airbus  = new Airbus();
            var boeing  = new Boeing();
            var dinghy  = new Dinghy();
            var titanic = new Yacht();
            var sequoia = new Sequoia();
            var beetle  = new Beetle();

            // Build a collection of all vehicles that fly
            // With a single `foreach`, have each vehicle Fly()
            var flyings = new List <Aircraft> {
                airbus, boeing
            };

            foreach (var flying in flyings)
            {
                flying.Flying();
            }

            // Build a collection of all vehicles that operate on roads
            // With a single `foreach`, have each road vehicle Drive()
            var drivings = new List <Car> {
                sequoia, beetle
            };

            foreach (var driving in drivings)
            {
                driving.Driving();
            }

            // Build a collection of all vehicles that operate on water
            // With a single `foreach`, have each water vehicle Drive()
            var waterings = new List <Watercraft> {
                dinghy, titanic
            };

            foreach (var watering in waterings)
            {
                watering.Driving();
            }
        }
Esempio n. 38
0
        internal static void Main()
        {
            var chatRoom = new ChatRoom();

            Participant george = new Beetle("George");
            Participant paul   = new Beetle("Paul");
            Participant ringo  = new Beetle("Ringo");
            Participant john   = new Beetle("John");
            Participant yoko   = new NonBeetle("Yoko");

            chatRoom.Register(george);
            chatRoom.Register(paul);
            chatRoom.Register(ringo);
            chatRoom.Register(john);
            chatRoom.Register(yoko);

            yoko.Send("John", "Hi John!");
            paul.Send("Ringo", "All you need is love");
            ringo.Send("George", "My sweet Lord");
            paul.Send("John", "Can't buy me love");
            john.Send("Yoko", "My sweet love");
        }
Esempio n. 39
0
        public override void OnMovement(Mobile m, Point3D oldLocation)
        {
            base.OnMovement(m, oldLocation);

            if (m == null || m.Deleted || m == Beetle || !m.Alive || !m.InRange3D(this, 1, -5, 5) ||
                (Beetle != null && !Beetle.CanBeHarmful(m)))
            {
                return;
            }

            if (Beetle != null)
            {
                Beetle.DoHarmful(m, true);
            }

            if (m is BaseCreature && m.IsControlled())
            {
                m.Damage(25);
            }
            else if (m is PlayerMobile)
            {
                m.Damage(1);
            }

            if (m.Poisoned)
            {
                return;
            }

            if (m is PlayerMobile)
            {
                m.ApplyPoison(Beetle ?? m, Poison.Deadly);
            }
            else if (m is BaseCreature)
            {
                m.ApplyPoison(Beetle ?? m, Poison.Lethal);
            }
        }
    private void OnCarriageSelected(Carriage c)
    {
        if (ReadyToFight)
        {
            Debug.Log("READY TO FIGHT");
            OnReadyToFight?.Invoke(m_player1, m_player2);
            return;
        }
        CarriageDefinition.Color color = c.CarriageDefinition.GetColor();

        if (color == CarriageDefinition.Color.Wild)
        {
            int rand = UnityEngine.Random.Range(0, 3);
            color = (CarriageDefinition.Color)rand;
        }

        CarriageDefinition.Ability ability = c.CarriageDefinition.GetAbility();

        Beetle player      = GetCurrentPlayer();
        Beetle otherPlayer = GetOtherPlayer();

        switch (ability)
        {
        case CarriageDefinition.Ability.None:
            player.AddCarriage(color);
            break;

        case CarriageDefinition.Ability.Copy:
            if (player.CarriageCount == 0)
            {
                return;
            }

            Carriage lastCarriage = player.GetLastCarriage();
            color = lastCarriage.CarriageDefinition.GetColor();
            player.AddCarriage(color);
            break;

        case CarriageDefinition.Ability.Send:
            if (otherPlayer.CarriageCount == GameConstants.MAX_CARRIAGE_CAPACITY)
            {
                player.AddCarriage(color);
            }
            else
            {
                otherPlayer.AddCarriage(color);
            }
            break;

        case CarriageDefinition.Ability.Swap:
            if (player.CarriageCount > 0 && otherPlayer.CarriageCount > 0)
            {
                Carriage c1 = player.RemoveLastCarriage();
                Carriage c2 = otherPlayer.RemoveLastCarriage();
                player.AddCarriage(c2.CarriageDefinition.GetColor());
                otherPlayer.AddCarriage(c1.CarriageDefinition.GetColor());
                Destroy(c1.gameObject);
                Destroy(c2.gameObject);
            }

            player.AddCarriage(color);
            break;

        case CarriageDefinition.Ability.DoubleDip:
            m_doubleDip = true;
            player.AddCarriage(color);
            break;

        case CarriageDefinition.Ability.Shuffle:
            player.AddCarriage(color);
            m_carriageContainer.GetComponent <CarriageMenu>().Reset();
            m_currentHand.Clear();
            DrawHand();
            m_carriageContainer.GetComponent <CarriageMenu>().Init();
            break;
        }

        c.gameObject.SetActive(false);

        if (m_doubleDip)
        {
            m_doubleDip = false;
        }
        else
        {
            NextTurn();
        }

        if (ReadyToFight)
        {
            OnReadyToFight?.Invoke(m_player1, m_player2);
        }
    }
Esempio n. 41
0
        public void AbsorbTarget(Mobile from, object obj)
        {
            if (!(obj is Beetle))
            {
                from.SendMessage("Ce pouvoir vous serait inutile pour la seule utilisation actuelle de ce crystal...");
                return;
            }

            Beetle targ = (Beetle)obj;

            if (!targ.Controlled || targ.ControlMaster != from || !targ.IsBonded)
            {
                from.SendMessage("La créature à qui vous capturerez l'âme doit vous être fortement liée.");
                return;
            }

            bool skill = from.CheckSkill(SkillName.Mysticism, 10, 60);

            if (!skill)
            {
                from.SendMessage("Vous échouez dans votre tentative d'absorber l'âme de cette créature");

                int bad = Utility.Random(1, 100);
                if (bad == 5)
                {
                    targ.Emote("S'effondre au sol, inerte");
                    targ.IsBonded = false;
                    targ.Kill();
                }
                else if (bad > 5 && bad < 9)
                {
                    targ.Emote("S'effondre au sol, inanimée");
                    targ.Kill();
                }
                else if (bad < 4)
                {
                    from.Emote("Le Crystal explore");
                    this.Delete();
                }
                else if (bad > 10 && bad < 20)
                {
                    targ.Emote("Faiblit");
                    targ.Str--;
                    if (targ.Str == 0)
                    {
                        targ.Delete();
                    }
                }
                else if (bad > 20 && bad < 30)
                {
                    targ.Emote("Faiblit");
                    targ.Dex--;
                    if (targ.Dex == 0)
                    {
                        targ.Delete();
                    }
                }
                else if (bad > 30 && bad < 40)
                {
                    targ.Emote("Faiblit");
                    targ.Int--;
                    if (targ.Int == 0)
                    {
                        targ.Delete();
                    }
                }
                return;
            }

            from.SendMessage("Vous absorbez une partie de l'âme de la bête");
            this.Completion += Math.Max(Utility.Random(1, 2), (int)from.Skills[SkillName.Mysticism].Value / 10);

            if (Completion > 100)
            {
                Completion = 100;
            }

            if (!from.CheckSkill(SkillName.AnimalLore, 0, 40))
            {
                targ.Emote("Exprime une douleur intense et ne semble pas vous reconnaitre");
                targ.IsBonded      = false;
                targ.Controlled    = false;
                targ.ControlMaster = null;
            }
            else if (!from.CheckSkill(SkillName.AnimalLore, 0, 120))
            {
                targ.Emote("Exprime une douleur intense et vous observe avec crainte");
                targ.IsBonded = false;
            }
            else
            {
                targ.Emote("Semble ne pas comprendre");
            }

            return;
        }
Esempio n. 42
0
        private void GeneratePlacementMoves()
        {
            foreach (KeyValuePair <Hex, Hivailability> kvp in _hivailableHexes)
            {
                if (kvp.Value.BlackCanPlace && !_whiteToPlay)
                {
                    // on turn 1 you cannot place a bee
                    if (!(turnNumber == 2))
                    {
                        QueenBee queenBee = _unplayedPieces.OfType <QueenBee>().Where(p => p.color == PieceColor.Black).FirstOrDefault();
                        if (null != queenBee)
                        {
                            _moves.Add(Move.GetMove(queenBee, kvp.Key));
                        }
                        // on turn 4 you must place a bee if you haven't already
                        if (!blackQueenPlaced && turnNumber == 8)
                        {
                            continue;
                        }
                    }

                    Beetle beetle = _unplayedPieces.OfType <Beetle>().Where(p => p.color == PieceColor.Black).FirstOrDefault();
                    Ant    ant    = _unplayedPieces.OfType <Ant>().Where(p => p.color == PieceColor.Black).FirstOrDefault();
                    Spider spider = _unplayedPieces.OfType <Spider>().Where(p => p.color == PieceColor.Black).FirstOrDefault();
                    Hopper hopper = _unplayedPieces.OfType <Hopper>().Where(p => p.color == PieceColor.Black).FirstOrDefault();
                    if (null != beetle)
                    {
                        _moves.Add(Move.GetMove(beetle, kvp.Key));
                    }
                    if (null != ant)
                    {
                        _moves.Add(Move.GetMove(ant, kvp.Key));
                    }
                    if (null != spider)
                    {
                        _moves.Add(Move.GetMove(spider, kvp.Key));
                    }
                    if (null != hopper)
                    {
                        _moves.Add(Move.GetMove(hopper, kvp.Key));
                    }
                }
                if (kvp.Value.WhiteCanPlace && _whiteToPlay)
                {
                    // on turn 1 you cannot place a bee
                    if (!(turnNumber == 1))
                    {
                        QueenBee queenBee = _unplayedPieces.OfType <QueenBee>().Where(p => p.color == PieceColor.White).FirstOrDefault();
                        if (null != queenBee)
                        {
                            _moves.Add(Move.GetMove(queenBee, kvp.Key));
                        }
                        // on turn 4 you must place a bee if you haven't already
                        if (!whiteQueenPlaced && turnNumber == 7)
                        {
                            continue;
                        }
                    }

                    Beetle beetle = _unplayedPieces.OfType <Beetle>().Where(p => p.color == PieceColor.White).FirstOrDefault();
                    Ant    ant    = _unplayedPieces.OfType <Ant>().Where(p => p.color == PieceColor.White).FirstOrDefault();
                    Spider spider = _unplayedPieces.OfType <Spider>().Where(p => p.color == PieceColor.White).FirstOrDefault();
                    Hopper hopper = _unplayedPieces.OfType <Hopper>().Where(p => p.color == PieceColor.White).FirstOrDefault();
                    if (null != beetle)
                    {
                        _moves.Add(Move.GetMove(beetle, kvp.Key));
                    }
                    if (null != ant)
                    {
                        _moves.Add(Move.GetMove(ant, kvp.Key));
                    }
                    if (null != spider)
                    {
                        _moves.Add(Move.GetMove(spider, kvp.Key));
                    }
                    if (null != hopper)
                    {
                        _moves.Add(Move.GetMove(hopper, kvp.Key));
                    }
                }
            }
        }
Esempio n. 43
0
 public void WearHelmet(Beetle beetle)
 {
     ; helmet = beetle;
     protectionState.Helmet();
 }