public void Destroy(bool createTowerPlace = true) { if (createTowerPlace) { GameObject towerPlace = GamePullController.CreateImage(); towerPlace.GetComponent <BoxCollider> ().enabled = true; switch (color) { case TeamColor.Red: GameController.towerPlacesRed.Add(towerPlace); break; case TeamColor.Blue: GameController.towerPlacesBlue.Add(towerPlace); break; } towerPlace.transform.position = towerPlacePosition; towerPlace.GetComponent <Renderer>().material.mainTexture = Resources.Load("Textures/Towers/TowerPlace" + color) as Texture; towerPlace.transform.localScale = new Vector3(3.08f * Settings.FhdToHD, 4.13f * Settings.FhdToHD, 1); towerPlace.name = "TowerPlace" + color; } GameController.towers.Remove(this); GameController.towersDictionary.Remove(gameObject); GamePullController.DestroyImage(gameObject); }
public GUIImage(bool make = true) { if (make) { gameObject = GamePullController.CreateImage(); GUIController.Add(this); isClickable = false; } }
public HealthBar() { healthBarRed = GamePullController.CreateImage(); healthBarGreen = GamePullController.CreateImage(); healthBarRed.GetComponent <Renderer> ().material.mainTexture = ResourcesController.Load("Textures/HealthBars/HealthBarRed") as Texture; healthBarGreen.GetComponent <Renderer> ().material.mainTexture = ResourcesController.Load("Textures/HealthBars/HealthBarGreen") as Texture; healthBarRed.transform.localScale = new Vector3(size.x, size.y, 1); healthBarGreen.transform.localScale = new Vector3(size.x, size.y, 1); health = 1; }
public Bomb(Vector2 position) { gameObject = GamePullController.CreateImage(); texture = Resources.Load("Textures/UserInterface/Bomb") as Texture; animation = new ObjectAnimation(gameObject); animation.Load("Bomb"); animation.Play(-2); size = new Vector2(1, 1); mapPosition = position; layer = 0.5f; BombsController.bombs.Add(this); }
public Missile(string _towerType, Texture _texture, Vector2 _position, Vector2 _size, float _damage, float _speed, Killable _target) { towerType = _towerType; gameObject = GamePullController.CreateImage(); GameController.missiles.Add(this); mapPosition = _position; damage = _damage; target = _target; texture = _texture; size = _size; speed = _speed; layer = _target.layer; }
public Tower(string _type, Colorable.TeamColor _color) { reloadTime = 0.6f; type = _type; color = _color; gameObject = GamePullController.CreateImage(); animation = new ObjectAnimation(gameObject); gameObject.name += "Tower"; gameObject.GetComponent <BoxCollider> ().enabled = true; texture = Resources.Load("Textures/Towers/" + type + "Tower") as Texture; attackAnimaton = type + "TowerAttack"; attackAnimatonTime = 0.2f; try { damage = BalanceSettings.damage [type]; damageDelta = BalanceSettings.deltaDamage [type]; attackRange = BalanceSettings.attackRange [type]; attackSpeed = BalanceSettings.attackSpeed [type]; } catch (Exception) { Debug.LogError("Wrong tower type: " + type); } layer = 6; size = new Vector2(texture.width / 50f, texture.height / 50f) / 2f * Settings.FhdToHD; GameController.towers.Add(this); GameController.towersDictionary.Add(gameObject, this); buffs = new Dictionary <Buff, float> (GameController.buffs[color]); foreach (var buff in TowersSettings.Buffs(type)) { buffs.Add((Buff)Enum.Parse(typeof(Buff), buff), 1); } }
private static void ParseMap(string map) { var maps = map.Split('|'); int i = 0; GameController.RoadRed = new List <List <Vector3> >(); GameController.RoadBlue = new List <List <Vector3> >(); for (int q = 0; q < 6; q++) { GameController.RoadRed.Add(new List <Vector3>()); int lng = int.Parse(maps[i]); i++; for (int p = 0; p < lng; p++) { GameController.RoadRed[q].Add(ParseRoad(maps[i])); i++; } } for (int q = 0; q < 6; q++) { GameController.RoadBlue.Add(new List <Vector3>()); int lng = int.Parse(maps[i]); i++; for (int p = 0; p < lng; p++) { GameController.RoadBlue[q].Add(ParseRoad(maps[i])); i++; } } Logger.LogList(GameController.RoadBlue); Logger.LogList(GameController.RoadRed); for (; i < maps.Length - 1; i += 7) { switch (maps[i]) { case "Layer": GameObject mapPlane = GamePullController.CreateImage(); float x, y, w, h; w = float.Parse(maps[i + 5]); h = float.Parse(maps[i + 6]); x = float.Parse(maps[i + 3]); y = float.Parse(maps[i + 4]); mapPlane.transform.position = new Vector3(x, int.Parse(maps[i + 1]), y); mapPlane.transform.localScale = new Vector3(w, h, 1); mapPlane.name = "Map"; mapPlane.GetComponent <Renderer>().material.mainTexture = Resources.Load("Levels/Level" + level + "/" + maps[i + 2].Split('.')[0]) as Texture; if (maps[i + 2].Split('.')[0] == "Map") { GameController.mapWidth = w; GameController.mapHeight = h; } break; case "Tower": GameObject towerPlace = GamePullController.CreateImage(); towerPlace.gameObject.GetComponent <BoxCollider> ().enabled = true; switch (maps[i + 2]) { case "Red": GameController.towerPlacesRed.Add(towerPlace); break; case "Blue": GameController.towerPlacesBlue.Add(towerPlace); break; } towerPlace.transform.position = new Vector3(float.Parse(maps[i + 3]), float.Parse(maps[i + 1]), float.Parse(maps[i + 4])); towerPlace.GetComponent <Renderer>().material.mainTexture = Resources.Load("Textures/Towers/TowerPlace" + maps[i + 2]) as Texture; towerPlace.transform.localScale = new Vector3(3.08f * Settings.FhdToHD, 4.13f * Settings.FhdToHD, 1); towerPlace.name = "TowerPlace" + maps[i + 2]; break; default: /* * PointObject pointObject = new PointObject (PointObject.PointObjectType.Road, 0.6f, 0.6f, * new Vector2 (float.Parse (maps[i+3]), float.Parse (maps[i+4])), maps[i] + maps[i+2]); */ break; } } }
protected Unit(TeamColor _color, int _road) { gameObject = GamePullController.CreateImage(); gameObject.name = "Unit"; shadow = GamePullController.CreateImage(); shadow.GetComponent <Renderer> ().material.mainTexture = ResourcesController.Load("Textures/Shadow") as Texture; healthBar = new HealthBar(); GameController.unitsDictionary.Add(gameObject, this); objectAnimation = new ObjectAnimation(gameObject); color = _color; roadIndex = 0; var count = (color == TeamColor.Red?GameController.RoadRed.Count:GameController.RoadBlue.Count); Vector3 _targetPosition; if (color == TeamColor.Red) { if (_road == -1) { do { roadNumber = Random.Range(0, count); } while (GameController.RoadRed[roadNumber].Count == 0); } else { roadNumber = _road; } _targetPosition = GameController.RoadRed[roadNumber][roadIndex]; } else { if (_road == -1) { do { roadNumber = Random.Range(0, count); } while (GameController.RoadBlue[roadNumber].Count == 0); } else { roadNumber = _road; } _targetPosition = new Vector3(); try { _targetPosition = GameController.RoadBlue[roadNumber][roadIndex]; } catch (System.Exception) { Debug.LogError(roadNumber + " " + roadIndex + "; " + GameController.RoadBlue.Count + " "); } } layer = _targetPosition.z; targetPosition = GetTruePosition(_targetPosition); mapPosition = targetPosition; isKilling = false; }