Beispiel #1
0
    virtual protected void UpdateOtherStayAway(object sender, MessageEventArgs msg)
    {
        if (!msg.GetMessage("Level").Equals(level))
        {
            return;
        }
        float   distance     = float.Parse(msg.GetMessage("AwayDistance"));
        Vector3 towardCenter = ((GameObject)sender).transform.localPosition - oriPos;

        transform.localPosition = -towardCenter * (distance - 1) + oriPos;
    }
Beispiel #2
0
 virtual protected void UpdateThisStayAway(object sender, MessageEventArgs msg)
 {
     if (!msg.GetMessage("Level").Equals(level))
     {
         return;
     }
 }
 void OnItemClicked(MessageEventArgs args)
 {
     int itemID = args.GetMessage<int>("ItemID");
     ItemData itemData = DataManager.Instance.GetItemDataSet().GetItemData(itemID);
     args.AddMessage ("Message", itemData.description);
     EventManager.Instance.PostEvent (UIEvent.OnMessageSet, args);
 }
    void OpenUIWindow(MessageEventArgs args)
    {
        UIWindowID windowID = args.GetMessage<UIWindowID>("WindowID");

        if(windowStack.Count > 0)
        {
            GameObject lastWindow = windowStack[windowStack.Count - 1];
            CanvasGroup canvasGroup = lastWindow.GetComponent<CanvasGroup>();
            canvasGroup.alpha = 1;
            canvasGroup.DOFade(0, 0.25f).OnComplete(()=>{lastWindow.SetActive(false);});
        }

        GameObject window = windowStack.Find((GameObject x)=>{return x.name.Contains(windowID.ToString());});
        if(window != null)
        {
            window.SetActive(true);
            windowStack.Remove(window);
            windowStack.Add(window);
        }
        else
        {
            window = GameObject.Instantiate(Resources.Load(GlobalDataStructure.PATH_UIPREFAB_WINDOW + windowID.ToString()) as GameObject);
            windowStack.Add(window);
        }

        if(windowStack.Count > 1)
        {
            CanvasGroup canvasGroup = window.GetComponent<CanvasGroup>();
            canvasGroup.alpha = 0;
            canvasGroup.DOFade(1, 0.5f);
        }
    }
Beispiel #5
0
    void OnSubmitInput(EventDefine eventName, object sender, EventArgs args)
    {
        MessageEventArgs msg       = (MessageEventArgs)args;
        string           inputText = msg.GetMessage("text");

        foreach (BlockState _blockState in blockStateList)
        {
            foreach (UniState _state in _blockState.stateList)
            {
                if (_state.recieveInput(inputText))
                {
                    _blockState.StateOver(_state);

                    foreach (UniState _for in _state.forwardStateList)
                    {
                        if (_for.isPreStatesOver())
                        {
                            _for.Active();
                            _for.parent.StateActive(_for);
                        }
                    }
                    return;
                }
            }
        }
    }
 void OnMessageUpdate(MessageEventArgs args)
 {
     string msg = args.GetMessage<string>("Message");
     //handle msgList
     msgList.Add(msg);
     while(msgList.Count > MAX_MSG_COUNT)
     {
         msgList.RemoveAt(0);
     }
     //handle alignment
     if (msgList.Count >= ALIGNMENT_MSG_COUNT)
     {
         message.alignment = TextAnchor.LowerLeft;
     }
     else
     {
         message.alignment = TextAnchor.UpperLeft;
     }
     //reassamble message
     message.text = "";
     for(int i = 0; i < msgList.Count - 1; i++)
     {
         message.text += msgList[i] + "\n";
     }
     //highlight latest message with animation
     message.DOKill();
     message.DOText(message.text + "<color=yellow>" + msgList[msgList.Count - 1] + "</color>", 0.5f).SetEase(Ease.Linear);
 }
 void OnMessageSet(MessageEventArgs args)
 {
     string msg = args.GetMessage<string>("Message");
     message.text = msg;
     msgList.Clear();
     msgList.Add(msg);
 }
Beispiel #8
0
    public void OnEnterCenter(EventDefine eventName, object sender, EventArgs args)
    {
        MessageEventArgs msg     = (MessageEventArgs)args;
        string           message = msg.GetMessage("message");
        string           type    = msg.GetMessage("type");

        if (type != null && type.Equals(Global.PERSON))
        {
            tempDifficulty++;
        }
        Process p = (Process)Enum.Parse(typeof(Process), msg.GetMessage("process"));

        if (SetProcess(p))
        {
            text.ShowText(message);
        }
    }
Beispiel #9
0
    void OnChangeInput(EventDefine eventName, object sender, EventArgs args)
    {
        MessageEventArgs msg   = (MessageEventArgs)args;
        string           input = msg.GetMessage("text");

        if (blockState.checkState(input))
        {
            TipsCoverText.text = input;
        }
    }
 void PlayBattleBGM(MessageEventArgs args)
 {
     int battleType = args.GetMessage<int>("BattleType");
     if(battleType == 0)
         AudioManager.Instance.PlayBGM ("Battle0" + UnityEngine.Random.Range(1,4));
     else if(battleType == 1)
         AudioManager.Instance.PlayBGM ("Boss0" + UnityEngine.Random.Range(1,3));
     else if(battleType == 2)
         AudioManager.Instance.PlayBGM ("FinalBoss");
 }
 void OnItemClicked(MessageEventArgs args)
 {
     if(args.GetMessage<int>("ItemID") == itemData.id)
     {
         this.GetComponent<Image>().sprite = Resources.Load(GlobalDataStructure.PATH_UIIMAGE_COMMON + "Box_Light", typeof(Sprite)) as Sprite;
     }
     else
     {
         this.GetComponent<Image>().sprite = Resources.Load(GlobalDataStructure.PATH_UIIMAGE_COMMON + "Box_Dark", typeof(Sprite)) as Sprite;
     }
 }
 void OnCommandClicked(MessageEventArgs args)
 {
     if(args.GetMessage<string>("CommandName") == nameText.text)
     {
         this.GetComponent<Image>().sprite = Resources.Load(GlobalDataStructure.PATH_UIIMAGE_COMMON + "Box_Light", typeof(Sprite)) as Sprite;
     }
     else
     {
         this.GetComponent<Image>().sprite = Resources.Load(GlobalDataStructure.PATH_UIIMAGE_COMMON + "Box_Dark", typeof(Sprite)) as Sprite;
     }
 }
 void PlayBGM(MessageEventArgs args)
 {
     UIWindowID windowID = args.GetMessage<UIWindowID>("WindowID");
     if(windowID == UIWindowID.IntroWindow)
     {
         AudioManager.Instance.PlayBGM ("Theme");
     }
     else if(windowID == UIWindowID.MapWindow)
     {
         AudioManager.Instance.PlayBGM ("Map");
     }
 }
    void OnBasicCommandSelected(MessageEventArgs args)
    {
        Player player = BattleManager.Instance.GetCurrentPlayer();
        foreach(Transform child in commandButtonPanel)
        {
            Destroy(child.gameObject);
        }

        CommandType commandType = (CommandType)args.GetMessage<int>("CommandID");
        List<Command> validCommands = player.availableCommands.FindAll((x)=>{return x.commandType == commandType;});
        for(int i = 0 ; i < validCommands.Count; i++)
        {
            GameObject commandButton = Instantiate(Resources.Load(GlobalDataStructure.PATH_UIPREFAB_BATTLE + "CommandButton")) as GameObject;
            commandButton.transform.SetParent(commandButtonPanel, false);
            commandButton.GetComponent<CommandButtonUIEvent>().Init(validCommands[i], validCommands[i].IsAvailable());
        }
    }
    IEnumerator StartBattle(MessageEventArgs args)
    {
        if(args.ContainsMessage("Man"))
        {
            GameObject player = Instantiate(Resources.Load(GlobalDataStructure.PATH_UIPREFAB_BATTLE + "Character")) as GameObject;
            player.transform.SetParent(playerPanel.transform, false);
            player.GetComponent<Player>().Init(0);

            player.transform.DOLocalMoveX(-250,0.5f);
        }

        if(args.ContainsMessage("Girl"))
        {
            GameObject player = Instantiate(Resources.Load(GlobalDataStructure.PATH_UIPREFAB_BATTLE + "Character")) as GameObject;
            player.transform.SetParent(playerPanel.transform, false);
            player.GetComponent<Player>().Init(1);

            player.transform.DOLocalMoveX(250,0.5f);
        }

        if(args.ContainsMessage("Enemy"))
        {
            int[] enemyIDs = args.GetMessage<int[]>("Enemy");
            for(int i = 0; i < enemyIDs.Length; i++)
            {
                GameObject enemy = Instantiate(Resources.Load(GlobalDataStructure.PATH_UIPREFAB_BATTLE + "Enemy")) as GameObject;
                enemy.transform.SetParent(enemyPanel.transform, false);
                enemy.GetComponent<Enemy>().Init(enemyIDs[i]);
                enemy.transform.localScale = new Vector3(0,0,0);
                enemy.transform.DOScale(1, 1);
                yield return new WaitForSeconds(1f);
                switch(enemyIDs.Length)
                {
                case 2: if(i == 0)
                        enemy.transform.DOLocalMoveX(-150,0.5f);
                    else if(i == 1)
                        enemy.transform.DOLocalMoveX(150,0.5f);
                    break;
                case 3:	if(i == 0)
                        enemy.transform.DOLocalMoveX(-200,0.5f);
                    else if(i == 1)
                        enemy.transform.DOLocalMoveX(200,0.5f);
                    break;
                }
            }
        }

        yield return new WaitForSeconds(0.5f);
        EventManager.Instance.PostEvent (BattleEvent.OnBattleStart);
    }
 void OnExecuteCommand(MessageEventArgs args)
 {
     string message = args.GetMessage<string>("Message");
     AddMessage(message);
 }
    void OnBattleObjectDied(MessageEventArgs args)
    {
        BattleObject bo = args.GetMessage<BattleObject>("Object");
        if(bo.isEnemy)
        {
            enemys.Remove((Enemy)bo);
            bo.GetComponent<BattleObjectUIEvent>().DestoryUI();
            if(enemys.Count == 0)
            {
                EventManager.Instance.PostEvent(BattleEvent.OnBattleWin);

                StartCoroutine(FinishBattle());
            }
        }
        else
        {
            EventManager.Instance.PostEvent(BattleEvent.OnBattleLose);
            StartCoroutine(FinishBattle());
        }
    }
 void OnEffectExecuted(MessageEventArgs args)
 {
     string message = args.GetMessage<string>("Message");
     AddMessage(message);
 }
    void OnCommandSelected(MessageEventArgs args)
    {
        currentPlayer.commandToExecute = currentCommand;
        bool result = SkillHelper.FillCommandTarget(currentPlayer);
        if(!result)
        {
            if(args.ContainsMessage("Target"))
            {
                BattleObject bo = args.GetMessage<BattleObject>("Target");
                currentCommand.targetList.Add(bo);
            }
        }
        currentPlayer.GetComponent<BattleObjectUIEvent>().EndReady();
        currentPlayer.battleStatus = BattleStatus.Action;
        foreach(Enemy enemy in enemys)
        {
            enemy.GetComponent<BattleObjectUIEvent>().DisableClick();
        }
        foreach(Player player in players)
        {
            player.GetComponent<BattleObjectUIEvent>().DisableClick();
        }

        readyQueue.Dequeue();
    }
 void OnBattleObjectHeal(MessageEventArgs args)
 {
     string name = args.GetMessage<string>("Name");
     int amount = args.GetMessage<int>("Amount");
     AddMessage(name + " 回复了 " + amount + "点生命!");
 }
Beispiel #21
0
 static void HandleConsumerOnMessageReceived(object sender, MessageEventArgs args)
 {
     Console.WriteLine("Message Received from channel <  " + args.GetChannel() + " > with data <  " + args.GetMessage() + " >");
     consumer.Unsubscribe();
 }
 void OnBattleObjectDied(MessageEventArgs args)
 {
     BattleObject bo = args.GetMessage<BattleObject>("Object");
     AddMessage(bo.GetName() + " 不敌!");
 }
 void OnBattleObjectCounter(MessageEventArgs args)
 {
     string name = args.GetMessage<string>("Name");
     AddMessage(name + " 看穿了攻击,并做出反击!");
 }
 void OnMPAutoRecover(MessageEventArgs args)
 {
     string name = args.GetMessage<string>("Name");
     int amount = args.GetMessage<int>("Amount");
     AddMessage(name + "的灵力自动恢复了" + amount + "点!");
 }
 void OnPlayerReady(MessageEventArgs args)
 {
     Player player = args.GetMessage<Player>("Player");
     readyQueue.Enqueue(player);
 }
 void OnBattleObjectMiss(MessageEventArgs args)
 {
     string name = args.GetMessage<string>("Name");
     AddMessage("被" + name + "躲开了!");
 }
 void OnEnemySpawn(MessageEventArgs args)
 {
     BattleObject bo = args.GetMessage<BattleObject>("Object");
     enemys.Add(bo as Enemy);
 }
 void OnBuffDeactivated(MessageEventArgs args)
 {
     string message = args.GetMessage<string>("Message");
     AddMessage(message);
 }
 void OnCommandClicked(MessageEventArgs args)
 {
     string commandName = args.GetMessage<string>("CommandName");
     currentCommand = currentPlayer.availableCommands.Find((Command cmd)=>{return cmd.commandName == commandName;});
     switch(currentCommand.targetType)
     {
     case TargetType.SingleEnemy:
         foreach(Enemy enemy in enemys)
         {
             enemy.GetComponent<BattleObjectUIEvent>().EnableClick();
         }
         break;
     case TargetType.SingleAlly:
         foreach(Player player in players)
         {
             player.GetComponent<BattleObjectUIEvent>().EnableClick();
         }
         break;
     case TargetType.OtherAlly:
         foreach(Player player in players)
         {
             if(player != currentPlayer)
             {
                 player.GetComponent<BattleObjectUIEvent>().EnableClick();
             }
         }
         break;
     default:
         EventManager.Instance.PostEvent(BattleEvent.OnCommandSelected);
         break;
     }
 }
Beispiel #30
0
 private void OnMessage(object myobject, MessageEventArgs myargs)
 {
     _synchronizationContext.Send(_ => { OutputTextBox.AppendText(myargs.GetMessage() + "\n"); }, this);
 }
Beispiel #31
0
 void OnChangeInput(EventDefine eventName, object sender, EventArgs args)
 {
     MessageEventArgs msg       = (MessageEventArgs)args;
     string           inputText = msg.GetMessage("text");
 }
 void OnPlayerSpawn(MessageEventArgs args)
 {
     BattleObject bo = args.GetMessage<BattleObject>("Object");
     players.Add(bo as Player);
 }
 void OnBattleObjectHurt(MessageEventArgs args)
 {
     string name = args.GetMessage<string>("Name");
     int damage = args.GetMessage<int>("Damage");
     AddMessage(name + " 受到" + damage + "点伤害!");
 }
 void OnEnemySpawn(MessageEventArgs args)
 {
     BattleObject bo = args.GetMessage<BattleObject>("Object");
     AddMessage(bo.GetName() + " 出现了!");
 }
 void OnBattleObjectInterrupted(MessageEventArgs args)
 {
     string name = args.GetMessage<string>("Name");
     AddMessage(name + " 的行动被打断了!");
 }
 void OnPlayDialogue(MessageEventArgs args)
 {
     dialogID = args.GetMessage<int>("DialogueID");
     PlayDialogue();
 }