private void Start() { //İlgili değişkenler start anında atanır. destroyManagerClass = this; destroyed = false; groupCount = -1; }
//Returns if blocks had same health public bool HandleEnemyHits(List <RaycastHit2D> hits, bool canDamage = false) { bool countChanged = false; bool wrongHit = false; foreach (RaycastHit2D hit in hits) { DestroyManager enemyDes = hit.transform.gameObject.GetComponent <DestroyManager>(); Health enemyHealth = hit.transform.gameObject.GetComponent <Health>(); if (enemyHealth && enemyHealth != health && !countChanged) { if (enemyHealth.health == health.health) { enemyHealth.Kill(); bullets++; countChanged = true; health.SetHealth((health.health + 1) % 5); } else { wrongHit = true; } } } bullets = Mathf.Clamp(bullets, 0, bulletHealthSprites.Length); return(countChanged); }
private void Awake() { if (!ins) { ins = this; } bm = GetComponent <BoardManager>(); }
Transform bnds; // Transform of kinematic bounds of gameobject // Use this for initialization void Start () { //rigidbody of gameobject rb = GetComponent<Rigidbody2D>(); dm = GetComponent<DestroyManager>(); //Get kinematic bounds gameobject bnds = transform.FindChild ("Bounds"); //Ignore collision between block crusher and its bounds collider so they don't push eachother Physics2D.IgnoreCollision(GetComponent<Collider2D>(), bnds.GetComponent<Collider2D>(), true); }
private void Awake() { if (INSTANCE == null) //Make sure that only one instance shall exist { INSTANCE = this; } else { Destroy(this); } }
void Awake() { if (mInstance == null) { mInstance = this; DontDestroyOnLoad(mInstance); } else { Destroy(this); } }
void Start() { Me = this; TerrianManager = transform.FindChild("TerrainManager").GetComponent<TerrianManager>(); SpawnManager = transform.FindChild("SpawnManager").GetComponent<SpawnManager>(); TurnManager = transform.FindChild("TurnManager").GetComponent<TurnManager>(); DamageManager = transform.FindChild("DamageAndScoreManager").GetComponent<DamageManager>(); ScoreManager = transform.FindChild("DamageAndScoreManager").GetComponent<ScoreManager>(); DestroyManager = transform.FindChild("DestroyManager").GetComponent<DestroyManager>(); WeaponManager = transform.FindChild("WeaponsManager").GetComponent<WeaponsCombo>(); ModesManager = transform.FindChild("ModesManager").GetComponent<ModesCombo>(); MapsManager = transform.FindChild("MapManager").GetComponent<MapManager>(); PlayerInfos = SpawnManager.GetComponent<PlayerInfo>(); MapsManager.StartMap((MapManager.Maps) RoundManager.RandomMap); SpawnManager.Spawn(TanksStaringCount); TurnManager.Begin(); Wind.StartWind(); WeaponsClass.InitiallizeWeaponsQuantities(); ModesClass.InitiallizeModesQuantities(); #if (!Debug) for (int i = 0; i < WeaponsClass.WeaponsQuantities.Count; i++) WeaponsClass.WeaponsQuantities[WeaponsClass.WeaponsQuantities.ElementAt(i).Key] = 99; for (int i = 0; i < ModesClass.ModesQuantities.Count; i++) ModesClass.ModesQuantities[ModesClass.ModesQuantities.ElementAt(i).Key] = 99; #endif PlayerInfos.DrawPlayerInfoInUI_SinglePlayer(); //begin clouds GameObject.Find("Cloud").GetComponent<Cload_Movement>().Begin(); GameObject.Find("Cloud (1)").GetComponent<Cload_Movement>().Begin(); GameObject.Find("Cloud (2)").GetComponent<Cload_Movement>().Begin(); // GameObject.Find("UIButtons").GetComponent<UIButtonClick>().InitilizeButtons(); //show round loadout GameObject fade = GameObject.Find("Fade"); fade.GetComponent<Fade>().ShowLoadout(); HideHUDS(); }
private static void DestroyLoadingScene() { Debug.Log("loading scene ruining"); DestroyManager.ClearGameObject(); }
public override void Update(GameTime gameTime) { // GameWindow.myText = new PointF(GameInput.GetMouseLocation().X - GameWindow.View.Location.X, GameInput.GetMouseLocation().Y - GameWindow.View.Location.Y).ToString(); GameWindow.GameMessages[1] = ("objCount:" + gameObjects.Count.ToString()); DestroyManager.DestroyFromList(ref gameObjects); DestroyManager.DestroyOutOfBounds(ref gameObjects, new Utilities.BoundF(0, 0, Screen.PrimaryScreen.Bounds.Size.Width, Screen.PrimaryScreen.Bounds.Size.Height)); BoundF bound = new BoundF( 0, // GameWindow.View.Size.Width , 0, // GameWindow.View.Size.Height / 4, GameWindow.DisplaySize.Width, // - GameWindow.View.Size.Width / 4, GameWindow.DisplaySize.Height // - GameWindow.View.Size.Height / 4 ); if (gameObjects.ContainsKey(mainPlayerID)) { var fighter = mainPlayerID.GetByKey <string, IGameBehavior>(gameObjects) as StarFighter; if (GameInput.isKeyDown(Keys.Down)) { // if (GetAsyncKeyState(Keys.Down)) fighter.Deaccelerate(); } if (GameInput.isKeyDown(Keys.Up)) { // if (GetAsyncKeyState(Keys.Up)) fighter.Accelerate(); } if (GameInput.isKeyDown(Keys.Right)) { // if (GetAsyncKeyState(Keys.Right)) fighter.TurnRight(); } if (GameInput.isKeyDown(Keys.Left)) { // if (GetAsyncKeyState(Keys.Left)) fighter.TurnLeft(); } if (gameActive) { if (GameInput.isKeyDown(Keys.Space)) { // if (GetAsyncKeyState(Keys.Space)) fighter.Shoot(); } } fighter.Location = ((IGame2DProperties)fighter) .KeepInBounds(bound ).Location; } if (gameObjects.ContainsKey(secondPlayer)) { var fighter2 = secondPlayer.GetByKey <string, IGameBehavior>(gameObjects) as StarFighter; if (GameInput.isKeyDown(Keys.W)) { fighter2.Accelerate(); } if (GameInput.isKeyDown(Keys.S)) { fighter2.Deaccelerate(); } if (GameInput.isKeyDown(Keys.D)) { fighter2.TurnRight(); } if (GameInput.isKeyDown(Keys.A)) { fighter2.TurnLeft(); } if (gameActive) { if (GameInput.isKeyDown(Keys.Q)) { fighter2.Shoot(); } } fighter2.Location = ((IGame2DProperties)fighter2).KeepInBounds(bound).Location; } foreach (var player in gameObjects.Values.OfType <StarFighter>()) { foreach (var bullet in gameObjects.Values.OfType <Projectile>()) { var delx = player.Size.Width; var dely = player.Size.Height; if (bullet.InBounds(new BoundF(player.Location.X - delx, player.Location.Y - dely, player.Location.X + delx, player.Location.Y + dely))) { if (!bullet.ID.Contains(player.ID)) { var id = bullet.ID.Split(',').Last(); bullet.ToBeDestroyed = true; if (player.IsDead.IsNotTrue()) { player.IsDead = true; scores[id]++; } } } } } angle += 1; if (angle > 360) { angle = 0; } var dx = 500 + 200 * Math.Cos(angle * Math.PI / 180f); GameWindow.View.Size = new SizeF((float)dx, (float)dx); var keys = gameObjects.Keys.ToArray <string>(); for (int i = 0; i < keys.Count <string>(); i++) { var ass = gameObjects[keys[i]]; if (ass.GetType() == typeof(Asteroid)) { ((IGame2DProperties)ass).Location = ((IGame2DProperties)ass).KeepInBounds(bound).Location; } } foreach (var obj in gameObjects) { obj.Value.Update(gameTime); } if (((StarFighter)gameObjects[mainPlayerID]).IsDead || ((StarFighter)gameObjects[secondPlayer]).IsDead) { gameActive = false; gameWaitTiming.WaitThenDoOnce(() => { foreach (var fighter in gameObjects.Values.OfType <StarFighter>()) { var v = new Vector2F(MathAssist.RandInt(0, (GameWindow.DisplaySize.Width - 50)), MathAssist.RandInt(0, GameWindow.DisplaySize.Height)); fighter.Location = v; fighter.IsDead = false; fighter.StopMoving(); } gameActive = true; gameWaitTiming.Reset(); }); } if (GameInput.isKeyDown(Keys.Escape)) { RunAgain = false; GameWindow.AudioPlayer.Item1.StopTrack("background"); GameWindow.CurrentScene = NextScene; GameWindow.View.Init(); gameObjects.Clear(); } }
// Use this for initialization void Start () { // Shuffle list for creation point for (int i = cpIndex.Count-1; i >= 1; i--) { randomIndex = Random.Range(0,i); temp = cpIndex[i]; cpIndex[i] = cpIndex[randomIndex]; cpIndex[randomIndex] = temp; } // Get amount of platforms platAmount = Random.Range((int)platAmountRange.x, (int)platAmountRange.y); // Create platforms for (int i = 0; i < platAmount; i++) { // Shuffle list for platforms for (int j = valPlats.Count-1; j >= 1; j--) { randomIndex = Random.Range(0,j); temp = valPlats[j]; valPlats[j] = valPlats[randomIndex]; valPlats[randomIndex] = temp; } // Get number that is index for platform prefabs temp = valPlats[0]; // Get all possible speeds for platform about to be created for (int j = 0; j < speed.Count; j++) { if (speed[j].x == temp) { speedList.Add(speed[j]); } } // Get creation point for platform creationPoint = cPoints[cpIndex[i]]; // Create platform Rigidbody2D plat; /* if (temp == 0) { plat = (Instantiate(bubble, creationPoint, Quaternion.identity)) as Rigidbody2D; } else if (temp == 1) { plat = (Instantiate(platform, creationPoint, Quaternion.identity)) as Rigidbody2D; } else { plat = (Instantiate(passPlat, creationPoint, Quaternion.identity)) as Rigidbody2D; } */ plat = (Instantiate(plats[temp], creationPoint, Quaternion.identity)) as Rigidbody2D; // Set Platforms speed plat.velocity = new Vector2(speedList[0].y, speedList[0].z); // Set platform destroy settings dm = plat.GetComponent<DestroyManager>(); if (dm != null) { dm.objsThatDestroy = objsToDestroy; dm.destroyTimer = destroyTimer; dm.destroyGO = destroyGO; dm.playerExit = playerExit; dm.playerEnter = playerEnter; dm.playerJumpOff = playerJumpOff; dm.timerDestroy = timerDestroy; dm.objDestroy = objDestroy; } } // Clear speed list speedList.Clear(); // Start timer to create next batch of platforms platTimer.x = Time.time; }