Esempio n. 1
0
    RandomEventController GetRootRandomEventControllerLink(Transform storyTransform, GeneralEvent generalEvent)
    {
        if (storyTransform == generalEvent.transform)
        {
            return(null);
        }

        RandomEventController randomEventController = storyTransform.GetComponent <RandomEventController>();

        if (randomEventController != null)
        {
            if (randomEventController.randomEventList.Exists(x => x == generalEvent))
            {
                //print(randomEventController.name);
                return(randomEventController);
            }
        }

        foreach (Transform transform in storyTransform)
        {
            RandomEventController foundRandomEventController = GetRootRandomEventControllerLink(transform, generalEvent);
            if (foundRandomEventController != null)
            {
                return(foundRandomEventController);
            }
        }

        return(null);
    }
Esempio n. 2
0
        public List <string> DoTask()
        {
            List <string> list = new List <string>();

            if (GeneralEvent == null)
            {
                return(null);
            }
            Delegate[] @delegate = GeneralEvent.GetInvocationList();
            //方法1
            //for (int i = 0; i < @delegate.Length; i++)
            //{
            //    GeneralEventHandler a =(GeneralEventHandler)@delegate[i];
            //    list.Add(a());
            //}

            //方法2
            //foreach (Delegate item in @delegate)
            //{
            //    try
            //    {
            //        item.DynamicInvoke(this);
            //    }
            //    catch (Exception e)
            //    {
            //        Console.WriteLine("Exception: {0}", e.Message);
            //    }
            //}

            //方法3
            FireEvent(GeneralEvent, null);
            return(list);
        }
Esempio n. 3
0
 private void onStartGame(GeneralEvent e)
 {
     _fader.FadeOut(FADE_TIME, () =>
     {
         _onComplete(JamStateType.LOAD_GAMEPLAY);
     });
 }
Esempio n. 4
0
 internal static void TryTriggerEvent(GeneralEvent Event, int Direction, EventTriggerType TriggerType, TrainManager.Train Train, int CarIndex)
 {
     if (!Event.DontTriggerAnymore)
     {
         Event.Trigger(Direction, TriggerType, Train, CarIndex);
     }
 }
Esempio n. 5
0
    public override void Draw(Transform trans)
    {
        textName.text = name;
        foreach (Transform transform in trans)
        {
            GeneralEvent generalEvent = transform.GetComponent <GeneralEvent>();
            if (generalEvent == null)
            {
                EditorAction eItem = (EditorBaseItem.CreatEditorChangeItem(transform.gameObject, actionPrefab, this.transform, transform.name) as EditorAction);

                Action action = transform.GetComponent <Action>();
                if (action != null)
                {
                    eItem.textName.text = action.text;
                    if (action.GetFirstComponentInChildren <Outcome>() != null)
                    {
                        eItem.SetStartColor(Color.green);
                        RandomEventController randomEvent = transform.GetComponent <RandomEventController>();
                        eItem.arrow_out.gameObject.SetActive(randomEvent != null && randomEvent.Count > 0);
                    }
                }
                else
                {
                    eItem.SetStartColor(Color.green);
                    eItem.arrow_out.gameObject.SetActive(false);
                }
            }
        }
    }
Esempio n. 6
0
 /// <summary>
 /// Raises a general event
 /// </summary>
 /// <param name="eventType">The type of event to raise</param>
 /// <param name="message">Description of the general event</param>
 void RaiseEvent(GeneralEvent eventType, string message)
 {
     if (GeneralEventHandler != null)
     {
         GeneralEventArgs args = new GeneralEventArgs(eventType, message);
         GeneralEventHandler(this, args);
     }
 }
Esempio n. 7
0
 private void onShowFTUE(GeneralEvent e)
 {
     _fader.FadeOut(FADE_TIME, () =>
     {
         mainMenu.ShowFTUE();
         _fader.FadeIn();
     });
 }
Esempio n. 8
0
 private void onBack(GeneralEvent e)
 {
     _fader.FadeOut(FADE_TIME, () =>
     {
         mainMenu.ShowMainMenu();
         _fader.FadeIn();
     });
 }
Esempio n. 9
0
 private void onGotoCredits(GeneralEvent e)
 {
     _fader.FadeOut(FADE_TIME, () =>
     {
         mainMenu.ShowCredits();
         _fader.FadeIn();
     });
 }
    private void onDamageTaken(GeneralEvent e)
    {
        DamageResult data = e.data as DamageResult;
        if (data != null)
        {

        }
    }
Esempio n. 11
0
    public void StopListening(string eventName, UnityAction <object> listener)
    {
        GeneralEvent thisEvent = null;

        if (eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
Esempio n. 12
0
    public static void TriggerEvent(int eventName, GeneralData generalData)
    {
        GeneralEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(generalData);
        }
    }
Esempio n. 13
0
    public void TriggerEvent(string eventName, object obj)
    {
        GeneralEvent thisEvent = null;

        if (eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(obj);
        }
    }
Esempio n. 14
0
    private void onFinishTurn(GeneralEvent e)
    {
        if (matchState.escrow.hasAllAssets)
        {
            _tuckMatchCore.ApplyTrade();
            _changeGameMatchMode(GameMatchMode.PLAYER_TURN);
        }

        _tuckMatchCore.ApplyNextPlayerTurn();
    }
Esempio n. 15
0
    public EventPanel CreatePanel(GeneralEvent generalEvent)
    {
        GameObject item = Instantiate(actionPrefab, content.transform, false) as GameObject;

        item.name = generalEvent.name;
        EventPanel eventPanel = item.GetComponent <EventPanel>();

        eventPanel.generalEvent = generalEvent;
        countItems++;
        return(eventPanel);
    }
    private void OnParentDamageTaken(GeneralEvent e)
    {
        DamageResult result = e.data as DamageResult;

        if (result != null)
        {
            _hudController.OnParentHealthChange(result.newHealth);
            if (_parentController.isDead)
            {
                _dispatcher.DispatchEvent(GameplayEventType.GAME_COMPLETE, false, false);
            }
        }
    }
Esempio n. 17
0
    public static void StopListening(int eventName, UnityAction <GeneralData> listener)
    {
        if (eventManager == null)
        {
            return;
        }
        GeneralEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
Esempio n. 18
0
    public override void OnPointerClick(PointerEventData eventData)
    {
        GeneralEvent generalEvent = storyTransform.GetComponent <GeneralEvent>();

        if (generalEvent != null)
        {
            SendMessageUpwards("DrawPreview", generalEvent);
        }
        else
        {
            SendMessageUpwards("DrawPreview", storyTransform.GetComponent <Outcome>());
        }

        SendMessageUpwards("DestroyChangeEventPanel");
    }
Esempio n. 19
0
    public static void StartListening(int eventName, UnityAction <GeneralData> listener)
    {
        GeneralEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new GeneralEvent();
            thisEvent.AddListener(listener);
            instance.eventDictionary.Add(eventName, thisEvent);
        }
    }
Esempio n. 20
0
    public void StartListening(string eventName, UnityAction <object> listener)
    {
        GeneralEvent thisEvent = null;

        if (eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new GeneralEvent();
            thisEvent.AddListener(listener);
            eventDictionary.Add(eventName, thisEvent);
        }
    }
Esempio n. 21
0
    void DrawChanceGeneralEvent()
    {
        RandomEventController randomEventController = action.GetComponent <RandomEventController>();
        GeneralEvent          revent = (randomEventController != null) ? randomEventController.GetEvent(0) : null;

        if (revent != null && randomEventController.Count == 1)
        {
            float chance = 0f;
            statImage.sprite = revent.GetIcon(ref chance);
            if (statImage.sprite != null)
            {
                DrawChance(chance);
            }
        }
    }
Esempio n. 22
0
    private void onTradeCardDrop(GeneralEvent e)
    {
        PointerEventData data        = (e.data as PointerEventData);
        CardView         droppedCard = data.pointerDrag.GetComponent <CardView>();

        if (_matchState.gameMatchMode != GameMatchMode.PARTNER_TRADE ||
            droppedCard == null ||
            _matchState.escrow.HasAssetFromPlayer(droppedCard.ownerIndex))
        {
            return;
        }

        Debug.Log("SwapCard: " + droppedCard);
        addTradeCard(droppedCard.ownerIndex, droppedCard.handIndex);
    }
Esempio n. 23
0
    public void LaunchGeneralEvent(bool continue_event)
    {
        if (current_event_id >= GeneralEventList.Count)
        {
            current_event_id = 0;
        }

        current_event = GeneralEventList[current_event_id];
        GeneralEvent eventData = current_event.GetComponent <GeneralEvent>();

        //print("--LaunchGeneralEvent " + continue_event);
        DrawActions(eventData.GetComponent <ActionListController>().actions, true);
        if (!continue_event)
        {
            WorldTime.Instance.UpdateTime(eventData.eventTime.start);
        }
    }
Esempio n. 24
0
    private void onPlayCardDrop(GeneralEvent e)
    {
        Debug.Log("PlayCard : " + e.data);

        PointerEventData data        = (e.data as PointerEventData);
        CardView         droppedCard = data.pointerDrag.GetComponent <CardView>();

        if (_playMoveState == PlayMoveState.PLAY_CARD)
        {
            _playMoveState = PlayMoveState.SELECT_PAWNS;
            _playerHandView.playCardMatEnabled = false;
            _currentMoveRequest.handIndex      = droppedCard.handIndex;


            DispatchEvent(e); // Pass on
        }
    }
Esempio n. 25
0
    public virtual List <EventPanel> CreateEventPanel(Transform transform)
    {
        List <EventPanel>     EventPanelList = new List <EventPanel>();
        RandomEventController randomEvent    = transform.GetComponent <RandomEventController>();

        if (randomEvent != null)
        {
            randomEvent.randomEventList.RemoveAll(x => x == null);
            foreach (GeneralEvent generalEvent in randomEvent.randomEventList)
            {
                if (!EventPanels.Exists(x => x.generalEvent == generalEvent))
                {
                    EventPanel eventPanel = CreatePanel(generalEvent);
                    EventPanelList.Add(eventPanel);
                    eventPanel.Draw(generalEvent.transform);
                }
            }
        }
        else
        {
            ActionMGController actionMGController = transform.GetComponent <ActionMGController>();
            if (actionMGController != null)
            {
                GeneralEvent generalEvent = actionMGController.MgComplite;
                if (!EventPanels.Exists(x => x.generalEvent == generalEvent))
                {
                    EventPanel eventPanel = CreatePanel(generalEvent);
                    EventPanelList.Add(eventPanel);
                    eventPanel.Draw(generalEvent.transform);
                }

                generalEvent = actionMGController.MgNotComplite;
                if (!EventPanels.Exists(x => x.generalEvent == generalEvent))
                {
                    EventPanel eventPanel = CreatePanel(generalEvent);
                    EventPanelList.Add(eventPanel);
                    eventPanel.Draw(generalEvent.transform);
                }
            }
        }
        EventPanels.AddRange(EventPanelList);
        return(EventPanelList);
    }
Esempio n. 26
0
    private void onPieceTapped(GeneralEvent e)
    {
        PieceView pieceView = e.data as PieceView;

        Debug.Log("Piece: " + pieceView.ToString());

        if (_playMoveState == PlayMoveState.SELECT_PAWNS)
        {
            CardData currentCard = activePlayer.hand.GetCard(_currentMoveRequest.handIndex);

            var piecePath = new MoveRequest.PiecePathData();
            piecePath.pieceIndex = pieceView.piece.index;

            var pathList = new List <MovePath>();
            if (_matchState.validator.GetValidPaths(pieceView.piece, currentCard, ref pathList))
            {
            }
        }
    }
Esempio n. 27
0
    public void DrawLineEvent(EditorAction eItem, GeneralEvent generalEvent, bool is_double_event = false)
    {
        EventPanel     ePanel     = EventPanels.Find(x => x.generalEvent == generalEvent);
        EventPanelLine ePanelLine = ePanel.GetComponent <EventPanelLine>();

        if (ePanel != null)
        {
            float scale = (eItem.line_event.position.y - ePanelLine.line_in.position.y) * 0.9965f;
            eItem.line_event.localScale = new Vector3(1, scale, 1);
            int step = 0;
            //print(" --generalEvent = " + generalEvent);
            if (scale > 0)
            {
                if (linesEventPanel.ContainsKey(ePanelLine))
                {
                    step = linesEventPanel[ePanelLine];
                }
                else
                {
                    step = (!is_double_event) ? FindEmptyStep() : eItem.level_line;
                    linesStep.Add(step);
                    linesEventPanel[ePanelLine]   = step;
                    eItem.level_line              = step;
                    ePanelLine.line_in.localScale = new Vector3((step + 1) * 2f, ePanelLine.line_in.localScale.y, 1);
                }
            }
            else
            {
                step             = FindMaxLevel() + 1;
                eItem.level_line = step;
                ePanelLine.line_in.localScale = new Vector3((step + 1) * 2f, ePanelLine.line_in.localScale.y, 1);
            }

            scale = (step + 1) * 2f;
            if (!is_double_event)
            {
                eItem.line_out.localScale = new Vector3(scale * eItem.line_out.localScale.x, 1, 1);
            }
            //print(eItem.line_out.localScale);
            eItem.line_event.localScale = new Vector3(1 / eItem.line_out.localScale.x, eItem.line_event.localScale.y, 1);
        }
    }
Esempio n. 28
0
    public void OnDelete()
    {
        Transform storyTransform = ContainerControllerBase.GetStoryTransform();

        if (storyTransform != null)
        {
            GeneralEvent generalEvent = storyTransform.GetComponent <GeneralEvent>();
            if (generalEvent != null)
            {
                foreach (RandomEventController randomEventController in container2.currentEditorBaseItem.storyTransform.GetComponentsInChildren <RandomEventController>())
                {
                    randomEventController.randomEventList.Remove(generalEvent);
                }
            }
            ReAttachRandomEventControllerLinks(storyTransform);
            //Destroy(storyTransform.gameObject);
            DestroyImmediate(storyTransform.gameObject);
            ContainerControllerBase.currentContainerController.currentEditorBaseItem = null;
            //ContainerController.current.Draw();
            EditorEventManager.TriggerEvent("RemoveItem_" + ContainerControllerBase.currentContainerController.name);
        }
    }
Esempio n. 29
0
    void SetEventPrefabName(GameObject go)
    {
        go.name = eventName + container3.EventPanelsCount();

        GeneralEvent generalEvent = go.GetComponent <GeneralEvent>();

        generalEvent.description_id = GameStrings.Instance.GetNextKey();
        string key = generalEvent.description_id.ToString();

        generalEvent.description = key;
        GameStrings.Instance.SetString(key, key);

        Action action = go.GetFirstComponentInChildren <Action>();

        if (action != null)
        {
            SetActionPrefabName(action);
        }
        else
        {
            SetOutcomePrefabName(go.GetFirstComponentInChildren <Outcome>());
        }
    }
Esempio n. 30
0
    public void Perform_Action()
    {
        if (type == "skip" && statChange.Count != 0)
        {
            foreach (Parameter param in statChange)
            {
                param.ChangeStat();
            }
        }

        RandomEventController randomEventController = GetComponent <RandomEventController>();

        if (randomEventController != null)
        {
            GeneralEvent generalEvent = randomEventController.GetRandomEvent();
            if (generalEvent != null && generalEvent.Launch())
            {
                return;
            }
        }

        gameObject.SendMessage("action_" + type);
    }
Esempio n. 31
0
 internal static void TryTriggerEvent(GeneralEvent Event, int Direction, EventTriggerType TriggerType, TrainManager.Train Train, int CarIndex)
 {
     if (!Event.DontTriggerAnymore) {
         Event.Trigger(Direction, TriggerType, Train, CarIndex);
     }
 }