Exemplo n.º 1
0
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 2
0
    public void Hit(BombController bomb)
    {
        if (PoweredUpTime > 0 && !BombermanSettings.GetEvno(Arena).PowerDoNothing)
        {
            return;
        }

        if (PoweredUpTime > 0)
        {
            PowerDoNothingDeath++;
        }
        else
        {
            NoPowerDeath++;
        }
        //5 Debug.Log(string.Format("Had power: {0}, total: {1}", PowerDoNothingDeath, PowerDoNothingDeath + NoPowerDeath));


        if ((StandingOnLine(transform.localPosition.x) || StandingOnLine(transform.localPosition.z)) && BombermanSettings.GetEvno(Arena).CellLineProtection)
        {
            SavedByLine++;
            //Debug.Log(string.Format("Saved: {0}, Total: {1}", SavedByLine, SavedByLine + NotSavedByLine));
            return;
        }
        else
        {
            NotSavedByLine++;
            //Debug.Log(string.Format("Saved: {0}, Total: {1}", SavedByLine, SavedByLine + NotSavedByLine));
        }

        LastKilledBy = bomb;
        StateMachine.TransitionTo <PlayerDeadState>();
    }
Exemplo n.º 3
0
    void FixedUpdate()
    {
        if (fire)
        {
            fire = false;
            if (selectedBomb != null)
            {
                BombController bombController = selectedBomb.GetComponent <BombController>();

                Vector3 forceDirection = (transform.position + Vector3.up) - selectedBomb.transform.position;


                float force = bombController.SolveForce(forceDirection.magnitude);
                if (force > 0)
                {
                    bombController.Detonate();

                    forceDirection = forceDirection.normalized * force;

                    Vector3 oldvel = GetComponent <Rigidbody>().velocity;
                    if (bombController.nullifyFall && forceDirection.y > 10)
                    {
                        oldvel.y = 0;
                    }
                    oldvel += forceDirection;
                    GetComponent <Rigidbody>().velocity = oldvel;
                }
            }
        }
    }
Exemplo n.º 4
0
    private void OnTriggerEnter2D(Collider2D enemyColl)
    {
        Vector2 enemySideDistance = hitDistance;

        enemyHP          = enemyColl.gameObject.GetComponentInParent <EnemyHealthManager>();
        bossHP           = enemyColl.GetComponentInParent <BossPatrolManager>();
        bombHP           = enemyColl.GetComponent <BombController>();
        bulletController = enemyColl.GetComponent <BulletHit>();
        if (enemyHP != null)
        {
            if (enemyColl.transform.position.x < transform.position.x)
            {
                enemySideDistance.x *= -1;//is on ur right
            }
            else
            {
                enemySideDistance.x *= 1;//is on ur left
            }
            enemyHP.TakeDamage(damageToGive, knockbackDuration, enemySideDistance, hitStopDuration);
            if (shouldScreenshakeOnHit)
            {
                Screenshake();
            }
            if (player != null)
            {
                player.AddMeter(meterToGive);
            }
        }
        if (bombHP != null)
        {
            if (enemyColl.transform.position.x < transform.position.x)
            {
                enemySideDistance.x *= -1;//is on ur right
            }
            else
            {
                enemySideDistance.x *= 1;//is on ur left
            }
            bombHP.TakeDamage(damageToGive);
            //bombHP.DoStopAndKnockback(knockbackDuration, enemySideDistance, hitStopDuration);
            if (shouldScreenshakeOnHit)
            {
                Screenshake();
            }
        }

        if (bulletController != null)
        {
            bulletController.ReverseForce();
        }

        if (shouldHitStop)
        {
            player.DoHitStop(hitStopDuration);
        }
        if (hitSpark != null)
        {
            hitSpark.Play();
        }
    }
Exemplo n.º 5
0
        public override void OnActivate(PlayerController caster)
        {
            //Man lässt eine Bombe beim Spawner fallen, die bei Kollision nach x Sekunden explodiert, Blöcke zerstört und anderen Spielern schadet
            BombController bomb = GameObject.Instantiate(bombPrefab, new Vector3(caster.SpawnController.transform.position.x, 34, 0), Quaternion.identity, GameObject.Find("Gameplay/Items").transform).GetComponent <BombController>();

            bomb.Init(delay, radius);
        }
Exemplo n.º 6
0
  public void Hit(BombController bomb)
  {
      Arena.DestroyGameObject(this.gameObject);
      GameObject obj = Instantiate(PickUp, transform.position, Quaternion.identity, Arena.transform);

      Arena.RegisterGameObject(obj);
  }
Exemplo n.º 7
0
 public PlayerService(PlayerView playerPrefab, BombController bombPrefab, ServiceManager serviceManager)
 {
     this.serviceManager         = serviceManager;
     this.playerPrefab           = playerPrefab;
     this.bombPrefab             = bombPrefab;
     serviceManager.restartGame += RestartGame;
 }
    private void DropBomb()
    {
        owner.CurrentBombCD = 0;
        Vector3 cellPos      = new Vector3(Mathf.RoundToInt(transform.localPosition.x), Mathf.RoundToInt(transform.localPosition.y), Mathf.RoundToInt(transform.localPosition.z));
        Vector3 cellPosWorld = owner.Arena.transform.TransformPoint(cellPos);

        if (!Physics.CheckBox(cellPos, Vector3.one / 2.1f, Quaternion.identity, KickLayer) && owner.CurrentBombAmount > 0)
        {
            if (BombermanSettings.GetEvno(_owner.Arena).PlayerColliderIgnoredOnBombDrop)
            {
                IgnoreCollisionTime = BombermanSettings.GetEvno(_owner.Arena).PlayerColliderIgnoredOnBombDropTime;
            }

            BombController bomb = Instantiate(owner.Bomb, cellPosWorld, Quaternion.identity, owner.Arena.transform).GetComponent <BombController>();
            bomb.Arena = owner.Arena;
            owner.Arena.RegisterGameObject(bomb.gameObject);
            owner.CurrentBombAmount--;
            bomb.Placer = owner;
            bomb.Owner  = owner;
            bomb.Team   = owner.Team;
            StateMachine.GetState <PlayerCooldownState>().Setup(this, DropBombCooldownTime);
            StateMachine.TransitionTo <PlayerCooldownState>();
            BombermanSettings.OnBombSpawn(bomb);
        }
    }
Exemplo n.º 9
0
        private void SpawnBomb()
        {
            float rarityRatio = Random.Range(0f, 1f);
            float rarityIndex = 0;

            foreach (var pair in _bombsRarity)
            {
                if (pair.Key < rarityRatio && pair.Key > rarityIndex)
                {
                    rarityIndex = pair.Key;
                }
            }

            int        bombIndex  = _bombsRarity[rarityIndex];
            BombConfig bombConfig = _configStorage.Get <BombConfig>(bombIndex);
            Vector3    position   = new Vector3(Random.Range(_spawnArea.xMin, _spawnArea.xMax), 45,
                                                Random.Range(_spawnArea.yMin, _spawnArea.yMax));

            BombModel      bomb           = new BombModel(bombConfig, position, this);
            BombController bombController = _controllerFactor.Create(bomb);

            bombController.transform.SetParent(_container, true);
            _bombs[bomb] = bombController;

            if (MaxSCount < _bombs.Count)
            {
                MaxSCount = _bombs.Count;
            }
            Debug.Log($"{_bombs.Count}/{MaxSCount}");
        }
Exemplo n.º 10
0
    private void InitComponent(CharInfo info)
    {
        UIMng.Instance.Add(UIList.HUD);
        UIMng.Instance.Add(UIList.Inventory);
        UIMng.Instance.Add(UIList.ShowItem);
        UIMng.Instance.Add(UIList.GunUpgrade);
        UIMng.Instance.Add(UIList.ActionUI);

        UIMng.Instance.CallEvent(UIList.Mouse, "SetUp");

        _inventory        = FindObjectOfType <InventoryUI>();
        _playerController = GetComponent <PlayerController>();
        _gunController    = GetComponent <GunController>();
        _bombController   = GetComponent <BombController>();
        _status           = GetComponent <PlayerStatus>();
        _animator         = GetComponent <Animator>();
        _getItem          = GetComponent <GetItem>();

        _status.Init(info);
        _gunController.Init(info.STARTGUN);
        _playerController.Init();
        _bombController.Init();

        UIMng.Instance.Destroyer(UIList.Select, 1.0f);
        UIMng.Instance.CallEvent(UIList.HUD, "PlayerInfoChnage");
        CheckMng.Instance.Init();
    }
Exemplo n.º 11
0
 public void SetBombController(BombController bc)
 {
     if (bc != null)
     {
         bomb = bc;
     }
 }
Exemplo n.º 12
0
    void SpawnBombView(BombController controller)
    {
        var bombView = bombPool.Pick();

        bombView.SetUp(controller);
        bombs.Add(bombView);
    }
Exemplo n.º 13
0
    public void EndTurn()
    {
        // a bomb has hit the ground. need to explode remaining bombs
        // all the way up, stop the player and robber and bomb spawns, then restart
        // the level
        endingTurn = true;
        // stop the player movement
        player.StopMovement();

        // stop the robber movement
        robber.StopMoving();
        // stop bomb spawns
        levelLost = true;

        // explode bombs remaining, from bottom to top
        foreach (GameObject bomb in bombs)
        {
            BombController bombController = bomb.GetComponent <BombController>();
            bombController.StopMovement();
            bombController.Explode();
            audioSource.clip = explosionSound;
            audioSource.Play();
        }
        Debug.Log("Exploding all bombs");

        // wait for 1 second and give player their controls back
        StartCoroutine(ResumeGame());
    }
Exemplo n.º 14
0
    void Update()
    {
        if (hull <= 0)
        {
            Instantiate(explosionPrefab, gameObject.transform.position, Quaternion.identity);
            gameController.AddRequisition(requisition);
            Destroy(gameObject);
        }

        List <GameObject> targets = new List <GameObject>();

        targets.AddRange(GameObject.FindGameObjectsWithTag("Harvester"));
        targets.AddRange(GameObject.FindGameObjectsWithTag("SolarPanel"));
        targets.AddRange(GameObject.FindGameObjectsWithTag("EnergyLink"));
        targets.AddRange(GameObject.FindGameObjectsWithTag("LaserTurret"));
        targets.AddRange(GameObject.FindGameObjectsWithTag("Bomb"));
        if (targets.Count == 0)
        {
            targets.AddRange(GameObject.FindGameObjectsWithTag("ConstructionBox"));
        }

        if (targets.Count > 0)
        {
            GameObject nearest         = targets[0];
            float      nearestDistance = float.MaxValue;
            foreach (GameObject target in targets)
            {
                float distance = (target.transform.position - gameObject.transform.position).magnitude;
                if (distance < nearestDistance)
                {
                    nearestDistance = distance;
                    nearest         = target;
                }
            }

            Vector2 direction = (nearest.transform.position - gameObject.transform.position).normalized;
            gameObject.GetComponent <Rigidbody2D>().AddForce(direction * thrust);
            gameObject.GetComponent <Rigidbody2D>().rotation = -Mathf.Atan2(gameObject.GetComponent <Rigidbody2D>().velocity.x, gameObject.GetComponent <Rigidbody2D>().velocity.y) * 180 / Mathf.PI;

            if (gameObject.GetComponent <Rigidbody2D>().velocity.magnitude > velocity)
            {
                gameObject.GetComponent <Rigidbody2D>().velocity = gameObject.GetComponent <Rigidbody2D>().velocity.normalized *velocity;
            }
            if (nearestDistance < destroyDistance)
            {
                Instantiate(explosionPrefab, nearest.transform.position, Quaternion.identity);
                gameController.AddRequisition(requisition);
                BombController bomb = nearest.gameObject.GetComponent <BombController>();
                if (bomb != null)
                {
                    bomb.WillDestroy();
                }
                Destroy(nearest.gameObject);
            }
        }
        else
        {
            gameController.GameOver();
        }
    }
Exemplo n.º 15
0
    void Awake()
    {
        mPlayer = GetComponent <Player>();
        mPlayer.spawnCallback    += OnPlayerSpawn;
        mPlayer.setStateCallback += OnPlayerSetState;
        mPlayer.setBlinkCallback += OnPlayerBlink;

        mBody = GetComponentInChildren <PlatformerController>();

        mBody.player     = 0;
        mBody.moveInputX = InputAction.MoveX;
        mBody.moveInputY = InputAction.MoveY;
        mBody.jumpInput  = InputAction.Jump;

        mBody.jumpCallback          += OnBodyJump;
        mBody.collisionStayCallback += OnBodyCollisionStay;
        mBody.triggerEnterCallback  += OnBodyTriggerEnter;

        mBodySpriteCtrl = mBody.GetComponent <PlatformerSpriteController>();
        mBodySpriteCtrl.flipCallback            += OnFlipCallback;
        mBodySpriteCtrl.anim.AnimationCompleted += OnBodySpriteAnimFinish;

        mBombCtrl = bomb.GetComponent <BombController>();
        mBombCtrl.deathCallback += OnBombDeathCallback;

        mTargetGO = GameObject.FindGameObjectWithTag("Goal");
    }
    public void KickBomb(BombController bomb)
    {
        Transform other = bomb.Owner.Arena.Players.First(p => p != bomb.Owner).transform;
        float     dot   = Vector3.Dot(bomb.Owner.AimVector.normalized, (other.position - bomb.transform.position).normalized);

        bomb.Owner.PlayerAgent.AddReward(KickBombReward);// * dot);
    }
Exemplo n.º 17
0
    public void Shoot()
    {
        if (!canShoot || reloading)
        {
            return;
        }

        if (currentShoots < magazine.MagazineSize)
        {
            GetComponentInParent <PlayerController>().ShootShake();
            transform.GetChild(1).gameObject.SetActive(true);
            currentShoots++;
            var bullet = GameManager.singleton.bombPool.GetObject(transform.position + playerRb.transform.forward);

            BombController bomb = bullet.GetComponent <BombController>();

            bomb.Initialize(magazine.Shoot());
            var rb = bullet.GetComponent <Rigidbody>();
            rb.velocity = transform.GetChild(0).forward * 10f + playerRb.velocity;

            StartCoroutine(Cooldown());
        }
        else
        {
            canShoot = false;
        }
    }
Exemplo n.º 18
0
 public PlayerManager(Player playerPrefab, BombController bombPrefab, GameManager gameManager)
 {
     this.gameManager         = gameManager;
     this.playerPrefab        = playerPrefab;
     this.bombPrefab          = bombPrefab;
     gameManager.restartGame += RestartGame;
 }
Exemplo n.º 19
0
    // Update is called once per frame
    void Update()
    {
        if (fileOpen)
        {
            List <PlayerController> playerList = GetPlayerControllerList();
            for (int i = 0; i < playerList.Count; i++)
            {
                if (!playerList[i].Dead)
                {
                    GameObject[] bombs = GameObject.FindGameObjectsWithTag("Bomb");
                    Vector2      bombpos;
                    bombpos.x = 10000;
                    bombpos.y = 10000;
                    float dist = 1000000;
                    for (int z = 0; z < bombs.Length; z++)
                    {
                        BombController bomb = bombs[z].GetComponent <BombController>();
                        if (bomb._bombId != playerList[i]._playerId)
                        {
                            float aux = Vector2.Distance(playerList[i].transform.position, bombs[z].transform.position);
                            if (aux < dist)
                            {
                                dist    = aux;
                                bombpos = bombs[z].transform.position;
                            }
                        }
                    }

                    int j = (i + 1) % playerList.Count;
                    dist = 1000000;
                    for (int z = 0; z < playerList.Count; z++)
                    {
                        if (z != i)
                        {
                            float aux = Vector2.Distance(playerList[i].transform.position, playerList[z].transform.position);
                            if (aux < dist)
                            {
                                dist = aux;
                                j    = z;
                            }
                        }
                    }


                    fileDatosPosicion.WriteLine(playerList[i].transform.position.x.ToString() + " " + playerList[i].transform.position.y.ToString() + " " + playerList[i]._rigidbody.velocity.x.ToString() + " " + playerList[i]._rigidbody.velocity.y.ToString() + " " + playerList[j].transform.position.x.ToString() + " " + playerList[j].transform.position.y.ToString() + " " + playerList[j]._rigidbody.velocity.x.ToString() + " " + playerList[j]._rigidbody.velocity.y.ToString() + " " + bombpos.x.ToString() + " " + bombpos.y.ToString());
                    fileDatosDistancia.WriteLine(Mathf.Sign(playerList[i].transform.position.y).ToString() + " " + playerList[i]._rigidbody.velocity.x.ToString() + " " + playerList[i]._rigidbody.velocity.y.ToString() + " " + (playerList[i].transform.position.x - playerList[j].transform.position.x).ToString() + " " + (playerList[i].transform.position.y - playerList[j].transform.position.y).ToString() + " " + Mathf.Sign(playerList[j].transform.position.y).ToString() + " " + playerList[j]._rigidbody.velocity.x.ToString() + " " + playerList[j]._rigidbody.velocity.y.ToString() + " " + (playerList[i].transform.position.x - bombpos.x).ToString() + " " + (playerList[i].transform.position.y - bombpos.y).ToString());

                    float _yAxisValue = playerList[i]._player.GetAxis("Propulse");
                    float _xAxisValue = playerList[i]._player.GetAxis("HorizontalAxis");
                    bool  _attack     = playerList[i]._player.GetButtonDown("Attack");

                    string input = _yAxisValue.ToString() + " " + _xAxisValue.ToString() + " " + _attack.ToString();
                    fileDatosPosicion.WriteLine(input);
                    fileDatosDistancia.WriteLine(input);
                    // fileDatosImagen.WriteLine(input);
                }
            }
        }
    }
Exemplo n.º 20
0
    private void BombDrop()
    {
        bomb = Instantiate(bombPrefab, new Vector2(bombTarget.x, 20), new Quaternion());
        BombController jorgeBomb = bomb.GetComponent <BombController>();

        jorgeBomb.skill = this;
        jorgeBomb.enemy = skillManager.enemy;
    }
Exemplo n.º 21
0
    public void Init()
    {
        _controller   = GetComponent <BombController>();
        _lineRenderer = GetComponent <LineRenderer>();

        _start  = transform.Find(Path);
        gravity = Physics.gravity.y;
    }
Exemplo n.º 22
0
    private void CmdCreateBomb(float x, float z)
    {
        GameObject     bomb           = Game.AddObjectToMap(this.bombPrefab, new Vector3(x, 0.5f, z), ObjectType.Bomb);
        BombController bombController = bomb.GetComponent <BombController>();

        bombController.countOfExplosions = this.countOfExplosions;

        this.playersBomb.Add(bomb);
    }
Exemplo n.º 23
0
 public void DestroyBomb(BombController bombController)
 {
     gameState.bombList.RemoveAll(b => b == bombController.bomb);
     activeBomb.RemoveAll(b => b == bombController);
     if (OnBombDestroyed != null)
     {
         OnBombDestroyed(bombController);
     }
 }
Exemplo n.º 24
0
    void DestroyBombView(BombController controller)
    {
        var bombView = bombs.Find(b => b.Controller == controller);

        if (bombView != null)
        {
            bombView.Return();
        }
    }
Exemplo n.º 25
0
    /// <summary>
    /// This function helper for create new hexagons to empty slot.
    /// </summary>
    public void FillEmptySlots()
    {
        Debug.Log("Fill Empty Slots Progress Started.");

        foreach (List <SlotController> verticalSlots in seperateSlotControllers)
        {
            List <SlotController> emptySlots = new List <SlotController>();

            foreach (SlotController slotController in verticalSlots)
            {
                if (slotController.GetHexagonController() != null)
                {
                    break;
                }

                emptySlots.Add(slotController);
            }

            if (emptySlots.Count == 0)
            {
                continue;
            }

            Debug.Log($"{emptySlots.Count} Empty Slot Detected.");
            emptySlots.Reverse();

            bool spawnBomb      = false;
            int  randomBombSlot = 0;

            if (GameManager.Instance.GetScore() >= board.NextBombPoint)
            {
                board.NextBombPoint += gameSettings.BombInitialPoint;
                randomBombSlot       = Random.Range(0, emptySlots.Count);

                spawnBomb = true;

                Debug.Log($"Bomb Time! Next Bomb Point : {board.NextBombPoint}");
            }

            for (int i = 0; i < emptySlots.Count; i++)
            {
                if (spawnBomb && i == randomBombSlot)
                {
                    BombController createdBomb = CreateBomb(null, emptySlots[i], true);
                    ((BombView)createdBomb.GetView()).DrawDefaultLayer(true, (float)i / 10);
                    spawnBomb = false;
                }
                else
                {
                    HexagonController createdHexagon = CreateHexagon(null, emptySlots[i], true);
                    ((HexagonView)createdHexagon.GetView()).DrawDefaultLayer(true, (float)i / 10);
                }
            }
        }

        Debug.Log("Fill Empty Slots Progress Completed.");
    }
Exemplo n.º 26
0
    private void BombSpawn()
    {
        Tile t = TileMover.instance.GetCurrentTile();

        Debug.Log("i done been spawned");
        bomby = Instantiate(bomb, ass.position, ass.rotation, null);
        bomby.transform.SetParent(t.transform);
        bombController = bomby.GetComponent <BombController>();
    }
Exemplo n.º 27
0
    private bool ExplodeTile(int xTile, int zTile)
    {
        Vector3 ExpolsionCenterWorldSpace = owner.Arena.transform.TransformPoint(new Vector3(xTile, 0, zTile));

        Collider[] hits   = Physics.OverlapBox(ExpolsionCenterWorldSpace, Vector3.one / 3f, Quaternion.identity, BombsHitLayer);
        Collider[] blocks = Physics.OverlapBox(ExpolsionCenterWorldSpace, Vector3.one / 3f, Quaternion.identity, BombsBlockedLayer);

        //Is blocked
        if (blocks.Length > 0)
        {
            return(true);
        }

        //Do come visual gargabe
        if (ShowDeBugExplosion)
        {
            Debug.DrawLine(ExpolsionCenterWorldSpace + new Vector3(0.5f, 0, 0.5f), ExpolsionCenterWorldSpace + new Vector3(-0.5f, 0, -0.5f), Color.red, 0.2f);
            Debug.DrawLine(ExpolsionCenterWorldSpace + new Vector3(0.5f, 0, -0.5f), ExpolsionCenterWorldSpace + new Vector3(-0.5f, 0, 0.5f), Color.red, 0.2f);
        }
        else
        {
            Instantiate(ExplosionGrapic, ExpolsionCenterWorldSpace, Quaternion.identity, null);
        }

        //Call hits on players and bomb in square!
        for (int i = 0; i < hits.Length; i++)
        {
            //Skip if object is not in right cell
            bool sameX = Mathf.RoundToInt(hits[i].gameObject.transform.localPosition.x) == xTile;
            bool sameZ = Mathf.RoundToInt(hits[i].gameObject.transform.localPosition.z) == zTile;
            if (!sameX || !sameZ)
            {
                continue;
            }

            PlayerController player = hits[i].GetComponentInParent <PlayerController>();
            if (player != null)
            {
                player.Hit(owner);
            }

            BombController bomb = hits[i].GetComponentInParent <BombController>();
            if (bomb != null)
            {
                bomb.Hit(owner);
            }

            BoxController box = hits[i].GetComponentInParent <BoxController>();
            if (box != null)
            {
                box.Hit(owner);
                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 28
0
    void Start()
    {
        Debug.Log("PlayerStart()");
        playerRb    = GetComponent <Rigidbody> ();
        playerTrans = GetComponent <Transform> ();

        speed                 = .75f;
        jumpPower             = 1050.0f;
        jumpThreshold         = 0.75f;
        fallOffValue          = 5.0f;
        groundColliderContact = false;
        shootDirection        = Vector3.left;

        health    = 100;
        maxHealth = 100;

        playerShield        = gameObject.GetComponent <ShieldController> ();
        playerShield.player = gameObject.GetComponent <PlayerController> ();

        playerMaterial = gameObject.GetComponent <MeshRenderer> ().material;
        baseColor      = playerMaterial.color;

        playerGunController = gameObject.GetComponent <GunController> ();
        playerBombs         = gameObject.GetComponent <BombController> ();

        cameraShake = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraShaker> ();

        input = GameController.Instance.GetComponent <InputController> ();
        Debug.Log("Setting Controllers...");
        input.SetGunController(playerGunController);
        input.SetShieldController(playerShield);
        input.SetBombController(playerBombs);
        //input.UpdateControllers ();

        Debug.Log("Finished setting Controllers.");

        GameObject audioObject = GameObject.FindGameObjectWithTag("AudioController");

        Debug.Log(audioObject);
        if (audioObject != null)
        {
            Debug.Log("Found the audioObject!");
            AudioSource[] audioSources = audioObject.GetComponents <AudioSource> ();
            spawnSound  = audioSources [0];
            damageSound = audioSources [1];
            shotSound   = audioSources [2];
            deathSound  = audioSources [3];
            shieldSound = audioSources [4];
            bombSound   = audioSources [5];
            spawnSound.Play();
        }
        else
        {
            Debug.Log("Well, we never found the audioObject.");
        }
    }
Exemplo n.º 29
0
 protected override void OnInitialize()
 {
     base.OnInitialize();
     playerController = new PlayerController();
     enemyController  = new EnemyController();
     bombController   = new BombController(levelScriptableObject.bombPrefab, levelScriptableObject.bombLife);
     boardController  = new BoardController(levelScriptableObject);
     uIService        = new UIService();
     uIService.OnStart();
 }
    public override void perform(GameObject playerGameObject)
    {
        AudioSource.PlayClipAtPoint(explosionClip, transform.position);
        int playerScore = PlayerPrefs.GetInt("score");

        PlayerPrefs.SetInt("score", playerScore + score);
        BombController.incrementWide();
        Debug.Log("Extra explosion player");
        GameObject.Destroy(gameObject);
    }
Exemplo n.º 31
0
    public bool activateEffect(BombController bomb)
    {
        bool continueExplosion = true;

        switch (bomb.BombType)
        {
            case BombController.BombTypes.normal: continueExplosion = activateFire(); break;
            case BombController.BombTypes.ice: continueExplosion = activateIce(); break;
            case BombController.BombTypes.wall: continueExplosion = activateWall(); break;
        }
        return continueExplosion;
    }
    protected override void Start()
    {
        base.Start();

        bombController = GetComponent<BombController>();
        damageImage = GameObject.Find("DamageImage").GetComponent<Image>();
        enemyHealthBar = GameObject.Find("EnemyHealth").GetComponent<Image>();
        ammunitionText = GameObject.Find("Ammunition").GetComponent<Text>();
        ammunitionText.text = "Ammo: " + ammunition;

        enemyLayer = LayerMask.GetMask("Enemy");                   // Get enemy mask
        currentFuel = maxFuel;
    }
        public GameObject SpawnBomb(BombController.BombInfo aBombInfo)
        {
            GameObject player = null;

            GameObject[] planes = GameObject.FindGameObjectsWithTag("Plane");
            for (int i = 0; i < planes.Length; i++)
            {
                if (planes[i].GetComponent<PhotonView>().owner == aBombInfo.m_shooter)
                {
                    player = planes[i];
                    break;
                }
            }

            if (player != null)
            {
                GameObject flare = (GameObject)Instantiate(m_bombDropPrefab, player.transform.position, player.GetComponent<PlaneController>().m_bulletSpawnPoint.rotation);
                flare.transform.parent = player.transform;
                if (aBombInfo.m_shooter == PhotonNetwork.player)
                {
                    flare.GetComponent<AudioSource>().spatialBlend = 0;
                }
                flare.GetComponent<AudioSource>().Play();
            }

            GameObject bomb = (GameObject)Instantiate(m_bombPrefab, aBombInfo.m_startPosition, Quaternion.LookRotation(aBombInfo.m_startDirection, -Vector3.forward));
            bomb.GetComponent<Rigidbody>().velocity = aBombInfo.m_startVelocity;
            bomb.GetComponent<BombController>().SetBombInfo(aBombInfo);
            return bomb;
        }
 public void DeleteBombCommand(BombController aBombController, int aID)
 {
     //BombController.BombInfo aBombInfo = aBombController.m_bombInfo;
     GameObject explosion;
     if (aID == 0)
     {
         explosion = (GameObject)Instantiate((GameObject)Resources.Load("BombWaterExplosion"), aBombController.transform.position, Quaternion.identity);
         explosion.GetComponent<AudioSource>().Play();
     }
     else if (aID == 1)
     {
         explosion = (GameObject)Instantiate((GameObject)Resources.Load("BombExplosion"), aBombController.transform.position, Quaternion.identity);
         explosion.GetComponent<AudioSource>().Play();
     }
     else
     {
         explosion = (GameObject)Instantiate((GameObject)Resources.Load("BombDud"), aBombController.transform.position, Quaternion.identity);
     }
     //CmdDeleteBomb(aJson, aID);
 }
Exemplo n.º 35
0
    public void BombExploded(BombController bomb)
    {
        //center
        tilesLookup[bomb.MyTile.indexI, bomb.MyTile.indexJ].GetComponent<FloorCube>().activateEffect(bomb);

        if (tilesLookup[bomb.MyTile.indexI, bomb.MyTile.indexJ].GetComponent<FloorCube> ().bombInTile != null) {
            tilesLookup[bomb.MyTile.indexI, bomb.MyTile.indexJ].GetComponent<FloorCube> ().bombInTile = null;
        }

        //right
        for (int i = 1; i < bomb.explosionDistance; i++) {
            if( bomb.MyTile.indexI + i < levelWidth){
                if(tilesLookup[bomb.MyTile.indexI + i,bomb.MyTile.indexJ].GetComponent<FloorCube>().walled == false){
                    bool continueExplosion = tilesLookup[bomb.MyTile.indexI + i, bomb.MyTile.indexJ].GetComponent<FloorCube>().activateEffect(bomb);

                    //if crate then end flame on crate
                    if (continueExplosion == false)
                    {
            //			i += bomb.explosionDistance;
                    }

                }else{
                    //break loop
            //		i += bomb.explosionDistance;
                }
            }
        }
        //left
        for (int i = 1; i < bomb.explosionDistance; i++) {
            if( bomb.MyTile.indexI - i >= 0){
                if(tilesLookup[bomb.MyTile.indexI - i,bomb.MyTile.indexJ].GetComponent<FloorCube>().walled == false){
                    bool continueExplosion = tilesLookup[bomb.MyTile.indexI - i, bomb.MyTile.indexJ].GetComponent<FloorCube>().activateEffect(bomb);

                    if (continueExplosion == false){
        //					i += bomb.explosionDistance;
                    }

                }else{
                    //break loop
        //				i += bomb.explosionDistance;
                }
            }
        }
        //up
        for (int i = 1; i < bomb.explosionDistance; i++) {
            if( bomb.MyTile.indexJ + i < levelHeight){
                if(tilesLookup[bomb.MyTile.indexI,bomb.MyTile.indexJ + i].GetComponent<FloorCube>().walled == false){
                    bool continueExplosion = tilesLookup[bomb.MyTile.indexI, bomb.MyTile.indexJ + i].GetComponent<FloorCube>().activateEffect(bomb);

                    if (continueExplosion == false)
                    {
        //					i += bomb.explosionDistance;
                    }

                }else{
                    //break loop
        //				i += bomb.explosionDistance;
                }
            }
        }
        //down
        for (int i = 1; i < bomb.explosionDistance; i++) {
            if( bomb.MyTile.indexJ - i >= 0){
                if(tilesLookup[bomb.MyTile.indexI,bomb.MyTile.indexJ - i].GetComponent<FloorCube>().walled == false){
                    bool continueExplosion = tilesLookup[bomb.MyTile.indexI, bomb.MyTile.indexJ - i].GetComponent<FloorCube>().activateEffect(bomb);

                    if (continueExplosion == false)
                    {
        //				i += bomb.explosionDistance;
                    }

                }else{
                    //break loop
        //				i += bomb.explosionDistance;
                }
            }
        }
    }
Exemplo n.º 36
0
    // Use this for initialization
    void Awake()
    {
        Cursor.lockState = CursorLockMode.Confined;
        audio_bullet = GetComponents<AudioSource>()[0];   //0: bullets, 1: engines, 2: shield, 3: impacts, 4: other
        audio_engineHum = GetComponents<AudioSource>()[1];

        audio_engineHum.enabled = true;
        audio_engineHum.Play();
        audio_accellerators = GetComponents<AudioSource>()[2];
        audio_thrusters = GetComponents<AudioSource>()[3];
        audio_hullHit = GetComponents<AudioSource>()[4];
        audio_wallImpact = GetComponents<AudioSource>()[5];
        audio_effects = GetComponents<AudioSource>()[6];
        audio_bomb = GetComponents<AudioSource>()[7];
        audio_accellerators_max_vol = audio_accellerators.volume;
        audio_thrusters_max_vol = audio_thrusters.volume;
        Time.timeScale = 1; // The time scale must be reset upon loading from the main menu

        rb = GetComponent<Rigidbody>();
        originalColor = mesh.GetComponent<Renderer>().material.color;

        curPowerUp = powerUpList[0];

        shield = GetComponentInChildren<ShieldController>();
        bomb = GetComponentInChildren<BombController> ();

        maxHullIntegrity = currHullIntegrity = 5;
        armorGauge = gameObject.GetComponentInChildren<ArmorController>();

        bombTimer = gameObject.GetComponentInChildren<BombCountdownController>();

        deathEndingTimer = 0.0f;
        sceneTransition = GameObject.FindGameObjectWithTag("Screen Transition").GetComponent<CanvasGroup>();
        transitionRate = 3;

        if (tutorialMode)
        {
            //Debug.Log("tutorial mode");
            currHullIntegrity = 0;
        }

        Transform[] temp = bulletSpawns.GetComponentsInChildren<Transform>();
        bulletSpawnLocations = new Transform[temp.Length - 1];
        bulletSpawnLocIndex = 0;
        for(int i = 0; i < temp.Length; ++i)
        {
            if(temp[i].gameObject.GetInstanceID() != bulletSpawns.GetInstanceID())
            {
                bulletSpawnLocations[bulletSpawnLocIndex] = temp[i];
                ++bulletSpawnLocIndex;
            }
        }

        if (GameObject.Find("GameController") == null)
        {
            Instantiate(gameController);
        }
        gameController = GameObject.FindGameObjectWithTag("GameController");
        im = gameController.GetComponent<InputManager>();

        mainThrusterLeft.Play ();
        mainThrusterRight.Play ();
    }
Exemplo n.º 37
0
    // Use this for initialization
    void Start()
    {
        baseSoundSource = GetComponents<AudioSource>()[0];
        effectSoundSource = GetComponents<AudioSource>()[1];

        // shield initializations
        shieldEnabled = true;           //Disables Shield Recharge for Tutorial
        shieldActive = false;
        maxShieldCharge = currShieldCharge = 100f;
        shieldChargeDelay = 2.0f;
        shieldChargeDelayTimer = 0.0f;
        shieldDepleteAmount = -20;
        shieldRechargeAmount = 10;

        flashTimer = 0;

        hudElementName = "shield";
        hudColorController = GameObject.FindGameObjectWithTag("GameController").GetComponent<HUDColorController>();

        shieldOutline.color = hudColorController.getColorByString(hudElementName);

        shieldParticles = transform.FindChild("Shield Field").gameObject.GetComponent<ParticleSystem>();
        shieldCollider = GetComponent<Collider>();

        bomb = GameObject.FindGameObjectWithTag("Bomb");
        bombBehavior = bomb.GetComponent<BombController>();
        GameObject[] temp = GameObject.FindGameObjectsWithTag("Shield Gauge");
        shieldGauge = new Image[temp.Length];
        for (int i = 0; i < shieldGauge.Length; ++i)
        {
            shieldGauge[i] = temp[i].GetComponent<Image>();
            shieldGauge[i].color = hudColorController.getColorByString(hudElementName);
        }
        particleSystems = new List<GameObject>();

        SetParticleColors();
    }
Exemplo n.º 38
0
    protected override void Start()
    {
        base.Start();
        ammunitionLeft = maxammunition;

        // get references
        magnetController = GetComponent<MagnetController>();
        animator = transform.FindChild("PlayerModel").GetComponent<Animator>();
        damageImage = GameObject.Find("DamageImage").GetComponent<Image>();
        enemyHealthBar = GameObject.Find("EnemyHealth").GetComponent<VisualBar>();
        ammunitionText = GameObject.Find("Ammunition").GetComponent<Text>();
        smokeController = GetComponent<SmokeController>();
        staminaController = GetComponent<StaminaController>();
        bombController = GetComponent<BombController>();

        ammunitionText.text = ammunitionLeft.ToString();
        enemyLayer = LayerMask.GetMask("Enemy");                                        // Get enemy mask
        orginalSpeed = horizontalMove;                                                  // remember orginal speed because some method can change it
        currentFuel = maxFuel;
        healthBar.UpdateBar(currentHealth, maxHealth);                                  // update healthBar
    }