示例#1
0
 void Awake()
 {
     fuel           = GetComponent <FuelController> ();
     movement       = GetComponent <SpaceShipMovement> ();
     useOfMinAndMax = GetComponent <Life> ();
     hud            = transform.GetComponentInChildren <Canvas> ();
 }
示例#2
0
 void Awake()
 {
     fuel              = GetComponent <FuelController> ();
     movement          = GetComponent <SpaceShipMovement> ();
     spaceshipRenderer = GetComponent <Renderer> ();
     hud = transform.GetComponentInChildren <Canvas> ();
 }
示例#3
0
    void Start()
    {
        // Turn off scripts we don't want for any players in the scene
        List <GameObject> players = new List <GameObject> (GameObject.FindGameObjectsWithTag("Player"));

        foreach (GameObject player in players)
        {
            FireShots         playerFireShots = player.GetComponent <FireShots> ();
            Rigidbody2D       playerRB        = player.GetComponent <Rigidbody2D> ();
            SpaceShipMovement playerMovement  = player.GetComponent <SpaceShipMovement> ();

            if (playerFireShots)
            {
                playerFireShots.enabled = false;
            }

            if (playerRB)
            {
                playerRB.Sleep();
            }

            if (playerMovement)
            {
                playerMovement.enabled = false;
            }
        }
    }
示例#4
0
    // This is what we call when hit "Play" from the UI
    public void StartGame()
    {
        // Hide the start UI
        infoPanel.SetActive(false);

        // Turn on scripts we don't want for any players in the scene
        List <GameObject> players = new List <GameObject> (GameObject.FindGameObjectsWithTag("Player"));

        foreach (GameObject player in players)
        {
            FireShots         playerFireShots = player.GetComponent <FireShots> ();
            Rigidbody2D       playerRB        = player.GetComponent <Rigidbody2D> ();
            SpaceShipMovement playerMovement  = player.GetComponent <SpaceShipMovement> ();
            if (playerFireShots)
            {
                playerFireShots.enabled = true;
            }

            if (playerRB)
            {
                playerRB.WakeUp();
            }

            if (playerMovement)
            {
                playerMovement.enabled = true;
            }
        }
        GameState.currentState = GameState.AvailableStates.Playing;
    }
示例#5
0
 public void processCloneSpaceShipDeath(SpaceShipMovement inDeadSpaceShipMovement, bool inDeathCausedByPlayer)
 {
     if (inDeathCausedByPlayer)
     {
         var theReplayController = inDeadSpaceShipMovement.GetComponent <SpaceShipActionsReplayController>();
         _replayForClones.Remove(theReplayController.replay);
     }
     Destroy(inDeadSpaceShipMovement.gameObject);
 }
示例#6
0
    public void processPlayerSpaceShipDeath(SpaceShipMovement inDeadSpaceShipMovement)
    {
        SpaceShipActionsReplay theReplayOfDeadPlayer = inDeadSpaceShipMovement.GetComponent <SpaceShipPlayerController>().stopRecordingAndGetReplay();

        _replayForClones.Add(theReplayOfDeadPlayer);

        _gameplayManager.EndIteration(false);
        // inDeadSpaceShipMovement.gameObject.SetActive(false);
    }
示例#7
0
    void GenerateHazzard()
    {
        int        prefabIndex = Random.Range(0, hazzardsPool.Length);
        GameObject newHazzard  = Instantiate(hazzardsPool[prefabIndex]) as GameObject;

        SpaceShipMovement spaceShip = playerTransform.GetComponent <SpaceShipMovement>();

        newHazzard.transform.position = new Vector3(spaceShip.currentRail.x, playerTransform.position.y, playerTransform.position.z + spawnDistance);
        newHazzard.SetActive(true);
    }
示例#8
0
    void Start()
    {
        target           = GameManager.instance.player;
        targetController = target.GetComponent <SpaceShipMovement>();



        rb       = GetComponent <Rigidbody2D>();
        targetRb = target.GetComponent <Rigidbody2D>();
        if (hud != null)
        {
            hudInstance = GameObject.Instantiate(hud, Camera.main.transform);
            hudInstance.transform.parent = Camera.main.transform;
            hudInstance.GetComponent <HUDController>().target = this.transform;
        }
    }
示例#9
0
    void Start()
    {
        activated = new Dictionary <ShipMovement, bool>();
        foreach (ShipMovement direction in activateOn)
        {
            activated.Add(direction, false);
        }
        currentSprite = 0;
        s             = this.GetComponent <SpriteRenderer>();
        ssm           = this.GetComponentInParent <SpaceShipMovement>();

        superFlameScale  = this.transform.localScale * 2;
        normalFlameScale = this.transform.localScale;
        s.sprite         = this.sprites[0];
        this.enabled     = true;
    }
示例#10
0
    void Start()
    {
        audioSource = GetComponent <AudioSource>();
        target      = GameObject.FindGameObjectWithTag("Player");
        controller  = GetComponent <SpaceShipMovement>();
        targetRb    = target.GetComponent <Rigidbody2D>();
        rb          = GetComponent <Rigidbody2D>();
        SpawnHUD();
        state = AIState.Seeking;

        if (hud != null)
        {
            hudInstance = GameObject.Instantiate(hud, Camera.main.transform);
            hudInstance.transform.parent = Camera.main.transform;
            hudInstance.GetComponent <HUDController>().target = this.transform;
        }
    }
示例#11
0
    void DisableComponents()
    {
        // Disable everything until sound has played
        PlayerSounds      pS   = gameObject.GetComponent <PlayerSounds> ();
        FireShots         fS   = gameObject.GetComponent <FireShots> ();
        SpaceShipMovement sS   = gameObject.GetComponent <SpaceShipMovement> ();
        Rigidbody2D       rb   = gameObject.GetComponent <Rigidbody2D> ();
        Collider2D        coll = gameObject.GetComponent <Collider2D> ();

        fS.enabled   = false;
        sS.enabled   = false;
        coll.enabled = false;
        rb.Sleep();

        foreach (Transform child in transform)
        {
            child.gameObject.SetActive(false);
        }

        pS.gunSource.Stop();
        pS.thrustersSource.Stop();
    }
示例#12
0
    // Called when the player dies
    public void End()
    {
        // We instantiate lots of players for tiling, we need to  turn scripts off
        List <GameObject> players = new List <GameObject> (GameObject.FindGameObjectsWithTag("Player"));

        foreach (GameObject player in players)
        {
            FireShots         playerFireShots = player.GetComponent <FireShots> ();
            Rigidbody2D       playerRB        = player.GetComponent <Rigidbody2D> ();
            SpaceShipMovement playerMovement  = player.GetComponent <SpaceShipMovement> ();

            if (playerFireShots)
            {
                playerFireShots.enabled = false;
            }

            if (playerRB)
            {
                playerRB.Sleep();
            }

            if (playerMovement)
            {
                playerMovement.enabled = false;
            }
        }

        // Did we get a new high score?
        if (scoreCtrl.newHighScore && scoreCtrl.currentScore > 0)
        {
            highScoreNotification.SetActive(true);
        }

        //Show the end UI
        endPanel.SetActive(true);
        // Prevent opening the pause menu, etc
        GameState.currentState = GameState.AvailableStates.Ended;
    }
示例#13
0
    public void spawnRocket(SpaceShipMovement inShooterSpaceShipMovement)
    {
        if (inShooterSpaceShipMovement.gameObject.name == "Spaceship")
        {
            if (_gameplayManager.CurBulletCount == 0)
            {
                return;
            }
            _gameplayManager.CurBulletCount--;
        }
        var theNewRocket = Instantiate(_rocketPrefab);

        _audioSource.PlayOneShot(_audioClip);
        if (isInverted())
        {
            theNewRocket.makeInverted();
        }
        Debug.Log($"Set speed - {inShooterSpaceShipMovement.FrontSpeedUnitsPerSecond}");
        theNewRocket.setSpeed(inShooterSpaceShipMovement.FrontSpeedUnitsPerSecond);
        theNewRocket.transform.position = _spawnPoint.position;
        theNewRocket.setIsShootedByPlayer(inShooterSpaceShipMovement.GetComponent <SpaceShipPlayerController>());
        iterationController.activeBulletsOnScene.Add(theNewRocket.gameObject);
    }
示例#14
0
    // Disable OR enable things on pause or unpause
    void SetComponentStats(bool state = true)
    {
        pausePanel.SetActive(!state);
        // If we're pausing, clear the rigidbody's dictionary so we can store all the latest velocities for un-pausing
        if (!state)
        {
            previousVelocities = new Dictionary <Rigidbody2D, Vector2> ();
        }
        objectsToDisable = new List <GameObject> (GameObject.FindGameObjectsWithTag("Asteroid"));
        objectsToDisable.AddRange(GameObject.FindGameObjectsWithTag("IncomingAsteroid"));
        foreach (GameObject asteroid in objectsToDisable)
        {
            rb               = asteroid.GetComponent <Rigidbody2D> ();
            coll             = asteroid.GetComponent <Collider2D> ();
            asteroidScript   = asteroid.GetComponent <Asteroid> ();
            incomingAsteroid = asteroid.GetComponent <IncomingAsteroid> ();
            if (rb)
            {
                if (state == true)
                {
                    rb.WakeUp();
                    if (previousVelocities.ContainsKey(rb))
                    {
                        rb.velocity = previousVelocities [rb];
                    }
                }
                else
                {
                    previousVelocities [rb] = rb.velocity;
                    rb.Sleep();
                }
            }
            if (coll)
            {
                coll.enabled = state;
            }

            if (asteroidScript)
            {
                asteroidScript.enabled = state;
            }

            if (incomingAsteroid)
            {
                incomingAsteroid.enabled = state;
            }
        }

        // TODO: could be cached as players should always be visible
        objectsToDisable = new List <GameObject> (GameObject.FindGameObjectsWithTag("Player"));

        foreach (GameObject player in objectsToDisable)
        {
            rb             = player.GetComponent <Rigidbody2D> ();
            coll           = player.GetComponent <Collider2D> ();
            fireShotScript = player.GetComponent <FireShots> ();
            moveScript     = player.GetComponent <SpaceShipMovement> ();
            if (rb)
            {
                if (state == true)
                {
                    rb.WakeUp();
                    if (previousVelocities.ContainsKey(rb))
                    {
                        rb.velocity = previousVelocities [rb];
                    }
                }
                else
                {
                    previousVelocities [rb] = rb.velocity;
                    rb.Sleep();
                }
            }
            if (coll)
            {
                coll.enabled = state;
            }

            if (fireShotScript)
            {
                fireShotScript.enabled = state;
            }

            if (moveScript)
            {
                moveScript.enabled = state;
            }
        }

        objectsToDisable = new List <GameObject> (GameObject.FindGameObjectsWithTag("Laser"));
        foreach (GameObject laser in objectsToDisable)
        {
            rb   = laser.GetComponent <Rigidbody2D> ();
            coll = laser.GetComponent <Collider2D> ();
            if (rb)
            {
                if (state == true)
                {
                    rb.WakeUp();
                    if (previousVelocities.ContainsKey(rb))
                    {
                        rb.velocity = previousVelocities [rb];
                    }
                }
                else
                {
                    previousVelocities [rb] = rb.velocity;
                    rb.Sleep();
                }
            }
            if (coll)
            {
                coll.enabled = state;
            }
        }
    }