public SubscriptionRouterService(IServiceBus bus, string network)
		{
			_peerUri = bus.ControlBus.Endpoint.Address.Uri;

			_network = network;

			_peerId = CombGuid.Generate();

			_observers = new List<SubscriptionObserver>();
			_listeners = new List<BusSubscriptionEventListener>();

			_unregister = () => true;

			_peerUri = bus.ControlBus.Endpoint.Address.Uri;

			var connector = new BusSubscriptionConnector(bus);

			_peerCache = ActorFactory.Create<PeerCache>(x =>
				{
					x.ConstructedBy((fiber, scheduler, inbox) =>
					                new PeerCache(fiber, scheduler, connector, _peerId, _peerUri));
					x.UseSharedScheduler();
					x.HandleOnPoolFiber();
				})
				.GetActor();
		}
Beispiel #2
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        ActorInstance tempInstnace = col.gameObject.GetComponent <ActorInstance>();

        if (tempInstnace != null && tempInstnace.Info.ID != LocalUserInfo.Me.ClientCharacter.ID)
        {
            CurrentActor = tempInstnace;
        }
    }
Beispiel #3
0
    public override void SetTarget(ActorInstance target)
    {
        base.SetTarget(target);

        if (target == null)
        {
            StopCurrentActionRoutine();
        }
    }
        private static ActorInstanceLayer GetActorInstanceLayer()
        {
            var           otherTopicsActor         = new OtherTopicsActor();
            ActorInstance otherTopicsActorInstance = otherTopicsActor.CreateActorInstance(
                BoardId,
                new Coordinate(10, 6),
                new EventHandlerCollection(new PlayerTouchedOtherTopicsActorInstanceEventHandler()));

            return(new ActorInstanceLayer(BoardId, BoardSize, otherTopicsActorInstance));
        }
        private static ActorInstanceLayer GetActorInstanceLayer()
        {
            var           messagesActor         = new MessagesActor();
            ActorInstance messagesActorInstance = messagesActor.CreateActorInstance(
                BoardId,
                new Coordinate(4, 6),
                new EventHandlerCollection(new PlayerTouchedMessagesActorInstanceEventHandler()));

            return(new ActorInstanceLayer(BoardId, BoardSize, messagesActorInstance));
        }
        private static ActorInstanceLayer GetActorInstanceLayer()
        {
            var           objectsActor         = new ObjectsActor();
            ActorInstance objectsActorInstance = objectsActor.CreateActorInstance(
                BoardId,
                new Coordinate(3, 4),
                new EventHandlerCollection(new PlayerTouchedObjectsActorEventHandler()));

            return(new ActorInstanceLayer(BoardId, BoardSize, objectsActorInstance));
        }
Beispiel #7
0
        private static ActorInstanceLayer GetActorInstanceLayer()
        {
            var           welcomeActor         = new IntroductionActor();
            ActorInstance welcomeActorInstance = welcomeActor.CreateActorInstance(
                BoardId,
                new Coordinate(40, 10),
                new EventHandlerCollection(new PlayerTouchedIntroductionActorEventHandler()));

            return(new ActorInstanceLayer(BoardId, BoardSize, welcomeActorInstance));
        }
Beispiel #8
0
 private void ShowMessage(ActorInstance actor, string text, Color color, string name = "")
 {
     if (actor != null)
     {
         actor.ChatBubble(text, color);
         name = name.Length > 0 ? name : actor.Info.Name;
     }
     // TODO there's a bug that it sends an error if it's the first message upon login (before opening chat)
     ChatlogUI.Instance.AddMessage(name, text, color);
     InGameMainMenuUI.Instance.SetLastChatMessage(name + ": \"" + text + "\"", color);
 }
Beispiel #9
0
    private ActorInstance GetActorIfInRoom(string id)
    {
        ActorInstance actorInstance = null;
        ActorInfo     actorInfo     = Game.Instance.CurrentScene.GetActor(id);

        if (actorInfo != null)
        {
            actorInstance = actorInfo.Instance;
        }

        return(actorInstance);
    }
Beispiel #10
0
    public virtual void Miss(ActorInstance attackSource, string cause = "attack")
    {
        AudioControl.Instance.PlayInPosition(WoundSounds[Random.Range(0, WoundSounds.Count)], attackSource.transform.position);

        if (attackSource.Info.ID == LocalUserInfo.Me.ClientCharacter.ID)
        {
            PopHint("MISS", Color.green, new Color(), "");
        }
        else
        {
            PopHint("MISS", Color.blue, new Color(), "");
        }
    }
Beispiel #11
0
    public virtual void SetInfo(ActorInstance instance, string actionKey, string actionValue, bool isPlayer)
    {
        this.ParentActor = instance;
        this.ActionKey   = actionKey;
        this.ActionValue = actionValue;
        this.IsPlayer    = isPlayer;

        this.gameObject.SetActive(true);

        CurrentAbility = Content.Instance.GetAbility(actionKey);

        Hit = false;
    }
Beispiel #12
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (CurrentPlayer != null)
        {
            if (collision.GetComponent <ActorInstance>() != null)
            {
                if (CurrentPlayer == collision.gameObject.GetComponent <ActorInstance>())
                {
                    OnExit.Invoke();

                    CurrentPlayer = null;
                }
            }
        }
    }
Beispiel #13
0
    public void SetBlur(bool state)
    {
        ActorInstance actorInstance = Game.Instance.ClientCharacter.GetComponent <ActorInstance>();

        GameCamera.Instance.SetBlurMode(state);
        if (state)
        {
            currentNPC.SetLayerInChildren(13);
            actorInstance.SetRenderingLayer(13);
        }
        else
        {
            currentNPC.SetLayerInChildren(0);
            actorInstance.SetRenderingLayer(8);
        }
    }
            public override EventResult HandleEvent(EventContext context, TimerElapsedEvent @event)
            {
                ActorInstance           timerActorInstance      = context.GetActorInstanceById(TimerActorInstanceId);
                SetTileCharacterCommand setTileCharacterCommand = Commands.SetTileCharacter(
                    timerActorInstance,
                    new Character(_symbols[_symbolIndex], timerActorInstance.Character.ForegroundColor, timerActorInstance.Character.BackgroundColor));

                context.EnqueueCommand(setTileCharacterCommand);

                if (++_symbolIndex == _symbols.Length)
                {
                    _symbolIndex = 0;
                }

                return(EventResult.Completed);
            }
Beispiel #15
0
    public override void Hurt(ActorInstance actor, int damage = 0, int currentHP = 0, string cause = "attack", bool crit = false)
    {
        base.Hurt(actor, damage, currentHP, cause, crit);

        if (Game.Instance.isBitch)
        {
            if (actor.transform.position.x < transform.position.x)
            {
                Rigid.AddForce((damage / Info.MaxHealth) * 3f * actor.Info.ClientPerks.KnockbackModifier * transform.right, ForceMode2D.Impulse);
            }
            else
            {
                Rigid.AddForce((damage / Info.MaxHealth) * 3f * actor.Info.ClientPerks.KnockbackModifier * -transform.right, ForceMode2D.Impulse);
            }
        }
    }
Beispiel #16
0
    void Awake()
    {
        Rigid       = GetComponent <Rigidbody2D>();
        Instance    = GetComponent <ActorInstance>();
        ActorAttack = GetComponent <ActorAttack>();

        if (Rigid == null)
        {
            Rigid = this.gameObject.AddComponent <Rigidbody2D>();
            Rigid.freezeRotation = true;
        }

        Collider         = GetComponent <BoxCollider2D>();
        Collider.enabled = true;

        Anim = transform.Find("Body").GetComponent <Animator>();
    }
Beispiel #17
0
    protected override void OnTriggerStay2D(Collider2D TargetCollider)
    {
        if (!Hit)
        {
            if (TargetCollider.tag == "Actor")
            {
                ActorInstance actorInstance = TargetCollider.GetComponent <ActorInstance>();

                if (actorInstance.Info.ID == LocalUserInfo.Me.ClientCharacter.ID)
                {
                    actorInstance.InputController.TookSpellDamage(this);
                }

                Hit = true;
            }
        }
    }
Beispiel #18
0
 static void Postfix(ActorInstance __instance, Team ___m_Team, ref float __result, ActorStatType actorStatType)
 {
     if (__instance.ActorName.Length == 0 || __result <= 0)
     {
         return;
     }
     if (actorStatType == ActorStatType.CRIT_CHANCE)
     {
         float newResult = __result * 2f;
         logger.LogInfo($"{__instance.ActorName} crit chance: {__result} -> {newResult}");
         __result = newResult;
     }
     else if (actorStatType == ActorStatType.DEATHS_DOOR_CHANCE)
     {
         float newResult = __result * 2f;
         logger.LogInfo($"{__instance.ActorName} death's door chance: {__result} -> {newResult}");
         __result = newResult;
     }
 }
Beispiel #19
0
    public void SetInfo(ActorInstance parent, string actionKey, string actionValue, bool triggerHit, uint attackIdCounter, float chargeValue, float speed, bool isPlayer)
    {
        base.SetInfo(parent, actionKey, actionValue, attackIdCounter, isPlayer);

        transform.parent = null;

        CurrentMaxFlightTime = MaxFlightTime;
        TriggerHit           = triggerHit;

        InFlight = true;
        m_Particles.Play();

        ChargeValue = chargeValue;

        if (Trail != null)
        {
            Trail.Clear();
        }
    }
Beispiel #20
0
    public override List <KeyAction> GetActions()
    {
        List <KeyAction> list = new List <KeyAction>();

        ActorInstance actorInstance = GetComponent <ActorInstance>();

        if (isMe)
        {
            list.Add(new KeyAction(OpenInfoUI, "i", "Info of " + actorInstance.Info.Name));
            list.Add(new KeyAction(SomeOtherAction, "x", "Some other action"));
        }
        else
        {
            list.Add(new KeyAction(OpenInfoUI, "i", "Info of " + actorInstance.Info.Name));
            list.Add(new KeyAction(SendWhisper, "w", "Whisper " + actorInstance.Info.Name));
        }

        return(list);
    }
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkBlue)
                                                .Text(indent0, "Actors", 1)
                                                .Text(indent1, "  - Provide a template for actor instances", 1)
                                                .Text(indent1, "  - Don't have any behavior or event handlers");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                if (_handledOnce)
                {
                    return(EventResult.Canceled);
                }

                _handledOnce = true;

                Actor         actor         = context.GetActorById(@event.Target.ActorId);
                ActorInstance actorInstance = actor.CreateActorInstance(BoardId, ExitCoordinates[0], new EventHandlerCollection(new PlayerTouchedActorsActorCopyEventHandler()));
                ActorInstanceCreateCommand actorInstanceCreateCommand = Commands.ActorInstanceCreate(context.GetBoardById(BoardId), actorInstance);

                context.EnqueueCommand(actorInstanceCreateCommand);

                ChainedCommand chainedCommand = Commands
                                                .Chain(Commands.Delay(TimeSpan.FromMilliseconds(200)))
                                                .And(Commands
                                                     .ActorInstanceMove(actorInstance, MoveDirection.Down)
                                                     .Repeat(TimeSpan.FromMilliseconds(200), 2))
                                                .And(Commands.Delay(TimeSpan.FromMilliseconds(200)))
                                                .And(Commands
                                                     .ActorInstanceMove(actorInstance, MoveDirection.Right)
                                                     .Repeat(TimeSpan.FromMilliseconds(200), 5));

                context.EnqueueCommand(chainedCommand);

                return(EventResult.Completed);
            }
Beispiel #22
0
        void OnCreateShelfService(CreateShelfService message)
        {
            _log.InfoFormat("[Topshelf] Create Shelf Service: {0}{1}", message.ServiceName,
                            message.BootstrapperType == null
                                                ? ""
                                                : " ({0})".FormatWith(message.BootstrapperType.ToShortTypeName()));

            ActorFactory <IServiceController> factory = _controllerFactory.CreateFactory(inbox =>
            {
                IServiceController controller = new ShelfServiceController(inbox, message.ServiceName, this, message.ShelfType,
                                                                           message.BootstrapperType, message.AssemblyNames);
                _serviceCache.Add(message.ServiceName, controller);

                return(controller);
            });

            ActorInstance instance = factory.GetActor();

            _actorCache.Add(message.ServiceName, instance);

            instance.Send(new CreateService(message.ServiceName));
        }
Beispiel #23
0
    private IEnumerator RefreshRoutine(ActorInfo Info)
    {
        m_txtName.text   = Info.Name;
        m_txtGender.text = "Gender: " + Info.Gender.ToString();
        m_txtLevel.text  = "Level: " + Info.LVL;

        m_btnAddFriend.interactable = false;
        m_btnAddParty.interactable  = CanSendPartyInvite(Info.Name);

        if (CharSpot.childCount > 0)
        {
            Destroy(CharSpot.GetChild(0).gameObject);
        }

        yield return(0);

        if (Info.Gender == Gender.Male)
        {
            Instantiate(ResourcesLoader.Instance.GetObject("actor_male")).transform.SetParent(CharSpot);
        }
        else
        {
            Instantiate(ResourcesLoader.Instance.GetObject("actor_female")).transform.SetParent(CharSpot);
        }

        CharSpot.GetChild(0).position             = CharSpot.position;
        CharSpot.GetChild(0).transform.localScale = Vector3.one;
        CharInstance = CharSpot.GetChild(0).GetComponent <ActorInstance>();

        CharInstance.GetComponent <PlayerShortcuts>().enabled = false;
        CharInstance.Info       = Info;
        CharInstance.nameHidden = true;

        CharInstance.SetElementsLayer("OverUI", 1);
        CharInstance.UpdateVisual();
    }
Beispiel #24
0
 public virtual void SetTarget(ActorInstance target)
 {
     CurrentTarget = target;
     CheckMobAggro();
 }
Beispiel #25
0
 public ShelfHost(ActorInstance instance)
 {
     _instance = instance;
 }
Beispiel #26
0
    public void ReceivePartyMessage(string id, string name, string message)
    {
        ActorInstance actorInstance = GetActorIfInRoom(id);

        ShowMessage(actorInstance, message, ChatConfig.COLOR_PARTY, name);
    }
 public ActorInstance GetActor()
 {
     return(_instance ?? (_instance = Factory.GetActor()));
 }
Beispiel #28
0
 public ShelfHost(ActorInstance instance)
 {
     _instance = instance;
 }
Beispiel #29
0
    public virtual void Hurt(ActorInstance attackSource, int damage = 0, int currentHP = 0, string cause = "attack", bool crit = false)
    {
        Anim.SetInteger("HurtType", Random.Range(0, HurtTypes));
        Anim.SetTrigger("Hurt");

        string dmgMessage = damage > 0 ? damage.ToString("N0") : "BLOCKED";

        int TextSize = 40;

        if (crit)
        {
            TextSize = 60;
        }

        switch (cause)
        {
        case "attack":
        case "world":
        case "spell":
        {
            if (crit)
            {
                AudioControl.Instance.PlayInPosition("sound_crit", attackSource.transform.position);
            }
            else
            {
                AudioControl.Instance.PlayInPosition(WoundSounds[Random.Range(0, WoundSounds.Count)], attackSource.transform.position);
            }

            if (attackSource.Info.ID == LocalUserInfo.Me.ClientCharacter.ID)
            {
                if (crit)
                {
                    PopHint("<size=" + TextSize + "> " + dmgMessage + "</size>", new Color(1f, 0.619f, 0.325f, 1f), Color.black);
                }
                else
                {
                    PopHint("<size=" + TextSize + "> " + dmgMessage + "</size>", Color.green);
                }
            }
            else
            {
                PopHint("<size=" + TextSize + "> " + dmgMessage + "</size>", Color.blue);
            }



            m_AlphaGroup.BlinkDamage();
            break;
        }

        case "aoe":
        {
            TextSize -= 15;

            AudioControl.Instance.PlayInPosition(WoundSounds[Random.Range(0, WoundSounds.Count)], attackSource.transform.position);

            if (attackSource.Info.ID == LocalUserInfo.Me.ClientCharacter.ID)
            {
                PopHint("<color=#ffff00ff><size=" + TextSize + "> " + dmgMessage + "</size></color>", Color.green, new Color(), "");
            }
            else
            {
                PopHint("<size=25>" + dmgMessage + "</size>", Color.blue, new Color(), "");
            }

            break;
        }

        case "burn":
        case "bleed":
        case "spikes":
        {
            TextSize -= 15;

            AudioControl.Instance.PlayInPosition("sound_smallHit", attackSource.transform.position);

            if (attackSource.Info.ID == LocalUserInfo.Me.ClientCharacter.ID)
            {
                PopHint("<color=#ffff00ff><size=" + TextSize + ">" + dmgMessage + "</size></color>", Color.green, new Color(), "");
            }

            break;
        }
        }



        if (!Info.isBoss)
        {
            if (m_HealthBar == null)
            {
                m_HealthBar = ResourcesLoader.Instance.GetRecycledObject("HealthBar").GetComponent <HealthBar>();
                m_HealthBar.transform.position = transform.position;
            }

            m_HealthBar.SetHealthbar(Info.CurrentHealth, currentHP, Info.MaxHealth, 2f);
        }
        else
        {
            InGameMainMenuUI.Instance.ShowBossHealthbar();
            InGameMainMenuUI.Instance.SetBossHealthbar(Info.CurrentHealth, currentHP, Info.MaxHealth, 2f);
        }

        Info.CurrentHealth = currentHP;
    }
Beispiel #30
0
		public ActorRegisteredImpl(ActorRegistry registry, ActorInstance actor, Guid key)
		{
			Registry = registry;
			Instance = actor;
			Key = key;
		}
Beispiel #31
0
		public void Run()
		{
			Stopwatch timer = Stopwatch.StartNew();

			const int actorCount = 20;
			const int pingCount = 4000;

			var actors = new ActorInstance[actorCount + 1];

			var complete = new Future<int>();

			var latch = new CountdownLatch(actorCount * pingCount, complete.Complete);

			for (int i = actorCount; i >= 0; i--)
			{
				actors[i] = AnonymousActor.New(inbox =>
					{
						var pong = new Pong();

						var server = actors[(i + 1)];

						inbox.Loop(loop =>
							{
								loop.Receive<Request<Ping>>(request =>
									{
										request.Respond(pong);
										loop.Continue();
									});
							});


						if (i < actorCount)
						{
							var ping = new Ping();
							int count = 0;

							Action loop = null;
							loop = () =>
								{
									server.Request(ping, inbox)
										.Receive<Response<Pong>>(response =>
											{
												latch.CountDown();
												count++;
												if (count < pingCount)
													loop();
											});
								};

							loop();
						}
					});
			}

			bool completed = complete.WaitUntilCompleted(5.Minutes());

			timer.Stop();

			for (int i = 0; i < actorCount; i++)
			{
				actors[i].Exit();
				actors[i] = null;
			}

			if (!completed)
			{
				Console.WriteLine("Process did not complete");
				return;
			}

			Console.WriteLine("Processed {0} messages in with {1} actors in {2}ms", pingCount, actorCount, timer.ElapsedMilliseconds);

			Console.WriteLine("That's {0} messages per second!", ((long)pingCount * actorCount * 2 * 1000) / timer.ElapsedMilliseconds);
		}
Beispiel #32
0
 public YesAnswerSelectedEventHandler(ActorInstance actorInstance)
 {
     _actorInstance = actorInstance;
 }
Beispiel #33
0
 public virtual void SetInfo(ActorInstance instance, string actionKey, string actionValue, uint attackIdCounter, bool isPlayer)
 {
     SetInfo(instance, actionKey, actionValue, isPlayer);
     this.AttackIdCounter = attackIdCounter;
 }
Beispiel #34
0
 /// <summary>
 /// Sends a Kill message to an actor instance
 /// </summary>
 /// <param name="instance">The actor instance</param>
 public static void Kill(this ActorInstance instance)
 {
     instance.Send <Kill>(new KillImpl());
 }