Inheritance: MonoBehaviour
コード例 #1
0
ファイル: Level.cs プロジェクト: yvog/SuperPlatformer
        /// <summary>
        /// Load entities.
        /// </summary>
        private void LoadEntities()
        {
            _entities = new List <Entity>();

            // Set the current time to the given level duration
            CurrentTime = _loader.GetTotalTime();

            // Initialize blocks
            List <Entity> blocks = _loader.InitializeBlocks();

            blocks.ForEach(AddEntity);

            // Initialize coins
            List <Entity> coins = _loader.InitializeCoins();

            coins.ForEach(AddEntity);

            // Initialize the enemies
            List <Entity> enemies = _loader.InitializeEnemies();

            enemies.ForEach(AddEntity);

            // Add the finish line
            FinishLine finishLine = _loader.GetFinishLine();

            _entities.Add(finishLine);

            // Listen to finishLine's on closed event
            finishLine.OnClosed += OnFinished;

            _entities.Add(Player);
        }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        FinishLine FL = GameObject.FindObjectOfType <FinishLine>();

        if (FL)
        {
            if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began && bRaceStarted && FL.bRaceEnded)
            {
                OnClickStartBtn();
            }
        }

        if (bRaceStarted)
        {
            RaceManager RaceGuru = GameObject.FindObjectOfType <RaceManager>();

            if (RaceGuru)
            {
                int PlayerSp  = (int)(RaceGuru.PlayerCar.GetComponent <CarController>().CurrentSpeed);
                int OponentSp = (int)(RaceGuru.OponentCar.GetComponent <CarController>().CurrentSpeed);
                PlayerSpeedText.SetText(PlayerSp.ToString() + "MPH");
                OponentSpeedText.SetText(OponentSp.ToString() + "MPH");
            }
        }
    }
コード例 #3
0
    void Start()
    {
        if (maxHealthPoints == 0)
        {
            maxHealthPoints = 5;
        }
        healthPoints = maxHealthPoints;

        finishLineHealthText.text = maxHealthPoints.ToString();

        //If the timer hasn't been set on the inspector, or it's 0, make it 1
        if (healthRemovalTimerOriginal == 0)
        {
            healthRemovalTimerOriginal = 1;
        }

        //We make the timer we use equal to the starting timer we set so we can start playing with it
        healthRemovalTimer = healthRemovalTimerOriginal;

        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Debug.Log("You have 2 finish lines, is this intended?");
        }
    }
コード例 #4
0
    public void GenerateLevel()
    {
        if (mode == Mode.regular)
        {
            lanesToSpawn = levels[lvlToSpawn];
            lvlToSpawn++;
        }
        int emptyLanes = chanceToNotSpawnLane / 100 * posibleLanes.Length;

        for (int i = 0; i < lanesToSpawn; i++)
        {
            int rand = UnityEngine.Random.Range(0, posibleLanes.Length + emptyLanes);

            if (rand < posibleLanes.Length)
            {
                nextLaneToSpawn = posibleLanes[rand];
            }
            else
            {
                nextLaneToSpawn = null;
            }
            if (nextLaneToSpawn)
            {
                Instantiate(nextLaneToSpawn, new Vector3(0, i * laneHeight + yOffsetToSpawnLane), Quaternion.identity);
            }
        }
        PassStageCosntrains();
        FinishLine finish = Instantiate(finishLine, new Vector3(0, lanesToSpawn * laneHeight + yOffsetToSpawnFinish, 0), Quaternion.identity);

        finish.OnFinishLine = OnEndOfLevel;
    }
コード例 #5
0
ファイル: finishLine.cs プロジェクト: JackieG19/finishLineCS
 public static void Main()
 {
   FinishLine game = new FinishLine(1, "Player 1");
   game.DisplayBoard();
   game.player1.markers[0].Move(5, 10, game.deck);
   game.DisplayBoard();
 }
コード例 #6
0
 // Use this for initialization
 void Start()
 {
     //if null at start, try to find one.
     if (finishLine == null)
     {
         finishLine = FindObjectOfType <FinishLine>();
     }
 }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        timerText = GameObject.Find("TimerText").GetComponent<Text>();
        finishLine = GameObject.Find("FinishLine").GetComponent<FinishLine>();

        timer = timerLimit;
        SetTimerText();
    }
コード例 #8
0
ファイル: PlayerCollision.cs プロジェクト: Icarrius/PlanetJam
 private void Finish(FinishLine finishLine)
 {
     if (finishLine)
     {
         finishLine.PlayAnimation(transform.position);
     }
     FlashEffect.singleton.FlashScreen();
     Manager.singleton.WinHandling();
 }
コード例 #9
0
ファイル: LevelManager.cs プロジェクト: dogabeey/Chick-Rescue
    // Start is called before the first frame update
    void Start()
    {
        pc    = FindObjectOfType <PlayerController>();
        fl    = FindObjectOfType <FinishLine>();
        stats = FindObjectOfType <PlayerStats>();


        FinishTime = float.PositiveInfinity;
    }
コード例 #10
0
ファイル: Character.cs プロジェクト: UnManuel/Cars
    // TO-DO: Use velocity to prevent lap miscount
    public void LapCheck(FinishLine finish)
    {
        ++lapCount;

        if (OnLapComplete != null)
        {
            OnLapComplete.Invoke();
        }
    }
コード例 #11
0
ファイル: GameController.cs プロジェクト: cadel560x/MAD3
    // Update is called once per frame
    //void Update () {

    //   }

    //private void FixedUpdate()
    //{
    //if ( player.transform.position.y <= -4)
    //{
    // Out to GameController
    //if (Lives.lives > 1)
    //{
    //    Time.timeScale = 0;
    //    Lives.lives -= 1;
    // player.transform.position = startingPoint.transform.position;
    //RestartScene();
    //}
    //else
    //{
    // Game over
    //Time.timeScale = 0;
    //player.gameObject.SetActive(false);
    //health.gameObject.SetActive(false);
    //lives.gameObject.SetActive(false);

    //gameOver.gameObject.SetActive(true);
    //restartButton.gameObject.SetActive(true);

    //}
    //}
    //}

    public void LevelCompleted()
    {
        Time.timeScale = 0;
        inplayUIController.LevelCompleted();
        scoreScript.Score *= (int)timeLeft.timeLeft;
        FinishLine finishLine = FindObjectOfType <FinishLine>();

        finishLine.GetComponent <NextLevel>().enabled = true;

        // SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
コード例 #12
0
ファイル: FinishLine.cs プロジェクト: Arckrys/Social-Rythme
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #13
0
    public static void Main()
    {
        FinishLine game = new FinishLine(1, "Player 1");

        /*Console.WriteLine("Player 1's {0} marker is at {1}",game.player1.markers[1].name, game.player1.markers[1].position);
         * Console.WriteLine("First card is {0}",game.deck.cards[0].Display());
         * Console.WriteLine("Last card is {0}",game.deck.cards[53].Display());
         * Console.WriteLine("Red die is {0}", game.redDie.val);
         * Console.WriteLine("Black die is {0}", game.blackDie.val);*/
        //game.DisplayBoard();
        //Console.WriteLine();
        game.CheckEdgeCards();
        game.DisplayBoard();
    }
コード例 #14
0
ファイル: Airplane.cs プロジェクト: AresMartial/AirplaneGame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         engenOn = true;
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         Cursor.visible = true;
         FinishLine.LoadNextScene();
         engenOn = false;
         landed  = false;
     }
 }
コード例 #15
0
 void Awake()
 {
     if (SceneManager.GetActiveScene().name == "Level02")
     {
         finishLine = new Vector3(4.5f, 0.1f, -19.5f);
     }
     else
     {
         finishLine = new Vector3(4.5f, 0.1f, -18.5f);
     }
     gameObject.transform.position = finishLine;
     F.transform.position          = finishLine;
     instance = this;
 }
コード例 #16
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            _background = Content.Load <Texture2D>("background");

            Road.LoadContent(Content, _graphics);
            FinishLine.LoadContent(Content, _graphics);

            _agentFactory.LoadContent(Content);
            _courseObjectFactory.LoadContent(Content);
            _playerFactory.LoadContent(Content);
            _dashboard.LoadContent(Content);
            // TEMP
            InitializeModel();

            _viewportManager.SetViewports(_players);
        }
コード例 #17
0
    public void Start(PhotonView targetView, string rpcCallback)
    {
        // Initialize ui
        ui.Start();

        // Create a new list
        ranking = new List <Player>();

        // Assign local variables
        this.targetView  = targetView;
        this.rpcCallback = rpcCallback;

        // Get the finish line and subscribe to the event raised when a racer finished
        finishLine = GameObject.FindGameObjectWithTag(finishLineTag).GetComponentInChildren <FinishLine>();
        finishLine.onRacerFinished.AddListener(BroadcastRacerFinished);
    }
コード例 #18
0
ファイル: GameController.cs プロジェクト: burly87/HorseRace
    // --- Observe ---
    private void FinishLine_OnEnterFinishLine(FinishLine obj)
    {
        // Stop any clickable/ Thread
        inputController.ClickAble = false;
        // Stop autoplay
        isAutoplay = false;
        //disable autoplayButton
        uiController.DisableButtons();

        // set winner to winning horsename
        string winner = obj.HorseName;

        ChooseWinner(winner[0]);                            // No functionality yet

        // tell UI to show winner
        uiController.ShowWinningText(winner[0]);
    }
コード例 #19
0
    public void StartGhostingPlayerLaps()
    {
        FinishLine finish = GameObject.FindGameObjectWithTag("FinishLine").GetComponent <FinishLine>();

        finish.lapComplete -= StartGhostingPlayerLaps;

        isGhosting = true;
        ghostCar   = Instantiate(ghostCar);
        rb         = ghostCar.GetComponent <Rigidbody>();
        ghostLap   = 0;
        pos        = 0;

        GhostTrackData data = savedTrackData.lap.Count > 0 ? savedTrackData : trackData;

        rb.MovePosition(data.lap[0].LapPositions[0]);
        rb.MoveRotation(data.lap[0].lapRotations[0]);
    }
コード例 #20
0
    //Private call to the PlayerUIManager to update UI with correct placement

    // Start is called before the first frame update
    public void Start(PhotonView targetView, string rpcCallback)
    {
        // Create a new list and add players to that list
        ranking = new List <Player>();
        foreach (Player p in PhotonNetwork.PlayerList)
        {
            ranking.Add(p);
        }

        // Assign local variables
        this.targetView  = targetView;
        this.rpcCallback = rpcCallback;

        // Get the finish line and position of the finish line
        finishLine         = GameObject.FindGameObjectWithTag(finishLineTag).GetComponentInChildren <FinishLine>();
        finishLinePosition = finishLine.transform.position;
    }
コード例 #21
0
ファイル: CarGame.cs プロジェクト: csombok/autonomous
        public void InitializeModel()
        {
            _road       = new Road();
            _finishline = new FinishLine()
            {
                Y = _length
            };
            _players     = _playerFactory.LoadPlayers(_gameStateManager).ToList();
            _gameObjects = new List <GameObject>(_players)
            {
                _road, _finishline
            };
            _gameObjects.AddRange(_courseObjectFactory.GenerateCourseArea());
            _gameObjects.AddRange(_agentFactory.GenerateInitialCarAgents(_agentDensity));
            _gameObjects.ForEach(go => go.Initialize());

            InitializeCommands();
        }
コード例 #22
0
    private void Start()
    {
        GameObject go = GameObject.FindGameObjectWithTag("FinishLine");

        if (go != null)
        {
            FinishLine finish = GameObject.FindGameObjectWithTag("FinishLine").GetComponent <FinishLine>();
            if (finish != null)
            {
                finish.lapComplete += StartGhostingPlayerLaps;
            }
        }

        trackData.name = GameManager.instance.raceInfo.selectedTrack.name;
        trackData.lap  = new List <GhostLapData>();
        for (int i = 0; i < GameManager.instance.raceInfo.numberOfLaps; i++)
        {
            trackData.lap.Add(new GhostLapData());
        }
    }
コード例 #23
0
    void Start()
    {
        scoreModel = null;
        try
        {
            playerNameInput.characterLimit = 12;
            scoreController = gameObject.GetComponent <ScoreController>();
        }
        catch (Exception)
        {
        }

        finishLine  = GameObject.FindObjectOfType(typeof(FinishLine)) as FinishLine;
        playerLives = GameObject.FindObjectOfType(typeof(PlayerLives)) as PlayerLives;
        pauseButton = Resources.LoadAll <AudioClip>("Audio/PauseSound");
        buttons     = GetComponent <AudioSource>();
        levelSelect = SceneManager.GetActiveScene().buildIndex;
        pausePanel.SetActive(false);
        prefs = PlayerPrefs.GetInt("LevelPassed");
    }
コード例 #24
0
ファイル: GenerateLevel.cs プロジェクト: oreoFOR/Snowman_Skis
 private void Start()
 {
     for (int i = 0; i < snowManNum; i++)
     {
         currentMan = Instantiate(snowmen[type], pos.position, pos.rotation).transform;
         float   xRand    = Random.Range(-horizontalDist, horizontalDist);
         float   zrand    = Random.Range(minMaxDist.x, minMaxDist.y);
         Vector3 offset   = new Vector3(xRand, 0, 0);
         Vector3 position = new Vector3(Mathf.Clamp(pos.position.x + offset.x, edges.x, edges.y), pos.position.y, pos.position.z);
         currentMan.position = position + pos.forward * zrand;
         GenerateTrigger(pos.position, currentMan.position);
         GenerateFever(pos.position, currentMan.position);
         pos.position = currentMan.position;
         type         = type == 1 ? 0 : 1;
         if (i == snowManNum - 1)
         {
             FinishLine finihsLine = Instantiate(finishLine, currentMan.position, Quaternion.identity).GetComponent <FinishLine>();
             finihsLine.manager = gameManager;
         }
     }
 }
コード例 #25
0
    void Update()
    {
        //if we've reached the level bottom by breaking through the gates
        if (player != null && player.position.y < lowestPoint && !done)
        {
            done = true;

            camMovement.yOffset = 2;

            gameOver.SetTrigger("Show");

            //show diamond count and save the new diamonds
            int score = manager.GetScore();
            gameOverDiamonds.text = "+" + score;
            PlayerPrefs.SetInt("Diamonds", PlayerPrefs.GetInt("Diamonds") + score);

            diamondsAnim.SetTrigger("Show");

            //unlock next level
            PlayerPrefs.SetInt("Level", PlayerPrefs.GetInt("Level") + 1);

            //show confetti
            FinishLine finish = GameObject.FindObjectOfType <FinishLine>();
            StartCoroutine(finish.Confetti());

            //disable the game panel and play some sound
            manager.gameOver = true;
            manager.gamePanel.SetBool("Show", false);
            manager.win.Play();

            //if the powerup was active, deactivate it
            Player  player  = GameObject.FindObjectOfType <Player>();
            Powerup powerup = GameObject.FindObjectOfType <Powerup>();

            if (player.bullet)
            {
                powerup.DisableBullet();
            }
        }
    }
コード例 #26
0
        private void Awake()
        {
            instance = this;
            controls = new Controls();
            if (designingLevel)
            {
                controls.LevelDesign.Enable();
            }
            else
            {
                controls.Player.Enable();
            }

            nPlayers = 0;

            if (!designingLevel)
            {
                loseText.enabled = false;
                winText.enabled  = false;
            }
            designLevelButton.SetActive(showDesignLevelButton);

            finishLine = GetComponent <FinishLine>();
        }
コード例 #27
0
    // Update is called once per frame
    void Update()
    {
        if (gmObject == null)
        {
            gmObject    = GameObject.Find("GameManager");
            buildButton = GameObject.Find("BuildButtonText").GetComponent <BuildButtonPress>();
            sendButton  = GameObject.Find("SendButtonText").GetComponent <SendButtonPress>();
        }
        else if (gm == null)
        {
            gm = gmObject.GetComponent <GameManager>();
        }

        if (myID == "" || myID == "Player(Clone)")
        {
            myID = myPN.playerUniqueIdentity;
            Debug.Log(myID);
        }
        else if (mySpawner == null)
        {
            if (gm != null)
            {
                int myIdx = gm.MyPlayerIndex(myID);

                if (myIdx == -1)
                {
                    Debug.Log("My index is not found yet");
                }
                else
                {
                    if (myIdx == 1)
                    {
                        Debug.Log("Set Spawner");
                        mySpawner    = GameObject.Find("EnemySpawn2").GetComponent <SpawnUnit>();
                        enemySpawner = GameObject.Find("EnemySpawn1").GetComponent <SpawnUnit>();
                        myFinish     = GameObject.Find("FinishLine1").GetComponent <FinishLine> ();
                        enemyFinish  = GameObject.Find("FinishLine2").GetComponent <FinishLine> ();
                    }
                    else if (myIdx == 0)
                    {
                        Debug.Log("Set Spawner");
                        mySpawner    = GameObject.Find("EnemySpawn1").GetComponent <SpawnUnit>();
                        enemySpawner = GameObject.Find("EnemySpawn2").GetComponent <SpawnUnit>();
                        myFinish     = GameObject.Find("FinishLine2").GetComponent <FinishLine> ();
                        enemyFinish  = GameObject.Find("FinishLine1").GetComponent <FinishLine> ();
                    }
                }
            }
        }

        if (mySpawnID.IsEmpty())
        {
            if (mySpawner != null)
            {
                Debug.Log("Set Spawn ID");
                mySpawnID = mySpawner.GetComponent <NetworkIdentity> ().netId;

                mySpawner.sendPlayer = gameObject;

                enemySpawner.attackPlayer = gameObject;

                myFinish.SetPlayerToHurt(gameObject, myID);
                myFinish.SetMyPlayer(myID);
                enemyFinish.setOtherPlayer(gameObject, myID);
            }
        }

        if (!isLocalPlayer)
        {
            return;
        }
        else if (gm != null)
        {
            if (gm.gameRunning)
            {
                if (cursorReset == true)
                {
                    cursorReset = false;
                }
                CheckButtons();                  //Checks if any buttons are pressed
            }
            else
            {
                if (cursorReset == false)
                {
                    cursorReset = true;
                    Cursor.SetCursor(normalCursor, hotSpot, CursorMode.Auto);
                    Cursor.visible = true;
                }
            }
        }
    }
コード例 #28
0
ファイル: FinishLine.cs プロジェクト: Fosmanthux/Ice-Chimes
 void Awake()
 {
     instance = this;
 }
コード例 #29
0
        public static void Main(string[] args)
        {
            var game = new FinishLine(2, new string[] { "Cliff", "Joe" });

            game.PlayGame();
        }
コード例 #30
0
 void Awake()
 {
     instance    = this;
     pointScript = GameObject.FindGameObjectWithTag("Points").GetComponent <Points>();
 }
コード例 #31
0
 private void Awake()
 {
     instance = this;
     gameObject.SetActive(false);
 }