コード例 #1
0
ファイル: Map.cs プロジェクト: HappyThreeFriends/HeroTactics
    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));
    }
コード例 #2
0
    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>();
    }
コード例 #3
0
    public void MoveHeroesTo(CheckPointController other)
    {
        foreach (var selectedHero in _selectedHeroes)
        {
            selectedHero.MoveTo(other);
        }

        Heroes = Heroes.Except(_selectedHeroes).ToList();
        _selectedHeroes.Clear();
    }
コード例 #4
0
    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);
    }
コード例 #5
0
 void Awake()
 {
     if (cc == null)
     {
         DontDestroyOnLoad(gameObject);
         cc = this;
     }
     else if (cc != this)
     {
         Destroy(gameObject);
     }
 }
コード例 #6
0
    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 }
        });
    }
コード例 #7
0
    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);
        }
    }
コード例 #8
0
ファイル: RaceController.cs プロジェクト: ljonathanl/BallRace
    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();
    }
コード例 #9
0
    /*** 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");
    }
コード例 #10
0
 public void MoveTo(CheckPointController checkpoint)
 {
     this.transform.position = checkpoint.transform.position;
     CurrentCheckpoint       = checkpoint;
     CurrentCheckpoint.PlaceHero(this);
 }
コード例 #11
0
ファイル: CheckPoint.cs プロジェクト: udutra/Plataforma-2D
 private void Start()
 {
     checkPointController = FindObjectOfType <CheckPointController>();
 }
コード例 #12
0
ファイル: SpeedLapGUI.cs プロジェクト: jiangsyk/2DRacingGame
 void Start()
 {
     movement = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMovement>();
     checkPointC = GameObject.FindGameObjectWithTag("Player").GetComponent<CheckPointController>();
 }
コード例 #13
0
ファイル: RaceController.cs プロジェクト: ljonathanl/BallRace
    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);
        }
    }
コード例 #14
0
 public void Awake()
 {
     instance = this;
 }
コード例 #15
0
    //初始化
    private void Start()
    {
        m_checkPointController = new CheckPointController();

        StartCoroutine(CheckChallengeState());          //开始协程安排闯关状态
    }
コード例 #16
0
ファイル: CheckPoint.cs プロジェクト: jiangsyk/2DRacingGame
 void Start()
 {
     controller = GameObject.FindGameObjectWithTag("Player").GetComponent<CheckPointController>();
 }
コード例 #17
0
 private void Awake()
 {
     instance = this;
 }
コード例 #18
0
ファイル: CheckPoint.cs プロジェクト: Char-Mander/The-Curse
 private void Start()
 {
     checkPointController = FindObjectOfType <CheckPointController>();
     hasBeenActivated     = !((GameManager.instance.GetCurrentCheckPoint()) < int.Parse(this.gameObject.name.Substring(this.gameObject.name.Length - 1)));
 }