Exemplo n.º 1
0
        public override void step()
        {
            foreach (var player in ownerPlayer.game.players)
            {
                foreach (var m in player.board.minions)
                {
                    if (m.Value.minionState == Science_Wars_Server.Minions.Minion.MinionState.DEAD)
                    {
                        continue;
                    }

                    // calculate the distance of each minion to this minion
                    var dist = (m.Value.getWorldPosition() - worldPosition).magnitude;

                    // if the minion in the range then add deal damage
                    if (dist < RADIUS_DEFAULT)
                    {
                        GameUtilities.Damage damage = new GameUtilities.Damage(dmgPerSecond * Chronos.deltaTime, GameUtilities.DamageType.PHYSICAL);
                        // bu çok gecici bir şey olduğu için network'den yollamak sıkıntı yaratıcak latency'den dolayı bunun yerine client bu olayı simule edicek.
                        NailTrapSlowEffect slowEffect = new NailTrapSlowEffect(slowAmount);
                        m.Value.dealDamage(damage, ownerPlayer, false);
                        if (m.Value.addEffect(slowEffect))
                        {
                            Messages.OutgoingMessages.Game.GAddEffectOnMinionNailTrapSlow.sendMessage(m.Value.game.players, m.Value, slowEffect);
                        }
                    }
                }
            }

            remainingDuration -= Chronos.deltaTime;
            if (remainingDuration <= 0)
            {
                destroyable = true;
            }
        }
        public override void processMessage(NetWorker.Utilities.RawMessage message)
        {
            Minion             minion     = Engine.Game.getMinionById(message.getInt("iid"));
            float              slowAmount = message.getFloat("sa");
            NailTrapSlowEffect effect     = new NailTrapSlowEffect(slowAmount);

            if (minion != null)
            {
                minion.effects.AddLast(effect);
                Runner.Graphics.addMinionEffect(minion, effect);
            }
        }
        public static void sendMessage(ICollection <Player> receiverPlayers, Minion minion, NailTrapSlowEffect effect)
        {
            RawMessage msg = new RawMessage();

            msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GAddEffectOnMinionNailTrapSlow)));

            if (receiverPlayers != null && receiverPlayers.Count != 0)
            {
                msg.putInt("iid", minion.instanceId);
                msg.putInt("tid", TypeIdGenerator.getMinionEffectId(effect.GetType()));
                msg.putFloat("sa", effect.slowAmount);

                foreach (var receiverPlayer in receiverPlayers)
                {
                    receiverPlayer.user.session.client.SendMessage(msg);
                }
            }
        }