// Use this for initialization void Start() { Vector3 pos = new Vector3(10, 0, 10); UnitAction action = new TerrainAction(gameObject, pos); GetComponent <ActionQueue>().Add(action); pos = new Vector3(-10, 0, 10); action = new TerrainAction(gameObject, pos); GetComponent <ActionQueue>().Add(action); pos = new Vector3(0, 0, 0); action = new TerrainAction(gameObject, pos); GetComponent <ActionQueue>().Add(action); }
void SpawnWave() { foreach (GameObject hero in heroes) { GameObject spawned = Instantiate(hero, transform.position, transform.rotation); currentHeroes.Add(spawned); } int pathPoints = 10; Transform target = GameManager.Instance.Headset; Vector3 pos = target == null ? new Vector3(500, 0, 500) : target.position; for (int i = 1; i <= pathPoints; i++) { Vector3 path = pos - transform.position; path *= (float)i / pathPoints; float angleRange = 90; Quaternion quat = Quaternion.Euler(0, (i == pathPoints) ? 0 : (angleRange / 2 - Random.value * angleRange), 0); path = quat * path; //var go = GameObject.CreatePrimitive(PrimitiveType.Cube); //go.transform.position = transform.position + path; foreach (GameObject hero in currentHeroes) { UnitAction action = new TerrainAction(hero, transform.position + path); hero.GetComponent <ActionQueue>().Add(action); } } }
private void ModifyLandHandler(Packet packet, LLAgent agent) { ModifyLandPacket modify = (ModifyLandPacket)packet; TerrainAction action = (TerrainAction)modify.ModifyBlock.Action; float height = modify.ModifyBlock.Height; float seconds = modify.ModifyBlock.Seconds; // TODO: Build a permission mask based on this agent's permission to edit the affected parcels bool[] allowMask = new bool[64 * 64]; for (int y = 0; y < 64; y++) { for (int x = 0; x < 64; x++) { allowMask[y * 64 + x] = true; } } // Build an edit mask that tracks all of the terrain blocks modified by this request bool[] editMask = new bool[16 * 16]; for (int i = 0; i < modify.ParcelData.Length; i++) { ModifyLandPacket.ParcelDataBlock block = modify.ParcelData[i]; int localID = block.LocalID; float north = block.North; float east = block.East; float south = block.South; float west = block.West; float size = (modify.ModifyBlockExtended.Length > i) ? modify.ModifyBlockExtended[i].BrushSize : modify.ModifyBlock.BrushSize; if (north == south && east == west) { // Terrain painting switch (action) { case TerrainAction.Raise: RaiseLowerSphere(allowMask, ref editMask, west, south, height, size, seconds); break; case TerrainAction.Flatten: FlattenSphere(allowMask, ref editMask, west, south, height, size, seconds); break; case TerrainAction.Lower: RaiseLowerSphere(allowMask, ref editMask, west, south, height, size, seconds * -1.0f); break; case TerrainAction.Noise: NoiseSphere(allowMask, ref editMask, west, south, height, size, seconds); break; case TerrainAction.Revert: RevertSphere(allowMask, ref editMask, west, south, height, size, seconds); break; case TerrainAction.Smooth: SmoothSphere(allowMask, ref editMask, west, south, height, size, seconds); break; default: m_log.Warn("Unhandled ModifyLand paint action " + action); break; } } else { // Terrain flooding switch (action) { case TerrainAction.Raise: case TerrainAction.Flatten: case TerrainAction.Lower: case TerrainAction.Noise: case TerrainAction.Revert: case TerrainAction.Smooth: default: m_log.Warn("Unhandled ModifyLand flood action " + action); break; } } } // Send updates out for any modified terrain blocks for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { if (editMask[y * 16 + x]) { m_scene.CreateInterestListEvent(new InterestListEvent( CreateTerrainEventID(x, y), TERRAIN, new Vector3(x * 16 + 8, y * 16 + 8, 0.0f), TERRAIN_SCALE, new int[] { x, y }) ); } } } }