Example #1
0
 public static void RaiseGameplayEvent(string message, GameplayEvent type)
 {
     if (OnGameplayEvent != null)
     {
         OnGameplayEvent(message, type);
     }
 }
Example #2
0
    public void RefreshRoomProperties(GameplayEvent state)
    {
        var chaPos   = new Dictionary <string, CharacterPos>();
        var allSaved = new Dictionary <string, FG_SavedCharacter>();

        foreach (var go in unitControlller.allCharacterUnit)
        {
            chaPos.Add(go.name, new CharacterPos()
            {
                TileX = go.tileX, TileY = go.tileY
            });
            allSaved.Add(go.name, go.savedCharacter);
        }
        GameConditions cc = new GameConditions()
        {
            State                   = state,
            CurrentChaName          = unitControlller.allCharacterUnit[unitControlller.currentId].name,
            TargetChaName           = unitControlller.allCharacterUnit[unitControlller.currentId].attackTarget == null ? "" : unitControlller.allCharacterUnit[unitControlller.currentId].attackTarget.name,
            MoveToTileX             = unitControlller.allCharacterUnit[unitControlller.currentId].currentPath == null ? unitControlller.allCharacterUnit[unitControlller.currentId].tileX : unitControlller.allCharacterUnit[unitControlller.currentId].currentPath[1].x,
            MoveToTileY             = unitControlller.allCharacterUnit[unitControlller.currentId].currentPath == null ? unitControlller.allCharacterUnit[unitControlller.currentId].tileY : unitControlller.allCharacterUnit[unitControlller.currentId].currentPath[1].y,
            RemainingMovement       = unitControlller.allCharacterUnit[unitControlller.currentId].remainingMovement,
            SelectedSpell           = unitControlller.allCharacterUnit[unitControlller.currentId].selectedSpell == null ? "" : unitControlller.allCharacterUnit[unitControlller.currentId].selectedSpell.SpellName,
            AllSavedChaharacterData = allSaved,
            AllCharacterPos         = chaPos,
        };

        if (GamePlayManager.IsMultiPlayer)
        {
            Hashtable hs = new Hashtable();
            hs.Add("Conditions", PlayFab.Json.PlayFabSimpleJson.SerializeObject(cc));
            PhotonNetwork.room.SetCustomProperties(hs, null, false);
        }
        else
        {
            this.conditions = cc;

            if (state == GameplayEvent.PreMoveState)
            {
                RaiseGameplayEvent("", GameplayEvent.MoveState);
            }
            else if (state == GameplayEvent.PreAttackState)
            {
                RaiseGameplayEvent("", GameplayEvent.AttackState);
            }
            else if (state == GameplayEvent.TurnEnd)
            {
                System.Action action = () => { RaiseGameplayEvent("", GameplayEvent.PreMoveState); };
                StartCoroutine(Wait(action, 1));
            }
            else
            {
                if (myEvent != conditions.State)
                {
                    RaiseGameplayEvent("", state);
                }
            }
        }
    }
Example #3
0
    /**
     * @brief Invoke a specified event.
     * @param a_eventName is the name of the event.
     * @param a_eventInfo is the information to pass into the event.
     * */
    public static void TriggerEvent(string a_eventName, IEventInfo a_eventInfo = null)
    {
        GameplayEvent foundEvent = null;

        // Event exists
        if (instance.eventDict.TryGetValue(a_eventName, out foundEvent))
        {
            foundEvent.Invoke(a_eventInfo);
        }
    }
Example #4
0
    void OnGameplayEventReceived(string message, GameplayEvent type)
    {
        if (type == GameplayEvent.IntroQuest)
        {
            //RaiseGameplayEvent("intro act", GameplayEvent.IntroAct);
            myEvent = GameplayEvent.IntroQuest;
            //string levelname = (string)PhotonNetwork.room.CustomProperties["Level"];
            //uiManager.OpenConfirmPanel(PF_GameData.Levels[levelname].Acts.Values.ToList()[0].IntroMonolog);
            //initialize all
        }

        if (type == GameplayEvent.StartQuest)
        {
            myEvent = GameplayEvent.StartQuest;
            RaiseGameplayEvent("", GameplayEvent.PreMoveState);
        }

        if (type == GameplayEvent.PreMoveState)
        {
            myEvent = GameplayEvent.PreMoveState;
        }

        if (type == GameplayEvent.MoveState)
        {
            myEvent = GameplayEvent.MoveState;
        }

        if (type == GameplayEvent.PreAttackState)
        {
            myEvent = GameplayEvent.PreAttackState;
        }

        if (type == GameplayEvent.AttackState)
        {
            myEvent = GameplayEvent.AttackState;
        }

        if (type == GameplayEvent.TurnEnd)
        {
            myEvent = GameplayEvent.TurnEnd;
        }

        if (type == GameplayEvent.MyPlayerPreMove)
        {
            map.ShowTilesCanBereached();
        }

        if (type == GameplayEvent.PreAttackState)
        {
            map.DisableTileMask();
        }
    }
Example #5
0
    /**
     * @brief Unsubscribe function from a specified event.
     * @param a_eventName is the name of the event.
     * @param a_listener is the function to subscribe to the event with.
     * */
    public static void StopListening(string a_eventName, UnityAction <IEventInfo> a_listener)
    {
        if (eventManager == null)
        {
            return;                         // Account for event manager being destroyed first in a clean-up situation
        }
        GameplayEvent foundEvent = null;

        // Event exists
        if (instance.eventDict.TryGetValue(a_eventName, out foundEvent))
        {
            foundEvent.RemoveListener(a_listener);
        }
    }
Example #6
0
    // Callback for individual event ending in the sequence
    private void OnEventEnd()
    {
        if (m_CurrentEventIndex < eventSequence.Count)
        {
            // unsubscribe now to avoid duplicate End signal on this event if this sequence is replayed (one-time event)
            GameplayEvent gameplayEvent = eventSequence[m_CurrentEventIndex];
            gameplayEvent.end -= OnEventEnd;
        }
        else
        {
            Debug.LogErrorFormat(this, "Event sequence {0} ends with index {1}, but count is {2}",
                                 this, m_CurrentEventIndex, eventSequence.Count);
        }

        Continue();
    }
Example #7
0
 private void TryExecuteEventAtCurrentIndex()
 {
     if (m_CurrentEventIndex < eventSequence.Count)
     {
         GameplayEvent gameplayEvent = eventSequence[m_CurrentEventIndex];
         // we will continue sequence as soon as this event ends
         // register end callback now in case Execute immediately ends
         gameplayEvent.end += OnEventEnd;
         // actually execute the next event
         gameplayEvent.ExecuteAsSlave();
     }
     else
     {
         End();
         Debug.LogFormat(this, "Event sequence {0} over after {1} events", this, eventSequence.Count);
     }
 }
Example #8
0
    /**
     * @brief Subscribe function to a specified event.
     * @param a_eventName is the name of the event.
     * @param a_listener is the function to subscribe to the event with.
     * */
    public static void StartListening(string a_eventName, UnityAction <IEventInfo> a_listener)
    {
        GameplayEvent foundEvent = null;

        // Event already exists
        if (instance.eventDict.TryGetValue(a_eventName, out foundEvent))
        {
            foundEvent.AddListener(a_listener);
        }
        // Event doesn't exist, create new event and add listener
        else
        {
            foundEvent = new GameplayEvent();

            foundEvent.AddListener(a_listener);
            instance.eventDict.Add(a_eventName, foundEvent);
        }
    }
 public Tuple <LootActions, ICard> LootPlayerAction(Player player, GameplayEvent gameplayEvent, IEnumerable <LootActions> availableActions, Game game, Player killedPlayer)
 {
     return(new Tuple <LootActions, ICard>(availableActions.First(), null));
 }
 public Tuple <PlayerActions, Player> PerformPlayerAction(Player player, GameplayEvent gameplayEvent, IEnumerable <PlayerActions> availableActions, Game game)
 {
     return(new Tuple <PlayerActions, Player>(availableActions.First(), null));
 }
 public Tuple <CardActions, ICard> PerformCardAction(Player player, GameplayEvent gameplayEvent, IEnumerable <CardActions> availableActions, Game game, ICard card = null)
 {
     return(new Tuple <CardActions, ICard>(availableActions.First(), null));
 }
 public BasicActions PerformAction(Player player, GameplayEvent gameplayEvent, IEnumerable <BasicActions> availableActions, Game game)
 {
     return(availableActions.First());
 }
 public Tuple <LootActions, ICard> LootPlayerAction(GameplayEvent gameplayEvent, IEnumerable <LootActions> availableActions, Game game, Player killedPlayer)
 {
     //TODO: Log user action here for player history
     return(this.Strategy.LootPlayerAction(this, gameplayEvent, availableActions, game, killedPlayer));
 }
 public Tuple <PlayerActions, Player> PerformPlayerAction(GameplayEvent gameplayEvent, IEnumerable <PlayerActions> availableActions, Game game)
 {
     //TODO: Log user action here for player history
     return(this.Strategy.PerformPlayerAction(this, gameplayEvent, availableActions, game));
 }
 public Tuple <CardActions, ICard> PerformCardAction(GameplayEvent gameplayEvent, IEnumerable <CardActions> availableActions, Game game, ICard card = null)
 {
     //TODO: Log user action here for player history
     return(this.Strategy.PerformCardAction(this, gameplayEvent, availableActions, game, card));
 }
Example #16
0
    public override void OnPhotonCustomRoomPropertiesChanged(ExitGames.Client.Photon.Hashtable propertiesThatChanged)
    {
        datas = propertiesThatChanged;

        if (datas["Conditions"] != null)
        {
            conditions = new GameConditions();
            conditions = (GameConditions)PlayFab.Json.PlayFabSimpleJson.DeserializeObject <GameConditions>((string)datas["Conditions"]);
        }

        if (myEvent != conditions.State)
        {
            myEvent = conditions.State;
            RaiseGameplayEvent(conditions.CurrentChaName, myEvent);
        }
        switch (myEvent)
        {
        case GameplayEvent.IntroQuest:
            Debug.Log("Game Staet State form room properties");
            break;

        case GameplayEvent.PreMoveState:
            if (PhotonNetwork.isMasterClient && !unitControlller.currentUnit.tag.Contains("Player"))
            {
                System.Action action = () => { RefreshRoomProperties(GameplayEvent.MoveState); };
                StartCoroutine(Wait(action, 0.25f));
            }
            break;

        case GameplayEvent.MoveState:
            break;

        case GameplayEvent.PreAttackState:

            if (PhotonNetwork.isMasterClient && !unitControlller.currentUnit.tag.Contains("Player"))
            {
                System.Action action = () => { RefreshRoomProperties(GameplayEvent.AttackState); };
                StartCoroutine(Wait(action, 0.25f));
            }

            if (PhotonNetwork.isMasterClient)
            {
                if (unitControlller.currentUnit.tag.Contains("Player") && unitControlller.allCharacterUnit[unitControlller.currentId].attackTarget != null)
                {
                    System.Action action = () => { RefreshRoomProperties(GameplayEvent.AttackState); };
                    StartCoroutine(Wait(action, 0.25f));
                }
            }
            break;

        case GameplayEvent.AttackState:

            break;

        case GameplayEvent.TurnEnd:
            if (PhotonNetwork.isMasterClient)
            {
                System.Action action = () => { RefreshRoomProperties(GameplayEvent.PreMoveState); };
                StartCoroutine(Wait(action, 1));
            }
            break;

        case GameplayEvent.OutroAct:

            //PhotonNetwork.Disconnect();
            Debug.Log("Game Over and disconnected photon");
            break;
            //case States.GameWin:

            //    Debug.LogError("game win !!!");
            //    PhotonNetwork.Disconnect();
            //    SceneController.Instance.RequestSceneChange(SceneController.GameScenes.Profile);
            //    break;
        }
    }