public bool HasDirectPath(CheckPointController from, CheckPointController to) { var fromNode = (Graph.Node)_checkpointsToNodes[from.gameObject]; var toNode = (Graph.Node)_checkpointsToNodes[to.gameObject]; return(_graph.HasDirectPath(fromNode, toNode)); }
Vector3 respawn_pos; //the position that the player gonna respawn // Use this for initialization void Start() { // Variable Setting life_count = 3; // player life originalJumpSpeed = jumpSpeed; originalSpeed = moveSpeed; beingCollected = false; coins = 0; CoinBoost = false; GameOver.SetActive(false); // hide game over // Get Components/Get Types myRigidbody = GetComponent <Rigidbody2D>(); MyLevelManager = FindObjectOfType <LevelManager>(); charaterKilling = FindObjectOfType <KillEnemy>(); checkPointChecker = FindObjectOfType <CheckPointController>(); }
public void MoveHeroesTo(CheckPointController other) { foreach (var selectedHero in _selectedHeroes) { selectedHero.MoveTo(other); } Heroes = Heroes.Except(_selectedHeroes).ToList(); _selectedHeroes.Clear(); }
private void Checkpoint_OnSelected(CheckPointController checkpoint) { var previouslySelectedCheckpoint = _map.CheckPoints.SingleOrDefault(c => c.IsSelected); if (previouslySelectedCheckpoint != null && _map.HasDirectPath(previouslySelectedCheckpoint, checkpoint)) { previouslySelectedCheckpoint.MoveHeroesTo(checkpoint); } OnCheckpointSelected?.Invoke(checkpoint); }
void Awake() { if (cc == null) { DontDestroyOnLoad(gameObject); cc = this; } else if (cc != this) { Destroy(gameObject); } }
void Start() { Time.timeScale = 1f; guic = GameObject.Find("Canvas/GameUI").GetComponent <GameUIController> (); pc = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController> (); // Get Level from Scene name string sceneName = SceneManager.GetActiveScene().name; LevelEnum lvlEnum = (LevelEnum)Enum.Parse(typeof(LevelEnum), sceneName); this.level = ApplicationController.ac.levels [lvlEnum]; // Init target targetKittyz = level.targetKittyz; targetTime = level.targetTime; targetLife = level.targetLife; // Load checkpoint if exists for this level GameObject checkpointControllerObject = GameObject.Find("CheckPointController"); if (checkpointControllerObject) { CheckPointController checkpointController = checkpointControllerObject.GetComponent <CheckPointController> (); if (checkpointController.levelEnum == lvlEnum) { checkpointController.Load(); } else { checkpointController.Reset(lvlEnum); } } // Check if we have to diplay to tip if the player get hit hasTipBeenConsulted = ApplicationController.ac.IsTipAlreadyConsulted(TipEnum.BUY_LIFE); // Analytics Analytics.CustomEvent("LevelStarted_" + this.level.name, new Dictionary <string, object> { { "date", System.DateTime.Now.ToString() }, { "kittys_total", ApplicationController.ac.playerData.kittyz } }); }
private void GameController_OnCheckpointSelected(CheckPointController checkpoint) { // destroy previous overview panels foreach (var item in _heroOverviewPanels) { DestroyImmediate(item); } _heroOverviewPanels.Clear(); // create overview panels for newly selected checkpoint foreach (var hero in checkpoint.Heroes) { var heroOverview = Instantiate(HeroOverviewPanelPrefab, this.transform); heroOverview.transform.localScale = new Vector2(1.0f / this.transform.localScale.x, 1.0f / this.transform.localScale.y); heroOverview.transform.localPosition = new Vector2(0, 0); heroOverview.GetComponent <HeroOverviewPanel>().SetHero(hero); _heroOverviewPanels.Add(heroOverview); } }
public void Reset() { if (playRandomColorCoroutine != null) { StopCoroutine(playRandomColorCoroutine); } foreach (var checkPoint in currentLevel.checkPoints) { checkPoint.ball = ball; checkPoint.raceController = this; checkPoint.gameObject.SetActive(false); } nextCheckPointIndex = 0; nextCheckPoint = currentLevel.checkPoints[0]; nextCheckPoint.gameObject.SetActive(true); nextCheckPoint.ChangeText("START"); color = GetRandomColor(); nextCheckPoint.ChangeColor(color); ball.position = currentLevel.startPosition.position; ball.rotation = currentLevel.startPosition.rotation.eulerAngles.y; terrainController.CleanTerrain(); race.timeElapsed = 0; race.lapTime = 0; race.lapTimes = new List <float>(); race.currentLap = 0; race.isRacing = false; race.isNewRecord = false; onlineController.LoadLeaderBoard(); }
/*** double jump - powerup1 * triple coin - powerup2 * faster movement - powerup3 * extra life - powerup4 ***/ // Use this for initialization void Start() { scoresAdded = false; db = FindObjectOfType <databaseController>(); userName = "******"; // Variable Setting life_count = 3; // player life originalJumpSpeed = jumpSpeed; originalSpeed = moveSpeed; beingCollected = false; coins = 0; CoinBoost = false; GameOver.SetActive(false); // hide game over isSpeedBoost = false; invincibleToSpikeDamage = false; // Get Components/Get Types myRigidbody = GetComponent <Rigidbody2D>(); MyLevelManager = FindObjectOfType <LevelManager>(); charaterKilling = FindObjectOfType <KillEnemy>(); checkPointChecker = FindObjectOfType <CheckPointController>(); myAnim = FindObjectOfType <Animator>(); //Get history coins number totalCoins = PlayerPrefs.GetInt("totalcoins"); if (PlayerPrefs.GetInt("hasPowerUp4") == 1) { life_count = 5; } //Get high score k = FindObjectOfType <KillEnemy>(); highScore = PlayerPrefs.GetInt("highscore"); }
public void MoveTo(CheckPointController checkpoint) { this.transform.position = checkpoint.transform.position; CurrentCheckpoint = checkpoint; CurrentCheckpoint.PlaceHero(this); }
private void Start() { checkPointController = FindObjectOfType <CheckPointController>(); }
void Start() { movement = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMovement>(); checkPointC = GameObject.FindGameObjectWithTag("Player").GetComponent<CheckPointController>(); }
public void OnCheckPoint(CheckPointController checkPoint) { if (nextCheckPoint == checkPoint) { checkPoint.gameObject.SetActive(false); PlaySound(checkPointSound); if (nextCheckPointIndex == 0) { race.currentLap++; if (race.currentLap == 1) // Start { PlaySound(startAudio); race.isRacing = true; race.timeElapsed = 0; if (playRandomColorCoroutine != null) { StopCoroutine(playRandomColorCoroutine); } } else { race.lapTimes.Add(race.lapTime); } if (race.currentLap > race.maxLaps) // End { race.isRacing = false; race.currentLap = 0; CheckLeaderBoard(); playRandomColorCoroutine = StartCoroutine(PlayRandomColor()); return; } if (race.currentLap == race.maxLaps) { Log(race.currentLap == race.maxLaps ? "FINAL LAP !!!" : "LAP #" + race.currentLap); PlaySound(finalLapAudio); } else { Log(race.currentLap == race.maxLaps ? "FINAL LAP !!!" : "LAP #" + race.currentLap); } race.lapTime = 0; } nextCheckPointIndex = (nextCheckPointIndex + 1) % currentLevel.checkPoints.Length; nextCheckPoint = currentLevel.checkPoints[nextCheckPointIndex]; nextCheckPoint.gameObject.SetActive(true); if (nextCheckPointIndex == 0) { if (race.currentLap == race.maxLaps) { nextCheckPoint.ChangeText("FINISH"); } else { nextCheckPoint.ChangeText("LAP " + (race.currentLap + 1)); } } else { nextCheckPoint.ChangeText("LAP " + race.currentLap + "." + nextCheckPointIndex); } hub.color = color; color = GetRandomColor(); nextCheckPoint.ChangeColor(color); } }
public void Awake() { instance = this; }
//初始化 private void Start() { m_checkPointController = new CheckPointController(); StartCoroutine(CheckChallengeState()); //开始协程安排闯关状态 }
void Start() { controller = GameObject.FindGameObjectWithTag("Player").GetComponent<CheckPointController>(); }
private void Awake() { instance = this; }
private void Start() { checkPointController = FindObjectOfType <CheckPointController>(); hasBeenActivated = !((GameManager.instance.GetCurrentCheckPoint()) < int.Parse(this.gameObject.name.Substring(this.gameObject.name.Length - 1))); }