private void Start() { if (instance == null) { instance = this; } }
IEnumerator FadeImageWhite(bool fadeAway) { // fade from opaque to transparent if (fadeAway) { // loop over 1 second backwards for (float i = 0; i <= 1; i += Time.deltaTime) { // set color with i as alpha WhiteScreen.color = new Color(255, 255, 255, i); yield return(null); } fireSprite.enabled = false; gasfire.enabled = true; for (float i = 1; i >= 0; i -= Time.deltaTime) { // set color with i as alpha WhiteScreen.color = new Color(255, 255, 255, i); yield return(null); } GoalScript.GoalScreen(); //GameOver.death_animator.Play("death", -1, 0.0f); } }
// Use this for initialization void Start() { // GoalScriptクラスを取得 goalScript = goal.GetComponent <GoalScript>(); // ボールを生成 Instantiate(ball, new Vector3(0f, 0.45f, -10f), Quaternion.identity); }
// Start is called before the first frame update public void Start() { back = GameObject.Find("back"); script = back.GetComponent <GoalScript>(); int getpoint = script.count; // Debug.Log(getpoint); count = 0; score = getpoint - count; countText.text = "失点" + count.ToString() + "\nScore" + score.ToString(); }
// Use this for initialization void Start() { anim = GetComponent <Animator> (); //ES = GameObject.Find ("Enemy").GetComponent<EnemyScript> (); PS = GameObject.Find("player").GetComponent <PlayerScript>(); PlayerATK = 1; GS = GameObject.Find("Goal").GetComponent <GoalScript> (); //Debug.Log (GS.goal); life = true; speed = 8; high = 2; }
// Use this for initialization void Start() { GameObject goalObject = GameObject.FindWithTag("Goal"); if (goalObject != null) { goalScript = goalObject.GetComponent <GoalScript>(); } if (goalObject == null) { Debug.Log("Can not find GoalScript script."); } cur_Health = max_Health; tr_Player = GameObject.FindGameObjectWithTag("Player").transform; }
private void Awake() { buildZone_ = GameObject.FindWithTag("BuildZone"); if (buildZone_ == null) { Debug.LogError("Cannot find BuildZone object"); } mainCameraObject_ = GameObject.FindWithTag("MainCamera"); if (mainCameraObject_) { mainCamera_ = mainCameraObject_.GetComponent <Camera>(); if (mainCamera_) { origCameraSize_ = mainCamera_.fieldOfView; origCameraPosition_ = mainCameraObject_.transform.position; cameraTargetSize_ = origCameraSize_; cameraTargetPosition_ = mainCamera_.transform.position; } else { Debug.LogError("Cannot find camera component"); } } else { Debug.LogError("Cannot find main camera object in scene"); } finishLine_ = GameObject.FindWithTag("Finish"); if (finishLine_) { GoalScript goal = finishLine_.GetComponent <GoalScript>(); if (goal) { goal.RegisterGameLevel(this); } else { Debug.LogError("FinishLine object has no GoalScript attached"); } } else { Debug.LogError("Cannot find FinishLine in this level"); } }
private void Start() { PlayerScore = 0; OpponentScore = 0; AudioSource[] audioSources = transform.parent.GetComponents <AudioSource>(); winPointAudio = audioSources[0]; losePointAudio = audioSources[1]; theScoreIsAudio = audioSources[2]; toScoreAudio = audioSources[3]; playerUpAudio = audioSources[4]; opponentUpAudio = audioSources[5]; tiedAudio = audioSources[6]; playerWins = audioSources[7]; opponentWins = audioSources[8]; gameOver = false; if (scoreTextGO != null) { scoreText = scoreTextGO.GetComponent <TextMesh>(); } Instance = this; }
private void Spawn() { string curr = SceneChanger.getScene(); if (curr == "StageOne") { p1 = Instantiate(player, new Vector3(-10, -5, 0), transform.rotation); g1 = Instantiate(goal, new Vector3(10, 5, 0), transform.rotation); } else if (curr == "StageTwo") { p1 = Instantiate(player, new Vector3(-12, -6, 0), transform.rotation); g1 = Instantiate(goal, new Vector3(12, 6, 0), transform.rotation); } else if (curr == "StageThree") { p1 = Instantiate(player, new Vector3(-14, -7, 0), transform.rotation); g1 = Instantiate(goal, new Vector3(14, 7, 0), transform.rotation); } }
private void LoadGoals(ModInfo mod) { foreach (var file in mod.Scripts) { var scriptStream = file.Value.MakeStream(); try { using (var reader = new BinaryReader(scriptStream)) { string path; if (file.Value is PackagedFileInfo) { var pkgd = file.Value as PackagedFileInfo; path = (pkgd.PackageStream as FileStream).Name + ":/" + pkgd.Name; } else { var fs = file.Value as FilesystemFileInfo; path = fs.FilesystemPath; } var script = new GoalScript { Name = Path.GetFileNameWithoutExtension(file.Value.Name), Path = path, ScriptBody = reader.ReadBytes((int)scriptStream.Length) }; GoalScripts.Add(script); } } finally { file.Value.ReleaseStream(); } } }
private void BallSpeedPoints() { if (rb.velocity.magnitude < 8 && GameUtils.playState == GameUtils.GamePlayState.InPlay) { if (timerStarted) { if (Time.time > oldTime + 2) { GameUtils.ResetBall(transform.gameObject); timerStarted = false; GameUtils.playState = GameUtils.GamePlayState.SettingBall; rb.isKinematic = true; if (transform.position.z > 0) { GoalScript.PlayerScore++; GoalScript.PlayWinSound(); } else { GoalScript.OpponentScore++; GoalScript.PlayLoseSound(); } StartCoroutine(GoalScript.ReadScore()); } } else { timerStarted = true; oldTime = Time.time; } } else { timerStarted = false; } }
private void Goal(GoalScript g) { animator.SetTrigger("but" + Random.Range(1, 4)); if (g.team == GameScript.TEAM1) { score1.text = g.score.ToString(); instance.butImage.sprite = gameScript.player1.definition.avatar; } else if (g.team == GameScript.TEAM2) { score2.text = g.score.ToString(); instance.butImage.sprite = gameScript.player2.definition.avatar; } }
//private void FixedUpdate() //{ // if (levelPassed){ // Debug.Log("Level Passed"); // } //} private void OnTriggerEnter2D(Collider2D collision) { // If the collision object is a gem, picks it up and marks the // gem boolean as true. GemScript gem = collision.gameObject.GetComponent <GemScript>(); if (gem != null) { power_acquired = true; Animator goalAni = goal.GetComponent <Animator>(); if (goalAni != null) { goalAni.SetBool("goalReached", true); } // TODO implement what happens when power_acquired is true. Destroy(gem.gameObject); } // If the player touches the goal, first check if player has the gem // If the player has the gem, then level is cleared. // If not, then throw some kind of message to remind player to pick // up the gem. GoalScript goal1 = collision.gameObject.GetComponent <GoalScript>(); if (goal1 != null) { if (power_acquired) { Collider2D goalCol = goal.GetComponent <Collider2D>(); // TODO Player animation of goal reached levelPassed = true; goalCol.enabled = false; } } // If the player touches hell fire before the player successfully // kills it with water, the player dies. Instantly. FireScript fire = collision.gameObject.GetComponent <FireScript>(); if (fire != null) { GetComponent <HealthScript>() .Damage(GetComponent <HealthScript>().hp); foreach (GameObject heart in hearts) { if (heart != null) { Destroy(heart); } } } // Checks if the player bumps into an enemy and reduces hp for both // sides accordingly. bool damagePlayer = false; EnemyScript enemy = collision.gameObject.GetComponent <EnemyScript>(); if (enemy != null) { HealthScript enemyHealth = enemy.GetComponent <HealthScript>(); if (enemyHealth != null) { enemyHealth.Damage(1); } damagePlayer = true; } if (damagePlayer) { HealthScript playerHealth = this.GetComponent <HealthScript>(); if (playerHealth != null) { playerHealth.Damage(1); // Destroys one heart if player is damaged by 1. Destroy(hearts[playerHealth.hp]); } } }
// Start is called before the first frame update override public void Start() { base.Start(); TowerShopRef = GameObject.Find("TowerShopUI").GetComponent <TowerShop>(); Goal = GameObject.Find("Goal").GetComponent <GoalScript>(); }
void Awake() { // Ball ball = FindObjectOfType<BallScript>(); // Players var players = FindObjectsOfType<PlayerScript>(); if (players.Length == 0) { Debug.LogError("No players WTF"); } foreach (var p in players) { p.OnBallPick += (pickingPlayer) => { SelectTeam(pickingPlayer, pickingPlayer.definition.team); }; p.OnShoot += (pl) => { soundShootCooldown = 2f; }; } mire1.SetActive(false); mire2.SetActive(false); team1 = players.Where(p => p.definition.team == TEAM1).ToList(); team2 = players.Where(p => p.definition.team == TEAM2).ToList(); InputHandleSelection(true); // Goal foreach (GoalScript g in FindObjectsOfType<GoalScript>()) { g.OnGoal += GOAL; if (g.team == TEAM1) goal1 = g; else if (g.team == TEAM2) goal2 = g; } }
private void GOAL(GoalScript goalScript) { paused = true; SoundsScript.Play("but", goalScript.transform.position); // Text, particles, juice BallCamera.FollowBall = false; CameraShaker.ShakeCamera(0.5f, 1f); foreach (var p in team1) { p.BackToYourPlace(); } foreach (var p in team2) { p.BackToYourPlace(); } // Wait StartCoroutine(Timer.Start(3f, () => { // Reset everything ball.Reset(); BallCamera.FollowBall = true; CameraShaker.Clean(); paused = false; })); }
Level boardState; //Row, Column // East col+, North row+ /* 0 = empty * 1 = wall * 2 = player * 3 = mimic * 4 = mirror * 10 = goal */ // Use this for initialization void Start() { firstStart = false; //load level using Melody's I/O boardState = IOScript.ParseLevel(levelName); // TODO: Below the way we get the index is DISGUSTING, this whole shitshow needs refactored levelNum = CreateLevelSelect.levelList.IndexOf(levelName); LoggingManager.instance.RecordLevelStart(levelNum, levelName); mapOrigin = new Vector2(-boardState.cols / 2.0f, -boardState.rows / 2.0f); mainCamera.orthographicSize = boardState.rows / 2.0f + 1; tutorial.text = boardState.tutorial; tutorial.enabled = true; if (levelNum == 0) { tutorial1.SetActive(true); } else if (levelNum == 5) { tutorial6.SetActive(true); } int buttonCount = 0; //instantiate lasers based on parsed lasers if (boardState.lasers != null) { foreach (Laser la in boardState.lasers) { LaserScript l = GameObject.Instantiate(laser); l.makeLaser(la, mapOrigin); laserList.Add(l); } } //instantiate items based on board for (int i = 0; i < boardState.rows; i++) { for (int j = 0; j < boardState.cols; j++) { if (boardState.board[i, j] == 1) { //wall GameObject w; if (i == 0 || boardState.board[i - 1, j] != 1) { w = GameObject.Instantiate(frontWall); } else { w = GameObject.Instantiate(wall); } w.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0); } else if (boardState.board[i, j] >= 10 && boardState.board[i, j] < 20) { // goal GoalScript c = GameObject.Instantiate(goal); c.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0); goalAtCoords.Add(new coord(i, j), c); goalCoords.Add(new coord(i, j)); } else if (boardState.board[i, j] >= 20 && boardState.board[i, j] < 30) { // swap GameObject c = GameObject.Instantiate(swap); c.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0); swapCoords.Add(new coord(i, j)); } else if (boardState.board[i, j] >= 30 && boardState.board[i, j] < 40) { // button ButtonToggleScript c = GameObject.Instantiate(button); c.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0); c.laser = laserList[boardState.buttons[buttonCount]]; c.InitButton(); buttonCoords.Add(new coord(i, j), c); buttonCount++; } else if (boardState.board[i, j] >= 50 && boardState.board[i, j] < 60) { // portal GameObject p = GameObject.Instantiate(portal); p.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0); portalCoords.Add(new coord(i, j)); } else { // ground GameObject g = GameObject.Instantiate(ground); g.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0); } if (boardState.board[i, j] % 10 == 2) { // player player = GameObject.Instantiate(player); player.SetCoords(j, i); player.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y + player.yOffset, -0.2f); moveables.Add(player); } else if (boardState.board[i, j] % 10 == 3) { // mimic MimicScript m = GameObject.Instantiate(mimic); m.SetCoords(j, i); m.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y + m.yOffset, -0.2f); moveables.Add(m); } else if (boardState.board[i, j] % 10 == 4) { // mirror MirrorScript m = GameObject.Instantiate(mirror); m.SetCoords(j, i); m.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y + m.yOffset, -0.2f); moveables.Add(m); } } } if (boardState.portals != null) { for (int i = 0; i < boardState.portals.Length; i++) { portalMap.Add(portalCoords[i], portalCoords[boardState.portals[i]]); } } }