ObstacleData GetRandomObstacle()
	{
		var obstacle = new ObstacleData();
		obstacle.deltaWidth = GetRandomObstacleDimension();
		obstacle.deltaHeight = GetRandomObstacleDimension();
		return obstacle;
	}
    public void SetObstaclesData(ObstacleData[] obstaclesData)
    {
        _grassComputeShader.SetFloat("_DeltaTime", Time.deltaTime);

        _obstaclesBuffer.SetData(obstaclesData);
        _grassComputeShader.SetInt("_NumObstacles", obstaclesData.Length);
        #if GRASS_CPU
        _obstaclesDataTestCPU = obstaclesData;
        #endif
    }
	bool TryPutObstacle(MapData mapData, ObstacleData obstacle, Position position)
	{
		var putSuccessfully = false;

		if( mapData.ObstacleFits(obstacle, position) )
		{
			mapData.PutObstacle(obstacle, position);
			putSuccessfully = true;
		}

		return putSuccessfully;
	}
Esempio n. 4
0
        internal void StartClearing()
        {
            ObstacleData Data = this.ObstacleData;

            if (this.ClearingOnGoing)
            {
                if (Data.ClearTimeSeconds <= 0)
                {
                    this.ClearingFinished();
                }
            }
        }
Esempio n. 5
0
    bool TryPutObstacle(MapData mapData, ObstacleData obstacle, Position position)
    {
        var putSuccessfully = false;

        if (mapData.ObstacleFits(obstacle, position))
        {
            mapData.PutObstacle(obstacle, position);
            putSuccessfully = true;
        }

        return(putSuccessfully);
    }
Esempio n. 6
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static void Postfix(ObstacleData __instance)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (__instance is CustomObstacleData customData)
            {
                dynamic dynData = customData.customData;
                IEnumerable <float?> position = ((List <object>)Trees.at(dynData, POSITION))?.Select(n => n.ToNullableFloat());
                IEnumerable <float?> scale    = ((List <object>)Trees.at(dynData, SCALE))?.Select(n => n.ToNullableFloat());
                List <float>         localrot = ((List <object>)Trees.at(dynData, LOCALROTATION))?.Select(n => Convert.ToSingle(n)).ToList();
                dynamic rotation = Trees.at(dynData, ROTATION);

                float?startX = position?.ElementAtOrDefault(0);
                float?scaleX = scale?.ElementAtOrDefault(0);

                IDictionary <string, object> dictdata = dynData as IDictionary <string, object>;

                float width = scaleX.GetValueOrDefault(__instance.width);
                if (startX.HasValue)
                {
                    dictdata[POSITION] = new List <object>()
                    {
                        (startX.Value + width) * -1, position.ElementAtOrDefault(1)
                    };
                }

                if (localrot != null)
                {
                    List <float> rot            = localrot.Select(n => Convert.ToSingle(n)).ToList();
                    Quaternion   modifiedVector = Quaternion.Euler(rot[0], rot[1], rot[2]);
                    Vector3      vector         = new Quaternion(modifiedVector.x, modifiedVector.y * -1, modifiedVector.z * -1, modifiedVector.w).eulerAngles;
                    dictdata[LOCALROTATION] = new List <object> {
                        vector.x, vector.y, vector.z
                    };
                }

                if (rotation != null)
                {
                    if (rotation is List <object> list)
                    {
                        List <float> rot            = list.Select(n => Convert.ToSingle(n)).ToList();
                        Quaternion   modifiedVector = Quaternion.Euler(rot[0], rot[1], rot[2]);
                        Vector3      vector         = new Quaternion(modifiedVector.x, modifiedVector.y * -1, modifiedVector.z * -1, modifiedVector.w).eulerAngles;
                        dictdata[ROTATION] = new List <object> {
                            vector.x, vector.y, vector.z
                        };
                    }
                    else
                    {
                        dictdata[ROTATION] = rotation * -1;
                    }
                }
            }
        }
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static void Postfix(Vector3 ____centerPos, ObstacleData obstacleData, ref Vector3 moveStartPos, ref Vector3 moveEndPos, ref Vector3 jumpEndPos, ref float obstacleHeight)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (obstacleData is CustomObstacleData customData)
            {
                dynamic dynData = customData.customData;
                IEnumerable <float?> position = ((List <object>)Trees.at(dynData, POSITION))?.Select(n => n.ToNullableFloat());
                IEnumerable <float?> scale    = ((List <object>)Trees.at(dynData, SCALE))?.Select(n => n.ToNullableFloat());
                float?njs         = (float?)Trees.at(dynData, NOTEJUMPSPEED);
                float?spawnoffset = (float?)Trees.at(dynData, NOTESPAWNOFFSET);

                float?startX = position?.ElementAtOrDefault(0);
                float?startY = position?.ElementAtOrDefault(1);

                float?height = scale?.ElementAtOrDefault(1);

                Vector3?finalNoteOffset = null;

                // Actual wall stuff
                if (startX.HasValue || startY.HasValue || njs.HasValue || spawnoffset.HasValue)
                {
                    GetNoteJumpValues(njs, spawnoffset, out float _, out float _, out Vector3 localMoveStartPos, out Vector3 localMoveEndPos, out Vector3 localJumpEndPos);

                    // Ripped from base game
                    Vector3 noteOffset = GetNoteOffset(obstacleData, startX, null);
                    noteOffset.y = startY.HasValue ? VerticalObstaclePosY + (startY.GetValueOrDefault(0) * NoteLinesDistance) : ((obstacleData.obstacleType == ObstacleType.Top)
                        ? (TopObstaclePosY + JumpOffsetY) : VerticalObstaclePosY);

                    finalNoteOffset = noteOffset;

                    moveStartPos = localMoveStartPos + noteOffset;
                    moveEndPos   = localMoveEndPos + noteOffset;
                    jumpEndPos   = localJumpEndPos + noteOffset;
                }

                if (height.HasValue)
                {
                    obstacleHeight = height.Value * NoteLinesDistance;
                }

                if (!finalNoteOffset.HasValue)
                {
                    Vector3 noteOffset = GetNoteOffset(obstacleData, startX, null);
                    noteOffset.y    = (obstacleData.obstacleType == ObstacleType.Top) ? (TopObstaclePosY + JumpOffsetY) : VerticalObstaclePosY;
                    finalNoteOffset = noteOffset;
                }

                dynData.noteOffset = ____centerPos + finalNoteOffset.Value;
                float?width = scale?.ElementAtOrDefault(0);
                dynData.xOffset = ((width.GetValueOrDefault(obstacleData.lineIndex) / 2f) - 0.5f) * NoteLinesDistance;
            }
        }
    ObstacleData CreateObstacleDataAndInstantiate(Vector3 position, Quaternion rotation, Vector3 scale, ObjectTypes objectType)
    {
        ObstacleData obsData = new ObstacleData();

        obsData.Position   = position;
        obsData.Rotation   = rotation;
        obsData.Scale      = scale;
        obsData.ObjectType = objectType;

        InstantiateWithData(ref obsData);

        return(obsData);
    }
Esempio n. 9
0
        private static float ObstacleTimeAdjust(float original, ObstacleData obstacleData, float move1Duration, float finishMovementTime)
        {
            if (original > move1Duration && NoodleObjectDatas.TryGetValue(obstacleData, out NoodleObjectData noodleData))
            {
                float?time = (float?)AnimationHelper.TryGetPropertyAsObject(noodleData.Track, TIME);
                if (time.HasValue)
                {
                    return((time.Value * (finishMovementTime - move1Duration)) + move1Duration);
                }
            }

            return(original);
        }
Esempio n. 10
0
 public void ExeuteObstacleActions()
 {
     if (ObstaclePresent())
     {
         ObstacleData data = ObstacleDatabase.GetObstacleData(_obstacleId);
         if (data.ObstacleActions != null && data.ObstacleActions.Length > 0)
         {
             //Get random action and execute
             int outcomeIndex = Random.Range(0, data.ObstacleActions.Length);
             data.ObstacleActions[outcomeIndex].ExecuteOutcome();
         }
     }
 }
	public ObstacleData getData()
	{
		ObstacleData lvData = new ObstacleData ();

		lvData.isBlockingLineOfSight = isBlockingLoS;
		lvData.isBlockingMovement = isBlockingMovement;
		lvData.isDifficultTerrain = isDifficultTerrain;
		lvData.providedCover = coverValue;
		lvData.obstaclePrefabName = this.prefabName;
		lvData.rotation = this.gameObject.transform.GetChild (0).eulerAngles.y;

		return lvData;
	}
Esempio n. 12
0
        public static BeatmapObjectData NoteToWall(BeatmapObjectData original, float bpm)
        {
            NoteData note        = original as NoteData;
            int      startHeight = 120 + (((int)note.noteLineLayer) * 120);
            int      height      = 150;
            int      width       = 1800;
            int      type        = height * 1000 + startHeight + 4001;
            float    duration    = (bpm / 60f) * (1f / 32f);

            BeatmapObjectData newWall = new ObstacleData(original.id * 14130, original.time, original.lineIndex, (ObstacleType)type, duration, width);

            return(newWall);
        }
Esempio n. 13
0
        public static ObstacleData ConvertObstacleData(ObstacleData obstacle, RawObstacleData rawData, float jumpSpeed, float secondEquivalentOfBeat, float3 lineOffset)
        {
            obstacle.TransformData.Position = GetPosition(rawData.LineIndex, 0, lineOffset);

            float height      = 0;
            float startHeight = 0;

            if (rawData.Type >= 40001 && rawData.Type <= 4005000)
            {
                int type = rawData.Type - 4001;
                height      = type / 1000;
                startHeight = type % 1000;

                float normalHeight = lineOffset.y * 2f;

                obstacle.TransformData.Position.y = startHeight / 1000f * normalHeight;
            }
            else if (rawData.Type >= 1000)
            {
                height  = rawData.Type;
                height -= 1000;
            }

            obstacle.TransformData.Scale.c1.y = height / 1000f;

            if (rawData.Type == 0)
            {
                obstacle.TransformData.Position.y = 1;
            }
            else if (rawData.Type == 1)
            {
                obstacle.TransformData.Position.y = 2;
            }

            if (rawData.Width >= 1000)
            {
                obstacle.TransformData.Scale.c0.x = (rawData.Width - 1000f) / 1000f;
            }
            else
            {
                obstacle.TransformData.Scale.c0.x = rawData.Width;
            }

            //obstacle.TransformData.Scale.c0.x *= lineOffset.x;
            obstacle.TransformData.Scale.c2 = new float4(0, 0, PlacementHelper.ConvertDurationToZScale((float)rawData.Duration, jumpSpeed, secondEquivalentOfBeat) / 2, 0);

            obstacle.TransformData.Scale.c2.z = PlacementHelper.ConvertDurationToZScale((float)rawData.Duration, jumpSpeed, secondEquivalentOfBeat) / 2;
            obstacle.TransformData.Position  += new float3(lineOffset.x * 1.6f, obstacle.TransformData.Scale.c1.y / 2, obstacle.TransformData.Scale.c2.z / 2);

            return(obstacle);
        }
        public override void SpawnObstacle(ObstacleData obstacleData)
        {
            if (_disableSpawning)
            {
                return;
            }
            _beatmapObjectSpawnMovementData.GetObstacleSpawnMovementData(obstacleData, out var moveStartPos, out var moveEndPos, out var jumpEndPos, out var obstacleHeight);
            float moveDuration      = _beatmapObjectSpawnMovementData.moveDuration;
            float jumpDuration      = _beatmapObjectSpawnMovementData.jumpDuration;
            float noteLinesDistance = _beatmapObjectSpawnMovementData.noteLinesDistance;
            float rotation          = _spawnRotationProcesser.rotation;

            onlineObjectManager.SpawnObstacle(obstacleData, moveStartPos, moveEndPos, jumpEndPos, moveDuration, jumpDuration, rotation, noteLinesDistance, obstacleHeight);
        }
 private static float GetCustomLength(float @default, ObstacleData obstacleData)
 {
     if (obstacleData is CustomObstacleData customData)
     {
         dynamic dynData            = customData.customData;
         IEnumerable <float?> scale = ((List <object>)Trees.at(dynData, SCALE))?.Select(n => n.ToNullableFloat());
         float?length = scale?.ElementAtOrDefault(2);
         if (length.HasValue)
         {
             return(length.Value * _noteLinesDistance);
         }
     }
     return(@default);
 }
Esempio n. 16
0
    private void SetSelectedEntity(EntityData entity)
    {
        Metrics.WaypointVisuals(false);

        selectedObstacle = null;
        selectedItem     = null;
        selectedEntity   = entity;
        selectedWaypoint = null;

        if (selectedEntity != null)
        {
            editorUI.entitySelectionUI.SetUIBasedOn(selectedEntity);
        }
    }
Esempio n. 17
0
        private static float GetCustomWidth(float @default, ObstacleData obstacleData)
        {
            if (NoodleObjectDatas.TryGetValue(obstacleData, out NoodleObjectData noodleObjectData))
            {
                NoodleObstacleData noodleData = (NoodleObstacleData)noodleObjectData;
                float?width = noodleData.Width;
                if (width.HasValue)
                {
                    return(width.Value);
                }
            }

            return(@default);
        }
Esempio n. 18
0
        private static float GetCustomLength(float @default, ObstacleData obstacleData)
        {
            if (NoodleObjectDatas.TryGetValue(obstacleData, out NoodleObjectData noodleObjectData))
            {
                NoodleObstacleData noodleData = (NoodleObstacleData)noodleObjectData;
                float?length = noodleData.Length;
                if (length.HasValue)
                {
                    return(length.Value * NoteLinesDistance);
                }
            }

            return(@default);
        }
Esempio n. 19
0
    private void SetSelectedObstacle(ObstacleData obstacle)
    {
        Metrics.WaypointVisuals(false);

        selectedObstacle = obstacle;
        selectedItem     = null;
        selectedEntity   = null;
        selectedWaypoint = null;

        if (selectedObstacle != null)
        {
            editorUI.obstacleSelectionUI.SetUIBasedOn(selectedObstacle);
        }
    }
Esempio n. 20
0
    public void PutObstacle(ObstacleData obstacle, Position position)
    {
        var obstacleMaxRow    = GetObstacleMaxPosition(position.row, obstacle.deltaHeight);
        var obstacleMaxColumn = GetObstacleMaxPosition(position.column, obstacle.deltaWidth);

        for (var row = position.row; row <= obstacleMaxRow; row++)
        {
            for (var column = position.column; column <= obstacleMaxColumn; column++)
            {
                var tileData = GetTileData(row, column);
                tileData.DisconnectFromNeighbors();
                tileData.objectOnTile = MapObject.OBSTACLE;
            }
        }
    }
 public ObstacleGenerator(ObstacleData[] obstacles, ObstacleData colourSwapper, Transform container, ColourData colourData)
 {
     this.obstacles     = obstacles;
     this.colourSwapper = colourSwapper;
     this.container     = container;
     this.colourData    = colourData;
     generatedObstacles = new List <IColorEntity>();
     Generate();
     GenerateColourSwapper();
     Generate();
     GenerateColourSwapper();
     Generate();
     GenerateColourSwapper();
     Generate();
 }
Esempio n. 22
0
    public void DamageObstacle(int damage)
    {
        if (!string.IsNullOrEmpty(_obstacleId))
        {
            _health -= damage;
            if (_health <= 0)
            {
                //Execute final outcome
                ObstacleData data = ObstacleDatabase.GetObstacleData(_obstacleId);
                data.CompletedOutcome.ExecuteOutcome();

                _obstacleId = null;
            }
        }
    }
        private static float GetCustomLength(float @default, ObstacleData obstacleData)
        {
            NoodleObstacleData?noodleData = TryGetObjectData <NoodleObstacleData>(obstacleData);

            if (noodleData != null)
            {
                float?length = noodleData.Length;
                if (length.HasValue)
                {
                    return(length.Value * NoteLinesDistance);
                }
            }

            return(@default);
        }
        private static float GetCustomWidth(float @default, ObstacleData obstacleData)
        {
            NoodleObstacleData?noodleData = TryGetObjectData <NoodleObstacleData>(obstacleData);

            if (noodleData != null)
            {
                float?width = noodleData.Width;
                if (width.HasValue)
                {
                    return(width.Value);
                }
            }

            return(@default);
        }
Esempio n. 25
0
    public void Init(int levelNumber)
    {
        int countObstacles = levelNumber + 2;

        _creatorData.Obstacles = new ObstacleData[countObstacles];
        ObstacleData[] obstaclesData = ForwardObstaclesPrefab;

        for (int i = 0; i < countObstacles; i++)
        {
            int          ranObstacle = Random.Range(0, obstaclesData.Length);
            ObstacleData obstacle    = obstaclesData[ranObstacle];
            _creatorData.Obstacles[i] = Instantiate(obstacle, _creatorData.AnchorObstacles.transform);
            obstaclesData             = ChooseData(obstacle);
        }
    }
Esempio n. 26
0
        private static float ObstacleTimeAdjust(float original, ObstacleData obstacleData, float move1Duration, float finishMovementTime)
        {
            if (original > move1Duration)
            {
                dynamic dynData = ((CustomObstacleData)obstacleData).customData;
                Track   track   = Trees.at(dynData, "track");
                float?  time    = AnimationHelper.TryGetProperty(track, TIME);
                if (time.HasValue)
                {
                    return((time.Value * (finishMovementTime - move1Duration)) + move1Duration);
                }
            }

            return(original);
        }
    public static ObstacleData Prototype(string instructionSetID, GameObject prefab, int width, int length, LightMode lightMode, DoorMode doorMode, bool isInteractable, bool useVFX)
    {
        ObstacleData prototype = new ObstacleData();

        prototype.instructionSetID = instructionSetID;
        prototype.prefab           = prefab;
        prototype.width            = width;
        prototype.length           = length;
        prototype.lightMode        = lightMode;
        prototype.doorMode         = doorMode;
        prototype.isInteractable   = isInteractable;
        prototype.useVFX           = useVFX;

        return(prototype);
    }
Esempio n. 28
0
    public bool SubmitObstacleAction(string action, string target)
    {
        ObstacleData data = ObstacleDatabase.GetObstacleData(_obstacleId);

        for (int j = 0; j < data.Interactions.Length; j++)
        {
            Interaction interaction = data.Interactions[j];
            if ((Helpers.LooseCompare(target, interaction.Target) || Helpers.LooseCompare(target, data.Name)) && Helpers.LooseCompare(action, interaction.Action))
            {
                interaction.ExecuteInteractionOutcome();
                return(true);
            }
        }
        return(false);
    }
Esempio n. 29
0
 public virtual void OnDispose()
 {
     if (Behaviour != null)
     {
         Behaviour.Dispose();
     }
     if (AssignedTo != null)
     {
         ObstacleData AssignedObstacle = (ObstacleData)AssignedTo;
         if (AssignedObstacle != null)
         {
             AssignedObstacle.AssignedCards.Remove(this);
         }
     }
 }
    void ResetData()
    {
        // Go over all the created obstacles, destroy the gameobject and add the data of the object
        // to the cancelled data list so we can undo the deleting.

        int count = ObstacleDataContainer.CurrentObstacleData.Count;

        for (int i = 0; i < count; ++i)
        {
            ObstacleData obsData = ObstacleDataContainer.CurrentObstacleData[i];
            DestroyImmediate(obsData.ReferenceToObstacle.gameObject);
            obsData.ReferenceToObstacle = null;
            ObstacleDataContainer.CancelledObstacleData.Add(obsData);
        }
        ObstacleDataContainer.CurrentObstacleData.Clear();
        SaveData();
    }
    public static bool LoadObstacleData()
    {
        _obstacleData = new Dictionary <string, ObstacleData>();
        ObstacleArray obstacleArray = GetObstacleArray();

        if (obstacleArray != null)
        {
            for (int i = 0; i < obstacleArray.Obstacles.Length; i++)
            {
                ObstacleData obstacle = obstacleArray.Obstacles[i];
                _obstacles.Add(obstacle.ObstacleId, obstacle);
            }
            return(true);
        }

        return(false);
    }
Esempio n. 32
0
        private bool obstacleHasSpace(ObstacleData od, int x, int y, int[,] field)
        {
            int w = od.Width, h = od.Height;

            for (var i = 0; i < w; i++)
            {
                for (var j = 0; j < h; j++)
                {
                    if (field[x + i, y + j] == 1)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        private static float ObstacleTimeAdjust(float original, ObstacleData obstacleData, float move1Duration, float finishMovementTime)
        {
            if (original > move1Duration)
            {
                NoodleObstacleData?noodleData = TryGetObjectData <NoodleObstacleData>(obstacleData);
                if (noodleData != null)
                {
                    float?time = noodleData.Track?.Select(n => AnimationHelper.TryGetProperty <float?>(n, TIME)).FirstOrDefault(n => n.HasValue);
                    if (time.HasValue)
                    {
                        return((time.Value * (finishMovementTime - move1Duration)) + move1Duration);
                    }
                }
            }

            return(original);
        }
Esempio n. 34
0
        private static void Prefix(ObstacleController __instance, ObstacleData obstacleData)
        {
            if (!(__instance is MultiplayerConnectedPlayerObstacleController))
            {
                ChromaObjectData chromaData = ChromaObjectDatas[obstacleData];
                Color?           color      = chromaData.Color;

                if (color.HasValue)
                {
                    __instance.SetObstacleColor(color.Value);
                }
                else
                {
                    __instance.Reset();
                }
            }
        }
Esempio n. 35
0
        public MapData(string text_boundary
		               , string text_obstacles
		               , string text_arsenals
		               )
        {
            string[] data_boundary = text_boundary.Split(',');
            width = Convert.ToInt32(data_boundary[0]);
            height = Convert.ToInt32(data_boundary[1]);

            string[] obstacleText = text_obstacles.Split('*');
            if(obstacleText[0] != "")
            {
                obstacleData = new ObstacleData[obstacleText.Length];
                for(int i = 0; i<obstacleText.Length; i++)
                {
                    obstacleData[i] = new ObstacleData(obstacleText[i]);
                }
            }
            else
            {
                obstacleData = null;
            }

            string[] arsenalText = text_arsenals.Split('*');
            if(arsenalText[0] != "")
            {
                arsenalData = new ArsenalData[arsenalText.Length];
                for(int i = 0; i<arsenalText.Length; i++)
                {
                    arsenalData[i] = new ArsenalData(arsenalText[i]);
                }
            }
            else
            {
                arsenalData = null;
            }
        }
	public void SetupObstacles(ObstacleData [] pmObstacleData)
	{
		GameObject[] lvCells = GridDrawer.instance.mCells;

		for (int i = 0; i < pmObstacleData.Length; i++) {
			if (pmObstacleData [i] != null) {
				ObstacleData lvData = pmObstacleData [i];
				GameObject lvPrefab = Resources.Load<GameObject> ("ObstaclePrefabs/"+lvData.obstaclePrefabName);

				GameObject lvInstance = Instantiate (lvPrefab);
				lvInstance.transform.parent = lvCells [i].transform;

				FigurineMover lvMover = lvInstance.GetComponent<FigurineMover> ();
				lvMover.gridX = GridDrawer.instance.getGridX (i);
				lvMover.gridZ = GridDrawer.instance.getGridZ (i);

				ObstacleStatus lvStatus = lvInstance.GetComponent<ObstacleStatus> ();
				lvStatus.isBlockingLoS = lvData.isBlockingLineOfSight;
				lvStatus.isDifficultTerrain = lvData.isDifficultTerrain;
				lvStatus.isBlockingMovement = lvData.isBlockingMovement;
				lvStatus.coverValue = lvData.providedCover;


				lvInstance.GetComponent<ObstacleRotator> ().Rotate (lvData.rotation);

				//lvInstance.transform.eulerAngles = new Vector3 (0.0f, lvData.rotation, 0.0f);

			}
		}
	}
	private ObstacleData[] CollectObstacleData()
	{
		GameObject[] lvCells = GridDrawer.instance.mCells;
		ObstacleData [] lvData = new ObstacleData[lvCells.Length];

		for (int i = 0; i < lvCells.Length; i++) {
			if (lvCells [i].transform.childCount > 0) {
				lvData [i] = lvCells [i].transform.GetChild (0).gameObject.GetComponent<ObstacleStatus> ().getData();
			} else {
				lvData [i] = null;
			}
		}

		return lvData;
	}