Ejemplo n.º 1
0
    public void TakeTurn()
    {
        ++turnCount;

        if (sim.currentTurn == Turn.Type.Player)
        {
            var playerProcessor = new PlayerProcessor(sim);
            playerProcessor.TakeTurn();
        }
        else if (sim.currentTurn == Turn.Type.Game)
        {
            var gameProcessor = new GameProcessor(sim);
            gameProcessor.TakeTurn();
        }

        bool atTurnLimit = (turnCount >= maxTurnCount);

        if (sim.requiresInput || atTurnLimit)
        {
            NotificationCenter.PostNotification(Constants.OnRenderEvents);
            return;
        }
        else
        {
            TakeTurn();
        }
    }
Ejemplo n.º 2
0
 void StartNewGame()
 {
     NotificationCenter.PostNotification(Constants.OnFirstPull);
     NotificationCenter.PostNotification(Constants.OnEnvironmentUpdate);
     EnvironmentProcessor.With(sim).Enter();
     sim.MarkGameStarted();
 }
Ejemplo n.º 3
0
        private void RunStart()
        {
            AddWindow(this);
            OnStart();

            NotificationCenter.PostNotification(this, WindowNotifications.WindowOpen, "window", this);
        }
Ejemplo n.º 4
0
        private void RunStop()
        {
            RemoveWindow(this);
            OnStop();

            NotificationCenter.PostNotification(this, WindowNotifications.WindowClose, "window", this);
        }
    private static int PostNotification(IntPtr L)
    {
        switch (LuaDLL.lua_gettop(L))
        {
        case 2:
        {
            NotificationCenter center        = (NotificationCenter)LuaScriptMgr.GetUnityObjectSelf(L, 1, "com.tencent.pandora.NotificationCenter");
            Notification       aNotification = (Notification)LuaScriptMgr.GetNetObject(L, 2, typeof(Notification));
            center.PostNotification(aNotification);
            return(0);
        }

        case 3:
        {
            NotificationCenter center2   = (NotificationCenter)LuaScriptMgr.GetUnityObjectSelf(L, 1, "com.tencent.pandora.NotificationCenter");
            Component          aSender   = (Component)LuaScriptMgr.GetUnityObject(L, 2, typeof(Component));
            string             luaString = LuaScriptMgr.GetLuaString(L, 3);
            center2.PostNotification(aSender, luaString);
            return(0);
        }

        case 4:
        {
            NotificationCenter center3    = (NotificationCenter)LuaScriptMgr.GetUnityObjectSelf(L, 1, "com.tencent.pandora.NotificationCenter");
            Component          component2 = (Component)LuaScriptMgr.GetUnityObject(L, 2, typeof(Component));
            string             aName      = LuaScriptMgr.GetLuaString(L, 3);
            object             varObject  = LuaScriptMgr.GetVarObject(L, 4);
            center3.PostNotification(component2, aName, varObject);
            return(0);
        }
        }
        LuaDLL.luaL_error(L, "invalid arguments to method: com.tencent.pandora.NotificationCenter.PostNotification");
        return(0);
    }
Ejemplo n.º 6
0
    void ChangePlayerResource()
    {
        var resourceKey    = (string)trigger.data[Trigger.resourceKey];
        int resourceAmount = (int)trigger.data[Trigger.resourceAmountKey];

        sim.player.ChangeAttribute(resourceKey, resourceAmount);

        NotificationCenter.PostNotification(Constants.OnUpdateAttribute);
    }
Ejemplo n.º 7
0
    void ChangePlayerStat()
    {
        var attrKey = (string)trigger.data[Trigger.statKey];
        var amount  = (float)trigger.data[Trigger.statChangeAmountKey];

        sim.player.ChangeAttribute(attrKey, amount);

        NotificationCenter.PostNotification(Constants.OnUpdateAttribute);
    }
Ejemplo n.º 8
0
    public void TriggerChoice(PlayerEvent ev, string choiceKey)
    {
        Debug.Log("Trigger choice " + choiceKey + " for event " + ev.Content);

        var interactionProcessor = new InteractionProcessor(sim);

        interactionProcessor.StoreChoice(choiceKey);

        NotificationCenter.PostNotification(Constants.OnUpdateEvents);
    }
Ejemplo n.º 9
0
    public void LogValues(string notificationName)
    {
        // Notify all listeners that we want the current value for all values that will be logged
        NotificationCenter.PostNotification(notificationName, this, null);

        foreach (string header in headers)
        {
            string value      = string.Empty;
            bool   valueFound = data.TryGetValue(header, out value);
            log.Write(string.Format("{0}: {1}", header, (valueFound) ? value : "undefined"));
        }
    }
Ejemplo n.º 10
0
    public void LogValues(string notificationName, Hashtable data)
    {
        // Notify all listeners that we want the current value for all values that will be logged
        NotificationCenter.PostNotification(notificationName, this, data);

        // build the current frame string and write it to the log file
        StringBuilder builder = new StringBuilder();

        foreach (string header in headers)
        {
            string value      = string.Empty;
            bool   valueFound = lastFrameValues.TryGetValue(header, out value);
            builder.AppendFormat("{0}\t", (valueFound) ? value : "undefined");
        }
        log.Write(builder.ToString());
    }
Ejemplo n.º 11
0
    public void TriggerAction(PlayerEvent ev, string actionName)
    {
        Debug.Log("Trigger action " + actionName + " for event " + ev.Content);

        if (ev.type == PlayerEvent.Type.Equipment)
        {
            var equipmentActionProcessor = new EquipmentActionProcessor(sim);
            equipmentActionProcessor.HandleAction(ev, actionName);
        }

        if (ev.type == PlayerEvent.Type.Consumable)
        {
            var consumableActionProcessor = new ConsumableActionProcessor(sim);
            consumableActionProcessor.HandleAction(ev, actionName);
        }

        NotificationCenter.PostNotification(Constants.OnUpdateEvents);
    }
Ejemplo n.º 12
0
    public void HandleAction(PlayerEvent _ev, string _actionKey)
    {
        ev           = _ev;
        actionKey    = _actionKey;
        ev.chosenKey = actionKey;
        consumable   = (Consumable)ev.data[PlayerEvent.consumableKey];

        if (actionKey == "consume")
        {
            Consume();
        }

        if (actionKey == "pickup")
        {
            PickUp();
        }

        NotificationCenter.PostNotification(Constants.OnUpdateAttribute);
        NotificationCenter.PostNotification(Constants.OnUpdateEvents);
    }
Ejemplo n.º 13
0
 void EndRefresh()
 {
     NotificationCenter.PostNotification(Constants.OnUpdateFeedDone);
     pullAnchorTitle.text = pullAnchorDefaultText;
     refreshFinishedHandler();
 }
Ejemplo n.º 14
0
 void OnRefreshFinished()
 {
     NotificationCenter.PostNotification(Constants.OnUpdateEvents);
     Debug.Log("Refresh finished");
     Invoke("Reset", 0.1f);
 }
Ejemplo n.º 15
0
 /// <summary>
 ///  发送消息
 /// </summary>
 public void SendNotificationMessage(ushort moduleID, int msgID, object obj)
 {
     NotificationCenter.PostNotification(new NotificationMessage(moduleID, msgID, this, obj));
 }
Ejemplo n.º 16
0
 void NotifyDone()
 {
     NotificationCenter.PostNotification(Constants.OnRenderEventsDone);
     NotificationCenter.PostNotification(Constants.OnUpdateFeed);
 }