Exemple #1
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        print(other.tag);
        if (other.CompareTag("Explosion"))
        {
            killPlayer();
        }
        else if (other.CompareTag("PowerUp"))
        {
            PowerupController puc = other.GetComponent <PowerupController> ();
            switch (puc.powerType)
            {
            case PowerupController.PowerType.BOMB:
                bombNbr++;
                break;

            case PowerupController.PowerType.POWER:
                power++;
                break;

            case PowerupController.PowerType.SPEED:
                speed += 1.0f;
                break;
            }
            puc.DestroyGo();
        }
    }
Exemple #2
0
    public static void Create(GameObject prefab, Vector3 position, PowerType powerType)
    {
        GameObject        powerup    = Instantiate(prefab, position, Quaternion.identity);
        PowerupController controller = powerup.GetComponent <PowerupController> ();

        controller.powerType = powerType;
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        //Get normalized direction vector and move the player
        direction = new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0f);
        direction.Normalize();
        transform.position += direction * moveSpeed * Time.deltaTime;


        if (Input.GetButtonDown("Fire1"))
        {
            gameObject.GetComponent <Weapon>().Fire();
        }

        if (Input.GetButtonDown("Fire2"))
        {
            enemy.SetActive(true);
            enemy.transform.position = new Vector3(0, 5, 0);
        }

        if (Input.GetButtonDown("Jump"))
        {
            var powerup = PowerupController.GetAvailble();
            powerup.gameObject.SetActive(true);
            powerup.transform.position = new Vector3(Random.Range(-10, 10), 10, 0);
        }
    }
Exemple #4
0
    public void OnTriggerEnter(Collider other)
    {
        //variable to store other object's PowerupController - if it has one
        PowerupController powCon = other.gameObject.GetComponent <PowerupController>();

        //If the other object has a PowerupController
        if (powCon != null)
        {
            //Add the powerup
            powCon.Add(powerup);

            //Play feedback(if it is set)
            if (feedback != null)
            {
                if (!PlayerPrefs.HasKey(soundEffectsVolumeKey))
                {
                    PlayerPrefs.SetFloat(soundEffectsVolumeKey, defaultSoundEffectsVolume);
                }

                float volume = Mathf.Clamp(PlayerPrefs.GetFloat(soundEffectsVolumeKey), 0.0f, 1.0f);
                AudioSource.PlayClipAtPoint(feedback, tf.position, volume);
            }

            //Destroy this pickup
            Destroy(gameObject);
        }
    }
    void SpawnPowerup(PowerupController powerup, Vector3 worldPosition)
    {
        var obj = powerupPool.GetObject(powerup);

        obj.transform.position = worldPosition;
        obj.Activate();
    }
    // Update is called once per frame
    void LateUpdate()
    {
        powerupController = player.pawn.powerupController;
        currentHealth     = player.pawn.currentHealth;
        maxHealth         = player.pawn.maxHealth;

        healthBar.fillAmount = (float)currentHealth / (float)maxHealth;

        //Prevent errors if there is no powerup controller
        if (powerupController == null)
        {
            Debug.LogWarning("Missing PowerupController!");
            return;
        }


        if (powerupController.activePowerups[PickupType.Shield] != null)
        {
            if (powerupController.shieldPowerup.currentHealth <= 0 || powerupController.shieldPowerup.duration <= 0)
            {
                shieldHealthBarBackground.gameObject.SetActive(false);
            }
            else
            {
                shieldHealthBar.fillAmount = (float)powerupController.shieldPowerup.currentHealth / (float)powerupController.shieldPowerup.maxHealth;
                shieldHealthBarBackground.gameObject.SetActive(true);
            }
        }
        else
        {
            shieldHealthBarBackground.gameObject.SetActive(false);
        }
    }
 // Use this for initialization
 void Start()
 {
     if (powCon == null)
     {
         powCon = gameObject.GetComponent <PowerupController>();
     }
 }
Exemple #8
0
    void Start()
    {
        player   = FindObjectOfType <PlayerController> ();
        powerups = FindObjectOfType <PowerupController> ();
        string loadString = null;

        loadString = PlayerPrefs.GetString("SaveString");
        if (loadString == null || loadString == "")
        {
            print("No existing save");
            SaveStats();
        }
        else
        {
            string[] saveArray = loadString.Split(',');
            if (saveArray.Length != 8)
            {
                print("Save in incorrect format");
                SaveStats();
                return;
            }
            print(loadString);
            totalCoins                  = System.Int32.Parse(saveArray [0]);
            highScore                   = System.Int32.Parse(saveArray [1]);
            adsDisabled                 = bool.Parse(saveArray [2]);
            powerups.magnetAmount       = System.Int32.Parse(saveArray [3]);
            powerups.magnetUpgradeLevel = System.Int32.Parse(saveArray [4]);
            powerups.ghostAmount        = System.Int32.Parse(saveArray [5]);
            powerups.ghostUpgradeLevel  = System.Int32.Parse(saveArray [6]);
            SaveStats();
        }
    }
Exemple #9
0
 void Start()
 {
     controller        = GetComponent <Controller2D>();
     powerupController = GetComponent <PowerupController>();
     ball           = GameObject.FindGameObjectWithTag("Ball").GetComponent <Rigidbody2D>();
     raycastOrigins = new RaycastOrigins();
     seeker         = GetComponent <Seeker>();
 }
Exemple #10
0
 // Use this for initialization
 void Start()
 {
     controller        = GetComponent <Controller2D>();
     powerupController = GetComponent <PowerupController>();
     horizontal       += player.ToString();
     vertical         += player.ToString();
     driveOne         += player.ToString();
     driveTwo         += player.ToString();
 }
Exemple #11
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Powerup")
     {
         powerupControllerScr = other.gameObject.GetComponent <PowerupController>();
         powerupControllerScr.PowerupVisuals(powerupTime);
         PowerupCheck();
     }
 }
Exemple #12
0
    // On collision with a powerup, add it
    void OnTriggerEnter(Collider other)
    {
        PowerupController powerup = other.gameObject.GetComponent <PowerupController>();

        if (powerup != null)
        {
            ActivatePowerup(powerup.type);
            powerup.Pickup(gameObject);
        }
    }
 private IEnumerator SpawnPowerUp()
 {
     while (true)
     {
         int               index         = UnityEngine.Random.Range(0, powerUpPrefabs.Length);
         Vector2           spawnPosition = ScreenBounds.RandomTopPosition();
         PowerupController powerUp       = Instantiate(powerUpPrefabs[index], spawnPosition, Quaternion.identity);
         yield return(new WaitForSeconds(UnityEngine.Random.Range(currentLevel.powerUpMinimumWait, currentLevel.powerUpMaximumWait)));
     }
 }
 //initialise scripts into variables
 void Start()
 {
     dead                    = false;
     playerController        = GameObject.FindObjectOfType <PlayerController>();
     powerupController       = GameObject.FindObjectOfType <PowerupController> ();
     enemyController         = gameObject.GetComponent <EnemyController> ();
     sideEnemyController     = gameObject.GetComponent <SideEnemyController> ();
     particleEnemyController = gameObject.GetComponent <ParticleEnemyController> ();
     missileSeek             = gameObject.GetComponent <MissileSeek> ();
 }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        PowerupController powerupController = collision.gameObject.GetComponent <PowerupController>();

        if (powerupController != null)
        {
            powerupController.Apply(m_CurrentEffect);
            Expire();
        }
    }
    private void OnParticleCollision(GameObject other)
    {
        PowerupController powerupController = other.GetComponentInParent <PowerupController>();

        if (powerupController != null)
        {
            powerupController.Apply(m_ShootEffect);
            Expire();
        }
    }
Exemple #17
0
    void OnTriggerEnter(Collider other)
    {
        PowerupController powCon = other.GetComponent <PowerupController>();

        // if the other object has a PowerupController
        if (powCon != null)
        {
            HasSpawned = false;
        }
    }
Exemple #18
0
    private void Awake()
    {
        instance = this;
        player   = GameObject.Find("Player");


        // Hiding Powerup Progress Icons

        // Vacuum
        coinMagnetCollider         = PowerupVacuumCollider.GetComponent <ColliderTrigger>();
        coinMagnetCollider.OnEnter = new ColliderTrigger.OnEnterDelegate(this.onCoinEnter);



        // Setup Powerups
        if (powerUps.Count <= 0)
        {
            // Letter
            PowerUp letter = new PowerUp();
            letter.powerUpType = powerUpTypes.Letter;
            letter.minSpawn    = 0;
            letter.maxSpawn    = 3;
            letter.spawnAt     = UnityEngine.Random.Range(letter.minSpawn, letter.maxSpawn);
            powerUps.Add(letter);

            // Fruit
            PowerUp fruit = new PowerUp();
            fruit.powerUpType = powerUpTypes.Fruit;
            fruit.minSpawn    = 0;
            fruit.maxSpawn    = 3;
            fruit.spawnAt     = UnityEngine.Random.Range(fruit.minSpawn, fruit.maxSpawn);
            powerUps.Add(fruit);

            // Vacuum
            PowerUp vacuum = new PowerUp();
            vacuum.powerUpType = powerUpTypes.Vacuum;
            vacuum.duration    = 10;
            vacuum.minSpawn    = 0;
            vacuum.maxSpawn    = 5;
            vacuum.spawnAt     = UnityEngine.Random.Range(vacuum.minSpawn, vacuum.maxSpawn);
            powerUps.Add(vacuum);

            // Bomb
            PowerUp bomb = new PowerUp();
            bomb.powerUpType = powerUpTypes.Bomb;
            bomb.duration    = 10;
            bomb.minSpawn    = 0;
            bomb.maxSpawn    = 1;
            bomb.spawnAt     = UnityEngine.Random.Range(bomb.minSpawn, bomb.maxSpawn);
            powerUps.Add(bomb);
        }

        initWords();
    }
Exemple #19
0
    // Start is called before the first frame update
    void Start()
    {
        obj        = this.transform;
        controller = GameObject.FindWithTag("powerupcontroller");
        power      = controller.GetComponent <PowerupController>();

        if (Random.value < /*0.01*/ 0.1)//Chance of powerup spawning
        {
            power.SpawnPowerup(power.powerups[Random.Range(0, 3)], obj.position);
        }
    }
Exemple #20
0
 void StartDestruction()
 {
     planet.Asteroids--;
     GetComponent <Collider2D>().enabled = false;
     GetComponent <Animator>().SetTrigger("Explode");
     if (Powerups != null && Powerups.Count > 0)
     {
         PowerupController prefab = Powerups[Random.Range(0, Powerups.Count)];
         GameObject        o      = (GameObject)GameObject.Instantiate(prefab.gameObject);
         o.transform.position = transform.position;
     }
 }
    private void Awake()
    {
        rb                = GetComponent <Rigidbody>();
        stats             = GetComponent <EntityStats>();
        powerupController = GetComponent <PowerupController>();

        RaceManager.Instance.OnRaceStart += StartRace;

        MaxRbSpeed = maxSpeedMagnitude * 40;

        CreateMovementVector();
    }
Exemple #22
0
    /// <summary>
    /// Returns true if the powerup is beyond DESPAWN_DISTANCE_MAX in any direction.
    /// </summary>
    private bool PowerupIsTooFar(PowerupController powerup)
    {
        var relativeDistanceToPlayer = GameManager.Instance.PlayerShip.GetRelativeDistance(
            powerup.transform.position, true
            );

        return(
            relativeDistanceToPlayer.x >= DESPAWN_DISTANCE_MAX ||
            relativeDistanceToPlayer.y >= DESPAWN_DISTANCE_MAX ||
            relativeDistanceToPlayer.z >= DESPAWN_DISTANCE_MAX
            );
    }
 // Collide with powerup
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Powerup")
     {
         // Apply Powerup
         PowerupController pc = other.gameObject.GetComponent <PowerupController>();
         powerup = (Powerup)pc.powerup;
         StartCoroutine("Cooldown");
         // Destroy the powerup
         Destroy(other.gameObject);
     }
 }
Exemple #24
0
    private void Awake()
    {
        agent             = GetComponent <NavMeshAgent>();
        stats             = GetComponent <EntityStats>();
        powerupController = GetComponent <PowerupController>();

        normalSpeed  = agent.speed;
        boostedSpeed = agent.speed * boostMultiplier;

        GetCheckpoints();

        RaceManager.Instance.OnRaceStart += MatchStart;
    }
Exemple #25
0
    private void OnTriggerEnter(Collider other)
    {
        PowerupController pc = other.gameObject.GetComponent <PowerupController>();

        if (pc == null)
        {
            return;
        }

        pc.RandomizePowerup();
        StartCoroutine(RespawnCoroutine());
        DeactivateObject();
    }
Exemple #26
0
    void Start()
    {
        GameObject powerupControllerObject = GameObject.FindGameObjectWithTag("PowerUpController");

        if (powerupControllerObject != null)
        {
            powerupController = powerupControllerObject.GetComponent <PowerupController>();
        }
        if (powerupController == null)
        {
            Debug.Log("Cannot find 'PowerupController' script");
        }
    }
Exemple #27
0
    public void OnTriggerEnter(Collider other)
    {
        PowerupController powerupController = other.GetComponentInParent <PowerupController>();

        if (powerupController == null)
        {
            return;
        }

        Transform tf = other.GetComponent <Transform>();

        //Transform tf = other.gameObject.GetComponentInParent<Transform>() == null ? other.gameObject.GetComponent<Transform>() : other.gameObject.GetComponentInParent<Transform>();


        switch (pickupType)
        {
        case PickupType.Speed:
            if (speedPowerup.audio != null)
            {
                AudioSource.PlayClipAtPoint(speedPowerup.audio, tf.position, PlayerPrefs.GetFloat("SFXVolume", 1));
            }
            powerupController.Add(speedPowerup);
            break;

        case PickupType.FireRate:
            if (fireRatePowerup.audio != null)
            {
                AudioSource.PlayClipAtPoint(fireRatePowerup.audio, tf.position, PlayerPrefs.GetFloat("SFXVolume", 1));
            }
            powerupController.Add(fireRatePowerup);
            break;

        case PickupType.Health:
            if (healPowerup.audio != null)
            {
                AudioSource.PlayClipAtPoint(healPowerup.audio, tf.position, PlayerPrefs.GetFloat("SFXVolume", 1));
            }
            powerupController.Add(healPowerup);
            break;

        case PickupType.Shield:
            if (shieldPowerup.audio != null)
            {
                AudioSource.PlayClipAtPoint(shieldPowerup.audio, tf.position, PlayerPrefs.GetFloat("SFXVolume", 1));
            }
            powerupController.Add(shieldPowerup);
            break;
        }

        Destroy(gameObject);
    }
Exemple #28
0
    public void OnTriggerEnter(Collider other)
    {
        PowerupController powCon = other.GetComponent <PowerupController>();

        if (powCon != null)
        {
            powCon.Add(powerup);
            if (feedback != null)
            {
                AudioSource.PlayClipAtPoint(feedback, tf.position, 1.0f);
            }
            Destroy(gameObject);
        }
    }
Exemple #29
0
    private void Awake()
    {
        // Singleton
        instance = this;


        // Begin
        Application.targetFrameRate = 60;

        highScorePanel.SetActive(false);

        // First Start Defaulu Settings
        if (PlayerPrefs.GetInt("firstStart", 0) == 0)
        {
            PlayerPrefs.SetInt("firstStart", 1);
            PlayerPrefs.SetInt("rate_complete", 0);
            PlayerPrefs.SetInt("rate_peak", 16);

            PlayerPrefs.SetInt("audio", 1);
            PlayerPrefs.SetInt("highscore", 0);
            PlayerPrefs.SetInt("ads_unitypeak", 5);
            PlayerPrefs.SetInt("ads_chartboostpeak", 0);
        }


        // Assing Bending Values
        Shader.SetGlobalFloat("_V_CW_X_Bend_Size", bendingX);
        Shader.SetGlobalFloat("_V_CW_Y_Bend_Size", bendingY);
        Shader.SetGlobalFloat("_V_CW_Z_Bend_Size", 0);
        Shader.SetGlobalFloat("_V_CW_Z_Bend_Bias", 0);
        Shader.SetGlobalFloat("_V_CW_Camera_Bend_Offset", 0);



        player           = GameObject.Find("Player");
        playerController = GameObject.Find("playerController");

        controller      = GetComponent <Controller>();
        audioController = GetComponent <AudioController>();

        mainCamera      = GameObject.Find("Main Camera").GetComponent <Camera>();
        cameraFovEffetc = GameObject.Find("Main Camera").GetComponent <TweenFOV>();

        cameraController = GetComponent <CameraController>();

        trackGenerator    = GetComponent <TrackGenerator>();
        achievements      = GetComponent <Achievements>();
        powerupController = GetComponent <PowerupController>();
        touchController   = GetComponent <TouchController>();
    }
Exemple #30
0
    void OnTriggerEnter(Collider c)
    {
        PowerupController pc = c.gameObject.GetComponent <PowerupController> ();

        if (pc != null)
        {
            switch (pc.powerupType)
            {
            case PowerupController.PowerupType.ExtraLife:
                Debug.Log("You Powered up!!!!!!!!!!!!!!!!!!");
                GameManager.instance.lives++;
                Destroy(pc.gameObject);
                sound.clip = extraCheeseSFX;
                sound.Play();
                break;

            case PowerupController.PowerupType.SpeedBall:
                Debug.Log("SPEEEEEEED");
                PaddleController.instance.speed = 15;
                Destroy(pc.gameObject);
                sound.clip = peppersSFX;
                sound.Play();
                break;

            case PowerupController.PowerupType.SlowBall:
                Debug.Log("SLOOOOOOOOW");
                PaddleController.instance.speed = 5;
                Destroy(pc.gameObject);
                sound.clip = anchoviesSFX;
                sound.Play();
                break;

            case PowerupController.PowerupType.BigPaddle:
                //PaddleController.instance.transform.localScale = new Vector3 (3.0f, 1.0f, 1.0f);
                paddleSize.localScale = new Vector3(10.0f, 1.0f, 1.0f);
                sound.clip            = extraLargeSFX;
                sound.Play();
                Destroy(pc.gameObject);
                StartCoroutine(ResetPaddleSize());
                break;

            default:
                Debug.LogWarning("DEFAULT");
                GameManager.instance.lives++;
                Destroy(pc.gameObject);
                break;
            }
        }
    }
Exemple #31
0
        public override void LoadContent()
        {
            ContentManager content = ScreenManager.Game.Content;

            map = content.Load<Map>("map");
            MapGeneration.Generate(map);

            camera = new Camera(ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight, map);

            //camera.Zoom = 0.5f;

            text = content.Load<Texture2D>("titles");

            hud = new HUD(content.Load<Texture2D>("hud"));

            waterLevel = ScreenManager.Game.RenderHeight;
            waterParallax = new Parallax(content.Load<Texture2D>("abovewater-parallax"), 12, 0.5f, waterLevel, (map.TileWidth * map.Width), new Viewport(0, 0, ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight), false, true);
            underwaterBGParallax = new Parallax(content.Load<Texture2D>("underwater-bg"), 4, 1f, waterLevel + 20, (map.TileWidth * map.Width), new Viewport(0, 0, ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight), true, false);
            skyBGParallax = new Parallax(content.Load<Texture2D>("sky-bg"), 72, 1f, 70, (map.TileWidth * map.Width), new Viewport(0, 0, ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight), false, false);
            rocksParallax = new Parallax(content.Load<Texture2D>("seabed-rocks"), 16, 0.35f, (map.TileHeight*map.Height) -15, (map.TileWidth * map.Width), new Viewport(0, 0, ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight), false, false);
            cloudsParallax = new Parallax(content.Load<Texture2D>("clouds"), 16, 0.35f, 25, (map.TileWidth * map.Width), new Viewport(0, 0, ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight), false, false, true);

            playerShip = new Ship(content.Load<Texture2D>("playership"), new Rectangle(0,0,10,10), null, Vector2.Zero);
            playerShip.Position = new Vector2(64, 190);

            particleController.LoadContent(content);

            projectileController = new ProjectileController(1000, sheet => new Projectile(sheet, new Rectangle(0, 0, 4, 4), null, new Vector2(0, 0)) , content.Load<Texture2D>("projectiles"));
            enemyController = new EnemyController(content.Load<Texture2D>("enemies"), content.Load<Texture2D>("boss"));
            powerupController = new PowerupController(1000,sheet => new Powerup(sheet, new Rectangle(0, 0, 6, 6), null, Vector2.Zero),content.Load<Texture2D>("powerup"));

            powerupController.BoxCollidesWith.Add(playerShip);
            projectileController.BoxCollidesWith.Add(playerShip);
            projectileController.BoxCollidesWith.Add(enemyController);
            projectileController.BoxCollidesWith.Add(projectileController);
            enemyController.BoxCollidesWith.Add(playerShip);
            enemyController.BoxCollidesWith.Add(projectileController);

            GameController.Reset();

            //enemyController.SpawnInitial(GameController.Wave, map);

            base.LoadContent();
        }