public EnemyTank InjectEnemy(EnemyType type) { EnemyTank nEnemy = null; switch (type) { case EnemyType.TankGreen: nEnemy = _tankGreenFactory.Create(); break; case EnemyType.TankEllo: nEnemy = _tankElloFactory.Create(); break; case EnemyType.TankBlue: nEnemy = _tankBlueFactory.Create(); break; case EnemyType.TankPurple: nEnemy = _tankPurpleFactory.Create(); break; case EnemyType.TankRed: nEnemy = _tankRedFactory.Create(); break; default: GDebug.LogError("Current Enemy type not found :" + type, this, LogCategory.ENEMY_FABRIC); break; } return(nEnemy); }
private bool CheckSelection() { selectedPoints.Clear(); foreach (GameObject item in Selection.objects) { selectedPoints.Add(item.GetComponent <GraphPoint>()); } if (selectedPoints.Count != 2) { GDebug.LogError("Выбери две вершины!"); } return(selectedPoints.Count == 2); }
public virtual void PlayMusic(string musicClipName, float volume) { MusicVolume = volume; if (!MuteAllSound) { AudioClip musicClip = MusicPlaylist.FindByName(musicClipName); if (musicClip == null) { GDebug.LogError("NO SOUNDTRACK " + musicClipName, this, LogCategory.SOUND_MANAGER); GDebug.Log("Tried to play music : " + musicClipName + " but soundManager could not find it!", this, LogCategory.SOUND_MANAGER); return; } //we have music playing already GDebug.Log("playing: " + musicClip.name, this, LogCategory.SOUND_MANAGER); DoMusicPlay(musicClip, volume); } }
private void OnCreatePoint(GraphPoint point) { if (graphPoints.Contains(point)) { return; } graphPoints.Add(point); GDebug.Log("Точка " + point.Id + " создана"); if (GraphPoint.Count == MAX_POINTS_COUNT - 1) { GDebug.LogWarning("количество точек на сцене достигло максимума!"); } else { if (GraphPoint.Count == MAX_POINTS_COUNT) { GDebug.LogError("количество точек на сцене достигло максимума! Лишняя точка удалена."); DestroyImmediate(point.gameObject); } } }
public Weapon InjectGun(WeaponType type) { if (type == WeaponType.None) { return(null); } _currentWeapon = null; Weapon nWeapon = null; switch (type) { case WeaponType.Berta: nWeapon = _bertaFactory.Create(); break; case WeaponType.Sparka: nWeapon = _sparkaFactory.Create(); break; case WeaponType.Isus: nWeapon = _IsusFactory.Create(); break; default: GDebug.LogError("Current Weapon type not found :" + type, this, LogCategory.WEAPON_FABRIC); break; } if (null != nWeapon) { _currentWeapon = nWeapon; _currentWeapon.NameWeapon = type.ToString(); } return(nWeapon); }
public void FindPath() { if (CheckSelection()) { GraphPoint pointA = selectedPoints[0]; GraphPoint pointB = selectedPoints[1]; passed.Clear(); for (int i = 0; i <= MAX_POINTS_COUNT; i++) { d[i] = INF; } //Начало пути int curPoint = pointA.Id; //Конец пути int endPoint = pointB.Id; for (int i = 0; i <= MAX_POINTS_COUNT; i++) { //Если между вершинами есть ребро, заносим его длину в массив if (sizeMatrix[curPoint, i] != 0 && sizeMatrix[curPoint, i] != INF) { d[i] = sizeMatrix[curPoint, i]; } else { if (curPoint == i) { d[i] = 0; } else { d[i] = INF; } } foundedPoints[i] = 0; } float min = INF; int minC = curPoint; passed.Add(curPoint); for (int i = 0; i < foundedPoints.Length; i++) { foundedPoints[i] = curPoint; } while (passed.Count < MAX_POINTS_COUNT) { min = INF; for (int i = 1; i <= MAX_POINTS_COUNT; i++) { if (!passed.Contains(i)) { if (d[i] < min) { min = d[i]; minC = i; } } } if (passed.Count == 1) { foundedPoints[minC] = curPoint; } curPoint = minC; passed.Add(curPoint); for (int i = 1; i <= MAX_POINTS_COUNT; i++) { if (!passed.Contains(i) && sizeMatrix[i, curPoint] != 0f) { float length = d[curPoint] + sizeMatrix[i, curPoint]; if (d[i] > length) { d[i] = length; foundedPoints[i] = curPoint; } } } } curPoint = pointA.Id; int wayPoint = pointB.Id; if (d[wayPoint] == INF) { GDebug.LogError("Невозможно построить путь."); return; } int h = 0; lineRenderer = GetComponent <LineRenderer>(); lineRenderer.positionCount = 0; lineRenderer.startColor = GraphEditor.PathColor; lineRenderer.endColor = GraphEditor.PathColor; bool isEnd = false; while (!isEnd && h < MAX_POINTS_COUNT) { foreach (var graphPoint in graphPoints) { if (graphPoint.Id == wayPoint) { path[wayPoint] = graphPoint.Position; } } lineRenderer.positionCount++; lineRenderer.SetPosition(lineRenderer.positionCount - 1, path[wayPoint]); if (wayPoint == curPoint) { isEnd = true; } wayPoint = foundedPoints[wayPoint]; h++; } } }