Esempio n. 1
0
        void Start()
        {
            instance = this;
            AttackEnemyCards_Listenner           atkEnemyCardsListener = new AttackEnemyCards_Listenner();
            CardOfKickTheDoorAtPresent_Listenner cardOfKickTheDoorAtPresentListener = new CardOfKickTheDoorAtPresent_Listenner();
            CardOfTheMonsterAtPresent_Listenner  cardOfTheMonsterAtPresentListener  = new CardOfTheMonsterAtPresent_Listenner();
            CardOfThePlayAtPresent_Listenner     cardOfThePlayAtPresent_Listener    = new CardOfThePlayAtPresent_Listenner();
            MomentTypeAtPresent_Listenner        momentTypeAtPresent_Listener       = new MomentTypeAtPresent_Listenner();

            CoreDataObserver.GetInstance().AddListenner(momentTypeAtPresent_Listener);
            PlayerDefine player = new PlayerDefine(1, "小磊君");

            CoreDataObserver.GetInstance().SetPlayer(player);//初始化玩家;
            EventTable.GetInstance().RegisterEventType("GetACardOfKickTheDoor", EventType.GetACardOfKickTheDoor);
            EventTable.GetInstance().RegisterEventType("PushAttackEnemyCards", EventType.PushAttackEnemyCards);
            EventTable.GetInstance().RegisterEventType("Magic_CreatEvent", EventType.Magic_CreatEvent);
            EventTable.GetInstance().RegisterEventType("Debuff_CreatEventOne", EventType.Debuff_CreatEventOne);
            EventTable.GetInstance().RegisterEventType("GetMonsterCardAndPushItToList", EventType.GetMonsterCardAndPushItToList);
            EventTable.GetInstance().RegisterEventType("SetACardOfKickTheDoor", EventType.SetACardOfKickTheDoor);
            EventTable.GetInstance().RegisterEventType("ChangeMomentType_CombatPhase", EventType.ChangeMomentType_CombatPhase);
            ////---------------------------------------------------------------------------------------------------------
            ////Test:
            EventTable.GetInstance().RegisterEventType("TestOneEvent", EventType.TestOneEvent);
            EventTable.GetInstance().RegisterEventType("TestTwoEvent", EventType.TestTwoEvent);
            EventTable.GetInstance().RegisterEventType("TestThreeEvent", EventType.TestThreeEvent);
            Run();
        }
Esempio n. 2
0
        private string _name; //名字;

        //----------------------------------------------------------------
        public CardOfTheMonsterAtPresent_Listenner(string name)
        {
            _name   = name;
            _double = null;
            //加入订阅者容器内部;
            CoreDataObserver.GetInstance().AddListenner(this);
        }
        public override void Execute()
        {
            //事件接口;
            //-----------------------------------------------------------------------
            _cardOfKickTheDoorAtPresent = CoreDataObserver.GetInstance().Get_CardOfKickTheDoorAtPresent();//获取当前的踢门牌;
            if (_cardOfKickTheDoorAtPresent != null && _cardOfKickTheDoorAtPresent.GetCardType() == CardType.DebuffCard)
            {
                //当前卡牌确实为诅咒卡;
                List <string> function = null;
                Base_Event    events   = null;
                function = _cardOfKickTheDoorAtPresent.GetDebuffCard().GetCurse();
                if (function != null)
                {
                    foreach (string i in function)
                    {
                        //通过字符串从EventTable中获取对应的事件类型,制造出对应的事件;(注意:先将事件类型与对应的字符串注册到EventTable中);
                        events = EventFactory.GetInstance().GetEvent(i);
                        events.SetCard(_cardOfKickTheDoorAtPresent);              //为此事件添加父类card;
                        EventQueue.GetInstance().PushEventForSecondqueue(events); //向事件队列中添加事件;
                    }
                }
            }
            else
            {
                //出错并不是诅咒卡;
                Console.WriteLine("此卡牌不是诅咒卡或者当前踢门卡为空");
                return;
            }



            //-----------------------------------------------------------------------
        }
        //----------------------------------------------------------------
        public override void Execute()
        {
            //事件接口;
            //----------------------------------------------------------------
            CoreDataObserver.GetInstance().SetMomentTypeAtPresent(MomentType.CombatPhase);

            //----------------------------------------------------------------
        }
        private string _name;          //名字;

        //----------------------------------------------------------------
        public AttackEnemyCards_Listenner(string name)
        {
            _name            = name;
            _attackEnemyCard = null;
            _double          = null;
            //加入订阅者容器内部;
            CoreDataObserver.GetInstance().AddListenner(this);
        }
Esempio n. 6
0
 public CardOfTheMonsterAtPresent_Listenner()
 {
     //..........
     _name   = "CardOfTheMonsterAtPresent_Listenner";
     _double = null;
     //加入订阅者容器内部;
     CoreDataObserver.GetInstance().AddListenner(this);
 }
        private string _name;           //名字;

        //----------------------------------------------------------------
        public MomentTypeAtPresent_Listenner(string name)
        {
            _name       = name;
            _momentType = MomentType.None;
            _double     = MomentType.None;
            //加入订阅者容器内部;
            CoreDataObserver.GetInstance().AddListenner(this);
        }
 public AttackEnemyCards_Listenner()
 {
     //..........
     _name            = "AttackEnemyCards_Listenner";
     _attackEnemyCard = null;
     _double          = null;
     //加入订阅者容器内部;
     CoreDataObserver.GetInstance().AddListenner(this);
 }
 public MomentTypeAtPresent_Listenner()
 {
     //..........
     _name       = "MomentTypeAtPresent_Listenner";
     _momentType = MomentType.None;
     _double     = MomentType.None;
     //加入订阅者容器内部;
     CoreDataObserver.GetInstance().AddListenner(this);
 }
Esempio n. 10
0
 //-----------------------------------------------------------------
 public static CoreDataObserver GetInstance()
 {
     if (instance == null)
     {
         instance = new CoreDataObserver();
         return(instance);
     }
     return(instance);
 }
Esempio n. 11
0
        //----------------------------------------------------------------
        //事件组合器;
        public override void Update()
        {
            //-------------------------------------------------------------
            if (CoreDataObserver.GetInstance().GetCardOfTheMonsterAtPresent().Count > 0 && CoreDataObserver.GetInstance().GetMomentTypeAtPresent() != MomentType.CombatPhase)
            {
                //当前场地上的怪兽容器存在怪兽卡片,并且当前游戏阶段不为战斗阶段,则执行此函数;
                //将当前的游戏阶段设置为战斗阶段;
                EventQueue.GetInstance().PushEventForSecondqueue(EventFactory.GetInstance().GetEvent("ChangeMomentType_CombatPhase"));//投递事件;
            }

            //-------------------------------------------------------------
        }
        //----------------------------------------------------------------
        //事件组合器;
        public override void Update()
        {
            //事件处理;
            //------------------------------------------------------------
            _double = CoreDataObserver.GetInstance().GetMomentTypeAtPresent();//获取当前的状态;
            if (_double != _momentType)
            {
                _momentType = _double;//触发了新的状态;
                //------------------------------------------------------------------------------------------------
                //Do something:
                //Put event;
                switch (_momentType)
                {
                case MomentType.KickTheDoor:
                    Debug.Log("MomentTypeAtPresent_Listenner");
                    EventQueue.GetInstance().PushEventForSecondqueue(EventFactory.GetInstance().GetEvent("SetACardOfKickTheDoor"));    //投递事件;
                    //----------------------------------------------------------------------------------------
                    //当前为踢门牌阶段;
                    //从踢门牌堆中获取一张卡牌;
                    //.............
                    //......
                    //...
                    //----------------------------------------------------------------------------------------
                    break;

                case MomentType.FreePhase:
                    //----------------------------------------------------------------------------------------
                    //当前为自由阶段;(抽到的踢门牌不为怪兽卡)
                    Console.WriteLine("当前为自由阶段,在此阶段你可以做任何想做的事情,阶段持续时间为10S,时间结束后,强制结束你的回合");

                    //----------------------------------------------------------------------------------------
                    break;

                case MomentType.CombatPhase:
                    //----------------------------------------------------------------------------------------
                    //当前为战斗阶段;(怪兽List不为空的时候)
                    Console.WriteLine("当前为战斗阶段");

                    //----------------------------------------------------------------------------------------
                    break;

                //----------------------------------------------------------------------------------------
                default:
                    break;
                }

                //-------------------------------------------------------------------------------------------------
            }



            //------------------------------------------------------------
        }
Esempio n. 13
0
        //----------------------------------------------------------------
        public override void Execute()
        {
            //事件接口;
            //----------------------------------------------------------------
            _cardOfKickTheDoorAtPresent = CoreDataObserver.GetInstance().Get_CardOfKickTheDoorAtPresent();//获取当前的踢门牌;
            if (_cardOfKickTheDoorAtPresent != null)
            {
                _cardOfKickTheDoorAtPresent.SetPlayerId(CoreDataObserver.GetInstance().GetPlayer().GetId()); //设置此卡牌的拥有者;
                CoreDataObserver.GetInstance().GetPlayer().SetCardInMyHand(_cardOfKickTheDoorAtPresent);     //将当前的踢门牌加入手牌中;
                Debug.Log(CoreDataObserver.GetInstance().GetPlayer().GetCardInMyHand().Count);
            }

            //----------------------------------------------------------------
        }
Esempio n. 14
0
        //----------------------------------------------------------------
        public override void Execute()
        {
            //事件接口;
            //----------------------------------------------------------------
            _cardOfThePlayAtPresent = CoreDataObserver.GetInstance().Get_CardOfThePlayAtPresent();
            if (_cardOfThePlayAtPresent != null)
            {
                //如果此卡牌不为空;
                //将其投递到卡牌队列中;
                CoreDataObserver.GetInstance().SetQueueOfAttackEnemyCards(_cardOfThePlayAtPresent);
            }



            //----------------------------------------------------------------
        }
        //----------------------------------------------------------------
        //事件组合器;
        public override void Update()
        {
            //-------------------------------------------------------------
            if (CoreDataObserver.GetInstance().GetQueueOfAttackEnemyCards().Count > 0)
            {
                //当前的队列不为空;
                _attackEnemyCard = CoreDataObserver.GetInstance().GetQueueOfAttackEnemyCards().Dequeue();

                //---------------------------------------------------------
                //通过网络将数据(AttackEnemyCard)发送给特定的玩家;(需要启动协程么?!)

                //---------------------------------------------------------
            }

            //-------------------------------------------------------------
        }
        //----------------------------------------------------------------
        //事件组合器;
        public override void Update()
        {
            //游戏阶段更新;

            _double = CoreDataObserver.GetInstance().Get_CardOfKickTheDoorAtPresent();//获取最新的卡牌数据;
            if (_double != _cardOfKickTheDoorAtPresent)
            {
                _cardOfKickTheDoorAtPresent = _double;
                //-------------------------------------------------------------------------------------------------
                //Do something:
                //Put event;
                switch (_cardOfKickTheDoorAtPresent.GetCardType())
                {
                case CardType.DebuffCard:
                    //-----------------------------------------------------------------------------------------
                    //当前抽到的卡片为诅咒卡和即时魔法卡;
                    EventQueue.GetInstance().PushEventForSecondqueue(EventFactory.GetInstance().GetEvent("Debuff_CreatEventOne"));    //投递事件;

                    //-----------------------------------------------------------------------------------------
                    break;

                case CardType.MonsterCard:
                    //-----------------------------------------------------------------------------------------
                    //当前抽到的卡片为怪兽卡;
                    EventQueue.GetInstance().PushEventForSecondqueue(EventFactory.GetInstance().GetEvent(" GetMonsterCardAndPushItToList"));

                    //-----------------------------------------------------------------------------------------
                    break;

                default:
                    //-----------------------------------------------------------------------------------------
                    //其余卡片;(将此卡片加入手牌中)
                    EventQueue.GetInstance().PushEventForSecondqueue(EventFactory.GetInstance().GetEvent("GetACardOfKickTheDoor"));    //投递事件;
                    //------------------------------------------------------------------------------------------
                    //Test:
                    //当前的手牌

                    //-----------------------------------------------------------------------------------------
                    break;
                }

                //-------------------------------------------------------------------------------------------------
            }
        }
        //----------------------------------------------------------------
        public override void Execute()
        {
            //事件接口;
            //----------------------------------------------------------------
            //将当前的踢门牌存入_cardOfTheMonsterAtPresent中;
            Card monstercard = CoreDataObserver.GetInstance().Get_CardOfKickTheDoorAtPresent();

            if (monstercard != null && monstercard.GetCardType() == CardType.MonsterCard)
            {
                //卡片不为空且为怪兽卡片;
                //将其存入list中;
                CoreDataObserver.GetInstance().SetCardOfTheMonsterAtPresent(monstercard);
            }
            else
            {
                Console.WriteLine("当前的踢门牌为空,或者当前的卡片不为怪兽卡");
            }
            //----------------------------------------------------------------
        }
Esempio n. 18
0
        //----------------------------------------------------------------
        public override void Execute()
        {
            //事件接口;
            //----------------------------------------------------------------
            Card card = null;

            card = UI_PlayerPanel.Instance.ReturnACard();
            Debug.Log(card.GetName());
            if (card != null)
            {
                CoreDataObserver.GetInstance().Set_CardOfKickTheDoorAtPresent(card);
            }
            else
            {
                Console.WriteLine("当前抽取的踢门牌为空");
            }

            //----------------------------------------------------------------
        }
Esempio n. 19
0
        //----------------------------------------------------------------
        public void Run()
        {
            //----------------------------------------------------------------
            //初始化;(携程申请,初始化牌堆.......//有关卡牌的东西都以发事件的方式进行)
            //游戏主逻辑流程;
            BaseEventListener();
            //CoreDataObserver.GetInstance().SetMomentTypeAtPresent(MomentType.KickTheDoor);
            CoreDataObserver.GetInstance().Set_CardOfThePlayAtPresent(UI_PlayerPanel.Instance.ReturnACard());
            //CoreDataObserver.GetInstance().Set_CardOfThePlayAtPresent(UI_PlayerPanel.Instance.ReturnBCard());
            //CoreDataObserver.GetInstance().Set_CardOfThePlayAtPresent(UI_PlayerPanel.Instance.ReturnCCard());



            //while (true)
            //{


            //}
            //...........
            //........
            //.....
            //----------------------------------------------------------------
        }
        //----------------------------------------------------------------
        //事件组合器;
        public override void Update()
        {
            _double = CoreDataObserver.GetInstance().Get_CardOfThePlayAtPresent();//获取最新的打出卡牌数据;
            if (_double != _cardOfThePlayAtPresent)
            {
                _cardOfThePlayAtPresent = _double;
                //-------------------------------------------------------------------------------------------------
                //Do something:
                //Put event;
                switch (_cardOfThePlayAtPresent.GetCardType())
                {
                case CardType.MagicCard:
                    //-----------------------------------------------------------------------------------------
                    //当前出的卡片为魔法卡;
                    //EventQueue.GetInstance().PushEventForSecondqueue(EventFactory.GetInstance().GetEvent("Debuff_CreatEventOne"));//投递事件;
                    if (CoreDataObserver.GetInstance().GetMomentTypeAtPresent() == MomentType.DisruptivePhase || CoreDataObserver.GetInstance().GetMomentTypeAtPresent() == MomentType.A_HandoutPhase)
                    {
                        //如果当前阶段为捣乱阶段或者施舍阶段;
                        EventQueue.GetInstance().PushEventForSecondqueue(EventFactory.GetInstance().GetEvent("PushAttackEnemyCards"));    //投递事件;
                    }
                    else
                    {
                        //为其他阶段;
                        //表明作用对象为本人或者为本人所面对的怪物;
                        EventQueue.GetInstance().PushEventForSecondqueue(EventFactory.GetInstance().GetEvent("Magic_CreatEvent"));    //投递事件;
                    }
                    //-----------------------------------------------------------------------------------------
                    break;

                case CardType.MonsterCard:
                    //-----------------------------------------------------------------------------------------
                    //当前出的卡片为怪兽卡;


                    //-----------------------------------------------------------------------------------------
                    break;

                case CardType.EquipmentCard:
                    //-----------------------------------------------------------------------------------------
                    //当前出的卡牌为装备卡;


                    //-----------------------------------------------------------------------------------------
                    break;

                case CardType.OccupationCard:
                    //-----------------------------------------------------------------------------------------
                    //当前出的卡牌为职业卡;


                    //-----------------------------------------------------------------------------------------
                    break;

                case CardType.RaceCard:
                    //-----------------------------------------------------------------------------------------
                    //当前出的卡牌为种族卡;


                    //-----------------------------------------------------------------------------------------
                    break;

                case CardType.DebuffCard:

                    //-----------------------------------------------------------------------------------------
                    //当前出的卡牌为诅咒卡;


                    //-----------------------------------------------------------------------------------------
                    break;



                default:
                    //-----------------------------------------------------------------------------------------


                    //-----------------------------------------------------------------------------------------
                    break;
                }

                //-------------------------------------------------------------------------------------------------
            }
        }