public int tileCountInitial; // The starting number of tiles public void SetLevel(int level) { if (levelAttributes.Count >= 2) { LevelAttributes levelAttributesA = null; LevelAttributes levelAttributesB = null; for (int i = 1; i < levelAttributes.Count; i++) { if (level <= levelAttributes[i].level) { levelAttributesA = levelAttributes[i - 1]; levelAttributesB = levelAttributes[i]; } } if (levelAttributesA == null && levelAttributesB == null) { levelAttributesCurrent = new LevelAttributes(levelAttributes[levelAttributes.Count - 1]); } else { levelAttributesCurrent.Interpolate(levelAttributesA, levelAttributesB, level); } } else { levelAttributesCurrent = new LevelAttributes(levelAttributes[0]); } }
private void OnDisable() { if (base.enabled) { instance = null; } }
// Update is called once per frame void LateUpdate() { LevelAttributes level = LevelAttributes.Instance; float xMax = level.transform.position.x + (level.Width / 2.0f); float xMin = level.transform.position.x - (level.Width / 2.0f); float zMax = level.transform.position.z + (level.Height / 2.0f); float zMin = level.transform.position.z - (level.Height / 2.0f); Vector3 newPos = transform.position; if (transform.position.x > xMax) { newPos.x = xMax; } if (transform.position.x < xMin) { newPos.x = xMin; } if (transform.position.z > zMax) { newPos.z = zMax; } if (transform.position.z < zMin) { newPos.z = zMin; } transform.position = newPos; }
public static LevelAttributes GetInstance() { if (!instance) { instance = FindObjectOfType(typeof(LevelAttributes)) as LevelAttributes; if (!instance) Debug.LogError ("There needs to be one active LevelAttributes script on a GameObject in your scene."); } return instance; }
// Update is called once per frame void Update() { transform.Translate(Vector3.forward * Time.deltaTime * speed); Vector3 bounceDir = Vector3.zero; if (followsTarget && LevelAttributes.Instance.Player) { Transform target = LevelAttributes.Instance.Player; Debug.Log("Following " + target.GetInstanceID()); transform.rotation = Quaternion.RotateTowards( transform.rotation, Quaternion.LookRotation(target.position - transform.position, transform.up), turnSpeed ); } LevelAttributes level = LevelAttributes.Instance; float xMax = level.transform.position.x + (level.Width / 2.0f); float xMin = level.transform.position.x - (level.Width / 2.0f); float zMax = level.transform.position.z + (level.Height / 2.0f); float zMin = level.transform.position.z - (level.Height / 2.0f); Vector3 newPos = transform.position; if (transform.position.x > xMax) { newPos.x = xMax; bounceDir += Vector3.left; } if (transform.position.x < xMin) { newPos.x = xMin; bounceDir += Vector3.right; } if (transform.position.z > zMax) { newPos.z = zMax; bounceDir += Vector3.back; } if (transform.position.z < zMin) { newPos.z = zMin; bounceDir += Vector3.forward; } transform.position = newPos; if (bouncesOffWalls && bounceDir != Vector3.zero) { BounceOffWalls(bounceDir); } Debug.DrawRay(transform.position, transform.forward); }
public static LevelAttributes GetInstance() { if (!instance) { instance = (Object.FindObjectOfType(typeof(LevelAttributes)) as LevelAttributes); if (!instance) { Logger.traceError("There needs to be one active LevelAttributes script on a GameObject in your scene."); } } return(instance); }
public static LevelAttributes GetInstance() { if (!LevelAttributes.instance) { LevelAttributes.instance = (LevelAttributes)FindObjectOfType(typeof(LevelAttributes)); if (!LevelAttributes.instance) { Debug.LogError("There needs to be one active LevelAttributes script on a GameObject in your scene."); } } return(instance); }
public void Interpolate(LevelAttributes levelAttributesA, LevelAttributes levelAttributesB, int currentLevel) { level = currentLevel; float valueBetweenLevels = (float)currentLevel / ((float)levelAttributesB.level - (float)levelAttributesA.level); tileValueCap = Mathf.Lerp(levelAttributesA.tileValueCap, levelAttributesB.tileValueCap, valueBetweenLevels); tileCountDesired = Mathf.Lerp(levelAttributesA.tileCountDesired, levelAttributesB.tileCountDesired, valueBetweenLevels); tileSpawnCountDeviation = Mathf.Lerp(levelAttributesA.tileSpawnCountDeviation, levelAttributesB.tileSpawnCountDeviation, valueBetweenLevels); tileWeight_Addition = Mathf.Lerp(levelAttributesA.tileWeight_Addition, levelAttributesB.tileWeight_Addition, valueBetweenLevels); tileWeight_Subtraction = Mathf.Lerp(levelAttributesA.tileWeight_Subtraction, levelAttributesB.tileWeight_Subtraction, valueBetweenLevels); tileWeight_Multiplication = Mathf.Lerp(levelAttributesA.tileWeight_Multiplication, levelAttributesB.tileWeight_Multiplication, valueBetweenLevels); tileWeight_Division = Mathf.Lerp(levelAttributesA.tileWeight_Division, levelAttributesB.tileWeight_Division, valueBetweenLevels); comboLength = Mathf.Lerp(levelAttributesA.comboLength, levelAttributesB.comboLength, valueBetweenLevels); comboLengthDeviation = Mathf.Lerp(levelAttributesA.comboLengthDeviation, levelAttributesB.comboLengthDeviation, valueBetweenLevels); }
public LevelAttributes(LevelAttributes copiedLevelAttributes) { name = copiedLevelAttributes.name; level = copiedLevelAttributes.level; tileValueCap = copiedLevelAttributes.tileValueCap; tileCountDesired = copiedLevelAttributes.tileCountDesired; tileSpawnCountDeviation = copiedLevelAttributes.tileSpawnCountDeviation; tileWeight_Addition = copiedLevelAttributes.tileWeight_Addition; tileWeight_Subtraction = copiedLevelAttributes.tileWeight_Subtraction; tileWeight_Multiplication = copiedLevelAttributes.tileWeight_Multiplication; tileWeight_Division = copiedLevelAttributes.tileWeight_Division; comboLength = copiedLevelAttributes.comboLength; comboLengthDeviation = copiedLevelAttributes.comboLengthDeviation; }
public void CheckBounds() { bool hit = false; GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); collisionNormal.Value = Vector3.zero; LevelAttributes level = LevelAttributes.Instance; float xMax = level.transform.position.x + (level.Width / 2.0f); float xMin = level.transform.position.x - (level.Width / 2.0f); float zMax = level.transform.position.z + (level.Height / 2.0f); float zMin = level.transform.position.z - (level.Height / 2.0f); if (go.transform.position.x > xMax) { collisionNormal.Value += Vector3.left; hit = true; } if (go.transform.position.x < xMin) { collisionNormal.Value += Vector3.right; hit = true; } if (go.transform.position.z > zMax) { collisionNormal.Value += Vector3.back; hit = true; } if (go.transform.position.z < zMin) { collisionNormal.Value += Vector3.forward; hit = true; } if (hit) { Fsm.Event(hitEvent); } }
void OnDisable() { instance = null; }
void Awake() { // Set up our convenience references. levelAttributes = LevelAttributes.GetInstance(); levelBounds = levelAttributes.bounds; }
/// Creates new level private void CreateLevel() { Tiles = new Dictionary <Point, TileScript>(); Vector3 maxTile = Vector3.zero; Vector3 worldStart = Camera.main.ScreenToWorldPoint(new Vector3(0, Screen.height)); level = JsonUtility.FromJson <LevelAttributes>(jsonFile.text); GameManager.Instance.RemainingWaves = level.waves; if (level.levelIdx == 2) { GameManager.Instance.Currency = 40; } else { GameManager.Instance.Currency = 10; } xLength = level.tiles.Length / level.rows; yLength = level.rows; int idx = 0; for (int y = 0; y < level.rows; y++) { for (int x = 0; x < xLength; x++) { PlaceTile(level.tiles[idx], x, y, worldStart); idx += 1; } } if (level.levelType == 1 || level.levelType == 3) { GeneratePath(); } else { Debug.Log("Freestyle path --> erst bei wavespawn berechnen"); } maxTile = Tiles[new Point(xLength - 1, level.rows - 1)].transform.position; cameraMovement.SetLimits(new Vector3(maxTile.x + TileSize, maxTile.y - TileSize)); /* * for (int y = 0; y < mapY; y++) * { * * char[] newTiles = mapData[y].ToCharArray(); * * for (int x = 0; x < mapX; x++) * { * PlaceTile(newTiles[x].ToString(), x, y, worldStart); * } * } * maxTile = Tiles[new Point(mapX - 1, mapY - 1)].transform.position; * * cameraMovement.SetLimits(new Vector3(maxTile.x + TileSize, maxTile.y - TileSize)); */ }
void Start() { target = Managers.Mission.thePlayer.transform; level = Managers.Mission.level.GetComponent<LevelAttributes>(); }
void Awake() { // Set up our convenience references. levelAttributes = LevelAttributes.GetInstance (); levelBounds = levelAttributes.bounds; }
void Awake() { level = gameObject.GetComponent<LevelAttributes>(); }