public override void Cancel(GameEventData data = null)
    {
        //Debug.Log("Cancel Select : " + m_Blocks.Count);
        if (m_selectedCardPreviewList.Count == 0)
        {
            if (!m_CanCancel)
            {
                return;
            }

            HideInfo();
            Unregister();
            UnhighlightAll();

            if (cancelCallback != null)
            {
                cancelCallback.Invoke();
            }
            else
            {
                ActionManager.Instance.CancelAction();
            }

            cancelCallback = null;
        }
        else
        {
            UnselectTarget();
        }
    }
Ejemplo n.º 2
0
 protected override void React(GameEventData eventData)
 {
     if (TargetObject != null)
     {
         TargetObject.Respawn();
     }
 }
Ejemplo n.º 3
0
        public Task QueueAppendToBlobAsync(GameEventData data, string line)
        {
            var queue = GetQueueForGameEvent(data);

            queue.Enqueue(line);
            return(Task.CompletedTask);
        }
    public override void SelectTrigger(GameEventData eventData)
    {
        //Debug.Log("Select");
        CardPreviewData data = eventData.CastDataType <CardPreviewData>();

        if (data == null)
        {
            return;
        }

        //Debug.Log("Check Select");
        GameObject cardPreview = data.m_Card;

        if (!m_CanRepeat && m_selectedCardPreviewList.Contains(cardPreview))
        {
            //Debug.Log("Repeat Select");
            UnselectTarget(cardPreview);
            return;
        }

        if (numberLeft <= 0)
        {
            return;
        }

        //Debug.Log("Confirm Select");
        m_selectedCardPreviewList.Add(cardPreview);

        HighlightTarget(cardPreview);

        numberLeft--;

        DisplayInfo();
    }
Ejemplo n.º 5
0
    public static GameEventData CreateGameEvent(string eventName)
    {
        GameEventData data = new GameEventData();

        data.eventImage = eventName;
        switch (eventName)
        {
        case "Bed":
            data.eventName        = "莫名其妙的床";
            data.eventDescription = "在前進的路上發現了一張床,非常突兀的放在遺忘迴廊的一處,如果睡上去會發生什麼事情呢?如果什麼都沒發生的話,大概是忘了裝補丁吧。但如果能入睡的話,可能會對記憶會有些幫助也說不定。";
            data.selection1       = new nGameEventSelection.CopyeCard();
            data.selection2       = new nGameEventSelection.DeleteCard();
            break;

        case "HotSpring":
            data.eventName        = "溫泉";
            data.eventDescription = "可以幫助你回復生命的溫泉,沒什麼特別的。";
            data.selection1       = new nGameEventSelection.AllHeroHealFull();
            data.selection2       = new nGameEventSelection.Nothing();
            break;

        case "Treasure":
            data.eventName        = "寶藏!";
            data.eventDescription = "路邊的寶箱,身為勇者就是要開啦。";
            data.selection1       = new nGameEventSelection.PickUpOneCard();
            data.selection2       = new nGameEventSelection.Nothing();
            break;

        default:
            return(null);
        }


        return(data);
    }
Ejemplo n.º 6
0
 public void InvokeEvent(GameEventData data = null)
 {
     for (int i = listeners.Count - 1; i >= 0; i--)
     {
         listeners[i].OnEventInvoked(data);
     }
 }
Ejemplo n.º 7
0
 protected void HandleDataReceived(GameEventData gameEventData)
 {
     if (gameEventData.data is NetReceivedData receivedData)
     {
         OnDataReceived?.Raise(this, receivedData);
     }
 }
    public void Display(GameEventData eventData)
    {
        //Debug.Log("Received");
        UnitStatsChangeData data = eventData.CastDataType <UnitStatsChangeData>();

        if (data == null)
        {
            return;
        }

        Unit   unit     = data.m_Unit;
        int    delta    = data.m_Delta;
        string property = data.m_ChangedStats.ToString();

        string op   = delta > 0 ? " +" : " ";
        string text = property + op + delta;

        Color color = m_NeutralColor;

        if (delta < 0)
        {
            color = m_NegativeColor;
        }
        else if (delta > 0)
        {
            color = m_PositiveColor;
        }

        GameObject go = m_Pool.Get(true);

        go.transform.SetParent(this.transform);
        go.GetComponent <EffectText>().Display(unit.transform.position, text, color);

        StartCoroutine(Hide(go));
    }
Ejemplo n.º 9
0
 public static void Invoke(GameEventData gameEvent, GameEventInfo info)
 {
     if (_gameEvents.ContainsKey(gameEvent))
     {
         _gameEvents[gameEvent].Invoke(info);
     }
 }
Ejemplo n.º 10
0
 public static void RemoveListener(GameEventData gameEvent, UnityAction <GameEventInfo> action)
 {
     if (_gameEvents.ContainsKey(gameEvent))
     {
         _gameEvents[gameEvent].RemoveListener(action);
     }
 }
Ejemplo n.º 11
0
    public void Show(GameEventData eventData)
    {
        //Debug.Log("Card Selection Triggered");
        CardSelectOptionsData data = eventData.CastDataType <CardSelectOptionsData>();

        if (data == null)
        {
            return;
        }

        if (data.m_Switch)
        {
            if (!data.isCondition)
            {
                m_Display.DisplayOptions(data.unitDatas);
            }
            else
            {
                m_Display.DisplayOptions(data.conditions);
            }
        }
        else
        {
            m_Display.Hide();
        }
    }
Ejemplo n.º 12
0
    public void OnAction(GameEventData gameEventData)
    {
        CameraController cameraController  = GameController.Instance.CameraControllerInstance;
        Vector3          cameraPosition    = cameraController.transform.position;
        float            frustumHalfHeight = Mathf.Abs(cameraPosition.z) * Mathf.Tan(cameraController.CameraComponent.fieldOfView * 0.5f * Mathf.Deg2Rad);
        float            cameraTopBound    = cameraPosition.y + frustumHalfHeight;

        cameraTopBound += 2.0f;             // idk arbitrary thing so the bomb's center isn't right on the screen edge but slightly outside

        for (int i = 0; i < gameEventData.Number; ++i)
        {
            float   x             = Random.Range(-gameEventData.Offset.x, gameEventData.Offset.x);
            float   y             = Random.Range(-gameEventData.Offset.y, gameEventData.Offset.y);
            Vector3 offset        = new Vector2(x, y).ToVec3();
            Vector3 spawnPosition = new Vector2(gameEventData.Position.x, cameraTopBound + gameEventData.Position.y).ToVec3();

            float   spread  = Random.Range(-gameEventData.Spread, gameEventData.Spread);
            float   radians = (gameEventData.Rotation + spread) * Mathf.Deg2Rad;
            float   cos     = Mathf.Cos(radians);
            float   sin     = Mathf.Sin(radians);
            Vector2 force   = new Vector3(cos, sin) * gameEventData.Speed.Get();

            MonoBehaviour bomb = Object.Instantiate(gameEventData.Object);
            bomb.transform.Reset();
            bomb.transform.position = spawnPosition + offset;
            BSGFakePhysics fakePhysics = bomb.GetComponent <BSGFakePhysics>();
            if (fakePhysics != null)
            {
                fakePhysics.AddForce(force);
            }
        }
    }
Ejemplo n.º 13
0
    private void TurnStartInit(GameEventData data)
    {
        SortList();

        foreach (GameObject mark in m_UnitMarkMap.Values)
        {
            mark.GetComponent <OrderMarkDisplay>().SetActiveColor(true);
        }

        if (m_SortedUnitList.Count > 0)
        {
            m_CurrentUnit = m_SortedUnitList[0];
            m_UnitMarkMap[m_CurrentUnit].GetComponent <OrderMarkDisplay>().Enlarge();

            m_NextUnitIndex = 1;
        }
        else
        {
            m_CurrentUnit = null;
        }


        AuraManager.Instance.RefreshAura(m_UnsortedUnitList);

        //Debug.Log("Order Manager Trigger ");
        m_EndOrderInitEvent.Trigger();
    }
Ejemplo n.º 14
0
    void StartEventData(GameEventData data)
    {
        LobbyManager.instance.SetBlackForEventCard(true);

        eventData = data;

        button1.gameObject.SetActive(false);
        button2.gameObject.SetActive(false);

        eventWindow.SetActive(true);
        eventName.text        = data.eventName;
        eventDescription.text = data.eventDescription;
        eventImage.sprite     = Resources.Load <Sprite>("EventImage/" + data.eventImage);

        if (data.selection1 != null)
        {
            button1.gameObject.SetActive(true);
            buttonText1.text = data.selection1.selectionContent;
        }
        if (data.selection2 != null)
        {
            button2.gameObject.SetActive(true);
            buttonText2.text = data.selection2.selectionContent;
        }
    }
Ejemplo n.º 15
0
 public void HandleDisconnectGameEvent(GameEventData gameEventData)
 {
     if (gameEventData.data is NetConnection connection)
     {
         ClientDisconnected(connection);
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 技能攻击
        /// </summary>
        public void NpcSkillAttack(NPCData attacker, NPCData defender, bool useSkill, Action <object> callback)
        {
            bool isMoveToTarget = false;

            if (LogicConst.BattleType == BattleType.TurnBase)
            {
                isMoveToTarget = attacker.jobType == JobType.Warrior;
            }
            var attackEvent = new NpcSkillAttackEvent();

            attackEvent.attackerid    = attacker.npcid;
            attackEvent.defenderid    = defender.npcid;
            attackEvent.bMoveToTarget = isMoveToTarget;
            attackEvent.bPlaySound    = LogicConst.BattleType == BattleType.TurnBase;
            attackEvent.bUseSkill     = useSkill;

            attackEvent.currHp   = defender.hp;
            attackEvent.maxHp    = defender.hpMax;
            attackEvent.amount   = LogicUtil.Random(-100, 0);
            attackEvent.callback = callback;

            var evData = new GameEventData(GameEventType.Battle, attackEvent);

            evMappingMgr.Add(evData);
            Messenger.Broadcast <GameEventData>(EventNames.EvNpcSkillAttack, evData);
        }
Ejemplo n.º 17
0
    /// <summary>
    /// execute all sub reactions in depth first order
    /// </summary>
    /// <param name="eventData">the event's data. possibly null</param>
    public void Execute(GameEventData eventData)
    {
        foreach (Reaction r in reactionComponents)
            r.Execute(eventData);

        React(eventData);
    }
Ejemplo n.º 18
0
 public void HandleDataGameEvent(GameEventData gameEventData)
 {
     if (gameEventData.data is NetReceivedData receivedData)
     {
         HandleDataEvent(receivedData);
     }
 }
Ejemplo n.º 19
0
        private void ExampleMod_Event_GameEvent(GameEventData obj)
        {
            Logger.log("*****************OMG it's a game event!!!");
            var eventMessage = $@"A game event occured, name:{obj.Name}, type:{obj.Type}, eventType:{obj.EventType}";

            MessageAllPlayers(eventMessage);
        }
Ejemplo n.º 20
0
    protected override void React(GameEventData eventData)
    {
        RaycastHit hitInfo;
        Ray ray = new Ray();

        // handle different kinds of event data
        // MouseInput event

        MouseInput.MouseData mouseData = (MouseInput.MouseData)eventData.Get(EventDataKeys.InputData).data;
        if (mouseData != null && mouseData.inputValue > 0)
        {
            ray = mouseData.rayFromPosition;
        }

        // raycast
        if (ray.direction != Vector3.zero)
        {
            Physics.Raycast(ray, out hitInfo, raycastDistance, raycastLayers.value);

            if (hitInfo.collider != null)
            {
                GetComponent<RaycastHitEvent>().Trigger(
                    GameEventData.Empty.Add(new DataPiece(EventDataKeys.RaycastData) { data = hitInfo })
                    .Add(new DataPiece(EventDataKeys.TargetObject) { data = hitInfo.collider.gameObject }));
            }
        }
    }
Ejemplo n.º 21
0
        static bool HandleEventActiveListCommand(StringArguments args, CommandHandler handler)
        {
            uint counter = 0;

            var events       = Global.GameEventMgr.GetEventMap();
            var activeEvents = Global.GameEventMgr.GetActiveEventList();

            string active = Global.ObjectMgr.GetCypherString(CypherStrings.Active);

            foreach (var eventId in activeEvents)
            {
                GameEventData eventData = events[eventId];

                if (handler.GetSession() != null)
                {
                    handler.SendSysMessage(CypherStrings.EventEntryListChat, eventId, eventId, eventData.description, active);
                }
                else
                {
                    handler.SendSysMessage(CypherStrings.EventEntryListConsole, eventId, eventData.description, active);
                }

                ++counter;
            }

            if (counter == 0)
            {
                handler.SendSysMessage(CypherStrings.Noeventfound);
            }

            return(true);
        }
Ejemplo n.º 22
0
 public void HandleConnectGameEvent(GameEventData gameEventData)
 {
     if (gameEventData.data is NetConnection connection)
     {
         AddUnauthenticatedClient(connection);
     }
 }
Ejemplo n.º 23
0
 private void TakeEffect(GameEventData data)
 {
     foreach (StatusEffect effect in effects)
     {
         effect.TakeEffect(m_Status.m_Owner, power, data);
     }
 }
Ejemplo n.º 24
0
    protected override void Trigger(GameEventData eventData)
    {
        SingleUnitData data = eventData.CastDataType <SingleUnitData>();

        if (data == null)
        {
            return;
        }

        Unit unit = data.m_Unit;

        int value = unit.m_Data.GetStat(property);

        if (value > 0)
        {
            int negative = unit.m_Data.GetStat(UnitStatsProperty.Negative);
            int dur      = unit.m_Data.GetStat(UnitStatsProperty.DUR);

            if (negative <= 0 && dur > 0)
            {
                value = -value;
            }

            data.m_Unit.m_Data.ChangeStats(UnitStatsProperty.DUR, value);
        }
    }
Ejemplo n.º 25
0
 public void HandleDataReceived(GameEventData gameEventData)
 {
     if (gameEventData.data is NetReceivedData data)
     {
         OnDataReceived.Raise(this, data);
         onDataReceived?.Invoke(data);
     }
 }
 private void End(GameEventData data = null)
 {
     m_Duration--;
     if (m_Duration <= 0)
     {
         m_Status.RemoveStatus(this);
     }
 }
Ejemplo n.º 27
0
        /// <summary>
        /// 移除并获取映射事件
        /// </summary>
        public GameEventData Remove(long id)
        {
            GameEventData result = null;

            evMappings.TryGetValue(id, out result);
            evMappings.Remove(id);
            return(result);
        }
Ejemplo n.º 28
0
 void TurnStart(GameEventData data)
 {
     foreach (ManaObject mana in m_ManaList)
     {
         mana.Increase();
         mana.Reset();
     }
 }
Ejemplo n.º 29
0
 public void OnEventDataRaised(GameEventData data)
 {
     if (debug)
     {
         Debug.Log(string.Format("{0}(GameEventListener): OnEventDataRaised({1})", this, data), this);
     }
     responseWithData.Invoke(data);
 }
Ejemplo n.º 30
0
    void ChangeSelect(GameEventData eventData)
    {
        CardPreviewData data = eventData.CastDataType <CardPreviewData>();

        m_SelectedSpirit = data.m_UnitData;

        Invoke("Display", 0.1f);
    }
Ejemplo n.º 31
0
        /// <summary>
        /// 添加事件映射
        /// </summary>
        public void Add(GameEventData gameEvent)
        {
            long id = gameEvent.eventId;

            if (!evMappings.ContainsKey(id))
            {
                evMappings.Add(id, gameEvent);
            }
        }
Ejemplo n.º 32
0
        private void Awake()
        {
            if (quantityText == null)
            {
                quantityText = GetComponentInChildren <TextMeshProUGUI>();
            }

            dataOutput = GameEventData.GetInstance();
        }
Ejemplo n.º 33
0
 public void HandleClientDisconnected(GameEventData gameEventData)
 {
     if (gameEventData.data is NetConnection connection)
     {
         ConnectedClient client = clientManager.ClientDisconnected(connection);
         OnClientDisconnected.Raise(this, client);
         onClientDisconnected?.Invoke(client);
     }
 }
    protected override void React(GameEventData data)
    {
        DataPiece inputData;
        if ((inputData = data.Get(EventDataKeys.InputData)) != null &&
            inputData.dataType == typeof(MouseInput.MouseData))
        {
            Vector2 deltaMovement = ((MouseInput.MouseData)inputData.data).axisValues;

            //((IRotate)Reactor).Rotate(data, deltaMovement);

            float xRotation = Reactor.transform.localEulerAngles.y + deltaMovement.x * Sensitivity;
            yRotation += deltaMovement.y * Sensitivity;

            yRotation = Mathf.Clamp(yRotation, -MaxYRotation, MaxYRotation);

            Reactor.transform.localEulerAngles = new Vector3(-yRotation, xRotation, 0);
        }
    }
Ejemplo n.º 35
0
    /// <summary>
    /// Trigger the event
    /// </summary>
    /// <param name="data">fill in event data</param>
    /// <returns>true once all reactions were executed, false if conditions aren't met</returns>
    public bool Trigger(GameEventData data)
    {
        //if (!ConditionsMet()) return false;

        for (int i = 0; i < triggeredReactions.Count; i++ )
        {
            if (triggeredReactions[i] != null)
            {
        #if UNITY_EDITOR
                EditorGUIUtility.PingObject(Actor.gameObject);
                EditorGUIUtility.PingObject(gameObject);
        #endif
                triggeredReactions[i].Execute(data);
            }
        }

        return true;
    }
Ejemplo n.º 36
0
    protected override void React(GameEventData eventData)
    {
        if (DirectionRelativeTo == RelativeTo.ACTOR && ActorDirectionIsRelativeTo == null)
            return;

        float v;
        if (eventData != null && eventData.Get(EventDataKeys.InputData) != null)
        {
            v = ((InputReceived.InputData)eventData.Get(EventDataKeys.InputData).data).inputValue;
        }
        else
            v = 1;

        Transform relevantTransform;
        if (DirectionRelativeTo == RelativeTo.ACTOR)
            relevantTransform = ActorDirectionIsRelativeTo.transform;
        else if (DirectionRelativeTo == RelativeTo.SELF)
            relevantTransform = Reactor.transform;
        else // world
            relevantTransform = new GameObject("origin").transform;

        Vector3 dir = Vector3.zero;
        if (DirectionRelativeTo != RelativeTo.ACTOR)
        {
            switch (MoveDirection)
            {
                case Direction.FORWARD:
                    dir = relevantTransform.forward;
                    dir.y = 0;
                    break;
                case Direction.BACKWARD:
                    dir = -relevantTransform.forward;
                    dir.y = 0;
                    break;
                case Direction.LEFT:
                    dir = -relevantTransform.right;
                    dir.y = 0;
                    break;
                case Direction.RIGHT:
                    dir = relevantTransform.right;
                    dir.y = 0;
                    break;
                case Direction.UP:
                    dir = relevantTransform.up;
                    break;
                case Direction.DOWN:
                    dir = -relevantTransform.up;
                    break;
            }
        }
        else
        {
            dir = (relevantTransform.position - Reactor.transform.position).normalized;
            switch (MoveDirection)
            {
                case Direction.FORWARD:
                    dir.y = 0;
                    break;
                case Direction.BACKWARD:
                    dir = -dir;
                    dir.y = 0;
                    break;
                case Direction.LEFT:
                    dir = -relevantTransform.right;
                    dir.y = 0;
                    break;
                case Direction.RIGHT:
                    dir = relevantTransform.right;
                    dir.y = 0;
                    break;
                case Direction.UP:
                    dir = relevantTransform.up;
                    break;
                case Direction.DOWN:
                    dir = -relevantTransform.up;
                    break;
            }
        }

        Reactor.rigidbody.AddForce(dir * v * MoveSpeed);

        if (relevantTransform.name == "origin")
            Destroy(relevantTransform.gameObject);

        if (RotateWithMovement)
        {
            Vector3 horizontalVelocity = Reactor.rigidbody.velocity;
            horizontalVelocity.y = 0;
            Reactor.transform.forward = Vector3.Lerp(Reactor.transform.forward, horizontalVelocity, RotationSpeed * Time.deltaTime);
        }
    }
Ejemplo n.º 37
0
 protected override void React(GameEventData eventData)
 {
     if (counter != null)
     {
         if (KindOfChange == Change.OVER_TIME)
         {
             float s = PerSeconds;
             if (PerSeconds == 0)
                 s = 0.1f;
             counter.ChangeBy(ChangeBy * Time.deltaTime / s);
         }
         else if (KindOfChange == Change.INSTANTLY)
         {
             counter.ChangeBy(ChangeBy);
         }
     }
     else
     {
         // hack as workaround for possibly wrong initialization order
         counter = Counter.Get(CounterName);
     }
 }
    protected override void React(GameEventData eventData)
    {
        if (TargetObj == TargetObject.EVENT_TARGET)
        {
            DataPiece o = eventData.Get(EventDataKeys.TargetObject);
            if (o != null && o.data as GameObject)
            {
                gameObjectToDeactivate = o.data as GameObject;
            }
        }
        else
            gameObjectToDeactivate = ObjectToDeactivate.gameObject;

        if (!deactivating)
            StartCoroutine(DeactivateAfter(Timeout));
        deactivating = true;
    }
Ejemplo n.º 39
0
 protected override void React(GameEventData eventData)
 {
     generator.Gui.ShowMessage(Message, Time);
 }
Ejemplo n.º 40
0
 protected override void React(GameEventData eventData)
 {
     // show gui overlay: player blup won! when pressing ok or timeout done, restart game
     showOverlay = true;
 }
Ejemplo n.º 41
0
 /// <summary>
 /// The actual reaction to the registered event.
 /// </summary>
 /// <param name="eventData">the event's data</param>
 protected abstract void React(GameEventData eventData);
Ejemplo n.º 42
0
 protected override void React(GameEventData eventData)
 {
     Debug.Log(logText);
 }
Ejemplo n.º 43
0
    protected override void React(GameEventData eventData)
    {
        DataPiece targetObject = eventData.Get(EventDataKeys.TargetObject);
        if (targetObject != null)
        {
            GameObject target = targetObject.data as GameObject;

            if (target != null)
            {
                targetTransform = target.transform;
            }
        }
    }
Ejemplo n.º 44
0
    protected override void React(GameEventData eventData)
    {
        if (SpawnedPrefabs == null || SpawnedPrefabs.Count == 0) return;

        string spawn = SpawnedPrefabs[Random.Range(0, SpawnedPrefabs.Count)];

        GameObject spawnedObjectPrefab = Resources.Load(spawn) as GameObject;
        if (spawnedObjectPrefab == null)
        {
            Debug.LogWarning("Couldn't spawn object '" + spawn + "'. It wasn't found in any of the Resources folders or is no GameObject.");
        }
        else
        {
            GameObject spawnedObject = Instantiate(spawnedObjectPrefab) as GameObject;

            AddNewSpawnedObject(spawnedObject);

            Vector3 dir = Reactor.transform.TransformDirection(Direction);

            // set object and rotation
            spawnedObject.transform.position = Reactor.transform.position + dir * Distance;
            if (RandomRotation)
            {
                spawnedObject.transform.rotation = Quaternion.Euler(0, Random.Range(0, 3) * 90, 0);
            }
            spawnedObject.tag = TagForSpawnedObjects;

            if (spawnedObject.rigidbody)
                spawnedObject.rigidbody.AddForce(Reactor.transform.TransformDirection(StartVelocity), ForceMode.Impulse);

            // handle deactivation of this reaction
            if (DeactivateAfterSpawning)
            {
                Unregister();
                gameObject.SetActive(false);
            }
        }
    }