示例#1
0
        public void MirrorRotation()
        {
            var rotationCb = Object.FindObjectOfType <RotationCallbackController>();

            rotationCb.Start();

            var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);

            if (container is EventsContainer eventsContainer)
            {
                var root           = eventsContainer.transform.root;
                var eventPlacement = root.GetComponentInChildren <EventPlacement>();

                var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_LATE_ROTATION, MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.ToList().IndexOf(45), JSON.Parse("{\"_rotation\": 33}"));

                eventPlacement.queuedData  = eventA;
                eventPlacement.queuedValue = eventPlacement.queuedData._value;
                eventPlacement.RoundedTime = eventPlacement.queuedData._time;
                eventPlacement.ApplyToMap();

                SelectionController.Select(eventA);

                _mirror.Mirror();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_LATE_ROTATION, MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.ToList().IndexOf(-45), JSON.Parse("{\"_rotation\": -33}"));

                // Undo mirror
                _actionContainer.Undo();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_LATE_ROTATION, MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.ToList().IndexOf(45), JSON.Parse("{\"_rotation\": 33}"));
            }
        }
示例#2
0
    public GameObject AddMapEvent(MapEvent mapEvent)
    {
        map.AddMapEvent(mapEvent);
        GameObject mapEventGO = CreateMapEventGameObject(mapEvent);

        return(mapEventGO);
    }
示例#3
0
    public override IEnumerable <MapEvent> StrobePassForLane(IEnumerable <MapEvent> original, int type, EventsContainer.PropMode propMode, JSONNode propID)
    {
        List <MapEvent> generatedObjects = new List <MapEvent>();

        IEnumerable <MapEvent> nonGradients = original.Where(x => x._lightGradient == null);

        for (int i = 0; i < nonGradients.Count() - 1; i++)
        {
            MapEvent currentChroma = nonGradients.ElementAt(i);
            MapEvent nextChroma    = nonGradients.ElementAt(i + 1);

            MapEvent generated = BeatmapObject.GenerateCopy(currentChroma);
            generated._lightGradient = new MapEvent.ChromaGradient(
                currentChroma._customData["_color"],    //Start color
                nextChroma._customData["_color"],       //End color
                nextChroma._time - currentChroma._time, //Duration
                easing);                                //Duration
            generated._customData.Remove("_color");

            generatedObjects.Add(generated);
        }

        generatedObjects.Add(BeatmapObject.GenerateCopy(original.Last()));

        return(generatedObjects);
    }
示例#4
0
        public void PlayAnimationOfEventExecuter(MapEvent mapEvent, Consequence consequence = null)
        {
            foreach (AnimationPerEvent animationPerEvent in animationsAsEventExecuter)
            {
                if (animationPerEvent.mapEvent != mapEvent)
                {
                    continue;
                }

                PlayAnimation(animationPerEvent.animationClip);
                return;
            }

            if (consequence == null)
            {
                foreach (Consequence mapEventConsequence in mapEvent.consequences)
                {
                    if (mapEventConsequence.affectedMapElement == AffectedMapElement.eventExecuter)
                    {
                        consequence = mapEventConsequence;
                        break;
                    }
                }
            }

            PlayAnimationOfStateType(consequence.stateUpdate.stateType);
        }
示例#5
0
        public void IncreaseLocalRelationsAfterBanditFight(MapEvent m)
        {
            TroopRoster rosterReceivingLootShare;
            int         mainPartSideInt = (int)PartyBase.MainParty.Side;

            rosterReceivingLootShare = PlayerEncounter.Current.RosterToReceiveLootMembers;

            //PartyBase partyReceivingLootShare = m.GetPartyReceivingLootShare(PartyBase.MainParty);


            MapEventSide banditSide;

            if (m.DefeatedSide == BattleSideEnum.Attacker)
            {
                banditSide = m.AttackerSide;
            }
            else
            {
                banditSide = m.DefenderSide;
            }
            if (!((int)m.DefeatedSide == -1 || (int)m.DefeatedSide == 2))
            {
                if (IsDefeatedBanditLike(m) && (rosterReceivingLootShare.TotalHealthyCount > 0 || !KBRRModLibSettings.Instance.PrisonersOnly))
                {
                    BanditDeathCounter += banditSide.Casualties;
                    InformationManager.DisplayMessage(new InformationMessage("BanditDeathCounter: " + BanditDeathCounter.ToString(), Color.FromUint(4282569842U)));
                    if (this.BanditGroupCounter == 1)
                    {
                        IncreaseLocalRelations(m);
                        this.ResetBanditDeathCounter();
                    }
                    this.BanditGroupCounterUpdate();
                }
            }
        }
示例#6
0
 public void MapEvicted(MapEvent mapEvent)
 {
     if (EvictAll != null)
     {
         EvictAll(mapEvent);
     }
 }
    private void PlayToggle(bool isPlaying)
    {
        if (!IsActive)
        {
            return;
        }
        float time = atsc.CurrentBeat;
        IEnumerable <BeatmapObjectContainer> rotations = events.LoadedContainers.Where(
            x => x.objectData._time <= atsc.CurrentBeat && (x as BeatmapEventContainer).eventData.IsRotationEvent);

        Rotation = 0;
        if (rotations.Any())
        {
            MapEvent e = null; //The last event in time should be the last one through the foreach loop so this should work.
            foreach (BeatmapObjectContainer o in rotations)
            {
                e = o.objectData as MapEvent;
                if (e._time == atsc.CurrentBeat && e._type == MapEvent.EVENT_TYPE_LATE_ROTATION)
                {
                    continue;
                }
                Rotation += e.GetRotationDegreeFromValue() ?? 0;
            }
            LatestRotationEvent = e;
        }
        else
        {
            LatestRotationEvent = null;
        }
        RotationChangedEvent.Invoke(false, Rotation);
    }
示例#8
0
 static IMapEvent BytesToEvent(byte[] bytes)
 {
     using var ms = new MemoryStream(bytes);
     using var br = new BinaryReader(ms);
     using var s  = new AlbionReader(br);
     return(MapEvent.Serdes(null, s, EventSetId.None, TextId.None, AssetMapping.Global));
 }
示例#9
0
        private static MapEvent addSingleEventLogic(JsonData data, Dictionary <string, MapEvent> eventTable)
        {
            MapEvent me = null;

            if (data != null)
            {
                if (data.IsString)
                {
                    me = eventTable[(string)data];
                }
                else if (data.IsObject && data.Contains("事件"))
                {
                    me = eventTable[(string)data["事件"]];

                    if (data.Contains("前置与"))
                    {
                        foreach (JsonData eventName in data["前置与"])
                        {
                            me.conditionAndEvents.Add((string)eventName);
                        }
                    }

                    if (data.Contains("前置或"))
                    {
                        foreach (JsonData eventName in data["前置或"])
                        {
                            me.conditionOrEvents.Add((string)eventName);
                        }
                    }
                }
            }
            return(me);
        }
示例#10
0
            private static void Prefix(MapEvent __instance)
            {
                if (__instance.DefeatedSide is BattleSideEnum.None)
                {
                    return;
                }

                var loserBMs = __instance.PartiesOnSide(__instance.DefeatedSide)
                               .Where(p => p.Party?.MobileParty?.PartyComponent is ModBanditMilitiaPartyComponent ||
                                      !string.IsNullOrEmpty(p.Party?.MobileParty?.LeaderHero?.CharacterObject?.StringId) &&
                                      p.Party.MobileParty.LeaderHero.CharacterObject.StringId.Contains("Bandit_Militia"));

                foreach (var party in loserBMs)
                {
                    var heroes = party.Party.MemberRoster.RemoveIf(t => t.Character.IsHero).ToListQ();
                    for (var i = 0; i < heroes.Count; i++)
                    {
                        Mod.Log($">>> Killing {heroes[i].Character.Name} ({heroes[i].Character.StringId}) at FinishBattle.");
                        heroes[i].Character.HeroObject.RemoveMilitiaHero();
                    }

                    if (party.Party.MobileParty.LeaderHero is null)
                    {
                        party.Party.MobileParty.SetCustomName(new TextObject("Leaderless Bandit Militia"));
                    }

                    Helper.RemoveUndersizedTracker(party.Party);
                }

                Helper.DoPowerCalculations();
            }
示例#11
0
        /// <summary>
        /// 读取事件表 json文件
        /// 【注意】具体事件逻辑在LoadStaticEventLogic中读取完毕
        /// </summary>
        public static Dictionary <string, MapEvent> GetStaticEvent()
        {
            string path = (Constants.DEBUG ? DEBUG_PATH : DEFAULT_PATH) + "Events/";
            Dictionary <string, MapEvent> eventTable = new Dictionary <string, MapEvent>();

            Debug.Log("读取事件表");
            foreach (TextAsset text in Resources.LoadAll <TextAsset>(path))
            {
                Debug.Log("读取:" + text.name);
                JsonData alldata = JsonMapper.ToObject(text.text);
                if (alldata.IsArray)
                {
                    foreach (JsonData data in alldata)
                    {
                        if (data.Contains("事件"))
                        {
                            MapEvent e = new MapEvent(data);
                            eventTable.Add(e.name, e);
                        }
                    }
                }
                else
                {
                    if (alldata.Contains("事件"))
                    {
                        MapEvent e = new MapEvent(alldata);
                        eventTable.Add(e.name, e);
                    }
                }
            }

            LoadStaticEventLogic(eventTable);
            return(eventTable);
        }
示例#12
0
    private void RawTeleport(string mapName, string targetEventName, OrthoDir?facing = null)
    {
        Map      newMapInstance = InstantiateMap(mapName);
        MapEvent target         = newMapInstance.GetEventNamed(targetEventName);

        RawTeleport(newMapInstance, target.Position, facing);
    }
示例#13
0
        public static void Prefix(MapEvent __instance)
        {
            if (MapEventCustomMembers.DefendersRanAway.TryRemove(__instance.Id, out _))
            {
                // Defender ran away
                // this._attackersRanAway = false;
                MapEvent__attackersRanAway.SetValue(__instance, false);

                // Place denfenders further away from attackers to prevent instantly get caught again
                foreach (PartyBase party in (IEnumerable <PartyBase>)__instance.DefenderSide.Parties)
                {
                    if (party.IsMobile)
                    {
                        MobileParty mobileParty = party.MobileParty;
                        if (mobileParty.IsActive && mobileParty.AttachedTo == null)
                        {
                            if (mobileParty.BesiegerCamp != null && mobileParty.BesiegerCamp.SiegeParties.Contains <PartyBase>(mobileParty.Party))
                            {
                                mobileParty.BesiegerCamp.RemoveSiegeParty(mobileParty);
                            }
                            Vec2 pointAroundPosition = mobileParty.FindReachablePointAroundPosition(mobileParty.Position2D, 3.1f, 3f, true);
                            mobileParty.Position2D = pointAroundPosition;
                            mobileParty.SetMoveModeHold();
                            mobileParty.IgnoreForHours(0.5f);
                        }
                    }
                }
            }
        }
示例#14
0
    // Start is called before the first frame update
    void Start()
    {
        if (seed != 0)
        {
            Random.seed = seed;
        }

        mapData = TerrainDataInstant.InstantMapChip(w, d, h, chaos);
        TerrainDataInstant.InstantProhibitedArea(mapData);

        MapEvent.InstantEvent(mapData, ObjType.Start);
        MapEvent.InstantEvent(mapData, ObjType.Goal);

        int xStart = MapEvent.eventPos[ObjType.Start].x;
        int zStart = MapEvent.eventPos[ObjType.Start].z;
        int xGoal  = MapEvent.eventPos[ObjType.Goal].x;
        int zGoal  = MapEvent.eventPos[ObjType.Goal].z;

        MapRoadInstant.IfWall_MakeRoad(mapData, xStart, zStart, roadLength, roadSpace);
        MapRoadInstant.IfWall_MakeRoad(mapData, xGoal, xGoal, roadLength, roadSpace);

        ListToDictionary();
        MapMaterialization.InstantFrame(w, d, frameObj, transform);
        MapMaterialization.ObjSet(mapData, wallObj, eventObj, transform);
    }
示例#15
0
 private void OnRaidCompleted(BattleSideEnum battle, MapEvent mapEvent)
 {
     if (mapEvent.IsRaid)
     {
         Settlement settlement = mapEvent.MapEventSettlement;
         if (settlement.IsVillage)
         {
             VillageData settlementAcreProperties;
             this._villageData.TryGetValue(settlement.StringId, out settlementAcreProperties);
             if (settlementAcreProperties.playerAcres > 0)
             {
                 Random rand = new Random();
                 if (rand.Next(1, 101) <= 25)
                 {
                     settlementAcreProperties.playerAcres--;
                     InformationManager.DisplayMessage(new InformationMessage($"The village of {mapEvent.MapEventSettlement.Name} was raided and one of your properties was destroyed."));
                 }
                 else
                 {
                     InformationManager.DisplayMessage(new InformationMessage($"The village of {mapEvent.MapEventSettlement.Name} was raided but none of your property were destroyed."));
                 }
             }
         }
     }
 }
示例#16
0
    private void EventPassed(bool initial, int index, BeatmapObject data)
    {
        if (!readyToGo || !IsActive)
        {
            return;
        }
        MapEvent e = data as MapEvent;

        if (!e.IsUtilityEvent())                                     //Filter out Ring Spin, Ring Zoom, and Laser Speeds
        {
            List <OscMessage> messages    = new List <OscMessage>(); //Collection of messages to mass send
            OscMessage        mainMessage = new OscMessage();
            mainMessage.address = $"/pb/{e._type}/{e._value}";
            messages.Add(mainMessage);
            if (e._value >= ColourManager.RGB_INT_OFFSET)                 //If we have a Chroma event in our hands...
            {
                Color      color = ColourManager.ColourFromInt(e._value); //Grab Chroma color from data
                OscMessage r     = new OscMessage();
                OscMessage g     = new OscMessage();                      //We hvae to make a new message for each RGB value, yay!
                OscMessage b     = new OscMessage();
                r.address = $"/exec/\"R\"/{color.r}";                     //Color values are floats from 0-1
                g.address = $"/exec/\"G\"/{color.g}";
                b.address = $"/exec/\"B\"/{color.b}";
                messages.AddRange(new List <OscMessage>()
                {
                    r, g, b
                });                                                    //Smack these guys into our messages list
            }
            foreach (OscMessage message in messages)
            {
                osc?.Send(message);                                      //Send those guys down the pipe.
            }
        }
    }
示例#17
0
        // add demo circle
        void MainMap_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            MapEvent?.Invoke("MainMap_MouseDoubleClick", "");

            //var cc = new GMapMarkerCircle(mainMap.FromLocalToLatLng(e.X, e.Y));
            //objects.Markers.Add(cc);
        }
示例#18
0
        private bool IsDefeatedBanditLike(MapEvent m)
        {
            try
            {
                if (m.GetLeaderParty(m.DefeatedSide).MapFaction.IsBanditFaction&& KBRRModLibSettings.Instance.IncludeBandits)
                {
                    return(true);
                }

                if (m.GetLeaderParty(m.DefeatedSide).MapFaction.IsOutlaw&& KBRRModLibSettings.Instance.IncludeOutlaws)
                {
                    return(true);
                }

                if (m.GetLeaderParty(m.DefeatedSide).Owner.Clan.IsMafia&& KBRRModLibSettings.Instance.IncludeMafia)
                {
                    return(true);
                }
            }

            catch (Exception ex)
            {
                //Avoids crash for parties without an owner set
            }
            return(false);
        }
示例#19
0
        private void OnSiegeEnded(MapEvent mapEvent)
        {
            if (mapEvent?.InvolvedParties == null)
            {
                return;
            }

            try
            {
                foreach (PartyBase party in mapEvent.InvolvedParties)
                {
                    if (party?.MobileParty?.Ai == null)
                    {
                        continue;
                    }

                    if (party.MobileParty.Ai.DoNotMakeNewDecisions)
                    {
                        party.MobileParty.Ai.SetDoNotMakeNewDecisions(false);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Info("Exception when trying to end siege");
                Log.Error(e);
            }
        }
示例#20
0
        private void IncreaseLocalRelations(MapEvent m)
        {
            float FinalRelationshipIncrease = KBRRModLibSettings.Instance.RelationshipIncrease;

            if (KBRRModLibSettings.Instance.SizeBonusEnabled)
            {
                FinalRelationshipIncrease = KBRRModLibSettings.Instance.RelationshipIncrease * this.BanditDeathCounter * KBRRModLibSettings.Instance.SizeBonus;
            }
            int FinalRelationshipIncreaseInt = (int)Math.Floor(FinalRelationshipIncrease);

            FinalRelationshipIncreaseInt = FinalRelationshipIncreaseInt < 1 ? 1 : FinalRelationshipIncreaseInt;
            InformationManager.DisplayMessage(new InformationMessage("Final Relationship Increase: " + FinalRelationshipIncreaseInt.ToString(), Color.FromUint(4282569842U)));

            List <Settlement> list = new List <Settlement>();

            foreach (Settlement settlement in Settlement.All)
            {
                if ((settlement.IsVillage || settlement.IsTown) && settlement.Position2D.DistanceSquared(m.Position) <= KBRRModLibSettings.Instance.Radius)
                {
                    list.Add(settlement);
                }
            }
            foreach (Settlement settlement2 in list)
            {
                if (settlement2.Notables.Any <Hero>())
                {
                    Hero h = settlement2.Notables.GetRandomElement <Hero>();
                    ChangeRelationAction.ApplyPlayerRelation(h, relation: FinalRelationshipIncreaseInt, affectRelatives: true, showQuickNotification: false);
                }
            }
            InformationManager.DisplayMessage(new InformationMessage("Your relationship increased with nearby notables.", Color.FromUint(4282569842U)));
        }
示例#21
0
    /// <summary>
    /// Copies the current selection for later Pasting.
    /// </summary>
    /// <param name="cut">Whether or not to delete the original selection after copying them.</param>
    public void Copy(bool cut = false)
    {
        Debug.Log("Copied!");
        CopiedObjects.Clear();
        SelectedObjects = SelectedObjects.OrderBy(x => x.objectData._time).ToList();
        float firstTime = SelectedObjects.First().objectData._time;

        foreach (BeatmapObjectContainer con in SelectedObjects)
        {
            BeatmapObject data = null;
            if (con.objectData is BeatmapNote)
            {
                data = new BeatmapNote(con.objectData.ConvertToJSON());
            }
            if (con.objectData is BeatmapObstacle)
            {
                data = new BeatmapObstacle(con.objectData.ConvertToJSON());
            }
            if (con.objectData is MapEvent)
            {
                data = new MapEvent(con.objectData.ConvertToJSON());
            }
            data._time = con.objectData._time - firstTime;
            CopiedObjects.Add(data);
            List <Material> containerMaterials = con.gameObject.GetComponentInChildren <MeshRenderer>().materials.ToList();
            containerMaterials.Last().SetColor("_OutlineColor", instance.copiedColor);
        }
        if (cut)
        {
            Delete();
        }
    }
示例#22
0
 public void MapCleared(MapEvent mapEvent)
 {
     if (ClearAll != null)
     {
         ClearAll(mapEvent);
     }
 }
示例#23
0
 private IEnumerator GenerateChromaStrobe(int type, float endTime, float startTime, int precision, float distanceOffset, List<MapEvent> containersBetween)
 {
     Dictionary<float, Color> chromaColors = new Dictionary<float, Color>();
     foreach (MapEvent e in containersBetween)
     {
         if (e is null) continue;
         if (e == containersBetween.First()) chromaColors.Add(startTime - distanceOffset, ColourManager.ColourFromInt(e._value));
         if (!chromaColors.ContainsKey(e._time))
             chromaColors.Add(e._time, ColourManager.ColourFromInt(e._value));
     }
     float distanceInBeats = endTime - startTime;
     while (distanceInBeats >= 0)
     {
         yield return new WaitForEndOfFrame();
         float time = endTime - distanceInBeats;
         float latestPastChromaTime = FindLastChromaTime(time, chromaColors, out float nextChromaTime);
         int color = ColourManager.ColourToInt(chromaColors.First().Value);
         if (nextChromaTime != -1 && latestPastChromaTime != -1)
         {
             Color from = chromaColors[latestPastChromaTime];
             Color to = chromaColors[nextChromaTime];
             float distanceBetweenTimes = nextChromaTime - latestPastChromaTime;
             color = ColourManager.ColourToInt(Color.Lerp(from, to, (time - latestPastChromaTime) / distanceBetweenTimes));
         }
         else if (time >= chromaColors.Last().Key) color = ColourManager.ColourToInt(chromaColors.Last().Value);
         MapEvent chromaData = new MapEvent(time  - distanceOffset, type, color);
         BeatmapEventContainer chromaContainer = eventsContainer.SpawnObject(chromaData, out _) as BeatmapEventContainer;
         generatedObjects.Add(chromaContainer);
         distanceInBeats -= 1 / (float)precision;
     }
 }
示例#24
0
    /// <summary>
    /// 特定の位置から3方向壁に囲まれている場合、一番近い壁を壊す
    /// </summary>
    /// <param name="map">マップデータ</param>
    /// <param name="x">ターゲット</param>
    /// <param name="z">ターゲット</param>
    /// <param name="dis">見る距離</param>
    /// <param name="roadSpace">壁の幅</param>
    public static void IfWall_MakeRoad(Map.ObjType[,] map, int x, int z, int dis, int roadSpace)
    {
        int wallCount = 0;

        Dictionary <MapEvent.Dir, int> wallCheckDis =
            new Dictionary <MapEvent.Dir, int>(MapEventSearch.WallSearch(map, x, z, dis));

        //辞書内にある最も小さい値を取り出す
        int minValue = wallCheckDis.Values.Min();
        var pair     = wallCheckDis.FirstOrDefault(c => c.Value == minValue);
        var key      = pair.Key;

        //壁に阻まれた方向の数を数える
        foreach (var str in wallCheckDis)
        {
            //Debug.Log("key " + str.Key+" value "+str.Value);
            if (str.Value < dis)
            {
                wallCount++;
            }
            if (str.Value == MapEventSearch.Outside)
            {
                wallCount++;
            }
        }

        //3方向囲まれた場合一番近い壁を壊す
        if (wallCount >= 3)
        {
            MapEvent.WallDestroy(map, x, z, pair.Key, pair.Value, roadSpace);
        }
    }
示例#25
0
        public void JsonMerge()
        {
            var eventContainer = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);
            var nodeEditor     = Object.FindObjectOfType <NodeEditorController>();
            var inputField     = nodeEditor.GetComponentInChildren <TMP_InputField>();

            var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_OFF, JSON.Parse(@"{""matches"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""differs"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""typeDiffer"":{""i"":1,""s"":""s"",""o"":{},""a"":[1,2]},""lenDiffer"":[1]}"));

            eventContainer.SpawnObject(eventA);

            var eventB = new MapEvent(2, MapEvent.EVENT_TYPE_LEFT_LASERS, MapEvent.LIGHT_VALUE_OFF, JSON.Parse(@"{""matches"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""differs"":{""i"":2,""s"":""t"",""b"":false,""a"":[2,2]},""typeDiffer"":{""i"":{},""s"":[],""o"":true,""a"":1},""lenDiffer"":[1,2]}"));

            eventContainer.SpawnObject(eventB);

            var eventC = new MapEvent(2, MapEvent.EVENT_TYPE_RIGHT_LASERS, MapEvent.LIGHT_VALUE_OFF);

            eventContainer.SpawnObject(eventC);

            SelectionController.Select(eventC);
            Assert.AreEqual("{\n  \"_time\" : 2,\n  \"_type\" : 3,\n  \"_value\" : 0\n}", inputField.text);

            SelectionController.Select(eventA);
            Assert.AreEqual("{\n  \"_time\" : 2,\n  \"_type\" : 0,\n  \"_value\" : 0,\n  \"_customData\" : {\n    \"matches\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"b\" : true,\n      \"a\" : [\n        1,\n        2\n      ]\n    },\n    \"differs\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"b\" : true,\n      \"a\" : [\n        1,\n        2\n      ]\n    },\n    \"typeDiffer\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"o\" : {\n      },\n      \"a\" : [\n        1,\n        2\n      ]\n    },\n    \"lenDiffer\" : [\n      1\n    ]\n  }\n}", inputField.text);

            SelectionController.Select(eventB, true);
            Assert.AreEqual("{\n  \"_time\" : 2,\n  \"_type\" : -,\n  \"_value\" : 0,\n  \"_customData\" : {\n    \"matches\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"b\" : true,\n      \"a\" : [\n        1,\n        2\n      ]\n    },\n    \"differs\" : {\n      \"i\" : -,\n      \"s\" : -,\n      \"b\" : -,\n      \"a\" : [\n        -,\n        2\n      ]\n    },\n    \"typeDiffer\" : {\n    }\n  }\n}", inputField.text);
        }
示例#26
0
        public void MirrorGradient()
        {
            var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);

            if (container is EventsContainer eventsContainer)
            {
                var root           = eventsContainer.transform.root;
                var eventPlacement = root.GetComponentInChildren <EventPlacement>();

                var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_RED_FADE, JSON.Parse("{\"_lightGradient\": {\"_duration\": 1, \"_startColor\": [1, 0, 0, 1], \"_endColor\": [0, 1, 0, 1], \"_easing\": \"easeLinear\"}}"));

                eventPlacement.queuedData  = eventA;
                eventPlacement.queuedValue = eventPlacement.queuedData._value;
                eventPlacement.RoundedTime = eventPlacement.queuedData._time;
                eventPlacement.ApplyToMap();

                SelectionController.Select(eventA);

                _mirror.Mirror();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_BLUE_FADE, JSON.Parse("{\"_lightGradient\": {\"_duration\": 1, \"_startColor\": [0, 1, 0, 1], \"_endColor\": [1, 0, 0, 1], \"_easing\": \"easeLinear\"}}"));

                // Undo mirror
                _actionContainer.Undo();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_RED_FADE, JSON.Parse("{\"_lightGradient\": {\"_duration\": 1, \"_startColor\": [1, 0, 0, 1], \"_endColor\": [0, 1, 0, 1], \"_easing\": \"easeLinear\"}}"));
            }
        }
示例#27
0
        public void JsonApply()
        {
            var eventContainer = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);
            var nodeEditor     = Object.FindObjectOfType <NodeEditorController>();
            var inputField     = nodeEditor.GetComponentInChildren <TMP_InputField>();

            var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_OFF, JSON.Parse(@"{""matches"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""differs"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""typeDiffer"":{""i"":1,""s"":""s"",""o"":{},""a"":[1,2]},""lenDiffer"":[1],""updatedLenDiffer"":[1],""updated"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""updatedDiffer"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""updatedTypeDiffer"":{""i"":1,""s"":""s"",""o"":{},""a"":[1,2]}}"));

            eventContainer.SpawnObject(eventA);

            var eventB = new MapEvent(2, MapEvent.EVENT_TYPE_LEFT_LASERS, MapEvent.LIGHT_VALUE_OFF, JSON.Parse(@"{""matches"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""differs"":{""i"":2,""s"":""t"",""b"":false,""a"":[2,2]},""typeDiffer"":{""i"":{},""s"":[],""o"":true,""a"":1},""lenDiffer"":[1,2],""updatedLenDiffer"":[1,2],""updated"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""updatedDiffer"":{""i"":2,""s"":""t"",""b"":false,""a"":[2,2]},""updatedTypeDiffer"":{""i"":{},""s"":[],""o"":true,""a"":1}}"));

            eventContainer.SpawnObject(eventB);

            SelectionController.Select(eventA);
            SelectionController.Select(eventB, true);

            nodeEditor.NodeEditor_EndEdit(@"{""_time"": -, ""_type"": -, ""_value"": -, ""_customData"": {""matches"":{},""differs"":{},""typeDiffer"":{},""updatedLenDiffer"":[1],""updated"":{""i"":4,""s"":""q"",""b"":false,""a"":[3,2]},""updatedDiffer"":{""i"":4,""s"":""q"",""b"":false,""a"":[3,2]},""updatedTypeDiffer"":{""i"":1,""s"":""s"",""o"":{},""a"":[1,2]}}}");

            Assert.AreEqual("{\n  \"_time\" : 2,\n  \"_type\" : -,\n  \"_value\" : 0,\n  \"_customData\" : {\n    \"matches\" : {\n    },\n    \"differs\" : {\n    },\n    \"typeDiffer\" : {\n    },\n    \"updatedLenDiffer\" : [\n      1\n    ],\n    \"updated\" : {\n      \"i\" : 4,\n      \"s\" : \"q\",\n      \"b\" : false,\n      \"a\" : [\n        3,\n        2\n      ]\n    },\n    \"updatedDiffer\" : {\n      \"i\" : 4,\n      \"s\" : \"q\",\n      \"b\" : false,\n      \"a\" : [\n        3,\n        2\n      ]\n    },\n    \"updatedTypeDiffer\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"o\" : {\n      },\n      \"a\" : [\n        1,\n        2\n      ]\n    }\n  }\n}", inputField.text);

            // Objects have been recreated, pick them up from the selection controller
            var events = SelectionController.SelectedObjects.ToArray();

            Assert.AreEqual("{\"_time\":2,\"_type\":0,\"_value\":0,\"_customData\":{\"matches\":{},\"differs\":{},\"typeDiffer\":{\"i\":1,\"s\":\"s\",\"o\":{},\"a\":[1,2]},\"lenDiffer\":[1],\"updatedLenDiffer\":[1],\"updated\":{\"i\":4,\"s\":\"q\",\"b\":false,\"a\":[3,2]},\"updatedDiffer\":{\"i\":4,\"s\":\"q\",\"b\":false,\"a\":[3,2]},\"updatedTypeDiffer\":{\"i\":1,\"s\":\"s\",\"o\":{},\"a\":[1,2]}}}", events[0].ConvertToJSON().ToString());
            Assert.AreEqual("{\"_time\":2,\"_type\":2,\"_value\":0,\"_customData\":{\"matches\":{},\"differs\":{},\"typeDiffer\":{\"i\":{},\"s\":[],\"o\":true,\"a\":1},\"lenDiffer\":[1,2],\"updatedLenDiffer\":[1],\"updated\":{\"i\":4,\"s\":\"q\",\"b\":false,\"a\":[3,2]},\"updatedDiffer\":{\"i\":4,\"s\":\"q\",\"b\":false,\"a\":[3,2]},\"updatedTypeDiffer\":{\"i\":1,\"s\":\"s\",\"o\":{},\"a\":[1,2]}}}", events[1].ConvertToJSON().ToString());
        }
示例#28
0
        public void MirrorProp()
        {
            var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);

            if (container is EventsContainer eventsContainer)
            {
                var root           = eventsContainer.transform.root;
                var eventPlacement = root.GetComponentInChildren <EventPlacement>();

                var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_RED_FADE, JSON.Parse("{\"_lightID\": 2}"));

                eventPlacement.queuedData  = eventA;
                eventPlacement.queuedValue = eventPlacement.queuedData._value;
                eventPlacement.RoundedTime = eventPlacement.queuedData._time;
                eventPlacement.ApplyToMap();

                SelectionController.Select(eventA);

                eventsContainer.EventTypeToPropagate = eventA._type;
                eventsContainer.PropagationEditing   = EventsContainer.PropMode.Light;

                _mirror.Mirror();
                // I'm sorry if you're here after changing the prop mapping for default env
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_BLUE_FADE, JSON.Parse("{\"_lightID\": 9}"));

                // Undo mirror
                _actionContainer.Undo();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_RED_FADE, JSON.Parse("{\"_lightID\": 2}"));

                eventsContainer.PropagationEditing = EventsContainer.PropMode.Off;
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e != null)
            {
                if (e.Parameter as Project != null)
                {
                    Project proj = (Project)e.Parameter;

                    ScheduleViewModel = new ScheduleViewModel(proj);
                    ViewModel         = new PersonalEventCreateViewModel();

                    ViewModel.CurrentMapEvent.ProjectId = proj.Id;
                    ViewModel.CurrentMapEvent.Color     = proj.Color;
                }

                if (e.Parameter as MapEvent != null)
                {
                    MapEvent mapEvent = (MapEvent)e.Parameter;
                    using (MainDatabaseContext db = new MainDatabaseContext())
                    {
                        var proj = db.Projects.FirstOrDefault(i => i.Id == mapEvent.ProjectId);
                        ScheduleViewModel = new ScheduleViewModel(proj);
                    }

                    ViewModel = new PersonalEventCreateViewModel(mapEvent);
                }
            }
        }
示例#30
0
    public void RemoveMapEvent(GameObject mapEventGO)
    {
        MapEvent mapEvent = mapEventGO.GetComponent <MapEventVO> ().MapEvent;

        map.RemoveMapEvent(mapEvent);
        Destroy(mapEventGO);
    }
 /// <summary>
 /// Sends an event into the instance.
 /// </summary>
 /// <param name="instanceId">The instance id.</param>
 /// <param name="event">The @event.</param>
 public void SendMapEvent(string instanceId, MapEvent @event)
 {
     try {
         var instance = GetInstanceOrFault(instanceId);
         var dictionary = @event.Atoms.ToDictionary();
         instance.SendEvent(dictionary, @event.Name);
     }
     catch (EPException e) {
         Log.Warn("SendMapEvent: BadRequest returned: {0}", e.Message);
         throw new WebFaultException<string>(e.Message, HttpStatusCode.BadRequest);
     }
 }