public void createWavesystem(triggerWaypoint startWaypoint) { _wavesystem = new GameObject("wavesystem"); wavesystem wavesystem = _wavesystem.AddComponent <wavesystem>(); Object[] objects = Resources.LoadAll("PrefabObjects/Elemental Invader"); GameObject healthbar = Resources.Load <GameObject>("PrefabObjects/UI Elements/healthbar"); GameObject[] invadertypes = new GameObject[4]; invadertypes[0] = (GameObject)objects[0]; invadertypes[1] = (GameObject)objects[1]; invadertypes[2] = (GameObject)objects[2]; invadertypes[3] = (GameObject)objects[3]; poolmanager.instance.createPool("airInvader", 6, true, invadertypes[0]); poolmanager.instance.createPool("earthInvader", 6, true, invadertypes[1]); poolmanager.instance.createPool("fireInvader", 6, true, invadertypes[2]); poolmanager.instance.createPool("waterInvader", 6, true, invadertypes[3]); poolmanager.instance.createPool("healthbar", 10, true, healthbar, GameObject.Find("worldinterface")); wavesystem.initiate(0, 10, 1f, 10.0f, startWaypoint, invadertypes); }
public void initiate(int level, int invaderCount, float timeBetweenInvaders, float timeBetweenWaves, elemantaryAffection elementaryAffection, triggerWaypoint startWaypoint, GameObject[] invadertypes) { this.level = level; this.elementaryAffection = elementaryAffection; _invaderCount = invaderCount; _spawnCount = invaderCount; _timeBetweenWaves = timeBetweenWaves; _timeBetweenInvaders = timeBetweenInvaders; _invaderTimeHelper.maxTime = _timeBetweenInvaders; _waveTimeHelper.maxTime = 0.0f; _startWaypoint = startWaypoint; _invadertypes = invadertypes; }
/*(random generation)waypoint functions*/ private triggerWaypoint createWaypoint(int positionX, int positionY, mapGfx mapGfx, triggerWaypoint connectWith, int identification) { GameObject newWaypoint = new GameObject("waypoint " + identification); triggerWaypoint triggerWaypoint = newWaypoint.AddComponent <triggerWaypoint>(); newWaypoint.transform.position = new Vector3(positionX, positionY); mapGfx.addGameObject(newWaypoint, "waypoint"); if (connectWith != null) { triggerWaypoint.nextWaypoint = connectWith; } return(triggerWaypoint); }
public void Update() { if (currentWaypoint != null) { Vector3 dir = currentWaypoint.transform.position - transform.position; dir.Normalize(); transform.position = Vector3.MoveTowards(transform.position, currentWaypoint.transform.position, speed * Time.deltaTime); if (currentWaypoint.transform.position == transform.position) { currentWaypoint = nextWaypoint; } } else { currentWaypoint = nextWaypoint; } }
public void update(float deltaTime, Transform transform) { if (_currentWaypoint != null) { Vector3 dir = _currentWaypoint.transform.position - transform.position; dir.Normalize(); transform.position = Vector3.MoveTowards(transform.position, _currentWaypoint.transform.position, movementSpeed * deltaTime); if (_currentWaypoint.transform.position == transform.position) { _currentWaypoint = _nextWaypoint; } } else { _currentWaypoint = _nextWaypoint; } }
public void initiate(int level, int invaderCount, float timeBetweenInvaders, float timeBetweenWaves, triggerWaypoint startWaypoint, GameObject[] invadertypes) { _level = level; _invaderCount = invaderCount; _spawnCount = invaderCount; _timeBetweenWaves = timeBetweenWaves; _timeBetweenInvaders = timeBetweenInvaders; _invaderTimeHelper.maxTime = _timeBetweenInvaders; _waveTimeHelper.maxTime = timeBetweenWaves; _waveTimeHelper.reset(); _startWaypoint = startWaypoint; _invadertypes = invadertypes; searchforui(); _invadercountslider.gameObject.SetActive(false); }
public void createWavesystem(triggerWaypoint startWaypoint) { _wavesystem = new GameObject("wavesystem"); wavesystem wavesystem = _wavesystem.AddComponent <wavesystem>(); Object[] objects = Resources.LoadAll("Invader"); GameObject[] invadertypes = new GameObject[4]; invadertypes[0] = (GameObject)objects[0]; invadertypes[1] = (GameObject)objects[1]; invadertypes[2] = (GameObject)objects[2]; invadertypes[3] = (GameObject)objects[3]; wavesystem.initiate(0, 10, 1f, 0.0f, startWaypoint, invadertypes); poolmanager.instance.createPool("airInvader", 6, true, invadertypes[0]); poolmanager.instance.createPool("earthInvader", 6, true, invadertypes[1]); poolmanager.instance.createPool("fireInvader", 6, true, invadertypes[2]); poolmanager.instance.createPool("waterInvader", 6, true, invadertypes[3]); }
public void initiate(int mapSize, int pathLengthReduktion) { _maxPathLength = ((mapSize / 2) * (mapSize - 2)) + (mapSize / 2 - 1); _minPathLength = _maxPathLength / 2; _targetPathLength = _maxPathLength - pathLengthReduktion; _pathLengthReduktion = pathLengthReduktion; //_actualPathLength = 0; _spawnX = 0; _spawnY = 0; _baseX = Random.Range(1, mapSize - 1); _baseY = Random.Range(1, mapSize - 1); if (_pathList == null) { _pathList = new List <path>(); } _pathList.Clear(); _startWaypoint = null; }
private void setupBuiltPath(mapData mapData, mapGfx mapGfx) { triggerWaypoint lastWaypoint = null; int waypointCount = 0; mapData.setTileOnLayer(_spawnX, _spawnY, "path", mapGfx.getPrefixedObjectRange("spawn").getRandom()); mapData.setTileOnLayer(_baseX, _baseY, "path", mapGfx.getPrefixedObjectRange("basis").getRandom()); lastWaypoint = createWaypoint(_baseX, _baseY, mapGfx, lastWaypoint, waypointCount++); mapData.setTileOnLayer(_baseX, _baseY, "tower", 1); for (int pathtileIndex = _pathList.Count - 1; pathtileIndex >= 1; pathtileIndex--) { int positionX = _pathList[pathtileIndex].positionX; int positionY = _pathList[pathtileIndex].positionY; int currentDirection = _pathList[pathtileIndex].direction; int nextDirection = _pathList[pathtileIndex - 1].direction; if (gamemanager.instance.debug) { Debug.Log("(mapGenerator:setupBuiltPath) Pathtile on " + positionX + "|" + positionY + "."); } if (currentDirection != nextDirection) { if ((currentDirection == 0 && nextDirection == 2) || (currentDirection == 3 && nextDirection == 1)) { mapData.setTileOnLayer(positionX, positionY, "path", mapGfx.getPrefixedObjectRange("upperLeftPath").getRandom()); } else if ((currentDirection == 1 && nextDirection == 2) || (currentDirection == 3 && nextDirection == 0)) { mapData.setTileOnLayer(positionX, positionY, "path", mapGfx.getPrefixedObjectRange("bottomLeftPath").getRandom()); } else if ((currentDirection == 0 && nextDirection == 3) || (currentDirection == 2 && nextDirection == 1)) { mapData.setTileOnLayer(positionX, positionY, "path", mapGfx.getPrefixedObjectRange("upperRightPath").getRandom()); } else if ((currentDirection == 1 && nextDirection == 3) || (currentDirection == 2 && nextDirection == 0)) { mapData.setTileOnLayer(positionX, positionY, "path", mapGfx.getPrefixedObjectRange("bottomRightPath").getRandom()); } lastWaypoint = createWaypoint(positionX, positionY, mapGfx, lastWaypoint, waypointCount++); } else { if (currentDirection == 0 || currentDirection == 1) { mapData.setTileOnLayer(positionX, positionY, "path", mapGfx.getPrefixedObjectRange("verticalPath").getRandom()); } else if (currentDirection == 2 || currentDirection == 3) { mapData.setTileOnLayer(positionX, positionY, "path", mapGfx.getPrefixedObjectRange("horizontalPath").getRandom()); } } mapData.setTileOnLayer(positionX, positionY, "tower", 1); } lastWaypoint = createWaypoint(_spawnX, _spawnY, mapGfx, lastWaypoint, waypointCount++); _startWaypoint = lastWaypoint; mapData.setTileOnLayer(_spawnX, _spawnY, "tower", 1); }