protected MapObstacleObject(String textureFileName, Vector2 position, Vector2 velocity, int totalFrames, ObstacleType obstacleType, bool behindScenery) : base(textureFileName, position, velocity, totalFrames) { this.obstacleType = obstacleType; collisionSensors = new Dictionary<SensorType, CollisionSensor>(); this.behindScenery = behindScenery; }
public ObstacleData(int x, ObstacleType type) { float y = 0.5f; m_type = type; if (m_type == ObstacleType.High) y = 1.5f; m_position = new Vector3 (6 - x , y, 0); }
public static GameObject GetObstaclePrefab(ObstacleType type) { string path = string.Empty; path = System.IO.Path.Combine("Prefabs", "Obstacle"); path = System.IO.Path.Combine(path, "Obstacle_" + type.ToString()).Replace("\\", "/"); GameObject go = GetPrefab(path); return go; }
public void Spawn(ObstacleType obstacleType = ObstacleType.ShortRock) { float height = BottomBound; Vector3 position = new Vector3(this.transform.position.x, height, this.transform.position.z); GameObject obstaclePrefab = Utilities.GetObstaclePrefab(obstacleType); GameObject newObstacle = GameObject.Instantiate(obstaclePrefab); newObstacle.transform.position = position; }
public Obstacle GetRandomObstacle(Vector2 position) { ObstacleType[] obstacleTypes = new ObstacleType[(int)ObstacleType.End]; //var obstacleTypes = (ObstacleType[])Enum.GetValues(typeof(ObstacleType)); for (int enumValue = 0; enumValue < (int)ObstacleType.End; ++enumValue) { ObstacleType next = (ObstacleType)enumValue; obstacleTypes[enumValue] = next; } return GetObstacleByType(obstacleTypes[rand.Next(0, obstacleTypes.Length)], position); }
public void Initialize(Vector2 position, Texture2D texture, Rectangle collisionRect, ObstacleType type) { this.position = position; this.worldPosition = position; this.texture = texture; this.CollisionRect = collisionRect; this.Type = type; IsInitialized = true; IsAlive = true; }
public ObstacleType GetRandomType() { ObstacleType[] obstacleTypes = new ObstacleType[(int)ObstacleType.End]; //var obstacleTypes = (ObstacleType[])Enum.GetValues(typeof(ObstacleType)); for (int enumValue = 0; enumValue < (int)ObstacleType.End; ++enumValue) { ObstacleType next = (ObstacleType)enumValue; obstacleTypes[enumValue] = next; } return obstacleTypes[rand.Next(0, obstacleTypes.Length)]; }
public static Obstacle GetObstacle(ObstacleType pType) { switch (pType) { case ObstacleType.None: return new AirObstacleFactory().CreateObstacle(); case ObstacleType.ConcreteWallThick: return new ConcreteWallThickObstacleFactory().CreateObstacle(); case ObstacleType.ConcreteWallThin: return new ConcreteWallThinObstacleFactory().CreateObstacle(); case ObstacleType.BrickLimeSilicon: return new BrickLimeSiliconFactory().CreateObstacle(); case ObstacleType.BrickThick: return new BrickThickFactory().CreateObstacle(); case ObstacleType.BrickThin: return new BrickThinFactory().CreateObstacle(); case ObstacleType.BrickVeryThick: return new BrickVeryThickFactory().CreateObstacle(); case ObstacleType.DoubleGlassAntiWarm: return new DoubleGlassAntiWarmFactory().CreateObstacle(); case ObstacleType.DoubleGlassAntiSun: return new DoubleGlassAntiSunFactory().CreateObstacle(); case ObstacleType.DoubleGlassWithNet: return new DoubleClassWithNetFactory().CreateObstacle(); case ObstacleType.EnforcedConcrete: return new EnforcedConcreteFactory().CreateObstacle(); case ObstacleType.EnforcedGlass: return new EnforcedGlassFactory().CreateObstacle(); case ObstacleType.GasConcreteThick: return new GasConcreteThickFactory().CreateObstacle(); case ObstacleType.GasConcreteThin: return new GasConcreteThinFactory().CreateObstacle(); case ObstacleType.TripleGlassWithoutNet: return new TripleGlassWithoutNetFactory().CreateObstacle(); default: throw new NotImplementedException(); } }
public ObstacleInfo(string type, float time, float speed){ switch(type){ case "Ball": this.type = ObstacleType.BlueBall; break; case "Bar": this.type = ObstacleType.GreenBar; break; default: this.type = ObstacleType.Benoit; break; } this.time = time; this.speed = speed; }
public void CreateObstacle(ObstacleType type, Vector2 pos) { Obstacle obstacle = new Obstacle(); obstacle.position = pos; obstacle.tag = type; switch (type) { case ObstacleType.Bush: obstacle.sprite = bushTexture; obstacle.canOverlapWith = true; obstacle.canSeeThrough = false; obstacle.rectangleBounds = new Point(BUSH_SPRITE_SIZE_X, BUSH_SPRITE_SIZE_Y); break; case ObstacleType.Tree: obstacle.sprite = treeTexture; obstacle.canOverlapWith = false; obstacle.canSeeThrough = false; obstacle.rectangleBounds = new Point(TREE_SPRITE_SIZE_X, TREE_SPRITE_SIZE_Y); break; case ObstacleType.Fountain: obstacle.sprite = fountainTextureOff; obstacle.canOverlapWith = false; obstacle.canSeeThrough = true; obstacle.rectangleBounds = new Point(FOUNTAIN_SPRITE_SIZE_X, FOUNTAIN_SPRITE_SIZE_Y); break; case ObstacleType.Pond: obstacle.sprite = pondTexture; obstacle.canOverlapWith = false; obstacle.canSeeThrough = true; obstacle.rectangleBounds = new Point(POND_SPRITE_SIZE_X, POND_SPRITE_SIZE_Y); break; case ObstacleType.Trash: obstacle.sprite = trashTexture; obstacle.canOverlapWith = false; obstacle.canSeeThrough = true; obstacle.rectangleBounds = new Point(TRASH_SPRITE_SIZE_X, TRASH_SPRITE_SIZE_Y); break; case ObstacleType.Border: obstacle.sprite = treeTexture; obstacle.canOverlapWith = false; obstacle.canSeeThrough = true; obstacle.rectangleBounds = new Point(TREE_SPRITE_SIZE_X, TREE_SPRITE_SIZE_Y); break; } this.AddObstacle(obstacle); }
// give the position of the bottom of the lane public Obstacle GetObstacleByType(ObstacleType type, Vector2 position) { Obstacle obstacle = null; switch (type) { case ObstacleType.Ground: obstacle = new GroundObstacle(); ((GroundObstacle)obstacle).Initialize(root, position); break; case ObstacleType.Sky: obstacle = new SkyObstacle(); ((SkyObstacle)obstacle).Initialize(branch, position); break; case ObstacleType.Breakable: obstacle = new BreakableObstacle(); ((BreakableObstacle)obstacle).Initialize(smash, position); break; } return obstacle; }
private void NewObstacle() { if (obstaclePending) { return; } obstaclePending = true; ObstacleType obstacleCode = GetNewObstacleRandom(); switch (obstacleCode) { case ObstacleType.AnimalCage: hunterCt.ThrowBox(); Invoke("ThrowNewAnimalCage", 1.0f); break; case ObstacleType.Crate: hunterCt.ThrowBox(); Invoke("ThrowNewCrate", 1.0f); break; case ObstacleType.Rocks: hunterCt.ThrowRock(); Invoke("ThrowRocks", 1.0f); break; case ObstacleType.Gun: hunterCt.Shoot(); Invoke("FireShotgun", 0.85f); break; default: break; } //Invoke("NewObstacle", 3.0f); }
// Use this for initialization void Start() { if (Random.Range(-1f, 1f) < 0) { type = ObstacleType.meteor; } switch (Util.gm.zoneID) { case 2: type = ObstacleType.meteor; break; case 3: type = ObstacleType.meteor; break; case 7: type = ObstacleType.meteor; break; case 12: type = ObstacleType.meteor; break; } switch (type) { case ObstacleType.meteor: GetComponent <SpriteRenderer>().sprite = Util.obstacleHolder.getMeteor(0); break; case ObstacleType.satellite: GetComponent <SpriteRenderer>().sprite = Util.obstacleHolder.getSatellite(0); break; } float size = Random.Range(0.7f * 0.8f, 0.7f * 1.2f); transform.position = new Vector3(Random.Range(-Util.width, Util.width), Camera.main.transform.position.y + 30f, 0); transform.localScale = new Vector3(size, size, size); transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360f)); alert = Instantiate(alertPrefab); alert.GetComponent <Alert>().parent = gameObject; GetComponent <Motion>().endPos = new Vector3(transform.position.x, Camera.main.transform.position.y, 0); GetComponent <Motion>().begin(); Invoke("playSwoosh", 1.5f); swooshSource.pitch = Random.Range(0.9f, 1.25f); }
public ObstacleMap Generate() { List <ObstacleFigure> obstacles = new List <ObstacleFigure>(); for (int row = 0; row < mapHeight; row++) { for (int column = 0; column < mapWidth; column++) { int tmp = Random.Range(0, 2); if (tmp == 1) { continue; } ObstacleType type = (ObstacleType)tmp; ObstacleFigure obs = ObstacleFactory.Get(type); obs.Place(row, column); obstacles.Add(obs); } } ObstacleMap map = new ObstacleMap(obstacles); return(map); }
public void HitObject(ObstacleType oType) { switch (oType) { case ObstacleType.stickPuddle: playerRef.SlowPlayer(_stickPuddleReduc); break; case ObstacleType.slipPuddle: playerRef.SlipPlayer(_slipPuddleTime); break; case ObstacleType.smallObject: Debug.LogError("Use the function that takes a Collision as a parameter."); break; case ObstacleType.largeObject: // break; case ObstacleType.noSlideGround: // break; default: Debug.LogWarning("There is no obstacle of that type!"); break; } }
public void HitObject(ObstacleType oType, Collision collision) { switch (oType) { case ObstacleType.stickPuddle: playerRef.SlowPlayer(_stickPuddleReduc); break; case ObstacleType.slipPuddle: playerRef.SlipPlayer(_slipPuddleTime); break; case ObstacleType.smallObject: playerRef.CollisionLaunch(collision); break; case ObstacleType.largeObject: // break; case ObstacleType.noSlideGround: // break; default: Debug.LogWarning("There is no obstacle of that type!"); break; } }
void SetSizeByObstacleType(ObstacleType type) { switch (type) { case ObstacleType.BigLeft: sizesMaxCube = new Vector3(Mathf.Abs(leftMax - rightMax) / 2 + 2, Mathf.Abs(upMax - downMax) + 2, 2); transform.position = new Vector3(leftMax - 1, downMax - 1, posZ); break; case ObstacleType.BigRight: sizesMaxCube = new Vector3(Mathf.Abs(leftMax - rightMax) / 2 + 2, Mathf.Abs(upMax - downMax) + 2, 2); transform.position = new Vector3(Mathf.Abs(leftMax - rightMax) / 2 + leftMax, downMax - 1, posZ); break; case ObstacleType.BigUp: sizesMaxCube = new Vector3(Mathf.Abs(leftMax - rightMax) + 2, Mathf.Abs(upMax - downMax) / 2 + 2, 2); transform.position = new Vector3(leftMax - 1, (upMax - downMax) / 2 + downMax, posZ); break; case ObstacleType.BigDown: sizesMaxCube = new Vector3(Mathf.Abs(leftMax - rightMax) + 2, Mathf.Abs(upMax - downMax) / 2 + 2, 2); transform.position = new Vector3(leftMax - 1, downMax - 1, posZ); break; case ObstacleType.SmallRandom: sizesMaxCube = new Vector3(4, 4, 4); transform.position = new Vector3(Random.Range(leftMax, rightMax), Random.Range(downMax, upMax), posZ); break; case ObstacleType.BigAll: sizesMaxCube = new Vector3((Mathf.Abs(leftMax - rightMax) + 2) / 2, (Mathf.Abs(upMax - downMax) + 2) / 2, 100); sizeCube = 2; transform.position = new Vector3(leftMax - 1, downMax - 1, posZ); break; } }
private Obstacle(int id, ObstacleType type) { this.Id = id; this.Type = type; }
/// <summary> /// Initializes a new instance of the Obstacle class(Collision). /// </summary> /// <param name="posX">The X position of the Obstacle.</param> /// <param name="posY">The Y position of the Obstacle.</param> /// <param name="width">The width of the Obstacle.</param> /// <param name="height">The height of the Obstacle.</param> public Obstacle(int posX, int posY, int width, int height) { this.myType = ObstacleType.Collision; this.mySize = new Size(width, height); this.coords = new Point(posX, posY); }
public void UnOccupy(int x, int z) { obstacleType = ObstacleType.None; }
public void SetOccupied(ObstacleType t) { obstacleType = t; }
GameObject GetObstacle(ObstacleType obs) { if (obs==ObstacleType.PoliceCar){ for(i=0;i<policeCar.Length;i++){ if(!policeCar[i].activeSelf){ policeCar[i].SetActive(true); policeCar[i].transform.localRotation=Quaternion.Euler(Vector3.zero); return policeCar[i]; } } } if (obs==ObstacleType.Taxi){ for(i=0;i<taxi.Length;i++){ if(!taxi[i].activeSelf){ taxi[i].SetActive(true); taxi[i].transform.localRotation=Quaternion.Euler(Vector3.zero); return taxi[i]; } } } if (obs==ObstacleType.Trailer){ for(i=0;i<trailer.Length;i++){ if(!trailer[i].activeSelf){ trailer[i].SetActive(true); trailer[i].transform.localRotation=Quaternion.Euler(Vector3.zero); return trailer[i]; } } } return null; }
public List <IObstacle> GetObstacles(int layer, ObstacleType type, bool isSlope) { return(this.Where(obstacle => (type & obstacle.Type) == obstacle.Type && obstacle.Z == layer && obstacle.IsSlope == isSlope).ToList()); }
private void SetObstacle(ObstacleType type) { var tiles = new List <Vector2>(); var mainTilePos = _tile.mapPosition; tiles.Add(_tile.mapPosition); var pos = _tile.mapPosition; var edgeUpPos = MapUtils.FromEdgeToVec2(Edge.Up); var edgeDownPos = MapUtils.FromEdgeToVec2(Edge.Down); var edgeLeftPos = MapUtils.FromEdgeToVec2(Edge.Left); var edgeRightPos = MapUtils.FromEdgeToVec2(Edge.Right); switch (type) { case ObstacleType.down: tiles.Add(mainTilePos + edgeDownPos); break; case ObstacleType.up: tiles.Add(mainTilePos + edgeUpPos); break; case ObstacleType.left: tiles.Add(mainTilePos + edgeLeftPos); break; case ObstacleType.right: tiles.Add(mainTilePos + edgeRightPos); break; case ObstacleType.left_down: tiles.Add(mainTilePos + edgeDownPos); tiles.Add(mainTilePos + edgeLeftPos); tiles.Add(mainTilePos + edgeDownPos + edgeLeftPos); break; case ObstacleType.left_up: tiles.Add(mainTilePos + edgeUpPos); tiles.Add(mainTilePos + edgeLeftPos); tiles.Add(mainTilePos + edgeUpPos + edgeLeftPos); break; case ObstacleType.right_down: tiles.Add(mainTilePos + edgeDownPos); tiles.Add(mainTilePos + edgeRightPos); tiles.Add(mainTilePos + edgeDownPos + edgeRightPos); break; case ObstacleType.right_up: tiles.Add(mainTilePos + edgeUpPos); tiles.Add(mainTilePos + edgeRightPos); tiles.Add(mainTilePos + edgeUpPos + edgeRightPos); break; } foreach (Vector2 tile in tiles) { _map[tile].state = TileState.Occupied; _map[tile].edge = Edge.Zero; } }
public Obstacle ChooseAndGetObstacle(ObstacleType prevObstacle, int streak, Transform parent) { return(GetObstacle(ChooseObstacleType(prevObstacle, streak), parent)); }
public Obstacle GetObstacle(ObstacleType obstacleType, Transform parent) { return(_pools[obstacleType].Spawn(parent)); }
public Obstacle(Platform parent, int position) { parentPlat = parent; oType = ObstacleType.JUMP_OVER; oBody = Instantiate(instance.obstacle, parent.pos + new Vector2((position * singleWidth) - (parent.width / 2), 1), Quaternion.identity); }
public Obstacle(Platform parent) { parentPlat = parent; oType = ObstacleType.JUMP_OVER; oBody = Instantiate(instance.obstacle, parent.pos + new Vector2(0, 1), Quaternion.identity); }
void Update() { if (currentPlatform != null) { currentPlatform.GetComponent <Renderer>().material.color = new Color(0, 1, 0); } if (transform.position.x < generationPoint.position.x && platformsThisLevel < stageLength) { Platform lastPlat = platforms[platforms.Count - 1]; PlatformType t = (PlatformType)Random.Range(0, System.Enum.GetValues(typeof(PlatformType)).Length); float newWidth = GetWidthOfType(t); float newHeight = Mathf.Floor(Random.Range(lastPlat.pos.y - 4, lastPlat.pos.y + 4f)); float newDistBetween = gameSpeedMultiplier * Mathf.Floor(Random.Range(initialDistanceBetween, initialDistanceBetween * 2.1f)); //New platform will be reachable from last platform transform.position = new Vector2(transform.position.x + (lastPlat.width / 2) + newWidth / 2 + newDistBetween, newHeight); platforms.Add(new Platform(transform.position, t)); nextPlatform = platforms[platforms.Count - 2]; platformsThisLevel += 1; if (platformsThisLevel >= stageLength) { //spawn the exit Instantiate(instance.goal, platforms[platforms.Count - 1].pos + new Vector2(0, 1), Quaternion.identity); } else if (platformsThisLevel == Mathf.Floor(stageLength / 2)) { //spawn the store Instantiate(instance.store, platforms[platforms.Count - 1].pos + new Vector2(0, 2.5f), Quaternion.identity); } else { //for each obstacle slot on top of the new platform for (int i = 1; i < platforms[platforms.Count - 1].width / singleWidth; i++) { int rn = Random.Range(1, 100); if (rn <= chanceOfObstacle) { //add obstacle ObstacleType ot = (ObstacleType)Random.Range(0, System.Enum.GetValues(typeof(ObstacleType)).Length); platforms[platforms.Count - 1].hazards.Add(new Obstacle(platforms[platforms.Count - 1], i, ot)); chanceOfObstacle -= 5f; if (ot == ObstacleType.ROOF_HOUSE) { i++; } } else { chanceOfObstacle += 2f; } } } } //Clean up old platforms if (platforms.Count > 10) { Platform toDestroy = platforms[0]; foreach (Obstacle h in toDestroy.hazards) { Destroy(h.oBody); } toDestroy.hazards.Clear(); platforms.Remove(toDestroy); Destroy(toDestroy.pBase); Destroy(toDestroy.pGround); Destroy(toDestroy.perfZone); } }
public ObstacleInfo(ObstacleType type, float time, float speed){ this.type = type; this.time = time; this.speed = speed; }
// Token: 0x0600125F RID: 4703 RVA: 0x000404A0 File Offset: 0x0003E6A0 public static CustomBeatmapData GetBeatmapDataFromBeatmapSaveData(List <CustomBeatmapSaveData.NoteData> notesSaveData, List <CustomBeatmapSaveData.ObstacleData> obstaclesSaveData, List <CustomBeatmapSaveData.EventData> eventsSaveData, float startBPM, float shuffle, float shufflePeriod, List <CustomBeatmapSaveData.CustomEventData> customEventsSaveData, dynamic customData, dynamic customLevelData, BeatmapDataLoader beatmapDataLoader) { try { // IPA's reflectionutil sucks object _notesInTimeRowProcessor = beatmapDataLoader.GetType().GetField("_notesInTimeRowProcessor", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(beatmapDataLoader); MethodInfo ProcessBasicNotesInTimeRow = _notesInTimeRowProcessor.GetType().GetMethod("ProcessBasicNotesInTimeRow", BindingFlags.Instance | BindingFlags.Public); MethodInfo ProcessNotesInTimeRow = _notesInTimeRowProcessor.GetType().GetMethod("ProcessNotesInTimeRow", BindingFlags.Instance | BindingFlags.Public); // remainder of this method copied from SongLoaderPlugin@12de0cf, with changes: // BeatmapData, NoteData, EventData, and ObstacleData replaced with their Custom counterparts // customData fields propagated to new objects List <BeatmapObjectData>[] array = new List <BeatmapObjectData> [4]; List <BeatmapEventData> list = new List <BeatmapEventData>(eventsSaveData.Count); List <BPMChangeData> list2 = new List <BPMChangeData>(); list2.Add(new BPMChangeData(0f, 0f, startBPM)); BPMChangeData bpmchangeData = list2[0]; foreach (CustomBeatmapSaveData.EventData eventData in eventsSaveData) { if (eventData.type.IsBPMChangeEvent()) { float time = eventData.time; int value = eventData.value; float bpmChangeStartTime = bpmchangeData.bpmChangeStartTime + beatmapDataLoader.GetRealTimeFromBPMTime(time - bpmchangeData.bpmChangeStartBPMTime, (float)value, shuffle, shufflePeriod); list2.Add(new BPMChangeData(bpmChangeStartTime, time, (float)value)); } } for (int i = 0; i < 4; i++) { array[i] = new List <BeatmapObjectData>(3000); } int num = 0; float num2 = -1f; List <CustomNoteData> list3 = new List <CustomNoteData>(4); List <CustomNoteData> list4 = new List <CustomNoteData>(4); int num3 = 0; foreach (CustomBeatmapSaveData.NoteData noteData in notesSaveData) { float time2 = noteData.time; while (num3 < list2.Count - 1 && list2[num3 + 1].bpmChangeStartBPMTime < time2) { num3++; } BPMChangeData bpmchangeData2 = list2[num3]; float num4 = bpmchangeData2.bpmChangeStartTime + beatmapDataLoader.GetRealTimeFromBPMTime(time2 - bpmchangeData2.bpmChangeStartBPMTime, bpmchangeData2.bpm, shuffle, shufflePeriod); int lineIndex = noteData.lineIndex; NoteLineLayer lineLayer = noteData.lineLayer; NoteLineLayer startNoteLineLayer = NoteLineLayer.Base; NoteType type = noteData.type; NoteCutDirection cutDirection = noteData.cutDirection; if (list3.Count > 0 && list3[0].time < num4 - 0.001f && type.IsBasicNote()) { ProcessBasicNotesInTimeRow.Invoke(_notesInTimeRowProcessor, new object[] { list3.Cast <NoteData>().ToList(), num4 }); num2 = list3[0].time; list3.Clear(); } if (list4.Count > 0 && list4[0].time < num4 - 0.001f) { ProcessNotesInTimeRow.Invoke(_notesInTimeRowProcessor, new object[] { list4.Cast <NoteData>().ToList() }); list4.Clear(); } CustomNoteData noteData2 = new CustomNoteData(num++, num4, lineIndex, lineLayer, startNoteLineLayer, type, cutDirection, float.MaxValue, num4 - num2, noteData._customData ?? Tree()); int lineNum = lineIndex > 3 ? 3 : lineIndex < 0 ? 0 : lineIndex; array[lineNum].Add(noteData2); CustomNoteData item = noteData2; if (noteData2.noteType.IsBasicNote()) { list3.Add(item); } list4.Add(item); } ProcessBasicNotesInTimeRow.Invoke(_notesInTimeRowProcessor, new object[] { list3.Cast <NoteData>().ToList(), float.MaxValue }); ProcessNotesInTimeRow.Invoke(_notesInTimeRowProcessor, new object[] { list4.Cast <NoteData>().ToList() }); num3 = 0; foreach (CustomBeatmapSaveData.ObstacleData obstacleData in obstaclesSaveData) { float time3 = obstacleData.time; while (num3 < list2.Count - 1 && list2[num3 + 1].bpmChangeStartBPMTime < time3) { num3++; } BPMChangeData bpmchangeData3 = list2[num3]; float time4 = bpmchangeData3.bpmChangeStartTime + beatmapDataLoader.GetRealTimeFromBPMTime(time3 - bpmchangeData3.bpmChangeStartBPMTime, bpmchangeData3.bpm, shuffle, shufflePeriod); int lineIndex2 = obstacleData.lineIndex; ObstacleType type2 = obstacleData.type; float realTimeFromBPMTime = beatmapDataLoader.GetRealTimeFromBPMTime(obstacleData.duration, startBPM, shuffle, shufflePeriod); int width = obstacleData.width; CustomObstacleData item2 = new CustomObstacleData(num++, time4, lineIndex2, type2, realTimeFromBPMTime, width, obstacleData._customData ?? Tree()); int lineNum = lineIndex2 > 3 ? 3 : lineIndex2 < 0 ? 0 : lineIndex2; array[lineNum].Add(item2); } foreach (CustomBeatmapSaveData.EventData eventData2 in eventsSaveData) { float time5 = eventData2.time; while (num3 < list2.Count - 1 && list2[num3 + 1].bpmChangeStartBPMTime < time5) { num3++; } BPMChangeData bpmchangeData4 = list2[num3]; float time6 = bpmchangeData4.bpmChangeStartTime + beatmapDataLoader.GetRealTimeFromBPMTime(time5 - bpmchangeData4.bpmChangeStartBPMTime, bpmchangeData4.bpm, shuffle, shufflePeriod); BeatmapEventType type3 = eventData2.type; int value2 = eventData2.value; CustomBeatmapEventData item3 = new CustomBeatmapEventData(time6, type3, value2, eventData2.customData ?? Tree()); list.Add(item3); } if (list.Count == 0) { list.Add(new CustomBeatmapEventData(0f, BeatmapEventType.Event0, 1, Tree())); list.Add(new CustomBeatmapEventData(0f, BeatmapEventType.Event4, 1, Tree())); } var customEvents = new Dictionary <string, List <CustomEventData> >(customEventsSaveData.Count); foreach (CustomBeatmapSaveData.CustomEventData customEventData in customEventsSaveData) { if (!customEvents.ContainsKey(customEventData.type)) { customEvents[customEventData.type] = new List <CustomEventData>(); } float time7 = customEventData.time; while (num3 < list2.Count - 1 && list2[num3 + 1].bpmChangeStartBPMTime < time7) { num3++; } BPMChangeData bpmchangeData5 = list2[num3]; float time8 = bpmchangeData5.bpmChangeStartTime + beatmapDataLoader.GetRealTimeFromBPMTime(time7 - bpmchangeData5.bpmChangeStartBPMTime, bpmchangeData5.bpm, shuffle, shufflePeriod); customEvents[customEventData.type].Add(new CustomEventData(time8, customEventData.type, customEventData.data ?? Tree())); } foreach (var pair in customEvents) { pair.Value.Sort((x, y) => x.time.CompareTo(y.time)); } BeatmapLineData[] array2 = new BeatmapLineData[4]; for (int j = 0; j < 4; j++) { array[j].Sort(delegate(BeatmapObjectData x, BeatmapObjectData y) { if (x.time == y.time) { return(0); } return((x.time <= y.time) ? -1 : 1); }); array2[j] = new BeatmapLineData(); array2[j].beatmapObjectsData = array[j].ToArray(); } return(new CustomBeatmapData(array2, list.ToArray(), customEvents, customData, customLevelData)); } catch (Exception e) { Plugin.logger.Critical("Exception loading CustomBeatmap!"); Plugin.logger.Critical(e); Debug.LogError("Exception loading CustomBeatmap!"); Debug.LogError(e); throw e; } }
public ObstacleType ChooseObstacleType(ObstacleType prevObstacle, int streak) { float rampChance = 0f, trainChance = 0f, noneChance = 0f, barrierChance = 0f; switch (prevObstacle) { case ObstacleType.Ramp: { return(ObstacleType.Train); trainChance = 1f; break; } case ObstacleType.Train: { trainChance = _settings.trainMaxChance - LimitToOne(streak) * _settings.trainMaxChance; noneChance = 1f - trainChance; break; } case ObstacleType.HighBarrier: case ObstacleType.MiddleBarrier: case ObstacleType.LowBarrier: { return(ObstacleType.None); noneChance = 1f; break; } case ObstacleType.None: { noneChance = _settings.noneMaxChance - LimitToOne(streak) * _settings.noneMaxChance; var leftOver = 1f - noneChance; var coeff = (_settings.trainBaseChance + _settings.rampBaseChance + _settings.barrierBaseChance) / leftOver; trainChance = _settings.trainBaseChance / coeff; rampChance = _settings.rampBaseChance / coeff; barrierChance = _settings.barrierBaseChance / coeff; break; } default: throw new ArgumentOutOfRangeException(); } var randValue = Random.value; if (randValue < rampChance) { return(ObstacleType.Ramp); } randValue -= rampChance; if (randValue < trainChance) { return(ObstacleType.Train); } randValue -= trainChance; if (randValue < barrierChance) { return(ChooseBarrierType()); } else { return(ObstacleType.None); } }
/// <summary> /// Sets obstacle in a cell with given Id. /// </summary> public void SetObstacleInCell(int pId, ObstacleType pType) { if (mCells != null) { mCells.ForEach(l => { var cell = l.FirstOrDefault(c => c.Id == pId); if (cell != null) { Log.Write(LogLevel.Info, string.Format("Pole z ID {0} będzie miało zmieniony typ przeszkody na: {1}.", pId, pType)); cell.Obstacle = ObstacleFactory.GetObstacle(pType); } }); } }
public static T GetRandomEnum <T>() { System.Array values = ObstacleType.GetValues(typeof(T)); return((T)values.GetValue(UnityEngine.Random.Range(0, values.Length))); }
public SNO(int sno, String internalname, ActorType? actortype=null, TargetType? targettype=null, MonsterType? monstertype=null, MonsterSize? monstersize=null, float? collisionradius=null, bool? canburrow=null, bool? grantsnoxp=null, bool? dropsnoloot=null, bool? isbarricade=null, ObstacleType? obstacletype=null, float? actorsphereradius=null, GizmoType? gimzotype=null) { //Creates the perm data SNOID=sno; _actortype=actortype; _targettype=targettype; _collisionradius=collisionradius; _monstersize=monstersize; _monstertype=monstertype; _internalname=internalname; _CanBurrow=canburrow; _DropsNoLoot=dropsnoloot; _GrantsNoXP=grantsnoxp; _IsBarricade=isbarricade; _obstacletype=obstacletype; _actorsphereradius=actorsphereradius; _gizmotype=gimzotype; //_RunningRate=runningrate; IsFinalized=true; }
public static float GetJumpVelocityFactor(ObstacleType type) { return(jumpVelocityFactors [(int)type]); }
public Obstacle(ObstacleId id, ObstacleType type, IEnumerable <LocationId> blockedPaths) { Id = id; Type = type; BlockedPaths = blockedPaths.ToList(); }
public ObstacleInfo(){ type = ObstacleType.Benoit; time = 0; speed = 0; }
// Start is called before the first frame update void Start() { IsInited = false; _instance = this; Map = new ObstacleType[Height][]; for (int i = 0; i < Height; i++) { Map[i] = new ObstacleType[Width]; for (int j = 0; j < Width; j++) { Map[i][j] = ObstacleType.Floor; } } EntityManager entityManager = World.Active.EntityManager; EntityArchetype obstacleArchetype = entityManager.CreateArchetype( typeof(Translation), typeof(RenderMesh), typeof(LocalToWorld)); var floorRenderMesh = new RenderMesh() { mesh = BlockMesh, material = FloorMaterial }; var undergroundRenderMesh = new RenderMesh() { mesh = BlockMesh, material = UndergroundMaterial }; var undergroundRenderMesh2 = new RenderMesh() { mesh = BlockMesh, material = UndergroundMaterial2 }; var obstacleRenderMesh = new RenderMesh() { mesh = BlockMesh, material = ObstacleMaterial }; var TreeRenderMesh = new RenderMesh() { mesh = BlockMesh, material = TreeMaterial }; for (int i = 0; i < Height; i++) { for (int j = 0; j < Width; j++) { Map[i][j] = Random.Range(0f, 1f) > ObstacleRatio ? ObstacleType.Floor : (ObstacleType)Random.Range(1, 3); var depth = Map[i][j] == ObstacleType.Tree ? Random.Range(Depth + 1, Depth + 3) : Depth; for (int k = 0; k < depth; k++) { RenderMesh renderMesh = floorRenderMesh; switch (Map[i][j]) { case ObstacleType.Floor: if (k == 0) { renderMesh = undergroundRenderMesh2; } else if (k == 1) { renderMesh = undergroundRenderMesh; } else { renderMesh = floorRenderMesh; } break; case ObstacleType.Stone: if (k == 0) { renderMesh = undergroundRenderMesh; } else if (k == 1) { renderMesh = floorRenderMesh; } else { renderMesh = obstacleRenderMesh; } break; case ObstacleType.Tree: if (k == 0) { renderMesh = floorRenderMesh; } else if (k == 1) { renderMesh = obstacleRenderMesh; } else { renderMesh = TreeRenderMesh; } break; } var entity = entityManager.CreateEntity(obstacleArchetype); entityManager.SetSharedComponentData(entity, renderMesh); entityManager.SetComponentData(entity, new Translation { Value = new float3(i, k + (int)Map[i][j], j) }); } } } IsInited = true; }
/// <summary> /// Gets color representation of the obstacle in blueprint. /// </summary> public static string GetObstacleColor(ObstacleType pObstacle) { var attributes = XmlParser.GetAttributesValues("Obstacles", pObstacle.ToString()); return attributes["Color"]; }
public void SetOccupied(ObstacleType t, BuildingObject b) { obstacleType = t; buildingRef = b; }
void typeSelected(object sender, EventArgs e) { btn1x3.Checked = false; btn1x2.Checked = false; btn3x1.Checked = false; btn2x1.Checked = false; (sender as ToolStripButton).Checked = true; currentType = (ObstacleType)Enum.Parse(typeof(ObstacleType), (sender as ToolStripButton).Tag.ToString()); }
public void CleanTile() { obstacleType = ObstacleType.None; }
public ObstacleEntity(ObstacleType obstacleType, float x = 0, float y = 0) : base(x, y, Constants.ObstaclesLayerDepth) { this.Type = obstacleType; }
/// <summary> /// Updates the chunk after it was spawned. /// </summary> /// <param name="frame">The current <see cref="ReferenceFrame"/></param> /// <param name="isFirstChunk">Whether this is the first chunk</param> public void UpdateChunk(ReferenceFrame frame, bool isFirstChunk) { // TBD probabilities for spawning obstacles. bool hasObstacle = !isFirstChunk && Util.RandomBool(m_ObstacleProbability); // Random ObstacleType. m_ObstacleType = hasObstacle ? (Util.RandomBool(0.2f) ? ObstacleType.Roadblock : (Util.RandomBool(0.5f) ? ObstacleType.Barrel : ObstacleType.Cone)) : m_ObstacleType = ObstacleType.None; // Random road side for obstacles. int side = Util.RandomBool(0.5f) ? -1 : 1; var tf = frame.transform; transform.rotation = tf.rotation; UpdateMesh(tf, 0); for (int z = 1, x; z <= c_Length; z++) { tf = frame.MoveFrame(); UpdateMesh(tf, z); if (z % 2 == 0) { // Poles. m_Obstacles.Push(m_Pool.Spawn(tf.position - tf.right * c_PoleDistance, tf.rotation, 3)); m_Obstacles.Push(m_Pool.Spawn(tf.position + tf.right * c_PoleDistance, tf.rotation, 3)); } switch (m_ObstacleType) { case ObstacleType.Roadblock: x = c_Length / 2; if (x == z) { // Single roadblock. m_Obstacles.Push(m_Pool.Spawn(ObstacleSpawnPos(tf, x * side), tf.rotation, 0)); } break; case ObstacleType.Barrel: x = (c_Length - z) * side; m_Obstacles.Push(m_Pool.Spawn(ObstacleSpawnPos(tf, x), tf.rotation, 1)); break; case ObstacleType.Cone: x = (c_Length - z) * side; m_Obstacles.Push(m_Pool.Spawn(ObstacleSpawnPos(tf, x), tf.rotation, 2)); break; } } m_Mesh.vertices = m_Vertices; m_Mesh.normals = m_Normals; m_Mesh.RecalculateBounds(); m_MeshFilter.sharedMesh = m_Mesh; m_MeshCollider.sharedMesh = m_Mesh; }
private Obstacle createObstacle(ObstacleType obsType) { Obstacle newObs = new Obstacle(); int newWidth = 0; Texture2D obstacleTexture = null; switch (obsType) { case ObstacleType.HOLE: obstacleTexture = getRandomHoleTexture(); break; case ObstacleType.HILL: obstacleTexture = getRandomHillTexture(); break; case ObstacleType.SLIDE: obstacleTexture = getRandomSlideTexture(); break; case ObstacleType.WALL: obstacleTexture = getRandomWallTexture(); newObs.AnimateOnDeath = true; newWidth = 100; break; } if (obstacleTexture != null) { if (obsType != ObstacleType.NULL) { newObs.Type = obsType; } newObs.Texture = obstacleTexture; newObs.Color = ColorHandler.getCurrentColor(); if (newWidth == 0) { newWidth = newObs.Texture.Width; } newObs.Width = newWidth; newObs.Height = newObs.Texture.Height; newObs.Move(obstacleCreationPointX, obstacleCreationPointY); newObs.AnimationSpeed = obstacleAnimSpeed; newObs.Speed = 2.5f; newObs.LayerDepth = 0.1f; newObs.Active = true; newObs.ReadyToAnimate = false; newObs.StayAtFrame = false; if (newObs.AnimateOnDeath != true) { newObs.AnimateOnDeath = false; } obstacleSprites.Add(newObs); } else { newObs = null; } return newObs; }
public static Obstacle CreateForType(ObstacleType type) { var id = IdGenerator.GetNextIdForType(IdGenerator.IdType.OBSTACLE); return(new Obstacle(id, type)); }
public Obstacle(double time, Line line, ObstacleType type, double duration, int width) { _time = time; _lineIndex = (int)line; _type = (int)type; _duration = duration; _width = width; }
public CachedSNOEntry(int sno, string internalname, ActorType? actortype = null, TargetType? targettype = null, float? collisionradius = null, int? interactrange=null, bool? canburrow = null, bool? isbarricade = null, ObstacleType? obstacletype = null, float? actorsphereradius = null, GizmoType? gizmotype = null, PluginDroppedItemTypes? baseitemtype = null, UnitFlags? unitflags = null, GizmoTargetTypes? gizmotargettypes = null, CacheEntry snoentry = null) : base(sno, internalname, actortype, targettype, collisionradius, interactrange, canburrow, isbarricade, obstacletype, actorsphereradius, gizmotype, baseitemtype, unitflags, gizmotargettypes, snoentry) { }
public SNO(int sno, string internalname, ActorType? actortype = null, TargetType? targettype = null, float? collisionradius = null, int? interactrange=null, bool? canburrow = null, bool? isbarricade = null, ObstacleType? obstacletype = null, float? actorsphereradius = null, GizmoType? gimzotype = null, PluginDroppedItemTypes? baseitemtype = null, UnitFlags? unitflags = null, GizmoTargetTypes? gizmotargettypes = null, CacheEntry snoentry = null) { //Creates the perm data SNOID = sno; _actortype = actortype; _targettype = targettype; _collisionradius = collisionradius; _internalname = internalname; _CanBurrow = canburrow; _IsBarricade = isbarricade; _obstacletype = obstacletype; _actorsphereradius = actorsphereradius; _gizmotype = gimzotype; _itemdroptype = baseitemtype; _unitflags = unitflags; _gizmoTargetTypes = gizmotargettypes; _snoentry = snoentry; UpdateLookUpFinalValues(); IsFinalized = true; }
public void setType(ObstacleType type) { this._type = type; }
public List <IObstacle> GetObstacles(ObstacleType type) { return(this.Where(obstacle => (type & obstacle.Type) == obstacle.Type).ToList()); }
public Obstacle() { _type = ObstacleType.Car; _y = 20; ConstructorBaseAction(); }
public CachedSNOEntry(int sno, String internalname, ActorType? actortype=null, TargetType? targettype=null, MonsterType? monstertype=null, MonsterSize? monstersize=null, float? collisionradius=null, bool? canburrow=null, bool? grantsnoxp=null, bool? dropsnoloot=null, bool? isbarricade=null, ObstacleType? obstacletype=null, float? actorsphereradius=null, GizmoType? gizmotype=null) : base(sno, internalname, actortype, targettype, monstertype, monstersize, collisionradius, canburrow, grantsnoxp, dropsnoloot, isbarricade, obstacletype, actorsphereradius, gizmotype) { }
static bool Prefix(List <BeatmapSaveData.NoteData> notesSaveData, List <BeatmapSaveData.ObstacleData> obstaclesSaveData, List <BeatmapSaveData.EventData> eventsSaveData, float beatsPerMinute, float shuffle, float shufflePeriod, ref BeatmapData __result) { List <BeatmapObjectData>[] array = new List <BeatmapObjectData> [4]; List <BeatmapEventData> list = new List <BeatmapEventData>(eventsSaveData.Count); for (int i = 0; i < 4; i++) { array[i] = new List <BeatmapObjectData>(3000); } int num = 0; NoteData noteData = null; float num2 = -1f; List <NoteData> list2 = new List <NoteData>(4); float num3 = 0f; foreach (BeatmapSaveData.NoteData noteData2 in notesSaveData) { float realTimeFromBPMTime = GetRealTimeFromBPMTime(noteData2.time, beatsPerMinute, shuffle, shufflePeriod); if (num3 > realTimeFromBPMTime) { Debug.LogError("Notes are not ordered."); } num3 = realTimeFromBPMTime; int lineIndex = noteData2.lineIndex; NoteLineLayer lineLayer = noteData2.lineLayer; NoteLineLayer startNoteLineLayer = NoteLineLayer.Base; if (noteData != null && noteData.lineIndex == lineIndex && Mathf.Abs(noteData.time - realTimeFromBPMTime) < 0.0001f) { if (noteData.startNoteLineLayer == NoteLineLayer.Base) { startNoteLineLayer = NoteLineLayer.Upper; } else { startNoteLineLayer = NoteLineLayer.Top; } } NoteType type = noteData2.type; NoteCutDirection cutDirection = noteData2.cutDirection; if (list2.Count > 0 && list2[0].time < realTimeFromBPMTime - 0.001f && type.IsBasicNote()) { ProcessBasicNotesInTimeRow(list2, realTimeFromBPMTime); num2 = list2[0].time; list2.Clear(); } NoteData noteData3 = new NoteData(num++, realTimeFromBPMTime, lineIndex, lineLayer, startNoteLineLayer, type, cutDirection, float.MaxValue, realTimeFromBPMTime - num2); int number = lineIndex; if (number < 0) { number = 0; } if (number > 3) { number = 3; } array[number].Add(noteData3); noteData = noteData3; if (noteData3.noteType.IsBasicNote()) { list2.Add(noteData); } } ProcessBasicNotesInTimeRow(list2, float.MaxValue); foreach (BeatmapSaveData.ObstacleData obstacleData in obstaclesSaveData) { float realTimeFromBPMTime2 = GetRealTimeFromBPMTime(obstacleData.time, beatsPerMinute, shuffle, shufflePeriod); int lineIndex2 = obstacleData.lineIndex; ObstacleType type2 = obstacleData.type; float realTimeFromBPMTime3 = GetRealTimeFromBPMTime(obstacleData.duration, beatsPerMinute, shuffle, shufflePeriod); int width = obstacleData.width; ObstacleData item = new ObstacleData(num++, realTimeFromBPMTime2, lineIndex2, type2, realTimeFromBPMTime3, width); int number2 = lineIndex2; if (number2 < 0) { number2 = 0; } if (number2 > 3) { number2 = 3; } array[number2].Add(item); } foreach (BeatmapSaveData.EventData eventData in eventsSaveData) { float realTimeFromBPMTime4 = GetRealTimeFromBPMTime(eventData.time, beatsPerMinute, shuffle, shufflePeriod); BeatmapEventType type3 = eventData.type; int value = eventData.value; BeatmapEventData item2 = new BeatmapEventData(realTimeFromBPMTime4, type3, value); list.Add(item2); } if (list.Count == 0) { list.Add(new BeatmapEventData(0f, BeatmapEventType.Event0, 1)); list.Add(new BeatmapEventData(0f, BeatmapEventType.Event4, 1)); } BeatmapLineData[] array2 = new BeatmapLineData[4]; for (int j = 0; j < 4; j++) { array[j].Sort(delegate(BeatmapObjectData x, BeatmapObjectData y) { if (x.time == y.time) { return(0); } return((x.time <= y.time) ? -1 : 1); }); array2[j] = new BeatmapLineData(); array2[j].beatmapObjectsData = array[j].ToArray(); } __result = new BeatmapData(array2, list.ToArray()); return(false); }
public static bool IsBlocked(WallState[] walls,ObstacleType[] obstacles) { foreach (WallState wall in walls) { if (wall == WallState.Sealed || wall == WallState.Breaking) { return true; } } foreach (ObstacleType obstacle in obstacles) { if (obstacle == ObstacleType.Rock) { return true; } } return false; }