Beispiel #1
0
 private static void OnLogMessage(string condition, string stackTrace, LogType type)
 {
     if (type == LogType.Log)
     {
         NotificationCenter <string> .Get().DispatchEvent("ShowINFO", condition);
     }
 }
Beispiel #2
0
    /// <summary>
    /// 我方精灵使用技能
    /// </summary>
    /// <param name="notific"></param>
    private void PlayerPokemonUseSkill(Notification <int> notific)
    {
        int skillID = PlayerCurPokemonData.skills[notific.param];
        int pp      = PlayerCurPokemonData.skillPPs[notific.param];

        if (pp <= 0)
        {
            NotificationCenter <int> .Get().DispatchEvent("DisableSkillButton", notific.param);

            return;
        }
        if (DisableSkill.context.ContainsKey(PlayerCurPokemonData.ID))
        {
            int disableskillID = DisableSkill.context[PlayerCurPokemonData.ID];
            for (int i = 0; i < PlayerCurPokemonData.skills.Count; ++i)
            {
                if (disableskillID == PlayerCurPokemonData.skills[i])
                {
                    NotificationCenter <int> .Get().DispatchEvent("DisableSkillButton", i);

                    return;
                }
            }
        }
        PlayChooseSkillID = skillID;
        DebugHelper.LogFormat("你选择使用了技能{0}", ResourceController.Instance.allSkillDic[PlayChooseSkillID].sname);
        UpdateBattleState();
    }
        private void OnEnable()
        {
            NotificationCenter <distroyWall> .Get().AddEventListener("distroyWall", DistroyWall);

            Init();
            GenerateMaze();
            StartCoroutine(ShowWaze());
        }
Beispiel #4
0
 protected override void Execute(List <GameEntity> entities)
 {
     foreach (GameEntity entity in entities)
     {
         NotificationCenter <int> .Get().DispatchEvent("PokemonDeathMessage"
                                                       , entity.battlePokemonData.data.ID);
     }
 }
Beispiel #5
0
    public override void Awake(GameObject go)
    {
        text = transform.Find("Text").GetComponent <Text>();
        text.horizontalOverflow = HorizontalWrapMode.Wrap;
        NotificationCenter <string> .Get().AddEventListener("ShowINFO", ShowINFO);

        LHCoroutine.CoroutineManager.DoCoroutine(showMessage());
        Application.logMessageReceived += OnLogMessage;
    }
Beispiel #6
0
    public void OnValueChanged(float value)
    {
        //获得RGB数值
        float r = sliderR.value;
        float g = sliderG.value;
        float b = sliderB.value;

        //分发事件,注意和接收者协议一致
        NotificationCenter.Get().DispatchEvent("ChangeColor", new Color(r, g, b));
    }
Beispiel #7
0
        public void Swap(int i, int j)
        {
            NotificationCenter <KeyValuePair <int, int> > .Get().DispatchEvent
                ("SwapPuke", new KeyValuePair <int, int>(pukes[i], pukes[j]));

            int m = pukes[i];

            pukes[i] = pukes[j];
            pukes[j] = m;
        }
    public override void Awake(GameObject go)
    {
        context = Contexts.sharedInstance.game;
        InitUnityComponents();
        NotificationCenter <int> .Get().AddEventListener("DisableSkillButton", DisableSkillButtonEvent);

        //NotificationCenter<int>.Get().AddEventListener("EnableSkillButton", EnableSkillButtonEvent);
        BattleStateForPlayer.InitEvent += PlayerRound;
        BattleStateForBattle.InitEvent += BattleRound;
        Refresh();
    }
    public override void Awake(GameObject go)
    {
        rectTransform = transform.GetComponent <RectTransform>();

        toolTipText           = transform.GetComponent <Text>();
        contentText           = transform.Find("Content").GetComponent <Text>();
        toolTipCanvasGroup    = transform.GetComponent <CanvasGroup>();
        this.toolTipText.text = "";
        this.contentText.text = "";
        NotificationCenter <ToolTipMessage> .Get().AddEventListener("UIToolTip", Show);
    }
Beispiel #10
0
    public override void Awake(GameObject go)
    {
        NotificationCenter <Pokemon> .Get().AddEventListener("CatchPokemonResult", Refresh);

        rectTransform      = transform.GetComponent <RectTransform>();
        pokemonIcon        = transform.Find("Icon").GetComponent <Image>();
        health_text        = transform.Find("Text/health").GetComponent <Text>();
        physicPower_text   = transform.Find("Text/physicPower").GetComponent <Text>();
        physicDefence_text = transform.Find("Text/physicDefence").GetComponent <Text>();
        energyDefence_text = transform.Find("Text/EnergyDefence").GetComponent <Text>();
        energyPower_text   = transform.Find("Text/EnergyPower").GetComponent <Text>();
        speed_text         = transform.Find("Text/speed").GetComponent <Text>();
    }
 /// <summary>
 /// 打通起点终点的边界墙,起点终点随机
 /// </summary>
 public void RandomOpenStartAndPoint()
 {
     if (Random.Range(0, 2) > 1)
     {
         if (Random.Range(0, 2) < 1)
         {
             int index = Random.Range(0, RowLength - 1);
             while (!row[index, 0])
             {
                 index = Random.Range(0, RowLength - 1);
             }
             row[index, 0] = false;
             NotificationCenter <distroyWall> .Get().DispatchEvent("distroyWall",
                                                                   new distroyWall(wall.row, index, 0));
         }
         else
         {
             int index = Random.Range(0, RowLength - 1);
             while (!row[index, RowLength])
             {
                 index = Random.Range(0, RowLength - 1);
             }
             row[index, ColLength] = false;
             NotificationCenter <distroyWall> .Get().DispatchEvent("distroyWall",
                                                                   new distroyWall(wall.row, index, ColLength));
         }
     }
     else
     if (Random.Range(0, 2) < 1)
     {
         int index = Random.Range(0, ColLength - 1);
         while (!row[index, 0])
         {
             index = Random.Range(0, ColLength - 1);
         }
         col[index, 0] = false;
         NotificationCenter <distroyWall> .Get().DispatchEvent("distroyWall",
                                                               new distroyWall(wall.col, index, 0));
     }
     else
     {
         int index = Random.Range(0, ColLength - 1);
         while (!row[index, RowLength])
         {
             index = Random.Range(0, ColLength - 1);
         }
         col[index, RowLength] = false;
         NotificationCenter <distroyWall> .Get().DispatchEvent("distroyWall",
                                                               new distroyWall(wall.col, index, RowLength));
     }
 }
    void Start()
    {
        //在接收者中注册事件及其回调方法
        NotificationCenter.Get().AddEventListener("ChangeColor", ChangeColor);

        //在发送者中分发事件,这里以UI逻辑为例
        sliderR = GameObject.Find("Canvas/SliderR").GetComponent <Slider>();
        sliderG = GameObject.Find("Canvas/SliderG").GetComponent <Slider>();
        sliderB = GameObject.Find("Canvas/SliderB").GetComponent <Slider>();
        //注册UI事件
        sliderR.onValueChanged.AddListener(OnValueChanged);
        sliderG.onValueChanged.AddListener(OnValueChanged);
        sliderB.onValueChanged.AddListener(OnValueChanged);
    }
    private static void UseBagItem(ItemUI itemUI)
    {
        BagItems bagItems = itemUI.Items;

        if (0 >= bagItems.count)
        {
            Debug.LogError("数量为0的道具不该存在");
        }
        bagItems.count -= 1;
        ShowBagItem();
        if (context.isBattleFlag)
        {
            NotificationCenter <string> .Get().DispatchEvent("UseBagItem", bagItems.ItemName);
        }
    }
Beispiel #14
0
        public void ResetPuke(int[] newpukes)
        {
            if (newpukes.Length != pukes.Length)
            {
                Debug.LogError("牌库数量出现了变化");
                return;
            }
            for (int i = 0; i < newpukes.Length; ++i)
            {
                NotificationCenter <KeyValuePair <int, int> > .Get().DispatchEvent
                    ("MovePuke", new KeyValuePair <int, int>(newpukes[i], i));
            }

            pukes = newpukes;
        }
Beispiel #15
0
 /// <summary>
 /// 打通起点终点的边界墙,起点终点随机
 /// </summary>
 public void RandomOpenStartAndPoint()
 {
     var arr = new[]
     {
         new
         {
             indexMax = RowLength - 1,
             rightIndex = 0,
             wall = wall.row,
             wallarr = this.row,
         },
         new
         {
             indexMax = RowLength - 1,
             rightIndex = ColLength,
             wall = wall.row,
             wallarr = this.row,
         },
         new
         {
             indexMax = ColLength - 1,
             rightIndex = 0,
             wall = wall.col,
             wallarr = this.col,
         },
         new
         {
             indexMax = ColLength - 1,
             rightIndex = RowLength,
             wall = wall.col,
             wallarr = this.col,
         },
     };
     
     int r = Random.Range(0, 3);
     var choose = arr[r];
     int index = Random.Range(0, choose.indexMax);
     while (!choose.wallarr[index, choose.rightIndex])
     {
         index = Random.Range(0, choose.indexMax);
     }
         
     choose.wallarr[index, choose.rightIndex] = false;
     NotificationCenter<distroyWall>.Get().DispatchEvent("distroyWall",
         new distroyWall(choose.wall, index, choose.rightIndex));
    
     
 }
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (this.transform.childCount > 0)
     {
         if (null == ItemUI.Item)
         {
             return;
         }
         string toolTipText = ItemUI.Item.ToString();
         //Contexts.sharedInstance.game.ReplaceToolTipString
         //    (toolTipText, RectTransform.anchoredPosition);
         NotificationCenter <ToolTipMessage> .Get()
         .DispatchEvent("UIToolTip"
                        , new ToolTipMessage(toolTipText, RectTransform.anchoredPosition));
     }
 }
        private void Awake()
        {
            for (int i = 0; i < 54; i++)
            {
                pukeTransform[i] = canvas.transform.GetChild(i);
                pukesPos[i]      = pukeTransform[i].position;
            }
            NotificationCenter <KeyValuePair <int, int> > .Get().AddEventListener
                ("SwapPuke", SwapPuke);

            NotificationCenter <KeyValuePair <int, int> > .Get().AddEventListener
                ("MovePuke", MovePuke);

            StartCoroutine(ShowSwap());
            StartCoroutine(ShowMove());
        }
Beispiel #18
0
        /// <summary>
        /// 抽牌 i小于j
        /// </summary>
        /// <param name="i">被抽的牌</param>
        /// <param name="j">放的位置</param>
        public void Draw(int i, int j)
        {
            int num = pukes[i];

            for (int k = i; k < j; ++k)
            {
                NotificationCenter <KeyValuePair <int, int> > .Get().DispatchEvent
                    ("MovePuke", new KeyValuePair <int, int>(pukes[k + 1], k));

                pukes[k] = pukes[k + 1];
            }
            NotificationCenter <KeyValuePair <int, int> > .Get().DispatchEvent
                ("MovePuke", new KeyValuePair <int, int>(num, j));

            pukes[j] = num;
        }
Beispiel #19
0
        /// <summary>
        /// 打通区域
        /// </summary>
        public void OpenArea(WallArea area1, WallArea area2)
        {
            if(area1.rowLength == area2.rowLength)
            {
                row[area1.rowLength, Mathf.Max(area1.colLength, area2.colLength)] = false;
                NotificationCenter<distroyWall>.Get().DispatchEvent("distroyWall", 
                    new distroyWall(wall.row, area1.rowLength, Mathf.Max(area1.colLength, area2.colLength)));
                return;
            }

            if (area1.colLength == area2.colLength)
            {
                col[area1.colLength, Mathf.Max(area1.rowLength, area2.rowLength)] = false;
                NotificationCenter<distroyWall>.Get().DispatchEvent("distroyWall",
                    new distroyWall(wall.col, area1.colLength, Mathf.Max(area1.rowLength, area2.rowLength)));
            }
        }
    private static void ShowBagItem()
    {
        List <BagItems> bagItems = context.playerData.scriptableObject.bagItems;
        int             count    = 0;

        foreach (BagItems items in bagItems)
        {
            var bagitemUI = bagItem_list[count];
            NotificationCenter <BagItems> .Get().DispatchEvent("StoreItem" + bagitemUI.GetHashCode(), items);

            count++;
        }

        for (; count < 24; count++)
        {
            var bagitemUI = bagItem_list[count];
            NotificationCenter <BagItems> .Get().DispatchEvent("StoreItem" + bagitemUI.GetHashCode(), BagItems.NullItems);
        }
    }
Beispiel #21
0
    private void Start()
    {
        context = Contexts.sharedInstance.game;
        NotificationCenter <int> .Get().AddEventListener("UseSkill", PlayerPokemonUseSkill);

        NotificationCenter <int> .Get().AddEventListener("PokemonDeathMessage", PokemonDeathEvent);

        NotificationCenter <string> .Get().AddEventListener("UseBagItem", PlayerUseBagItem);

        NotificationCenter <int> .Get().AddEventListener("CatchPokemon", CatchPokemonResultEvent);

        NotificationCenter <int> .Get().AddEventListener("ExchangePokemon", ExchangePokemon);

        NotificationCenter <bool> .Get().AddEventListener("BattlePause", StopBattlePause);

        EndBattleSystem.EndBattleEvent += EndBattleEvent;

        BattleStateForPlayer.InitEvent += PlayerRound;
        BattleStateForBattle.InitEvent += BattleRound;
    }
    private void InitUnityComponents()
    {
        if (null == thisrect)
        {
            thisrect = gameObject.GetComponent <RectTransform>();
        }
        button_list.Clear();
        skill1rect_list.Clear();
        SkillPokemonTypeText_list.Clear();
        SkillNameText_list.Clear();
        SkillPPText_list.Clear();
        for (int i = 1; i <= 4; i++)
        {
            var sb = new StringBuilder(10)
                     .AppendFormat("Skill{0}", i);
            button_list.Add(transform.Find(
                                sb.ToString()).GetComponent <Button>());
            skill1rect_list.Add(transform.Find(sb.ToString()).GetComponent <RectTransform>());

            SkillPokemonTypeText_list.Add(transform.Find(
                                              new StringBuilder(10)
                                              .AppendFormat("Skill{0}", i)
                                              .Append("/Att").ToString()).GetComponent <Text>());
            SkillNameText_list.Add(transform.Find(
                                       new StringBuilder(10)
                                       .AppendFormat("Skill{0}", i)
                                       .Append("/Text").ToString()).GetComponent <Text>());
            SkillPPText_list.Add(transform.Find(
                                     new StringBuilder(10)
                                     .AppendFormat("Skill{0}", i)
                                     .Append("/PP").ToString()).GetComponent <Text>());

            int j = i - 1;
            button_list[i - 1].onClick.AddListener(() =>
            {
                NotificationCenter <int> .Get().DispatchEvent("UseSkill", j);
            });
        }
    }
Beispiel #23
0
 void Start()
 {
     _test_btn.onClick.AddListener(() => NotificationCenter.Get().DispatchEvent("TestEvt", 0));
 }
Beispiel #24
0
 // Use this for initialization
 void Start()
 {
     NotificationCenter.Get().AddEventListener("ColEvt", OnColEvt);
     Debug.Log("Regist Event");
 }
 private void CallPokemon(int index)
 {
     Hide();
     NotificationCenter <int> .Get().DispatchEvent("ExchangePokemon", index);
 }
Beispiel #26
0
 void Start()
 {
     NotificationCenter.Get().AddEventListener("TestEvt", OnCallBackFunc);
 }
Beispiel #27
0
 void OnCollisionEnter(Collision collision)
 {
     NotificationCenter.Get().DispatchEvent("ColEvt", this.gameObject);
     Debug.Log("Dispatch Event");
 }
 private void Awake()
 {
     NotificationCenter <BagItems> .Get().AddEventListener("StoreItem" + this.GetHashCode(), StoreItem);
 }
        public override void Effect(BattlePokemonData pokemon)
        {
            DebugHelper.LogFormat("你选择使用了{0}", BagItemName);
            ChangeCatachCorrection(pokemon);

            //精灵球和精灵球特效
            GameObject pokemonBallInPool = PokemonFactory.GetPokemonBall();

            pokemonBallInPool.transform.position =
                pokemon.transform.position +
                Vector3.up * 3;
            PokemonFactory.PokemonBallEffect(pokemon.transform.position);

            //精灵捕捉率计算
            int  shadeNum  = 0;
            bool issuccess = false;

            CatchPokemon.CatchPokemonResult(
                pokemon,
                this.CatachCorrection,
                1
                , out shadeNum, out issuccess);

            DebugHelper.Log(
                new StringBuilder(40)
                .AppendFormat("正在捕捉精灵{0},{1}振动了", pokemon.Ename, BagItemName)
                .Append(shadeNum)
                .AppendFormat("次,最后捕捉{0}了", issuccess ? "成功" : "失败")
                .ToString());

            pokemon.transform.GetComponent <Rigidbody>().useGravity = false;
            //精灵变小
            pokemon.transform
            .DOScale(0.01f, 0.5f)
            .OnComplete(
                () =>
            {
                Sequence mySequence = DOTween.Sequence();

                //精灵球振动
                for (int i = 0; i < shadeNum; ++i)
                {
                    mySequence.Append(pokemonBallInPool.transform.DOShakePosition(0.3f, new Vector3(-0.03f, 0.03f, 0.03f), 30));
                    mySequence.AppendInterval(0.2f);
                }

                mySequence.AppendCallback(() =>
                {
                    if (issuccess)
                    {
                        //捕捉精灵
                        LHCoroutine.CoroutineManager.DoCoroutine(CatachPokeomon(pokemon.pokemon));

                        //通知结束对战
                        NotificationCenter <int> .Get().DispatchEvent("CatchPokemon", 1);


                        //显示捕捉结果UI
                        NotificationCenter <Pokemon> .Get().DispatchEvent("CatchPokemonResult", pokemon.pokemon);

                        NotificationCenter <bool> .Get().DispatchEvent("BattlePause", false);
                    }
                    else
                    {
                        pokemon.transform.DOScale(1, 0.5f).
                        OnComplete(() =>
                        {
                            pokemon.transform.GetComponent <Rigidbody>().useGravity = true;
                            PokemonFactory.StorePokemonBallInPool(pokemonBallInPool);
                            NotificationCenter <bool> .Get().DispatchEvent("BattlePause", false);
                        });
                    }
                });
            }
                );
        }
Beispiel #30
0
 void OnDestroy()
 {
     NotificationCenter.Get().RemoveEventListener("ColEvt");
     Debug.Log("Remove Event");
 }