Пример #1
0
 public bool Add(Item item)
 {
     animator.SetBool("Start", true);
     if (items.Count >= space)
     {
         return(false);
     }
     items.Add(item);
     if (item.name == "Gun" || item.name == "Machine gun" || item.name == "RocketLauncher")
     {
         if (item.name == "Gun" || item.name == "Machine gun")
         {
             Soundmanager.PlaySound("pickupgun");
         }
         selectobject = item.name;
         shoot        = true;
         imageArmeUI.GetComponent <Image>().sprite = item.icon;
         var tempcolor = imageArmeUI.GetComponent <Image>().color;
         tempcolor.a = 255f;
         imageArmeUI.GetComponent <Image>().color = tempcolor;
     }
     if (onItemChangedCallback != null)
     {
         onItemChangedCallback.Invoke();
     }
     return(true);
 }
Пример #2
0
 void Attack()
 {
     Soundmanager.PlaySound("Attack"); // Sound
     animator.SetTrigger("Attack");    // Animation
     // Detect the enemies
     // Damage to them
 }
Пример #3
0
    public void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
        bgmAudioSource = gameObject.AddComponent <AudioSource>();
        seAudioSource  = gameObject.AddComponent <AudioSource>();
        bgm            = Resources.LoadAll <AudioClip>("Audio/BGM");
        se             = Resources.LoadAll <AudioClip>("Audio/SE");
        for (int i = 0; i < bgm.Length; i++)
        {
            bgmIndex.Add(bgm[i].name, i);
        }
        for (int i = 0; i < se.Length; i++)
        {
            seIndex.Add(se[i].name, i);
        }
    }
Пример #4
0
    private float anxietyVolume; //volume della musica di anxiety

    void Awake()
    {
        if (instance != null) { 
            Destroy(gameObject);
        } else {  
            DontDestroyOnLoad(gameObject);
            instance = this;
        }
    }
Пример #5
0
 public void EndGame()
 {
     if (gameHasEnded == false)
     {
         text.SetActive(true);
         gameHasEnded = true;
         Soundmanager.PlaySound("rocketshot");
         Invoke("Restart", restartDelay);
     }
 }
Пример #6
0
 // Use this for initialization
 void Start()
 {
     //owner = GameObject.FindGameObjectWithTag ("Enemy").GetComponent<EnemyStatistics> ();
     startLocation = transform.position;
     distance = travelDistance + 0.25f * owner.Dexterity;
     sounds = GameObject.FindGameObjectWithTag("Sound Manager").GetComponent<Soundmanager>();
     float degrees = transform.rotation.eulerAngles.y + 90.0f;
     float radians = degrees * (Mathf.PI / 180.0f);
     direction = new Vector3 (-Mathf.Cos (radians), Mathf.Sin (radians), 0.0f);
 }
Пример #7
0
 void Update()
 {
     if (hit == true)
     {
         Soundmanager.PlaySound("rocketshot");
         explosion = (GameObject)Instantiate(ExplosionPrefab, ExplosionPoint.position, ExplosionPoint.rotation);
         Destroy(explosion.gameObject, t);
         Destroy(gameObject);
     }
 }
Пример #8
0
 public void touchingUp()
 {
     if (!gamemanager.isgameover)
     {
         playerparticle.Play();
         Rb.AddForce(Vector2.up * force);
         anim.SetTrigger("jump");
         Soundmanager.PlaySound("jump");
     }
 }
    public void Load(string scenename)
    {
        Soundmanager s = FindObjectOfType <Soundmanager>();

        if (s != null)
        {
            s.PlaySeByName(StaticStrings.EnterSoundEffect);
        }

        StartCoroutine(loadGameCo());
    }
 void Awake()
 {
     if (Instance)
     {
         DestroyImmediate(this);
     }
     else
     {
         Instance = this;
         DontDestroyOnLoad(this);
     }
 }
 void Start()
 {
     soundmanager = FindObjectOfType <Soundmanager>();
     if (soundmanager != null)
     {
         soundmanager.PlayBgmByName(StaticStrings.MenuBGM);
     }
     anim = GetComponent <Animator>();
     anim.SetTrigger(StaticStrings.walking);
     introcubepos = new Vector3(introCube.transform.position.x, transform.position.y, introCube.transform.position.z);
     init();
 }
Пример #12
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(this.gameObject);
 }
Пример #13
0
    private void Fire()
    {
        switch (selectobject)
        {
        case "Machine gun":
            animator.SetBool("IsShooting", false);
            gunImage.SetActive(false);
            animator.SetBool("IsShootingMg", true);
            machinegunImage.SetActive(true);
            animator.SetBool("IsShootingRl", false);
            RocketImage.SetActive(false);
            if (Input.GetButton("Fire1") && mitraillette.Ammo > 0)
            {
                mitraillette.Bullet = (GameObject)Instantiate(mitraillette.BulletPrefab, firePoint.position, firePoint.rotation);
                Destroy(mitraillette.Bullet, mitraillette.BulletLife);
                mitraillette.Ammo -= 1;
                Soundmanager.PlaySound("gunshot");
            }
            break;

        case "Gun":
            animator.SetBool("IsShooting", true);
            gunImage.SetActive(true);
            animator.SetBool("IsShootingMg", false);
            machinegunImage.SetActive(false);
            animator.SetBool("IsShootingRl", false);
            RocketImage.SetActive(false);
            if (Input.GetButtonDown("Fire1") && pistolet.Ammo > 0)
            {
                Soundmanager.PlaySound("gunshot");
                pistolet.Bullet = (GameObject)Instantiate(pistolet.BulletPrefab, firePoint.position, firePoint.rotation);
                Destroy(pistolet.Bullet, pistolet.BulletLife);
                pistolet.Ammo -= 1;
            }
            break;

        case "RocketLauncher":
            animator.SetBool("IsShooting", false);
            gunImage.SetActive(false);
            animator.SetBool("IsShootingMg", false);
            machinegunImage.SetActive(false);
            animator.SetBool("IsShootingRl", true);
            RocketImage.SetActive(true);
            if (Input.GetButtonDown("Fire1") && bazouka.Ammo > 0)
            {
                bazouka.Bullet = (GameObject)Instantiate(bazouka.BulletPrefab, firePoint.position, firePoint.rotation);
                Destroy(bazouka.Bullet, bazouka.BulletLife);
                bazouka.Ammo -= 1;
            }
            break;
        }
    }
Пример #14
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Box"))
     {
         Destroy(this.gameObject);
     }
     if (collision.gameObject.CompareTag("Player"))
     {
         Destroy(this.gameObject);
         gamemanager.coinpoint += 1;
         Soundmanager.PlaySound("coin");
     }
 }
Пример #15
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Box"))
        {
            gamemanager.GameOver();

            Soundmanager.PlaySound("hurt");
        }
        if (collision.gameObject.CompareTag("envedge"))
        {
            dust.Play();
        }
    }
Пример #16
0
    // Use this for initialization
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(instance);
        }

        DontDestroyOnLoad(gameObject);
    }
Пример #17
0
        /// <summary>
        /// Spawns a Missile directly at the players current position
        /// </summary>
        /// <param name="player"></param>
        public void SpawnMissile(Player player)
        {
            _missiles.Clear();
            if (_lastMissile.AddSeconds(0.3) < DateTime.Now)
            {
                string imagePath = @"../../Resources/Images/laser.png";
                Soundmanager.PlayShotSound();
                var missileSpawn = new Coords((player.Coords.X + (player.Image.ActualWidth / 2)), player.Coords.Y);
                var missile      = new Missile(imagePath, missileSpawn);

                _missiles.Add(missile);
                _lastMissile = DateTime.Now;
                this.ObjectsSpawned?.Invoke(_missiles);
            }
        }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }

        AudioSource theSource = GetComponent <AudioSource>();

        soundEffectAudio = theSource;
    }
Пример #19
0
 // Use this for initialization
 void Start()
 {
     soundmanager = this;
     backgrod     = gameObject.transform.FindChild("backgroud").gameObject;
     police       = gameObject.transform.FindChild("police").gameObject;
     slide        = gameObject.transform.FindChild("slide").gameObject;
     coin         = gameObject.transform.FindChild("coin").gameObject;
     rung         = gameObject.transform.FindChild("rung").gameObject;
     Getitem      = gameObject.transform.FindChild("Getitem").gameObject;
     UIclick      = gameObject.transform.FindChild("Uiclick").gameObject;
     PlayAgian    = gameObject.transform.FindChild("PlayAgian").gameObject;
     newhighscore = gameObject.transform.FindChild("newhighscore").gameObject;
     itemmax      = gameObject.transform.FindChild("maxspeed").gameObject;
     xe           = gameObject.transform.FindChild("xe").gameObject;
     backgrod.GetComponent <AudioSource>().Pause();
 }
Пример #20
0
 // Update is called once per frame
 void Update()
 {
     if (!gamemanager.isgameover)
     {
         if (Input.GetKeyDown(KeyCode.Space))
         {
             playerparticle.Play();
             Rb.AddForce(Vector2.up * force);
             anim.SetTrigger("jump");
             Soundmanager.PlaySound("jump");
         }
         if (Input.GetKey(KeyCode.S))
         {
             Rb.AddForce(Vector2.down * force1);
         }
     }
 }
    public void activeGame()
    {
        spawner = FindObjectOfType <PancakeSpawner>();

        Clock clock = FindObjectOfType <Clock>();

        clock.GaneStart = true;
        Camera.main.gameObject.SetActive(false);
        gameObject.SetActive(false);
        Soundmanager sm = FindObjectOfType <Soundmanager>();

        if (sm != null)
        {
            sm.StopBgm();
            sm.PlayBgmByName(StaticStrings.BattleSceneBGM);
        }
        spawner.startGame();
    }
Пример #22
0
    // Use this for initialization
    void Start()
    {
        // This is a singleton that makes sure you only
        // ever have one Sound Manager
        // If there is any other Sound Manager created destroy it
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }

        AudioSource theSource = GetComponent <AudioSource>();

        soundEffectAudio = theSource;
    }
Пример #23
0
    void Update()
    {
        // Jumping
        vertical = rb.velocity.y;
        if (isGrounded())
        {
            vertical = 0;
            animator.SetBool("isJumping", false);
            extraJumpValue = extraJumps;
        }

        animator.SetFloat("Vertical", vertical);
        // End of jumping
        animator.SetBool("isJumping", !isGrounded());
        if (Input.GetKeyDown(KeyCode.W) && extraJumpValue > 0)
        {
            Soundmanager.PlaySound("Jump");
            rb.velocity     = Vector2.up * jumpforce;
            extraJumpValue -= 1;
        }
    }
Пример #24
0
 public void ChangeScreen(Type screen, Type from = null)
 {
     if (screen == typeof(IntroViewModel))
     {
         Soundmanager.PlayMainMenuTheme(true);
         this.ActivateItem(this.Items.Single(s => s is IntroViewModel));
     }
     if (screen == typeof(MainMenuViewModel) && from != null && from == typeof(IntroViewModel))
     {
         this.ActivateItem(this.Items.Single(s => s is MainMenuViewModel));
     }
     else if (screen == typeof(MainMenuViewModel))
     {
         Soundmanager.PlayInGameTheme(false);
         this.ActivateItem(this.Items.Single(s => s is MainMenuViewModel));
         Soundmanager.PlayMainMenuTheme(true);
     }
     if (screen == typeof(PlayViewModel))
     {
         Soundmanager.PlayMainMenuTheme(false);
         this.ActivateItem(this.Items.Single(s => s is PlayViewModel));
         Soundmanager.PlayInGameTheme(true);
     }
 }
Пример #25
0
 void Death()
 {
     Soundmanager.PlaySound("Death");
     animator.SetTrigger("Death");
 }
Пример #26
0
    // Use this for initialization
    void Start()
    {
        sound = GameObject.FindGameObjectWithTag("Sound Manager").GetComponent<Soundmanager>();
        gameObject.GetComponent<Renderer>().material.color = Color.red;
        gameObject.GetComponent<Rigidbody> ().maxAngularVelocity = Speed;
        player = gameObject.GetComponent<PlayerStatistics> ();

        //bullet.tag = "Player Bullet";										// Tags bullets created by player as a player bullet.
    }
Пример #27
0
 void Start()
 {
     sounds = GameObject.FindGameObjectWithTag("Sound Manager").GetComponent<Soundmanager>();
 }
Пример #28
0
        private void AnimateObjects(object sender, EventArgs e)
        {
            if (!this.Canvas.IsFocused)
            {
                this.Canvas.Focus();
            }

            // Handles Input for the player
            this._inputHandler.ApplyInput();

            if (_currentWave >= maxWave)
            {
                _spawnAllowed = false;
            }

            if (_spawnAllowed && _nextSpawn <= DateTime.Now)
            {
                var enemies = _spawner.SpawnEnemies(this.CurrentQuestion);
                _objects.AddRange(enemies);
                _enemies.AddRange(enemies);
                _nextSpawn = DateTime.Now.AddSeconds(spawnInterval);
                this.CurrentWave++;
            }
            if (!_spawnAllowed && _enemies.Count <= 0)
            {
                this.CurrentWave     = 0;
                this.CurrentQuestion = _spawner.GetQuestion();
                Soundmanager.PlayNewQuestion();
                // Ends the game once the maximum question counter is reached
                if (this.CurrentQuestion == null)
                {
                    var result = MessageBox.Show("Die Invasion ist zu Ende!\n" +
                                                 "Die Aldebaranische Flotte ist geschlagen!\n" +
                                                 $"Deine Punkte: {this.Points}", "Gratulation", MessageBoxButton.OK);
                    if (result.Equals(MessageBoxResult.OK))
                    {
                        this.EndGame();
                    }
                }
                this.QuestionCounter++;
                _nextSpawn    = DateTime.Now.AddSeconds(questionStartTime);
                _spawnAllowed = true;
            }

            foreach (var item in _objects)
            {
                item.Animate(_timer.Interval, this.Canvas);

                if (item.ReachedEnd)
                {
                    _objectsToBeDeleted.Add(item);

                    if (item.GetType() != typeof(Enemy))
                    {
                        continue;
                    }

                    var ship = item as Enemy;
                    if (ship?.GetType() == typeof(Enemy) &&
                        !ship.AlienName.Equals(this.CurrentQuestion?.CorrectAnswer.Alien))
                    {
                        this.Points -= enemyEscapePenalty;
                    }
                }
            }

            foreach (var enemy in _objects.OfType <Enemy>())
            {
                foreach (var missile in _objects.OfType <Missile>())
                {
                    if (!enemy.IntersectsWith(missile.Coords.X, missile.Coords.Y, enemy.Image, missile.Image))
                    {
                        continue;
                    }

                    if (enemy.AlienName.Equals(this.CurrentQuestion?.CorrectAnswer.Alien))
                    {
                        Soundmanager.PlayFriendlyExplosion();
                        _objectsToBeDeleted.Add(enemy);
                        _enemies.Remove(enemy);
                        _objectsToBeDeleted.Add(missile);
                        this.Message = "That was a friendly ship!";
                        this.Points -= friendlyFirePenalty;
                    }
                    else
                    {
                        Soundmanager.PlayEnemyExplosion();
                        _objectsToBeDeleted.Add(enemy);
                        _enemies.Remove(enemy);
                        _objectsToBeDeleted.Add(missile);
                        this.Message = "Good hit!";
                        this.Points++;
                    }
                }
            }
            _objectsToBeDeleted.ForEach(obj => _objects.Remove(obj));

            var eny = _objectsToBeDeleted.Where(obj => obj.GetType() == typeof(Enemy)).ToList();

            eny.ForEach(obj => _enemies.Remove(obj));

            _objectsToBeDeleted.Clear();

            this.Canvas.Children.Clear();
            _objects.ForEach(item => item.Draw(this.Canvas));
        }
Пример #29
0
 void Awake()
 {
     Instance = this;
 }