private void ActivateBoss(ushort musicFile) { if (activeBoss != null) { return; } foreach (GameObject obj in ActiveObjects) { activeBoss = obj as BossBase; if (activeBoss != null) { break; } } if (activeBoss == null) { return; } if (!activeBoss.HandleBossActivated()) { return; } // ToDo }
public virtual bool HandlePlayerDied(Player player) { if (activeBoss != null) { activeBoss.DeactivateBoss(); activeBoss = null; Hud hud = rootObject.GetComponent <Hud>(); if (hud != null) { hud.ActiveBoss = null; } if (music != null) { music.FadeOut(1.8f); } // Load default music again music = new OpenMptStream(musicPath, true); music.BeginFadeIn(0.4f); DualityApp.Sound.PlaySound(music); } // Single player can respawn immediately return(true); }
private void Awake() { _boss = this.gameObject.GetComponent <BossBase> (); _coolTime = _maxCoolTime; _target = _boss.GetComponent <BossBase> ()._target; _col = gameObject.GetComponent <Collider> (); _rid = gameObject.GetComponent <Rigidbody> (); }
public virtual bool HandlePlayerDied(Player player) { if (activeBoss != null) { if (activeBoss.HandlePlayerDied()) { activeBoss = null; // ToDo } } root.HandlePlayerDied(player.Index); return(false); }
// Use this for initialization void Start() { if (_bossPrefab == null) { print("Bossプレハブがセットされていません"); return; } GameObject obj = ObjectManager.Instance.InstantiateWithObjectPooling(_bossPrefab, gameObject.transform.position, new Quaternion()); obj.transform.Rotate(new Vector3(0, 180, 0)); BossBase boss = obj.GetComponent <BossBase> (); boss.Init(EnumHolder.Instance.GetStats(_bossPrefab.name)); }
//public override void PlayEffect() //{ // GameObject go = Instantiate<GameObject>(fireEffect, effectPoint.transform.position, gun.transform.rotation, transform); // Destroy(go, 1f); //} public override bool Shoot() { if (GetIsShoot()) { //Debug.Log("开枪"); for (int i = 0; i < data.SingelBulletCount; i++) { //Debug.DrawLine(physicGunPos.position, Quaternion.Euler(Random.Range(-data.BulletOffsetMax, data.BulletOffsetMax), Random.Range(-data.BulletOffsetMax, data.BulletOffsetMax), 0) * lookFoward.forward * 500, Color.red, 5f); if (Physics.Raycast(physicGunPos.position, Quaternion.Euler(Random.Range(-data.BulletOffsetMax, data.BulletOffsetMax), Random.Range(-data.BulletOffsetMax, data.BulletOffsetMax), Random.Range(-data.BulletOffsetMax, data.BulletOffsetMax)) * lookFoward.forward, out hitInfo, 500, 1 << 10 | 1 << 11 | 1 << 12)) { //Debug.LogError(hitInfo.transform.gameObject.tag); if (hitInfo.transform.gameObject.tag == "Ground") { GameObject go1 = Instantiate <GameObject>(impacts[Random.Range(0, impacts.Count - 1)], hitInfo.point, Quaternion.Euler(transform.rotation.eulerAngles) * Quaternion.Euler(0, 180, 0)); Destroy(go1, 4f); } else if (hitInfo.transform.gameObject.tag == "enemy") { GameObject go2 = Instantiate <GameObject>(blood[Random.Range(0, blood.Count - 1)], hitInfo.point, Quaternion.Euler(transform.rotation.eulerAngles) * Quaternion.Euler(0, 180, 0)); Destroy(go2, 4f); float dis = Vector3.Distance(physicGunPos.position, hitInfo.point); float hurt = data.GetRealAtkDamage(dis); if (hitInfo.transform.gameObject.name.Equals("Hand")) { //Debug.LogError("爆头"); hurt *= 2; } GetEnemyBase e = hitInfo.transform.GetComponent <GetEnemyBase>(); e.enemy.SetTarget(player); e.enemy.Hurt(hurt); } else if (hitInfo.transform.gameObject.tag == "Boss") { float dis = Vector3.Distance(physicGunPos.position, hitInfo.point); BossBase boss = hitInfo.transform.GetComponent <BossBase>(); float hurt = data.GetRealAtkDamage(dis); boss.Hurt(hurt); } } } return(base.Shoot()); } return(false); }
private void ActivateBoss(ushort musicFile) { if (activeBoss != null) { return; } foreach (GameObject obj in ActiveObjects) { activeBoss = obj as BossBase; if (activeBoss != null) { break; } } if (activeBoss == null) { return; } if (!activeBoss.HandleBossActivated()) { return; } Hud hud = rootObject.GetComponent <Hud>(); if (hud != null) { hud.ActiveBoss = activeBoss; } #if !DISABLE_SOUND if (music != null) { music.FadeOut(3f); } // ToDo: Hardcoded music file string musicPath = PathOp.Combine(DualityApp.DataDirectory, "Music", "boss" + (musicFile + 1).ToString(CultureInfo.InvariantCulture) + ".j2b"); music = new OpenMptStream(musicPath, true); music.BeginFadeIn(1f); DualityApp.Sound.PlaySound(music); #endif }
public bool ActivateBoss(ushort musicFile) { if (activeBoss != null) { return(false); } foreach (GameObject obj in ActiveObjects) { activeBoss = obj as BossBase; if (activeBoss != null) { break; } } if (activeBoss == null) { return(false); } activeBoss.OnBossActivated(); Hud hud = rootObject.GetComponent <Hud>(); if (hud != null) { hud.ActiveBoss = activeBoss; } if (music != null) { music.FadeOut(3f); } // ToDo: Hardcoded music file string musicPath = PathOp.Combine(DualityApp.DataDirectory, "Music", "Boss" + (musicFile + 1).ToString(CultureInfo.InvariantCulture) + ".j2b"); music = DualityApp.Sound.PlaySound(new OpenMptStream(musicPath)); music.BeginFadeIn(1f); return(true); }
public override bool Shoot() { if (GetIsShoot()) { if (Physics.Raycast(physicGunPos.position, lookFoward.forward, out hitInfo, 500, 1 << 10 | 1 << 11 | 1 << 12)) { if (hitInfo.transform.gameObject.tag == "Ground") { GameObject go1 = Instantiate <GameObject>(impacts[Random.Range(0, impacts.Count - 2)], hitInfo.point, Quaternion.Euler(transform.rotation.eulerAngles) * Quaternion.Euler(0, 180, 0)); Destroy(go1, 2f); } else if (hitInfo.transform.gameObject.tag == "enemy") { GameObject go1 = Instantiate <GameObject>(blood[Random.Range(0, blood.Count - 1)], hitInfo.point, Quaternion.identity); Destroy(go1, 2f); float dis = Vector3.Distance(physicGunPos.position, hitInfo.point); float hurt = data.GetRealAtkDamage(dis); if (hitInfo.transform.gameObject.name.Equals("Hand")) { hurt *= 2; } GetEnemyBase e = hitInfo.transform.GetComponent <GetEnemyBase>(); e.enemy.SetTarget(player); e.enemy.Hurt(hurt); } else if (hitInfo.transform.gameObject.tag == "Boss") { float dis = Vector3.Distance(physicGunPos.position, hitInfo.point); BossBase boss = hitInfo.transform.GetComponent <BossBase>(); float hurt = data.GetRealAtkDamage(dis); boss.Hurt(hurt); } } return(base.Shoot()); } return(false); }
private void GetBossData() { bossBase = GetComponentInChildren <BossBase>(); }
protected virtual void OnFixedUpdate(float timeMult) { if (currentCarryOver.HasValue) { bool playersReady = true; foreach (Player player in players) { // Exit type is already provided playersReady &= player.OnLevelChanging(ExitType.None); } if (playersReady) { if (levelChangeTimer > 0) { levelChangeTimer -= timeMult; } else { root.ChangeLevel(currentCarryOver.Value); currentCarryOver = null; initState = InitState.Disposed; return; } } } if (difficulty != GameDifficulty.Multiplayer) { if (players.Count > 0) { Vector3 pos = players[0].Transform.Pos; int tx1 = (int)pos.X >> 5; int ty1 = (int)pos.Y >> 5; int tx2 = tx1; int ty2 = ty1; #if ENABLE_SPLITSCREEN for (int i = 1; i < players.Count; i++) { Vector3 pos2 = players[i].Transform.Pos; int tx = (int)pos2.X >> 5; int ty = (int)pos2.Y >> 5; if (tx1 > tx) { tx1 = tx; } else if (tx2 < tx) { tx2 = tx; } if (ty1 > ty) { ty1 = ty; } else if (ty2 < ty) { ty2 = ty; } } #endif // ToDo: Remove this branching #if __ANDROID__ const int ActivateTileRange = 20; #else const int ActivateTileRange = 26; #endif tx1 -= ActivateTileRange; ty1 -= ActivateTileRange; tx2 += ActivateTileRange; ty2 += ActivateTileRange; for (int i = 0; i < actors.Count; i++) { if (actors[i].OnTileDeactivate(tx1 - 2, ty1 - 2, tx2 + 2, ty2 + 2)) { i--; } } eventMap.ActivateEvents(tx1, ty1, tx2, ty2, initState != InitState.Initializing); } eventMap.ProcessGenerators(timeMult); } ResolveCollisions(); // Ambient Light Transition if (ambientLightCurrent != ambientLightTarget) { float step = timeMult * 0.012f; if (MathF.Abs(ambientLightCurrent - ambientLightTarget) < step) { ambientLightCurrent = ambientLightTarget; } else { ambientLightCurrent += step * ((ambientLightTarget < ambientLightCurrent) ? -1 : 1); } } // Weather if (weatherType != WeatherType.None && commonResources.Graphics != null) { // ToDo: Apply weather effect to all other cameras too Vector3 viewPos = cameras[0].Transform.Pos; for (int i = 0; i < weatherIntensity; i++) { TileMap.DebrisCollisionAction collisionAction; if (weatherOutdoors) { collisionAction = TileMap.DebrisCollisionAction.Disappear; } else { collisionAction = (MathF.Rnd.NextFloat() > 0.7f ? TileMap.DebrisCollisionAction.None : TileMap.DebrisCollisionAction.Disappear); } Vector3 debrisPos = viewPos + MathF.Rnd.NextVector3((LevelRenderSetup.TargetSize.X / -2) - 40, (LevelRenderSetup.TargetSize.Y * -2 / 3), MainPlaneZ, LevelRenderSetup.TargetSize.X + 120, LevelRenderSetup.TargetSize.Y, 0); if (weatherType == WeatherType.Rain) { GraphicResource res = commonResources.Graphics["Rain"]; Material material = res.Material.Res; Texture texture = material.MainTexture.Res; float scale = MathF.Rnd.NextFloat(0.4f, 1.1f); float speedX = MathF.Rnd.NextFloat(2.2f, 2.7f) * scale; float speedY = MathF.Rnd.NextFloat(7.6f, 8.6f) * scale; debrisPos.Z = MainPlaneZ * scale; tileMap.CreateDebris(new TileMap.DestructibleDebris { Pos = debrisPos, Size = res.Base.FrameDimensions, Speed = new Vector2(speedX, speedY), Scale = scale, Angle = MathF.Atan2(speedY, speedX), Alpha = 1f, Time = 180f, Material = material, MaterialOffset = texture.LookupAtlas(res.FrameOffset + MathF.Rnd.Next(res.FrameCount)), CollisionAction = collisionAction }); } else { GraphicResource res = commonResources.Graphics["Snow"]; Material material = res.Material.Res; Texture texture = material.MainTexture.Res; float scale = MathF.Rnd.NextFloat(0.4f, 1.1f); float speedX = MathF.Rnd.NextFloat(-1.6f, -1.2f) * scale; float speedY = MathF.Rnd.NextFloat(3f, 4f) * scale; float accel = MathF.Rnd.NextFloat(-0.008f, 0.008f) * scale; debrisPos.Z = MainPlaneZ * scale; tileMap.CreateDebris(new TileMap.DestructibleDebris { Pos = debrisPos, Size = res.Base.FrameDimensions, Speed = new Vector2(speedX, speedY), Acceleration = new Vector2(accel, -MathF.Abs(accel)), Scale = scale, Angle = MathF.Rnd.NextFloat(MathF.TwoPi), AngleSpeed = speedX * 0.02f, Alpha = 1f, Time = 180f, Material = material, MaterialOffset = texture.LookupAtlas(res.FrameOffset + MathF.Rnd.Next(res.FrameCount)), CollisionAction = collisionAction }); } } } // Active Boss if (activeBoss != null && activeBoss.Scene == null) { activeBoss = null; Hud hud = rootObject.GetComponent <Hud>(); if (hud != null) { hud.ActiveBoss = null; } InitLevelChange(ExitType.Normal, null); levelChangeTimer = 300; } if (initState == InitState.Initializing) { initState = InitState.Initialized; } collisionsCountA = 0; collisionsCountB = 0; collisionsCountC = 0; }
private void OnUpdate() { if (currentCarryOver.HasValue) { if (levelChangeTimer > 0) { levelChangeTimer -= Time.TimeMult; } else { root.ChangeLevel(currentCarryOver.Value); currentCarryOver = null; return; } } Vector3 pos = players[0].Transform.Pos; //int tx = (int)(pos.X / 32); //int ty = (int)(pos.Y / 32); int tx = (int)pos.X >> 5; int ty = (int)pos.Y >> 5; // ToDo: Remove this branching #if __ANDROID__ const int ActivateTileRange = 20; #else const int ActivateTileRange = 26; #endif for (int i = 0; i < actors.Count; i++) { if (actors[i].OnTileDeactivate(tx, ty, ActivateTileRange + 2)) { i--; } } eventMap.ActivateEvents(tx, ty, ActivateTileRange); eventMap.ProcessGenerators(); ResolveCollisions(); // Ambient Light Transition if (ambientLightCurrent != ambientLightTarget) { float step = Time.TimeMult * 0.012f; if (MathF.Abs(ambientLightCurrent - ambientLightTarget) < step) { ambientLightCurrent = ambientLightTarget; } else { ambientLightCurrent += step * ((ambientLightTarget < ambientLightCurrent) ? -1 : 1); } } // Weather if (weatherType != WeatherType.None) { Vector3 viewPos = camera.Transform.Pos; for (int i = 0; i < weatherIntensity; i++) { TileMap.DebrisCollisionAction collisionAction; if (weatherOutdoors) { collisionAction = TileMap.DebrisCollisionAction.Disappear; } else { collisionAction = (MathF.Rnd.NextFloat() > 0.7f ? TileMap.DebrisCollisionAction.None : TileMap.DebrisCollisionAction.Disappear); } Vector3 debrisPos = viewPos + MathF.Rnd.NextVector3((LevelRenderSetup.TargetSize.X / -2) - 40, (LevelRenderSetup.TargetSize.Y * -2 / 3), MainPlaneZ, LevelRenderSetup.TargetSize.X + 120, LevelRenderSetup.TargetSize.Y, 0); if (weatherType == WeatherType.Rain) { GraphicResource res = commonResources.Graphics["Rain"]; Material material = res.Material.Res; Texture texture = material.MainTexture.Res; float scale = MathF.Rnd.NextFloat(0.4f, 1.1f); float speedX = MathF.Rnd.NextFloat(2.2f, 2.7f) * scale; float speedY = MathF.Rnd.NextFloat(7.6f, 8.6f) * scale; debrisPos.Z = MainPlaneZ * scale; tileMap.CreateDebris(new TileMap.DestructibleDebris { Pos = debrisPos, Size = res.Base.FrameDimensions, Speed = new Vector2(speedX, speedY), Scale = scale, Angle = MathF.Atan2(speedY, speedX), Alpha = 1f, Time = 180f, Material = material, MaterialOffset = texture.LookupAtlas(res.FrameOffset + MathF.Rnd.Next(res.FrameCount)), CollisionAction = collisionAction }); } else { GraphicResource res = commonResources.Graphics["Snow"]; Material material = res.Material.Res; Texture texture = material.MainTexture.Res; float scale = MathF.Rnd.NextFloat(0.4f, 1.1f); float speedX = MathF.Rnd.NextFloat(-1.6f, -1.2f) * scale; float speedY = MathF.Rnd.NextFloat(3f, 4f) * scale; float accel = MathF.Rnd.NextFloat(-0.008f, 0.008f) * scale; debrisPos.Z = MainPlaneZ * scale; tileMap.CreateDebris(new TileMap.DestructibleDebris { Pos = debrisPos, Size = res.Base.FrameDimensions, Speed = new Vector2(speedX, speedY), Acceleration = new Vector2(accel, -MathF.Abs(accel)), Scale = scale, Angle = MathF.Rnd.NextFloat(MathF.TwoPi), AngleSpeed = speedX * 0.02f, Alpha = 1f, Time = 180f, Material = material, MaterialOffset = texture.LookupAtlas(res.FrameOffset + MathF.Rnd.Next(res.FrameCount)), CollisionAction = collisionAction }); } } } // Active Boss if (activeBoss != null && activeBoss.ParentScene == null) { activeBoss = null; Hud hud = rootObject.GetComponent <Hud>(); if (hud != null) { hud.ActiveBoss = null; } InitLevelChange(ExitType.Normal, null); levelChangeTimer *= 2; } if (DualityApp.Keyboard.KeyHit(Key.Escape)) { Scene.SwitchTo(new InGameMenu(root, this)); } Hud.ShowDebugText("- FPS: " + Time.Fps.ToString("N0") + " (" + Math.Round(Time.UnscaledDeltaTime * 1000, 1).ToString("N1") + " ms)"); Hud.ShowDebugText(" Diff.: " + difficulty + " | Actors: " + actors.Count.ToString("N0")); Hud.ShowDebugText(" Ambient Light: " + ambientLightCurrent.ToString("0.00") + " / " + ambientLightTarget.ToString("0.00")); Hud.ShowDebugText(" Collisions: " + collisionsCountA + " > " + collisionsCountB + " > " + collisionsCountC); collisionsCountA = 0; collisionsCountB = 0; collisionsCountC = 0; }
protected virtual void OnFixedUpdate(float timeMult) { eventMap.ProcessGenerators(timeMult); ResolveCollisions(); // ToDo: Weather /*if (weatherType != WeatherType.None && commonResources.Graphics != null) * { * // ToDo: Apply weather effect to all other cameras too * Vector3 viewPos = cameras[0].Transform.Pos; * for (int i = 0; i < weatherIntensity; i++) * { * TileMap.DebrisCollisionAction collisionAction; * if (weatherOutdoors) * { * collisionAction = TileMap.DebrisCollisionAction.Disappear; * } * else * { * collisionAction = (MathF.Rnd.NextFloat() > 0.7f * ? TileMap.DebrisCollisionAction.None * : TileMap.DebrisCollisionAction.Disappear); * } * * Vector3 debrisPos = viewPos + MathF.Rnd.NextVector3((LevelRenderSetup.TargetSize.X / -2) - 40, * (LevelRenderSetup.TargetSize.Y * -2 / 3), MainPlaneZ, * LevelRenderSetup.TargetSize.X + 120, LevelRenderSetup.TargetSize.Y, 0); * * if (weatherType == WeatherType.Rain) * { * GraphicResource res = commonResources.Graphics["Rain"]; * Material material = res.Material.Res; * Texture texture = material.MainTexture.Res; * * float scale = MathF.Rnd.NextFloat(0.4f, 1.1f); * float speedX = MathF.Rnd.NextFloat(2.2f, 2.7f) * scale; * float speedY = MathF.Rnd.NextFloat(7.6f, 8.6f) * scale; * * debrisPos.Z = MainPlaneZ * scale; * * tileMap.CreateDebris(new TileMap.DestructibleDebris * { * Pos = debrisPos, * Size = res.Base.FrameDimensions, * Speed = new Vector2(speedX, speedY), * * Scale = scale, * Angle = MathF.Atan2(speedY, speedX), * Alpha = 1f, * * Time = 180f, * * Material = material, * MaterialOffset = texture.LookupAtlas(res.FrameOffset + MathF.Rnd.Next(res.FrameCount)), * * CollisionAction = collisionAction * }); * } * else * { * GraphicResource res = commonResources.Graphics["Snow"]; * Material material = res.Material.Res; * Texture texture = material.MainTexture.Res; * * float scale = MathF.Rnd.NextFloat(0.4f, 1.1f); * float speedX = MathF.Rnd.NextFloat(-1.6f, -1.2f) * scale; * float speedY = MathF.Rnd.NextFloat(3f, 4f) * scale; * float accel = MathF.Rnd.NextFloat(-0.008f, 0.008f) * scale; * * debrisPos.Z = MainPlaneZ * scale; * * tileMap.CreateDebris(new TileMap.DestructibleDebris * { * Pos = debrisPos, * Size = res.Base.FrameDimensions, * Speed = new Vector2(speedX, speedY), * Acceleration = new Vector2(accel, -MathF.Abs(accel)), * * Scale = scale, * Angle = MathF.Rnd.NextFloat(MathF.TwoPi), * AngleSpeed = speedX * 0.02f, * Alpha = 1f, * * Time = 180f, * * Material = material, * MaterialOffset = texture.LookupAtlas(res.FrameOffset + MathF.Rnd.Next(res.FrameCount)), * * CollisionAction = collisionAction * }); * } * } * }*/ // Active Boss if (activeBoss != null && activeBoss.Scene == null) { activeBoss = null; // ToDo InitLevelChange(ExitType.Normal, null); } if (initState == InitState.Initializing) { initState = InitState.Initialized; } //collisionsCountA = 0; //collisionsCountB = 0; //collisionsCountC = 0; }