void OnokSkillBtn(Transform panel) { MusicManager.PlaySe("click"); if (BattleGlobals.currentSid != "") { Skill s = GameFuncs.GetSkill(BattleGlobals.currentSid); Hero h = BattleGlobals.currentObj.GetComponent <Hero>(); if ((!s.isCp && h.currentMp >= s.cost) || (s.isCp && h.cp >= s.cost))//可消耗 { BattleCamera.SetAnimStop(); skillPanel.SetActive(false); heroPanel.SetActive(false); if (!s.isAoe)//单体 { BattleGlobals.isSelectEnemy = true; } else { BattleCamera.Instance.SetPos(0); BattleGlobals.currentObj.GetComponent <Hero>().Magic(BattleGlobals.currentSid); } foreach (Transform so in panel.Find("list/grid")) { Destroy(so.gameObject); } BattleGlobals.isMagic = true; } else//mp(cp)不足 { string msg = (s.isCp ? "cp" : "mp") + "不足!"; GameFuncs.CreateMsg(msg); } } }
public void PlaySpawnTransition() { BattleCamera.Shake(0.6f); AudioConstants.Instance.PlayerSpawn.PlaySFX(); SetShieldAlpha(0.0f); spawnTransition_.AnimateIn(() => { SetShieldAlpha(GameConstants.Instance.PlayerShieldAlphaMin); }); }
void OnatkBtnClick() { MusicManager.PlaySe("click"); BattleCamera.SetAnimStop(); if (true) { BattleGlobals.isNearAttack = true; //近战 } BattleGlobals.isSelectEnemy = true; heroPanel.SetActive(false); }
private void ToggleMainMenuVisible() { if (mainMenu_ != null) { CleanupMainMenu(); BattleCamera.SetDepthOfFieldEnabled(false); } else { CreateMainMenu(); BattleCamera.SetDepthOfFieldEnabled(true); } }
protected override void OnStateExited() { dynamicGroup_.Enabled = false; BattleCamera.SetDepthOfFieldEnabled(false, animate: true); InGameConstants.BattlePlayerPartsFade = false; PlayerScores.Clear(); RegisteredPlayers.Clear(); PlayerSpawner.ShouldRespawn = false; PlayerSpawner.CleanupAllPlayers(); CleanupMainMenu(); }
private void Update() { if (BattleGlobals.isSelectEnemy) { if (Input.GetMouseButtonDown(1)) { BattleGlobals.isSelectEnemy = false; BattleCamera.SetIsStop(); //active hero ui BattleUI.heroPanel.SetActive(true); } } }
void OndefBtnClick() { MusicManager.PlaySe("click"); if (BattleGlobals.currentObj != null && BattleGlobals.currentObj.tag == "Hero") { BattleCamera.SetAnimStop(); Hero hero = BattleGlobals.currentObj.GetComponent <Hero>(); hero.isDef = true; heroPanel.SetActive(false); BattleGlobals.isStop = false; BattleGlobals.currentObj = null; BattleGlobals.otherObjs.Clear(); } }
public virtual void Magic(string sid, Entity other = null) { Skill s = GameFuncs.GetSkill(sid); Hero h = BattleGlobals.currentObj.GetComponent <Hero>(); GameObject effect = Instantiate((GameObject)GameFuncs.GetResource("Effect/" + sid)); Destroy(effect, 2); BattleCamera.Shake(); int cost = s.isCp ? s.cost : s.cost / 5; float ats = s.isCp ? h.infos[4] : (h.infos[2] + h.infos[4]) / 2; float value = cost * ats; if (s.isAoe) { if (BattleGlobals.currentObj.tag == "Hero") { effect.transform.position = Battle.mone.position; List <string> temp = new List <string>(); foreach (string lm in BattleGlobals.liveMonsters) { temp.Add(lm); } for (int i = 0; i < temp.Count; i++) { string es = temp[i]; Enemy en = BattleFuncs.FindObj(es).GetComponent <Enemy>(); en.GetHurt(value, GetRestrict(en, ref value)); } } else if (BattleGlobals.currentObj.tag == "Enemy") { List <string> temp = BattleGlobals.liveHeroes; for (int i = 0; i < temp.Count; i++) { string hs = temp[i]; Hero he = BattleFuncs.FindObj(hs).GetComponent <Hero>(); he.GetHurt(value, GetRestrict(he, ref value)); } } } else { effect.transform.position = other.gameObject.transform.position; other.GetHurt(value, GetRestrict(other, ref value)); } BattleGlobals.currentSid = ""; Invoke("SetTurnOver", 2); }
public void Init(BattlePlayer battlePlayer) { ChangeBattlePlayerSource(battlePlayer); AddSpeedFromVelocity(battlePlayer.Rigidbody.velocity); AudioConstants.Instance.LaserShoot.PlaySFX(volumeScale: 0.33f); BattleCamera.Shake(0.14f); Color laserColor = battlePlayer.Skin.LaserColor; laserRenderer_.material = battlePlayer.Skin.SmearedLaserMaterial; light_.color = laserColor; laserHitMaterial_ = battlePlayer.Skin.LaserMaterial; particleSystemRenderer_.material = battlePlayer.Skin.LaserMaterial; GameNotifications.OnBattlePlayerShotLaser.Invoke(this, battlePlayer); }
protected override void OnStateEntered() { dynamicGroup_.Enabled = true; #if DEMO PHASERBEAKDebug.ResetAllThings(); #endif BattleCamera.SetDepthOfFieldEnabled(true); InGameConstants.BattlePlayerPartsFade = true; RegisteredPlayers.Clear(); ArenaManager.Instance.AnimateLoadRandomArena(() => { RegisteredPlayersUtil.RegisterAIPlayers(4); PlayerSpawner.ShouldRespawn = true; PlayerSpawner.SpawnAllPlayers(); }); CreateMainMenu(); }
public static BattleCamera instance = null; //Static instance of GameManager which allows it to be accessed by any other script. void Awake() { Debug.Log("Awake BattleCamera"); //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(this); }
public static void CameraChange(string onCamera, string offCamera) { switch (onCamera) { case "Main": MainCamera.SetActive(true); break; case "Battle": BattleCamera.SetActive(true); break; } switch (offCamera) { case "Main": MainCamera.SetActive(false); break; case "Battle": BattleCamera.SetActive(false); break; } }
public void EnterNextWave() { if (BattleGlobals.liveMonsters.Count <= 0)//这波敌人死亡 { BattleGlobals.isStop = true; if (BattleGlobals.currentWave < BattleGlobals.waves)//进入下一波 { BattleGlobals.currentObj = null; BattleGlobals.otherObjs.Clear(); foreach (Transform mp in GameObject.Find("mpoints").transform) { foreach (Transform m in mp) { Destroy(m.gameObject); } } //wave ui BattleGlobals.currentWave++; UIManager.ChangeText("waveText", "Battle " + BattleGlobals.currentWave.ToString() + "/" + BattleGlobals.waves.ToString()); //create monsters Battle.currentMonsters = BattleGlobals.monsters[BattleGlobals.currentWave - 1]; Battle.CreateCurrentEnemy(); BattleUI.CreateHeads(); //is boss if (BattleGlobals.currentWave == BattleGlobals.waves) { BattleGlobals.isStop = true; BattleUI.canvas.SetActive(false); //boss(play boss bgm;hp slider;camera anim) MusicManager.PlayBgm("boss"); BattleCamera.PlayAnim("_boss"); StartCoroutine(DelayToInvoke.DelayToInvokeDo(WaitNotStop, 6)); } else { StartCoroutine(DelayToInvoke.DelayToInvokeDo(WaitNotStop, 0.2f)); } } else//win { BattleGlobals.isOver = true; BattleUI.HideUI(); //if current hero else random(live heroes) -> set win bool true GameObject winObj = null; Hero winHero = null; if (BattleGlobals.currentObj.tag == "Hero") { winObj = BattleGlobals.currentObj; } else { winObj = BattleFuncs.FindObj (BattleGlobals.liveHeroes[Random.Range(0, BattleGlobals.liveHeroes.Count - 1)]); } //camera string winIndex = winObj.transform.parent.gameObject.name [winObj.transform.parent.gameObject.name.Length - 1].ToString(); BattleCamera.SetAnimStop(); BattleCamera.PlayAnim("h" + winIndex); winHero = BattleGlobals.currentObj.GetComponent <Hero>(); winHero.Win(); //show win ui(every select heroes exp++;date(attribute) ++;click->return select map) StartCoroutine(DelayToInvoke.DelayToInvokeDo(WaitShowWin, 4f)); } } if (BattleGlobals.liveHeroes.Count <= 0)//英雄全部死亡,失败 { BattleGlobals.isOver = true; BattleGlobals.isStop = true; BattleUI.HideUI(); //show lose ui(click->return select map) BattleUI.ShowLosePanel(); } }
void OnEnable() { battleCamera = (BattleCamera) target; go = battleCamera.gameObject; }
// Start is called before the first frame update void Start() { monsterArray = GameObject.FindGameObjectsWithTag(tagName); camReference = GameObject.Find(cameraName).GetComponent <BattleCamera>(); }
public void TakeDamage(int damage, Vector3 forward, object damageSource = null) { if (health_ <= 0) { return; } if (invulnerable_) { return; } health_ -= damage; OnBattlePlayerDamaged.Invoke(Player_, damage); if (health_ <= 0) { GameObject playerParts = ObjectPoolManager.Create(playerPartsPrefab_, this.transform.position, Quaternion.identity, parent: BattleRecyclables.Instance); // NOTE (darren): remove any negative y component from damage forward vector // since gravity + explosive downwards force looks crazy Vector3 explosionForward = forward.SetY(Mathf.Max(forward.y, 0.0f)); Vector3 explosionPosition = this.transform.position - (explosionForward.normalized * kExplosionRadius / 4.0f); foreach (Rigidbody rigidbody in playerParts.GetComponentsInChildren <Rigidbody>()) { float distance = (rigidbody.position - explosionPosition).magnitude; float explosionForce = Mathf.Clamp(1.0f - (distance / kExplosionForce), 0.0f, 1.0f); explosionForce *= UnityEngine.Random.Range(0.1f, 1.3f); rigidbody.AddExplosionForce(explosionForce * kExplosionForce, explosionPosition, kExplosionRadius, upwardsModifier: 1.0f); } // Animate single material to batch SetEmissiveMaterialsFor(playerParts, Player_.Skin.BodyPartMaterial); Material[] partMaterialArray = new Material[] { Player_.Skin.BodyPartMaterial }; AnimateDamageEmissionFor(partMaterialArray); AudioConstants.Instance.PlayerDeath.PlaySFX(); BattleCamera.Shake(1.0f); BattleCamera.StopTimeForKill(); OnBattlePlayerDied.Invoke(Player_); if (damageSource != null) { GameNotifications.OnBattlePlayerDiedWithSource.Invoke(Player_, damageSource); } ObjectPoolManager.Recycle(this); } else { float multiplier = 1.0f; if (damage > 0) { AnimateShieldHit(hideShieldAfterwards: health_ <= 1); // AnimateDamageEmissionFor(Player_.BodyRenderers.Select(r => r.sharedMaterial)); multiplier = 0.5f; } Knockback(forward, damageSource: damageSource); AudioConstants.Instance.PlayerHurt.PlaySFX(volumeScale: multiplier); BattleCamera.Shake(0.55f * multiplier); } }
void OnLevelWasLoaded(int level) { if (level == 0) { battleCamera = GameObject.Find ("CameraRotate").GetComponent<BattleCamera> (); } }
public void dealloc() { Instance = null; Destroy(gameObject); }
void Awake() { Instance = this; }
private static void ReadCamera() { Memory.BS_CameraStruct = new Memory.VIII_cameraMemoryStruct(); uint cCameraHeaderSector = pbs.ReadUShort(); //if (cCameraHeaderSector != 0x2) // ; //error handler? uint pCameraSetting = pbs.ReadUShort(); uint pCameraAnimationCollection = pbs.ReadUShort(); uint sCameraDataSize = pbs.ReadUShort(); //Camera settings parsing? BattleCameraSettings bcs = new BattleCameraSettings() { unk = pbs.ReadBytes(24) }; //end of camera settings parsing pbs.Seek(bs_cameraPointer, 0); pbs.Seek(pCameraAnimationCollection, System.IO.SeekOrigin.Current); BattleCameraCollection bcc = new BattleCameraCollection { cAnimCollectionCount = pbs.ReadUShort() }; BattleCameraSet[] bcset = new BattleCameraSet[bcc.cAnimCollectionCount]; bcc.battleCameraSet = bcset; for (int i = 0; i < bcc.cAnimCollectionCount; i++) { bcset[i] = new BattleCameraSet() { globalSetPointer = (uint)(pbs.Tell() + pbs.ReadUShort() - i * 2 - 2) } } ; bcc.pCameraEOF = pbs.ReadUShort(); for (int i = 0; i < bcc.cAnimCollectionCount; i++) { pbs.Seek(bcc.battleCameraSet[i].globalSetPointer, 0); bcc.battleCameraSet[i].animPointers = new uint[8]; for (int n = 0; n < bcc.battleCameraSet[i].animPointers.Length; n++) { bcc.battleCameraSet[i].animPointers[n] = (uint)(pbs.Tell() + pbs.ReadUShort() * 2 - n * 2); } bcc.battleCameraSet[i].cameraAnimation = new CameraAnimation[bcc.battleCameraSet[i].animPointers.Length]; for (int n = 0; n < bcc.battleCameraSet[i].animPointers.Length; n++) { pbs.Seek(bcc.battleCameraSet[i].animPointers[n], 0); bcc.battleCameraSet[i].cameraAnimation[n] = new CameraAnimation() { header = pbs.ReadUShort() }; } } battleCamera = new BattleCamera() { battleCameraCollection = bcc, battleCameraSettings = bcs }; //DEBUG DELETE ME ReadAnimation(7); //END OF DEBUG pbs.Seek(bs_cameraPointer + sCameraDataSize, 0); //debug out }
private void Awake() { Instance = this; }
// Update is called once per frame void Update() { if (!BattleGlobals.isStop && !BattleCamera.anim.isPlaying) { BattleGlobals.canEnterNext = true; BattleGlobals.currentObj = null; BattleGlobals.otherObjs.Clear(); //heads move by speed foreach (GameObject head in heads) { string id = head.name; Entity e = BattleFuncs.FindObj(id).GetComponent <Entity>(); //move head.transform.Translate(Vector3.right * e.infos[5]); head.transform.position = new Vector2(Mathf.Clamp( head.transform.position.x, start.position.x, end.position.x), head.transform.position.y); //turn if (Vector2.Distance(head.transform.position, end.position) <= 1) { BattleGlobals.currentObj = null; BattleGlobals.otherObjs.Clear(); BattleGlobals.isStop = true; BattleGlobals.currentObj = BattleFuncs.FindObj(id); if (BattleGlobals.currentObj.tag == "Enemy") { if (true) { BattleGlobals.isNearAttack = true; //近战 } if (BattleGlobals.liveHeroes.Count > 0) { GameObject ranHero = BattleFuncs.FindObj(BattleGlobals.liveHeroes [Random.Range(0, BattleGlobals.liveHeroes.Count)]); BattleGlobals.otherObjs.Clear(); BattleGlobals.otherObjs.Add(ranHero); } } else if (BattleGlobals.currentObj.tag == "Hero") { if (!BattleGlobals.isOver) { BattleCamera.SetIsStop(); //active hero ui heroPanel.SetActive(true); //Bind heroPanelBtns Button atkBtn = UIManager.GetButton("atkBtn"); Button skillBtn = UIManager.GetButton("skillBtn"); Button defBtn = UIManager.GetButton("defBtn"); atkBtn.onClick.AddListener(OnatkBtnClick); skillBtn.onClick.AddListener(OnskillBtnClick); defBtn.onClick.AddListener(OndefBtnClick); } } head.transform.position = start.position; } } if (heroPanel.activeInHierarchy) { BattleGlobals.isStop = true; } } else//停止时获得当前对象 { if (heroPanel != null && heroPanel.activeInHierarchy && !BattleCamera.anim.isPlaying) { foreach (GameObject head in heads) { string id = head.name; if (!id.Contains("m")) { if (Vector2.Distance(head.transform.position, start.position) <= 1) { BattleGlobals.currentObj = null; BattleGlobals.otherObjs.Clear(); BattleGlobals.currentObj = BattleFuncs.FindObj(id); } } else { BattleFuncs.FindObj(id).GetComponent <Animator>().SetBool("run", false); } } } } }