Exemplo n.º 1
0
        public void OnUpdateFrame(EventPayload payload)
        {
            if (payload.ContentType != "Float")
            {
                return;
            }

            List <Glop> garbageCollection = new List <Glop>();

            foreach (Glop g in _contents.Values)
            {
                if (g.Garbage)
                {
                    garbageCollection.Add(g);
                }
                else
                {
                    g.Update((float)payload.GetContent());
                }
            }

            if (garbageCollection.Count > 0)
            {
                foreach (Glop g in garbageCollection)
                {
                    _contents.Remove(g.Id);
                }
            }
        }
Exemplo n.º 2
0
        public void TestPayloadNullContentAccepted()
        {
            EventPayload payload = new EventPayload("null", null);

            Assert.NotNull(payload);
            Assert.Null(payload.GetContent());
        }
Exemplo n.º 3
0
        public void TestPayloadConstructs()
        {
            EventPayload payload = new EventPayload("string", "Test");

            Assert.NotNull(payload);
            Assert.AreEqual(payload.GetContent(), "Test");
            Assert.AreEqual("string", payload.ContentType);
        }
Exemplo n.º 4
0
        public void TestPayloadGetContentDynamic()
        {
            EventPayload payload      = new EventPayload("integer", 4);
            EventPayload payloadFloat = new EventPayload("float", 2.3f);

            Assert.AreEqual(2.3f, payloadFloat.GetContent());
            Assert.AreEqual(4, payload.GetContent());
        }
Exemplo n.º 5
0
        public void DummyEventAction(EventPayload payload)
        {
            DummyActionsCalled++;

            if (payload.ContentType == "Float")
            {
                float contentFloat = ((float)payload.GetContent());
                DummyActionsCapturedFloats += contentFloat;
            }
        }
Exemplo n.º 6
0
        public void Zarfed(EventPayload eP)
        {
            if (eP.ContentType == "String")
            {
                string value = eP.GetContent();
                LastZarfPayload = value;
            }

            ZarfCalled++;
        }
Exemplo n.º 7
0
        protected void UnitDestroyed(EventPayload eventPayload)
        {
            if (eventPayload.ContentType != "Agent")
            {
                return;
            }
            Agent agent = eventPayload.GetContent();

            if (agent.Id == Renderable.Id)
            {
                UnbindListener(EventContext.GetEvent(EventKey.UnitDies), UnitDestroyed, EventContext);
                ToDestroy = true;
            }
        }
Exemplo n.º 8
0
    private string HandleType(EventPayload payload)
    {
        //TODO: improve this.
        switch (payload.ContentType)
        {
        case "Float":
            float fVal   = payload.GetContent();
            float pow    = Mathf.Pow(10, DecimalPointsForFloat);
            int   intVal = Mathf.FloorToInt(Mathf.FloorToInt(fVal * pow) / pow);
            return(intVal.ToString());

        case "Integer":
            int iVal = payload.GetContent();
            return(iVal.ToString());

        case "String":
            return(payload.GetContent());

        case "ResourceEventPayload":
            ResourceEventPayload rePayload = payload.GetContent();
            Player player = rePayload.Target as Player;
            if (player != null && player.Name == PlayerNameSelector)
            {
                return(rePayload.Amount.ToString());
            }

            return(_text.text);

        case "StringsRequest":
            StringsRequest sR = payload.GetContent();
            return(StringsService.Format(sR.StringId, sR.Values));

        default:
            return("Type not found");
        }
    }
Exemplo n.º 9
0
    private void OnReceiveUpdate(EventPayload payload)
    {
        if (payload.ContentType != "ResourceStateEventPayload")
        {
            return;
        }
        ResourceStateEventPayload resourceState = payload.GetContent();

        if (resourceState.Target.Id != OwnerGlopId)
        {
            return;
        }

        float percent = (float)resourceState.Amount / resourceState.Max;

        Rerender(percent);
    }
Exemplo n.º 10
0
        private void HandleAVFXRequest(EventPayload payload)
        {
            if (payload.ContentType != "AVFXRequest")
            {
                return;
            }

            AVFXRequest req = payload.GetContent();

            Vector3 target = req.Target;
            Vector3 origin = req.Origin;
            List <EffectAVFXEntry> fxList = req.Entries;

            bool    projectile = false;
            Vector3 end        = Vector3.zero;

            foreach (EffectAVFXEntry fx in fxList)
            {
                //TODO: afvx delays
                //TODO: afvx configs

                Vector3 pos = target;
                switch (fx.EffectTarget)
                {
                case EffectAVFXTarget.ORIGIN:
                    pos = origin;
                    break;

                case EffectAVFXTarget.TARGET:
                    pos = target;
                    break;

                case EffectAVFXTarget.GLOBAL:
                    pos = Vector3.zero;
                    break;

                case EffectAVFXTarget.PROJ_SELF_TO_TARGET:
                    pos        = origin + Vector3.up;
                    projectile = true;
                    end        = target;
                    break;

                case EffectAVFXTarget.PROJ_TARGET_TO_SELF:
                    pos        = target + Vector3.up;
                    projectile = true;
                    end        = origin;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                if (projectile)
                {
                    SpawnAVFXInstance(fx.EffectId, pos, end);
                }
                else
                {
                    SpawnAVFXInstance(fx.EffectId, pos);
                }
            }
        }