상속: MonoBehaviour
예제 #1
0
    void Start()
    {
        bomb = GetComponentInParent<BombScript>();

        timer = this.gameObject.GetComponentInParent<BombScript>().timer;
        timerMax = this.gameObject.GetComponentInParent<BombScript>().timerMax;
    }
예제 #2
0
    void Start()
    {
        manager = GameObject.Find("Main Camera").GetComponent <NPCManager>();

        characterController = GetComponent <CharacterController>();
        //weaponText = canvas.GetComponentInChildren<Text>();

        shield = gameObject.GetComponentInChildren <ShieldScript>();
        laser  = gameObject.GetComponentInChildren <LaserScript>();
        charge = gameObject.GetComponentInChildren <ChargeScript>();
        bomb   = gameObject.GetComponentInChildren <BombScript>();

        laserSound = gameObject.GetComponent <AudioSource>();

        cameraScript = GameObject.Find("Main Camera").GetComponent <CameraFollow>();

        futurePosition = GetComponentInChildren <FuturePositionScript>().transform;

        if (Input.GetJoystickNames().Length > 0)
        {
            isControllerConnected = true;
        }

        transform.position = spawnPoint;

        if (GameObject.Find("PlayerUI"))
        {
            ui = GameObject.Find("PlayerUI").GetComponent <PlayerUI>();
        }
    }
예제 #3
0
    void UseTile(int trap)
    {
        used     = true;
        chosen   = false;
        sr.color = oriColor;
        usedTrap = trap;

        if (trap == 1 && GM.spikeAmount > 0)
        {
            Instantiate(spikeTrap, transform.position, Quaternion.identity);
            GM.spikeAmount--;
        }
        else if (trap == 2 && GM.flameAmount > 0)
        {
            Instantiate(flameTrap, transform.position, Quaternion.identity);
            GM.flameAmount--;
        }
        else if (trap == 3 && GM.bombAmount > 0)
        {
            numOfBombs += 1;
            GameObject bomb = (GameObject)Instantiate(bombTrap, transform.position, Quaternion.identity);
            BombScript bs   = bomb.GetComponent <BombScript> ();
            bs.bombNum = numOfBombs;
            GM.bombAmount--;
        }
    }
    void Start()
    {
        tilemap    = gameObject.GetComponent <Tilemap>();
        bombScript = gameObject.GetComponent <BombScript>();

        this.SetTiles();
        this.DrawTiles();
    }
예제 #5
0
 public void HandleExplode(BombScript script, IntVector2 pos, int radius)
 {
     Debug.Log("ça pete !");
     //current_map.ExplodeAt(pos, radius);
     networkView.RPC("ClientRecvBomb", RPCMode.Others, pos.x, pos.y, radius);
     Network.RemoveRPCs(script.gameObject.GetComponent <NetworkView>().viewID);
     Network.Destroy(script.gameObject);
 }
예제 #6
0
    void OnTriggerStay(Collider coll)
    {
        if (transform.parent == null)
        {
            if (coll.gameObject.layer == walkLayer)
            {
                transform.parent = coll.transform;
            }
        }

        if (coll.CompareTag("Spike"))
        {
            if (coll.GetComponent <SpikeActivateScript>().enabled&& !pickedUp)
            {
                spikeTrap         = coll.GetComponent <SpikeActivateScript>();
                spikeTrap.enabled = false;
            }
        }
        else if (coll.CompareTag("Spring"))
        {
            if (coll.GetComponent <SpringboardScript>().enabled&& !pickedUp)
            {
                springTrap         = coll.GetComponent <SpringboardScript>();
                springTrap.enabled = false;
            }
        }
        else if (coll.CompareTag("Bomb"))
        {
            if (coll.GetComponent <BombScript>().enabled&& !pickedUp)
            {
                bombTrap         = coll.GetComponent <BombScript>();
                bombTrap.enabled = false;
            }
        }
        else if (coll.CompareTag("FireWall"))
        {
            if (!fireWallGet)
            {
                fireWallGet = true;
                fireWall    = coll.transform.parent.GetComponentInChildren <ParticleSystem>();
            }
        }

        if (coll.CompareTag("Knight"))
        {
            pickedUp = true;
            coll.GetComponent <KnightAttackScript>().carryingShield = true;
        }
        else if (coll.CompareTag("Enemy") && coll.GetComponent <EnemyAIScript>().EnemyType != EnemyAIScript.EnemyClass.Phantom &&
                 coll.GetComponent <EnemyAIScript>().EnemyType != EnemyAIScript.EnemyClass.Swarm)
        {
            pickedUp = true;
            if (coll.GetComponent <EnemyAIScript>().health == 1)
            {
                coll.GetComponent <EnemyAIScript>().health = 2;
            }
        }
    }
    void Spawnbomb()
    {
        Vector3    randPos  = new Vector3(Random.Range(leftBorder, rightBorder), Random.Range(downBorder, upBorder));
        GameObject instance = Instantiate(bomb, randPos, Quaternion.identity);

        BombScript enemyScript = instance.GetComponent <BombScript>();

        enemyScript.block_hp = Random.Range(enemyBlock_MIN_HP, enemyBlock_MAX_HP);
    }
예제 #8
0
        internal void BulletFlyCompleeted(GameObject bullet, Collider target)
        {
            BombScript bombScript = bullet.GetComponent <BombScript>();

            bombScript.OnBombCall -= BulletFlyCompleeted;
            _bombsPool.Intake(ref bullet);

            if (target.TryGetComponent(out IReactToHit react))
            {
                react.Hit((uint)_hitCount);
            }
        }
예제 #9
0
	// Update is called once per frame
	void Update () {
        if (isAggroed && player.isDead == false) {
            //Throw a bomb with a cooldown towards the direction of the player if the player is within aggro range
            currentTime += Time.deltaTime;
            if (currentTime >= throwCooldown) {
                bombObject = Instantiate(bomb, transform.position, transform.rotation) as BombScript;
                Vector2 toPlayer = new Vector2(playerPosition.position.x - transform.position.x, playerPosition.position.y - transform.position.y);
                bombObject.GetComponent<Rigidbody2D>().velocity = (toPlayer * throwForce);
                currentTime = 0;
            }
        }
	}
예제 #10
0
        public bool Attack(Vector3 place, Vector3 targetPoint, IThing actionThing)
        {
            GameObject bullet = _bombsPool.Create();

            bullet.transform.position = place;
            bullet.SetActive(true);
            Rigidbody rigidBody = bullet.GetComponent <Rigidbody>();

            rigidBody.velocity = (targetPoint - place).normalized * 50f;

            BombScript bombScript = bullet.GetComponent <BombScript>();

            bombScript.OnBombCall += BulletFlyCompleeted;
            return(true);
        }
예제 #11
0
 private void ThrowBomb()
 {
     if (facingRight == true)
     {
         GameObject bomb = Object.Instantiate(Resources.Load("Prefabs/Bomb"), new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity) as GameObject;
         BombScript bs   = bomb.GetComponent <BombScript> ();
         bs.Initialize(new Vector3(_rb.velocity.x * velocityMultiplier, 1f, 0f), bombIndex);
     }
     else
     {
         GameObject bomb = Object.Instantiate(Resources.Load("Prefabs/Bomb"), new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity) as GameObject;
         BombScript bs   = bomb.GetComponent <BombScript> ();
         bs.Initialize(new Vector3(_rb.velocity.x * velocityMultiplier, 1f, 0f), bombIndex);
     }
 }
예제 #12
0
    public void RegisterObj(Object o, ObjectType type)
    {
        if (type == ObjectType.OBJECT_BOMB && server)
        {
            BombScript script = ((BombScript)o);
            m_bombs[o.GetInstanceID()] = script;

            /*script.callback = () =>
             * {
             *  Vector3 pos = script.transform.position;
             *  IntVector2 tpos = current_map.GetTilePosition(pos.x, pos.z);
             *  this.HandleExplode(script, tpos, 1);
             * };*/
        }
    }
예제 #13
0
    public void Throw(GameObject player, float spdx, float spdy)
    {
        GameObject g = ops.GetPooledObject();

        if (g != null)
        {
            g.transform.position = player.transform.position;
        }
        g?.SetActive(true);
        g?.GetComponent <Rigidbody2D>()?.AddForce(new Vector3(spdx, spdy, 0));

        BombScript bs = null;

        g?.TryGetComponent <BombScript>(out bs);
        bs?.BombSpawned();
    }
예제 #14
0
    public void DropBomb()
    {
        if (_cooldownTimer > 0f)
        {
            return;
        }

        GameObject newBomb = Instantiate(bomb);

        newBomb.transform.position = transform.position;

        BombScript bombScript = newBomb.GetComponent <BombScript>();

        bombScript.bombDamage = damagePerBomb;

        _cooldownTimer = cooldown;
    }
예제 #15
0
    private void createFire(int i, int j, int x, int y, int rot)
    {
        if (x + i >= 0 && x + i < 11 && y + j >= 0 && y + j < 11)
        {
            if (LevelArray.level[x + i, y + j].Type == ArrayTypes.EMPTY)
            {
                GameObject o;
                if (remaining == 1)
                {
                    o = fireend;
                }
                else
                {
                    o = fire;
                }
                GameObject s = LevelArray.createObject(x + i, y + j, o, rot);
                LevelArray.level[x + i, y + j] = new ArrayClass(ArrayTypes.FIRE, s);

                FireScript f = (FireScript)s.GetComponent("FireScript");
                f.remaining = remaining - 1;
                f.xDir      = i; f.yDir = j;
            }
            else if (LevelArray.level[x + i, y + j].Type == ArrayTypes.FIRE)
            {
                GameObject s = LevelArray.createObject(x + i, y + j, firecross, rot);
                LevelArray.level[x + i, y + j] = new ArrayClass(ArrayTypes.FIRECROSS, s);

                FireScript f = (FireScript)s.GetComponent("FireScript");
                f.remaining = remaining - 1;
                f.xDir      = i; f.yDir = j;
            }
            else if (LevelArray.level[x + i, y + j].Type == ArrayTypes.BLOCK)
            {
                BlockScript b = (BlockScript)LevelArray.level[x + i, y + j].Obj.GetComponent("BlockScript");
                b.hit = true;
            }
            else if (LevelArray.level[x + i, y + j].Type == ArrayTypes.BOMB)
            {
                BombScript b = (BombScript)LevelArray.level[x + i, y + j].Obj.GetComponent("BombScript");
                b.TIMER = 0;
            }
        }
    }
예제 #16
0
    // Update is called once per frame
    void Update()
    {
        BomberPlayer p      = (BomberPlayer)cc.GetComponent("BomberPlayer");
        string       button = "Fire1Player" + p.NAME.ToString();

        if (Input.GetButtonDown(button))
        {
            int x = Mathf.RoundToInt(cc.transform.position.x) + 5; int y = Mathf.RoundToInt(cc.transform.position.z) + 5;
            if (p.BOMBCNT > 0 && LevelArray.level[x, y].Type == ArrayTypes.EMPTY)
            {
                ;
                GameObject b = LevelArray.createObject(x, y, bomb, 0);
                BombScript s = (BombScript)b.GetComponent("BombScript");
                s.owner = p;
                LevelArray.level[x, y] = new ArrayClass(ArrayTypes.BOMB, b);
                p.BOMBCNT--;
            }
        }
    }
예제 #17
0
 private void ThrowBomb()
 {
     if (bombIndex != -1)
     {
         if (facingRight == true)
         {
             GameObject bomb = Object.Instantiate(Resources.Load("Prefabs/Bomb"), new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity) as GameObject;
             BombScript bs   = bomb.GetComponent <BombScript> ();
             bs.Initialize(new Vector3(runSpeed, 1f, 0f), bombIndex);
         }
         else
         {
             GameObject bomb = Object.Instantiate(Resources.Load("Prefabs/Bomb"), new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity) as GameObject;
             BombScript bs   = bomb.GetComponent <BombScript> ();
             bs.Initialize(new Vector3(-runSpeed, 1f, 0f), bombIndex);
         }
         PlayRandomSound();
     }
 }
예제 #18
0
    // Update is called once per frame
    void Update()
    {
        bool buttonPressed = Input.GetAxis("P1_Bomb") > 0;

        if(buttonPressed == true && prevButtonPressed == false) //pressed
        {
            bomb = ((GameObject)Instantiate(bombPrefab, bombDropLocation.position, Quaternion.identity)).GetComponent<BombScript>();
            bomb.transform.parent = this.transform;
            bomb.transform.LookAt(bombDropLocation.position + bombDropLocation.transform.forward);
        }

        if(buttonPressed == false && prevButtonPressed == true) //released
        {
            if(bomb != null)
                bomb.Release(rb.velocity);

        }

        prevButtonPressed = buttonPressed;
    }
예제 #19
0
    // Update is called once per frame
    void Update()
    {
        bool buttonPressed = Input.GetAxis("P1_Bomb") > 0;

        if (buttonPressed == true && prevButtonPressed == false) //pressed
        {
            bomb = ((GameObject)Instantiate(bombPrefab, bombDropLocation.position, Quaternion.identity)).GetComponent <BombScript>();
            bomb.transform.parent = this.transform;
            bomb.transform.LookAt(bombDropLocation.position + bombDropLocation.transform.forward);
        }

        if (buttonPressed == false && prevButtonPressed == true) //released
        {
            if (bomb != null)
            {
                bomb.Release(rb.velocity);
            }
        }

        prevButtonPressed = buttonPressed;
    }
예제 #20
0
        public void Defuse()
        {
            GameObject bomb       = GameObject.Find(Misc.Constants.GAME_CONTROLLER_NAME).GetComponent <Core.GameController>().Bomb;
            BombScript bombScript = bomb.GetComponent <BombScript>();

            if (!(NextPointInPath < Path.Count - 1) && WillDefuse)
            {
                if (!bombScript.IsTimerZero() && !bombScript.BeingDefused)
                {
                    Defusing = true;
                    bombScript.StartDefuse(gameObject);
                    DefusingStarted = Core.Vars.SimulationTime;
                }
            }
            else
            {
                Defusing = false;
                if (bombScript.Defuser == gameObject)
                {
                    bombScript.StopDefuse();
                }
            }
        }
예제 #21
0
 public void Fire()
 {
     if (bombsFired < maxBombsCurrent)
     {
         Vector3 vec = tank.transform.position + tank.transform.forward * bombSpawnDistance; // distance between a tank and a bomb
         vec.y = 0.8f;                                                                       // height at which a bomb will be released
         for (int i = 0; i < maxBombsCurrent; i++)
         {
             if (bombs[i] == null)
             {
                 GameObject bomb       = Instantiate(projectilePrefab, vec, transform.rotation);
                 BombScript bombScript = bomb.GetComponent <BombScript>();
                 bombScript.barrelScript = this;
                 bombScript.id           = i;
                 bombScript.StartCoroutine(bombScript.BombCoroutine());
                 bombs[i] = bomb;
                 bombsFired++;
                 Debug.Log("Fire. Remaning shots: " + (maxBombsCurrent - bombsFired));
                 break;
             }
         }
     }
 }
예제 #22
0
        public void StepThrough()
        {
            // ct
            CounterTerroristAI.UpdateChildrenList();
            TerroristAI.UpdateChildrenList();
            CounterTerroristAI.CheckVisibility(TerroristAI.Children);
            SimulationStep(CounterTerroristAI);
            HideDead();

            // tero
            CounterTerroristAI.UpdateChildrenList();
            TerroristAI.UpdateChildrenList();
            TerroristAI.CheckVisibility(CounterTerroristAI.Children);
            SimulationStep(TerroristAI);
            HideDead();

            // end visibility check for recording
            UpdateVisibility();

            Vars.SimulationTime += Time.fixedDeltaTime;
            //Debug.Log(Vars.SimulationTime);

            BombScript bomb = GameController.Bomb.GetComponent <BombScript>();

            if (GameController.Winner == null)
            {
                if (CounterTerroristAI.Children.Count == 0 || bomb.IsTimerZero())
                {
                    GameController.Winner = Side.Terrorist;
                }
                else if (((TerroristAI.Children.Count == 0 || Vars.SimulationTime > 60) && !bomb.Planted) || bomb.IsDefused())
                {
                    GameController.Winner = Side.CounterTerrorist;
                }
            }
        }
예제 #23
0
    // Update is called once per frame
    void FixedUpdate()
    {
        Vector2    mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Collider2D hitCollider   = Physics2D.OverlapPoint(mousePosition);


        if (phase == Phase.Setting)
        {
            if (Input.GetButtonDown("PhaseSwitch"))
            {
                phase = Phase.Action;
            }
            if (hitCollider == null)
            {
                if (Input.GetMouseButtonDown(0) && createNum > 0)
                {
                    createNum--;
                    GameObject blockStone = (GameObject)Instantiate(Resources.Load("BlockStone"));
                    blockStone.transform.position = new Vector3(Mathf.Round(mousePosition.x), mousePosition.y, 1);
                    GameObject obj = (GameObject)Instantiate(Resources.Load("Object"));
                    blockStone.transform.parent = obj.transform;
                }
                return;
            }

            //////////////////////bomb
            if (Input.GetMouseButtonDown(2))
            {
                if (hitCollider.gameObject.tag == "Block")
                {
                    if (bombNum > 0)
                    {
                        bombNum--;
                        GameObject bomb        = (GameObject)Instantiate(Resources.Load("Bomb"));
                        BombScript bombManager = bomb.GetComponent <BombScript>();
                        bombManager.attach(hitCollider.transform);
                    }
                    else if (timeBombNum > 0)
                    {
                        timeBombNum--;
                        GameObject bomb        = (GameObject)Instantiate(Resources.Load("Bomb"));
                        BombScript bombManager = bomb.GetComponent <BombScript>();
                        bombManager.attach(hitCollider.transform);
                        bombManager.time    = 0.1f;
                        bombManager.isTimed = true;
                    }
                }
            }


            /////////////////////////wood/steal
            if (hitCollider.gameObject.tag == "Block")
            {
                BlockScript block = hitCollider.gameObject.GetComponent <BlockScript> ();
                if (block.type == BlockScript.BlockType.Stone)
                {
                    if (replaceWoodNum > 0 || replaceSteelNum > 0)
                    {
                        if (Input.GetMouseButtonDown(0) && replaceWoodNum > 0)
                        {
                            replaceWoodNum--;
                            block.IfMouseClick(BlockScript.BlockType.Wood);
                        }
                        else if (Input.GetMouseButtonDown(1) && replaceSteelNum > 0)
                        {
                            replaceSteelNum--;
                            block.IfMouseClick(BlockScript.BlockType.Steel);
                        }
                        else
                        {
                            block.IfMouseOver();
                        }
                    }
                }
                /////////////////////////bomb timer
            }
            else if (hitCollider.gameObject.tag == "Bomb")
            {
                float      delta = 1 * Input.GetAxis("Mouse ScrollWheel");
                BombScript bomb  = hitCollider.gameObject.GetComponent <BombScript>();
                if (delta < 0 && bomb.time == 0)
                {
                    Destroy(bomb.gameObject);
                    bombNum++;
                }
                else
                {
                    bomb.time = Mathf.Clamp(bomb.time + delta, 0, 10);
                }
                if (bomb.time >= 0.1f && !bomb.isTimed && timeBombNum > 0)
                {
                    bomb.isTimed = true;
                    bombNum++; timeBombNum--;
                }
            }
        }
        else if (phase == Phase.Action)
        {
            if (Input.GetButtonDown("Suicide"))
            {
                GameObject.Find("Player").GetComponent <PlayerScript>().die("Suicide");
            }
            if (hitCollider == null)
            {
                return;
            }
            if (hitCollider.gameObject.tag == "Block")
            {
                BlockScript  block          = hitCollider.gameObject.GetComponent <BlockScript> ();
                GameObject   playerObject   = GameObject.Find("Player");
                Vector3      blockPosition  = block.transform.position;
                Vector3      playerPosition = playerObject.transform.position;
                float        dist           = Vector3.Distance(blockPosition, playerPosition);
                PlayerScript player         = playerObject.GetComponent <PlayerScript>();
                if (block.type == BlockScript.BlockType.Wood && dist < 1.2 && player.onPlatform)
                {
                    if (Input.GetMouseButtonDown(1))
                    {
                        Destroy(block.gameObject);
                    }
                    else
                    {
                        block.IfMouseOver();
                    }
                }
            }
        }
    }
예제 #24
0
     public void Update()
     {

          rnd = new System.Random();
          checkInvincibility();
          if (checkStun())
          {
               stunTimer -= Time.deltaTime;
               moveController.Move(0, 0);
          }
          else if (player != null)
          {
               health.cancelKnockback();
               findPos();
               float xSp = player.transform.position.x - transform.position.x;
               float ySp = player.transform.position.y - transform.position.y;
               distance = player.transform.position - transform.position;

               if (distance.magnitude <= AgroRange)
               {
                    isAgro = true;

               }
               else
               {
                    isAgro = false;
               }
               distanceFromPoint = locArr[loc % 4] - transform.position;
               if (distanceFromPoint.magnitude < 0.3)
               {
                    loc++;
                    distanceFromPoint = locArr[loc % 4] - transform.position;
               }
               moveController.Move(distanceFromPoint.normalized/8);

               if (isAgro)
               {
                    if (cooldown >= 2)
                    {
                         cooldown = 0;
                         findPos();
                         //No prep animation, just has default spinning and creates projectiles
                         if (mine_CD > 5)
                         {
                              mine = Instantiate(mineObj, transform.position, transform.rotation) as BombScript;
                              mine_CD = 0;
                         }
                         if (homing_CD > 8)
                         {
                              homing = Instantiate(homingObj, transform.position, transform.rotation) as Homer;
                              homing_CD = 0;
                         }
                         else if (bomb_CD > 8)
                         {
                              //bomb = Instantiate(bombObj, transform.position, transform.rotation) as BombScript;
                             // bomb.GetComponent<Rigidbody>().velocity = direction * 6;
                              bomb_CD = 0;

                              bomb = Instantiate(bombObj, transform.position, transform.rotation) as BombScript;
                              Vector2 toPlayer = new Vector2(player.transform.position.x - transform.position.x, player.transform.position.y - transform.position.y);
                              bomb.GetComponent<Rigidbody2D>().velocity = (toPlayer.normalized/3);
                         }
                         else if (shot_CD > 6)
                         {
                              float angle = Mathf.Atan2(direction.x, direction.y) * Mathf.Rad2Deg;
                              var q = Quaternion.AngleAxis(angle, Vector3.forward);
                              missile = Instantiate(missileObj, transform.position, q) as WindupProjectile;
                              missile.Shoot(0,direction.normalized);
                              shot_CD = 0;
                         }
                         else
                         {
                              cooldown = 1;
                         }
                    }
               }
               bomb_CD += Time.deltaTime;
               shot_CD += Time.deltaTime;
               mine_CD += Time.deltaTime;
               homing_CD += Time.deltaTime;
               cooldown += Time.deltaTime;
          }
     }
예제 #25
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        int damagePlayer = 0;

        // Ignore collision when player is invincible
        Physics2D.IgnoreCollision(collision.gameObject.GetComponent <Collider2D>(), GetComponent <Collider2D>(), isInvincible);
        if (!isInvincible)
        {
            // Collision with enemy
            EnemyScript enemy = collision.gameObject.GetComponent <EnemyScript>();
            if (enemy != null && collision.gameObject.GetComponent <BossScript>() == null)
            {
                // Kill the enemy
                HealthScript enemyHealth = enemy.GetComponent <HealthScript>();
                if (enemyHealth != null)
                {
                    damagePlayer = enemyHealth.hp / 3;
                    if (shieldLevel + 1 >= damagePlayer)
                    {
                        enemyHealth.Damage(enemyHealth.hp); // kill enemy
                    }
                }
                if (damagePlayer < 1)
                {
                    damagePlayer = 1;
                }
            }
        }

        // Is this a bonus?
        CollectableScript collectable = collision.gameObject.GetComponentInChildren <CollectableScript>();

        if (collectable != null)
        {
            // Is this a shield bonus?
            ShieldScript shield = collision.gameObject.GetComponent <ShieldScript>();
            if (shield != null)
            {
                shieldLevel     = shield.shieldLevel;
                lastShieldLevel = shieldLevel;
                updateShieldUi();
                updateLifeUi(false);
                SoundEffectsHelper.Instance.MakeShieldSound(true);
                Destroy(shield.gameObject); // Remember to always target the game object, otherwise you will just remove the script
            }
            else
            {
                SoundEffectsHelper.Instance.MakePickupSound();
            }
            // Is this a weapon bonus?
            changeWeapon(collision.gameObject);
            // Is this a bomb bonus?
            BombScript bomb = collision.gameObject.GetComponent <BombScript>();
            if (bomb != null)
            {
                if (nbBombs < MAX_BOMB)
                {
                    nbBombs++;
                    GameHelper.Instance.pickupBomb();
                }
                SoundEffectsHelper.Instance.MakePickupSound();
            }

            GameHelper.Instance.collectBonus(collectable.getId());
            Destroy(collision.gameObject); // Remember to always target the game object, otherwise you will just remove the script
        }

        // Damage the player if necessery
        if (this.takeDamage(damagePlayer))
        {
            GetComponent <HealthScript>().Damage(1);
        }
    }
예제 #26
0
    void OnCollisionEnter(Collision collision)
    {
        GameObject victim = collision.collider.gameObject;

        if (victim.CompareTag("bomb"))
        {
            hapticStart = true;
            BombScript bs = victim.GetComponent <BombScript>();
            if (bs.died)
            {
                return;
            }

            global.health--;
            bs.Die(collision.contacts[0].point);
            Destroy(victim);
            return;
        }

        if (trackedObj)
        {
            if ((trackedObj.GetVelocity()).magnitude < 0.8f)
            {
                return;
            }
        }

        if (!(victim.CompareTag("fruit") || victim.CompareTag("fruitPieces")))
        {
            return;
        }

        if (victim.CompareTag("fruit"))
        {
            for (int i = 0; i < 100; i++)
            {
                RightHandPulse(1.5f, 1f, 1f);
            }


            victim.GetComponent <cutSound>().playClip();
            DestroyFruit df = victim.GetComponent <DestroyFruit>();
            if (!df.died)
            {
                df.Die();
                if (global)
                {
                    global.score += 10;
                }
            }
        }

        Material capMaterial = victim.GetComponent <DestroyFruit>().capMat;

        GameObject[] pieces = BLINDED_AM_ME.MeshCut.Cut(victim, transform.position, transform.right, capMaterial);

        if (!pieces[0].GetComponent <Rigidbody>())
        {
            pieces[0].AddComponent <Rigidbody>();
            MeshCollider tmp = pieces[0].AddComponent <MeshCollider>();
            tmp.convex = true;
        }

        if (!pieces[0].GetComponent <DestroyFruit>())
        {
            DestroyFruit df = pieces[0].AddComponent <DestroyFruit>();
            df.useGravity = true;
            df.capMat     = capMaterial;
            df.sliced     = true;
        }
        else
        {
            DestroyFruit df = pieces[0].GetComponent <DestroyFruit>();
            df.sliced = true;
        }

        if (!pieces[1].GetComponent <Rigidbody>())
        {
            pieces[1].AddComponent <Rigidbody>();
            MeshCollider tmp = pieces[1].AddComponent <MeshCollider>();
            tmp.convex = true;
        }

        if (!pieces[1].GetComponent <DestroyFruit>())
        {
            DestroyFruit df = pieces[1].AddComponent <DestroyFruit>();
            df.useGravity = true;
            df.capMat     = capMaterial;
            df.sliced     = true;
        }
        else
        {
            DestroyFruit df = pieces[1].GetComponent <DestroyFruit>();
            df.sliced = true;
        }

        pieces[0].tag = "fruitPieces";
        pieces[1].tag = "fruitPieces";
    }
예제 #27
0
 void Start()
 {
     bombScript = gameObject.GetComponentInChildren<BombScript>();
     sphereCollider = this.GetComponent<SphereCollider>();
     prov = this.gameObject;
 }
예제 #28
0
    void Start()
    {
        manager = GameObject.Find("Main Camera").GetComponent<NPCManager>();

        characterController = GetComponent<CharacterController>();
        //weaponText = canvas.GetComponentInChildren<Text>();

        shield = gameObject.GetComponentInChildren<ShieldScript>();
        laser = gameObject.GetComponentInChildren<LaserScript>();
        charge = gameObject.GetComponentInChildren<ChargeScript>();
        bomb = gameObject.GetComponentInChildren<BombScript>();

        laserSound = gameObject.GetComponent<AudioSource>();

        cameraScript = GameObject.Find("Main Camera").GetComponent<CameraFollow>();

        futurePosition = GetComponentInChildren<FuturePositionScript>().transform;

        if (Input.GetJoystickNames().Length > 0)
        {
            isControllerConnected = true;
        }

        transform.position = spawnPoint;

        if (GameObject.Find("PlayerUI"))
        {
            ui = GameObject.Find("PlayerUI").GetComponent<PlayerUI>();
        }
    }
    //we detect collision with balloons. every balloon that touch this trigger is destroyed
    void OnTriggerEnter(Collider c)
    {
        if (c.collider.gameObject.layer == 9)
        {
            hitObject = c.collider.gameObject.GetComponent<Balloon>();
            GameObject particleProv = (GameObject)GameObject.Instantiate(particle);
            particleProv.transform.position = hitObject.transform.position;
            if (hitObject.Idballoon == "red")
            {
                particleProv.renderer.material.mainTexture = particleTexture[0];
                if (menuScript.survivorMode)
                {
                    scoreScript.SurvivorDestroyed();
                }
            }
            if (hitObject.Idballoon == "blue")
            {
                particleProv.renderer.material.mainTexture = particleTexture[1];
                if (menuScript.survivorMode)
                {
                    scoreScript.SurvivorDestroyed();
                }
            }
            if (hitObject.Idballoon == "green")
            {
                particleProv.renderer.material.mainTexture = particleTexture[2];
                if (menuScript.survivorMode)
                {
                    scoreScript.SurvivorDestroyed();
                }
            }
            if (hitObject.Idballoon == "yellow")
            {
                particleProv.renderer.material.mainTexture = particleTexture[3];
                if (menuScript.survivorMode)
                {
                    scoreScript.SurvivorDestroyed();
                }
            }

            Destroy(c.collider.gameObject);
        }
        if (c.collider.gameObject.layer == 10)
        {
            hitObject = c.collider.gameObject.GetComponent<Balloon>();
            if (hitObject.Idballoon == "bullet")
            {
                Destroy(hitObject.collider.gameObject.transform.root.gameObject);
            }
            if (hitObject.Idballoon == "theray")
            {
                Destroy(hitObject.collider.gameObject.transform.root.gameObject);
            }
            if (hitObject.Idballoon == "black")
            {
                Camera.mainCamera.animation.CrossFade("@CameraShakeLight");
                if (menuScript.multiply >= 5 && menuScript.multiply < 7)
                {
                    Camera.mainCamera.animation.CrossFade("@CameraShakingLight");
                }
                if (menuScript.multiply >= 7 && menuScript.multiply < 10)
                {
                    Camera.mainCamera.animation.CrossFade("@CameraShakingHeavy");
                }
                if (menuScript.multiply >= 10)
                {
                    Camera.mainCamera.animation.CrossFade("@CameraShakingSuperHeavy");
                }
                bombScript = hitObject.gameObject.GetComponentInChildren<BombScript>();
                bombChild = hitObject.gameObject.GetComponent<BombGetChildren>();
                hitObject.renderer.enabled = false;
                bombScript.timerBomb = 10;
                bombChild.sphereCollider.radius = 4;
                bombArrayLenght = bombScript.arrayList.Length-1;
                if (bombScript.arrayList != null)
                {
                    for (int i = bombArrayLenght; 0 <= i; i--)
                    {
                        if (hitObject != null)
                        {
                            Destroy(bombScript.arrayList[i].gameObject);
                            scoreScript.SurvivorDestroyed();
                        }
                    }
                }
                bombScript.thisMesh.renderer.enabled = false;
                GameObject particleBoom1 = (GameObject)GameObject.Instantiate(particleBoom);
                particleBoom1.transform.position = hitObject.transform.position;
                Destroy(hitObject.transform.root.gameObject,0.3f);
            }
            if (hitObject.Idballoon == "orange")
            {
                GameObject particleProv = (GameObject)GameObject.Instantiate(particle);
                particleProv.transform.position = hitObject.transform.position;
                particleProv.renderer.material.mainTexture = particleTexture[0];
                Destroy(hitObject.transform.root.gameObject);
            }
            if (hitObject.Idballoon == "eater")
            {
                GameObject particleProv = (GameObject)GameObject.Instantiate(particle);
                particleProv.transform.position = hitObject.transform.position;
                particleProv.renderer.material.mainTexture = particleTexture[0];
                Destroy(hitObject.transform.root.gameObject);
            }
        }
    }
예제 #30
0
	// Use this for initialization
	void Start () {
		player = GameObject.Find ("Player");
		hud = GameObject.Find ("HUD").GetComponent<HUD>();
		score = GetComponent<ScoreScript>();
		bomb = player.GetComponent<BombScript>();
	}
예제 #31
0
    public void KillPlayer(Cross cross, int bombGUID)
    {
        Debug.Log("In kill player by bomb");
        IList <GameObject> m_player = ObjectMgr.Instance.Get(GOType.GO_PLAYER);
        BombScript         bomb     = ObjectMgr.Instance.Get(bombGUID).GetComponent <BombScript>();
        int killerGUID = bomb.OwnerGuid;

        int[] scores = hud.getScores();
        int   score = 0;
        bool  suicide = false, hasvictim = false;;

        for (int i = 0, len = m_player.Count; i < len; i++)
        {
            GameObject t     = m_player[i];
            int        curID = t.GetComponent <Guid>().GetGUID();

            if (t == null)
            {
                continue;
            }
            IntVector2 tpos = maps.GetTilePosition(t.transform.position.x, t.transform.position.z);
            Debug.Log(tpos);
            if (tpos == null)
            {
                continue;
            }
            if (cross.IsIn(tpos))
            {
                hasvictim = true;
                PlayAnnounce(Announce.ANNOUNCE_PLAYER_KILL, 0, "" + (i + 1));
                if (this.gameIntel.game_mode == Config.GameMode.SURVIVAL)
                {
                    scores    = hud.getScores();
                    scores[i] = -1;
                    hud.setScores(scores);
                    s.SendPacketBroadCast(PacketBuilder.BuildPlayerDespawn(curID));
                    this.Despawn(curID);
                    nbDeads++;
                }
                else
                {
                    scores = hud.getScores();
                    if (curID == killerGUID)
                    {
                        score--;
                        suicide = true;
                    }
                    else
                    {
                        score++;
                    }



                    RespawnPlayer(curID);
                }
            }
        }
        int sessionID = GameMgr.Instance.s.GetSessionId(killerGUID);

        scores[sessionID - 1] += score;


        if (score != 0 || hasvictim)
        {
            hud.setScores(scores);
            s.SendPacketBroadCast(PacketBuilder.BuildUpdateScoresPacket(scores));
        }
        if (nbDeads == this.s.client_count - 1)
        {
            if ((this.type & GameMgrType.SERVER) != 0)
            {
                this.s.SendPacketBroadCast(PacketBuilder.BuildSendEndOfGame((int)GameMgr.Instance.gameIntel.game_mode));
                EndGame(GameMgr.Instance.gameIntel.game_mode);
            }
        }
    }
예제 #32
0
//	public void bombFromNetwork(int index) {
//		if (board [index] == BoardElement.empty) {
//			board [index] = BoardElement.bomb;
//			Transform obj = Instantiate (bomb, new Vector3 (index % BOARD_WIDTH, index / BOARD_WIDTH, this.transform.position.z), Quaternion.identity);
//			obj.parent = this.transform;
//		}
//	}

    public void detonateBomb(Transform bomb, int power)
    {
        board[(int)bomb.transform.position.y * BOARD_WIDTH + (int)bomb.transform.position.x] = BoardElement.empty;
        bomb.GetComponent <BombScript> ().detonate();
        Destroy(bomb.gameObject);
        int bombIndex = (int)bomb.position.y * BOARD_WIDTH + (int)bomb.position.x;

        gameObjects.Remove(bombIndex);

        int row    = (int)bomb.position.y;
        int column = (int)bomb.position.x;

        List <Vector3> list = new List <Vector3> ();

        list.Add(bomb.position);
        Transform parentObj = Instantiate(fireGroup, bomb.position, Quaternion.identity);

        parentObj.parent = this.transform;

        int[] directionsX = { 1, -1, 0, 0 };
        int[] directionsY = { 0, 0, 1, -1 };

        for (int dir = 0; dir < 4; dir++)
        {
            int xdir = directionsX [dir];
            int ydir = directionsY [dir];
            for (int i = 0; i < power; i++)
            {
                BoardElement element;
                GameObject   gameObj;
                int          targetRow    = row + (1 + i) * ydir;
                int          targetColumn = column + (1 + i) * xdir;
                int          index        = targetRow * BOARD_WIDTH + targetColumn;
                board.TryGetValue(index, out element);
                if (element == BoardElement.wall)
                {
                    gameObjects.TryGetValue(index, out gameObj);
                    DestroyObject(gameObj);
                    Transform bonus = Instantiate(bonus_bomb, new Vector3(targetColumn, targetRow, this.transform.position.z + 1), Quaternion.identity);
                    Transform obj   = Instantiate(fireWall, new Vector3(targetColumn, targetRow, this.transform.position.z), Quaternion.identity);
                    obj.parent   = this.transform;
                    bonus.parent = this.transform;
                    NetworkServer.Spawn(obj.gameObject);
                    NetworkServer.Spawn(bonus.gameObject);
                    gameObjects [index] = bonus.gameObject;
                    DestroyObject(obj.gameObject, 1);
                    BoardElement dropElement = BoardElement.bonus_bomb;
                    board [index] = dropElement;
                    RpcUpdateBoard(dropElement, index);
                    break;
                }
                else if (element == BoardElement.solid)
                {
                    break;
                }
                else if (element == BoardElement.bomb)
                {
                    gameObjects.TryGetValue(index, out gameObj);
                    BombScript bombObj = gameObj.GetComponent <BombScript> ();
                    detonateBomb(gameObj.transform, bombObj.owner.flameLength);
                }
                list.Add(new Vector3((int)bomb.position.x + (1 + i) * xdir, bomb.position.y + (i + 1) * ydir));
            }
        }

        foreach (Vector3 position in list)
        {
            Transform obj = Instantiate(fire, position, Quaternion.identity);
            obj.tag    = "Fire";
            obj.parent = parentObj.transform;
            NetworkServer.Spawn(obj.gameObject);
        }
    }
예제 #33
0
    void Update()
    {
        //BulletTimer Settings
        if (bulletTime)
        {
            if (bulletTimer < 3)
            {
                soundScript.ChangePitch();
                bulletTimer += Time.deltaTime;
            }
            else
            {
                soundScript.ResumePitch();
                bulletTime = false;
                bulletTimer = 0;
            }
        }
        //BulletTimer SettingsEnd

        //Levels Settings //ObjectiveScore-Timer between instanciating Balloons-Loading
        if (level == 46)
        {
            if (!once)
            {
                balloonsCuantity = 100000;
                timerBalloons = 3;
                loadingSurvivor = true;
                once = true;
            }
        }
        if (level == 1)
        {
            if (!once)
            {
                objectiveScore = 500;
                balloonsCuantity = 30;
                timerBalloons = 3;
                loading = true;
                once = true;
            }
        }
        if (level == 2)
        {
            if (!once)
            {
                objectiveScore = 750;
                balloonsCuantity = 35;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 3)
        {
            if (!once)
            {
                objectiveScore = 1000;
                balloonsCuantity = 40;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 4)
        {
            if (!once)
            {
                objectiveScore = 1250;
                balloonsCuantity = 45;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 5)
        {
            if (!once)
            {
                objectiveScore = 800;
                balloonsCuantity = 45;
                timerBalloons = 1.5f;
                loading = true;
                once = true;
            }
        }
        if (level == 6)
        {
            if (!once)
            {
                objectiveScore = 800;
                balloonsCuantity = 40;
                timerBalloons = 2f;
                loading = true;
                once = true;
            }
        }
        if (level == 7)
        {
            if (!once)
            {
                objectiveScore = 1000;
                balloonsCuantity = 45;
                timerBalloons = 2f;
                loading = true;
                once = true;
            }
        }
        if (level == 8)
        {
            if (!once)
            {
                objectiveScore = 1000;
                balloonsCuantity = 40;
                timerBalloons = 1.5f;
                loading = true;
                once = true;
            }
        }
        if (level == 9)
        {
            if (!once)
            {
                objectiveScore = 1250;
                balloonsCuantity = 45;
                timerBalloons = 1.5f;
                loading = true;
                once = true;
            }
        }
        if (level == 10)
        {
            if (!once)
            {
                objectiveScore = 2000;
                balloonsCuantity = 55;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 11)
        {
            if (!once)
            {
                objectiveScore = 2000;
                balloonsCuantity = 50;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 12)
        {
            if (!once)
            {
                objectiveScore = 2000;
                balloonsCuantity = 50;
                timerBalloons = 1.5f;
                loading = true;
                once = true;
            }
        }
        if (level == 13)
        {
            if (!once)
            {
                objectiveScore = 2250;
                balloonsCuantity = 55;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 14)
        {
            if (!once)
            {
                objectiveScore = 2250;
                balloonsCuantity = 55;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 15)
        {
            if (!once)
            {
                objectiveScore = 2000;
                balloonsCuantity = 55;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 16)
        {
            if (!once)
            {
                objectiveScore = 1250;
                balloonsCuantity = 40;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 17)
        {
            if (!once)
            {
                objectiveScore = 1250;
                balloonsCuantity = 35;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 18)
        {
            if (!once)
            {
                objectiveScore = 1500;
                balloonsCuantity = 40;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 19)
        {
            if (!once)
            {
                objectiveScore = 1500;
                balloonsCuantity = 40;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 20)
        {
            if (!once)
            {
                objectiveScore = 1250;
                balloonsCuantity = 35;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 21)
        {
            if (!once)
            {
                objectiveScore = 1500;
                balloonsCuantity = 40;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 22)
        {
            if (!once)
            {
                objectiveScore = 1500;
                balloonsCuantity = 35;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 23)
        {
            if (!once)
            {
                objectiveScore = 1500;
                balloonsCuantity = 40;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 24)
        {
            if (!once)
            {
                objectiveScore = 1500;
                balloonsCuantity = 35;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 25)
        {
            if (!once)
            {
                objectiveScore = 1500;
                balloonsCuantity = 40;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 26)
        {
            if (!once)
            {
                objectiveScore = 1750;
                balloonsCuantity = 40;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 27)
        {
            if (!once)
            {
                objectiveScore = 1750;
                balloonsCuantity = 40;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 28)
        {
            if (!once)
            {
                objectiveScore = 1500;
                balloonsCuantity = 40;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 29)
        {
            if (!once)
            {
                objectiveScore = 1750;
                balloonsCuantity = 45;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 30)
        {
            if (!once)
            {
                objectiveScore = 1750;
                balloonsCuantity = 45;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 31)
        {
            if (!once)
            {
                objectiveScore = 1750;
                balloonsCuantity = 40;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 32)
        {
            if (!once)
            {
                objectiveScore = 2000;
                balloonsCuantity = 50;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 33)
        {
            if (!once)
            {
                objectiveScore = 2000;
                balloonsCuantity = 35;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 34)
        {
            if (!once)
            {
                objectiveScore = 2500;
                balloonsCuantity = 40;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 35)
        {
            if (!once)
            {
                objectiveScore = 2500;
                balloonsCuantity = 40;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 36)
        {
            if (!once)
            {
                objectiveScore = 2500;
                balloonsCuantity = 35;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 37)
        {
            if (!once)
            {
                objectiveScore = 2750;
                balloonsCuantity = 40;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 38)
        {
            if (!once)
            {
                objectiveScore = 2750;
                balloonsCuantity = 40;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 39)
        {
            if (!once)
            {
                objectiveScore = 2500;
                balloonsCuantity = 40;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 40)
        {
            if (!once)
            {
                objectiveScore = 3000;
                balloonsCuantity = 60;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 41)
        {
            if (!once)
            {
                objectiveScore = 3000;
                balloonsCuantity = 55;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 42)
        {
            if (!once)
            {
                objectiveScore = 3000;
                balloonsCuantity = 50;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 43)
        {
            if (!once)
            {
                objectiveScore = 3000;
                balloonsCuantity = 55;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        if (level == 44)
        {
            if (!once)
            {
                objectiveScore = 3000;
                balloonsCuantity = 45;
                timerBalloons = 2;
                loading = true;
                once = true;
            }
        }
        if (level == 45)
        {
            if (!once)
            {
                objectiveScore = 3500;
                balloonsCuantity = 45;
                timerBalloons = 1;
                loading = true;
                once = true;
            }
        }
        //ButtonsLevelsEnd

        //Pause && Sound
        if (pause)
        {
            pauseOptions.SetActiveRecursively(true);
            soundScript.StopSound();
            Time.timeScale = 0;
            pauseGo.renderer.material.mainTexture = pauseOn;
        }
        else
        {
            pauseOptions.SetActiveRecursively(false);
            if (!soundOnOff)
            {
                soundScript.ResumeSound();
            }
            else
            {
                soundScript.StopSound();
            }
            if (bulletTime)
            {
                Time.timeScale = 0.3f;
            }
            else
            {
                Time.timeScale = 1;
            }
            pauseGo.renderer.material.mainTexture = pauseOff;
        }
        if (soundOnOff)
        {
            soundInMenu.renderer.material.mainTexture = soundOff;
            soundButton.renderer.material.mainTexture = soundOff;
            soundScript.StopSound();
        }
        else
        {
            soundInMenu.renderer.material.mainTexture = soundOn;
            soundButton.renderer.material.mainTexture = soundOn;
            if (!pause)
            {
                soundScript.ResumeSound();
            }
        }
        //Pause && Sound End

        //Buttons-Balloons Manipulator
        if (!pause)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit))
                {
                    //Menu
                    if (hit.collider.gameObject.GetComponent<ButtonId>())
                    {
                        buttonPressed = hit.collider.gameObject.GetComponent<ButtonId>();
                        if (buttonPressed.id == "face")
                        {
                            soundScript.PlaySound(19, false, 1f);
                            Application.OpenURL("https://www.facebook.com/pages/Crusher-Balloons/192136817565820");
                        }
                        if (buttonPressed.id == "twitter")
                        {
                            soundScript.PlaySound(19, false, 1f);
                            Application.OpenURL("https://twitter.com/#!/MG_Developments");
                        }

                        if (buttonPressed.id == "restart")
                        {
                            soundScript.PlaySound(19, false, 1f);
                            Reset();
                        }
                        if (buttonPressed.id == "sound")
                        {
                            soundOnOff = !soundOnOff;
                        }
                        if (buttonPressed.id == "okIntro")
                        {
                            Destroy(intro.gameObject);
                        }
                        if (buttonPressed.id == "pause")
                        {
                            pause = !pause;
                        }
                        if (buttonPressed.id == "survivor")
                        {
                            level = buttonPressed.idLevel;
                            highScore = scoreScript.highScoreList[level];
                            entireMenu.animation.Play("@SurvivorToLoading");
                        }
                        if (buttonPressed.id == "toMenu")
                        {
                            soundScript.PlaySound(19, false, 1f);
                            level = 0;
                            once = false;
                            gameStarted = false;
                            survivorMode = false;
                            ballonManagerScript.timerEnd = 5;
                            entireMenu.animation.Play("@LoadingToLevels");
                            Reset();
                        }
                        if (buttonPressed.id == "toNextLevel")
                        {
                            soundScript.PlaySound(19, false, 1f);
                            gameStarted = false;
                            once = false;
                            Reset();
                            level++;
                        }
                        if (buttonPressed.id == "play")
                        {
                            soundScript.PlaySound(19, false, 1f);
                            entireMenu.animation.Play("@PlayToLevelSurvivor");
                        }
                        if (buttonPressed.id == "BackFromHow")
                        {
                            soundScript.PlaySound(20, false, 0.5f);
                            entireMenu.animation.Play("@HowToPlay");
                        }
                        if (buttonPressed.id == "how")
                        {
                            entireMenu.animation.Play("@PlayToHow");
                            soundScript.PlaySound(19, false, 1f);
                        }
                        if (buttonPressed.id == "exit")
                        {
                            System.Diagnostics.Process.GetCurrentProcess().Kill();
                        }
                        if (buttonPressed.id == "levels")
                        {
                            soundScript.PlaySound(19, false, 1f);
                            entireMenu.animation.Play("@LevelsToSelectLevel");
                        }
                        if (buttonPressed.id == "back1")
                        {
                            soundScript.PlaySound(20, false, 0.5f);
                            entireMenu.animation.Play("@LevelSurvivorToPlay");
                        }
                        if (buttonPressed.id == "back2")
                        {
                            soundScript.PlaySound(20, false, 0.5f);
                            entireMenu.animation.Play("@SelectLevelsToLevelSurvivor");
                        }
                        if (buttonPressed.id == "next1")
                        {
                            soundScript.PlaySound(19, false, 1f);
                            levels.animation.Play("@Level1ToLevel2");
                            back.animation.Play("@BackToLevel2");
                            inStorm = true;
                        }
                        if (buttonPressed.id == "next2")
                        {
                            soundScript.PlaySound(19, false, 1f);
                            levels.animation.Play("@Level2ToLevel3");
                            back.animation.Play("@BackToLevel3");
                            inStorm = false;
                        }
                        if (buttonPressed.id == "backlevel1")
                        {
                            soundScript.PlaySound(20, false, 0.5f);
                            levels.animation.Play("@Level2ToLevel1");
                            back.animation.Play("@BackToLevel1");
                            inStorm = false;
                        }
                        if (buttonPressed.id == "backlevel2")
                        {
                            soundScript.PlaySound(20, false, 0.5f);
                            levels.animation.Play("@Level3ToLevel2");
                            back.animation.Play("@ReturnBack2");
                            inStorm = true;
                        }
                        ///////levels
                        if (buttonPressed.who == "levels")
                        {
                            entireMenu.animation.Play("@SelectLevelsToLoading");
                            level = buttonPressed.idLevel;
                            highScore = scoreScript.highScoreList[level];
                        }
                    }
                    //MenuEnd

                    ///Balloons
                    if (hit.collider.gameObject.layer == 10)
                    {
                        hitObject = hit.collider.gameObject.GetComponent<Balloon>();
                        if (hitObject.Idballoon == "orange")
                        {
                            Destroy(hit.collider.gameObject.transform.root.gameObject);
                            GameObject particleProv = (GameObject)GameObject.Instantiate(particle);
                            particleProv.transform.position = hitObject.transform.position;
                            particleProv.renderer.material.mainTexture = particleTexture[0];
                        }
                        if (hitObject.Idballoon == "bullet")
                        {
                            bulletTime = true;
                            Destroy(hit.collider.gameObject.transform.root.gameObject);
                        }
                        if (hitObject.Idballoon == "black")
                        {
                            Camera.mainCamera.animation.Play("@CameraShakeLight");
                            if (multiply >= 5 && multiply < 7)
                            {
                                this.animation.CrossFade("@CameraShakingLight");
                            }
                            if (multiply >= 7 && multiply < 10)
                            {
                                this.animation.CrossFade("@CameraShakingHeavy");
                            }
                            if (multiply >= 10)
                            {
                                this.animation.CrossFade("@CameraShakingSuperHeavy");
                            }
                            bombScript = hit.collider.gameObject.GetComponentInChildren<BombScript>();
                            bombChild = hit.collider.gameObject.GetComponent<BombGetChildren>();
                            hitObject.renderer.enabled = false;
                            bombScript.timerBomb = 10;
                            bombChild.sphereCollider.radius = 4;
                            bombArrayLength = bombScript.arrayList.Length-1;
                            for (int i = bombArrayLength; 0 <= i; i--)
                            {
                                if (bombScript.arrayList != null)
                                {
                                    Destroy(bombScript.arrayList[i].gameObject);
                                    scoreScript.SurvivorDestroyed();
                                }
                            }
                            bombScript.thisMesh.renderer.enabled = false;
                            GameObject particleBoom1 = (GameObject)GameObject.Instantiate(particleBoom);
                            particleBoom1.transform.position = hitObject.transform.position;
                            Destroy(hit.collider.gameObject.transform.root.gameObject,0.1f);
                        }
                        if (hitObject.Idballoon == "eater")
                        {
                            Destroy(hit.collider.gameObject.transform.root.gameObject);
                        }

                        if (hitObject.Idballoon == "theray")
                        {
                            particleGreen2 = (GameObject)GameObject.Instantiate(particleGreen);
                            particleGreen2.transform.position = hitObject.transform.position;
                            particleGreen2.renderer.material.mainTexture = yellowParticle;
                            if (hitObject.randomRayColor == 0)
                            {
                                ballonManagerScript.DestroyAllRed();
                            }
                            else
                            {
                                if (hitObject.randomRayColor == 1)
                                {
                                    ballonManagerScript.DestroyAllGreen();
                                }
                                else
                                {
                                    if (hitObject.randomRayColor == 2)
                                    {
                                        ballonManagerScript.DestroyAllBlue();
                                    }
                                    else
                                    {
                                        if (hitObject.randomRayColor == 3)
                                        {
                                            ballonManagerScript.DestroyAllYellow();
                                        }
                                    }
                                }
                            }
                            scoreScript.PlusScore(ballonManagerScript.calculationScore, 1);
                            ballonManagerScript.calculationScore = 0;
                            Destroy(hit.collider.gameObject.transform.root.gameObject);
                        }
                    }
                    if (hit.collider.gameObject.layer == 9)
                    {
                        hitObject = hit.collider.gameObject.GetComponent<Balloon>();
                        GameObject particleProv = (GameObject)GameObject.Instantiate(particle);
                        particleProv.transform.position = hitObject.transform.position;
                        if (gameStarted||survivorMode)
                        {
                            particleGreen2 = (GameObject)GameObject.Instantiate(particleGreen);
                            particleGreen2.transform.position = hitObject.transform.position;
                        }
                        if (hitObject.Idballoon == "red")
                        {
                            particleProv.renderer.material.mainTexture = particleTexture[0];
                        }
                        if (hitObject.Idballoon == "blue")
                        {
                            particleProv.renderer.material.mainTexture = particleTexture[1];
                        }
                        if (hitObject.Idballoon == "green")
                        {
                            particleProv.renderer.material.mainTexture = particleTexture[2];
                        }
                        if (hitObject.Idballoon == "yellow")
                        {
                            particleProv.renderer.material.mainTexture = particleTexture[3];
                        }

                        if (hitObject.Idballoon == "joker")
                        {
                            if (provisorio == "red" || provisorio == "blue" || provisorio == "yellow" || provisorio == "green" || provisorio != null)
                            {
                                hitObject.Idballoon = provisorio;
                            }
                            else
                            {
                                if (gameStarted || survivorMode)
                                {
                                    GameObject scoreFeedbackProv = (GameObject)GameObject.Instantiate(scoreFeedback);
                                    scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[0];
                                    scoreFeedbackProv.transform.position = hit.collider.gameObject.transform.position;
                                    scoreFeedbackProv.animation.Play("@ScoreFeedback");
                                    multiply = 1;
                                    scoreScript.PlusScore(10, multiply);
                                }
                            }
                        }
                        if (hitObject.Idballoon == "incognit")
                        {
                            if (gameStarted || survivorMode)
                            {
                                randomIncognit = Random.Range(0, 3);
                                if (randomIncognit == 0)
                                {
                                    particleGreen2 = (GameObject)GameObject.Instantiate(particleGreen);
                                    particleGreen2.transform.position = hitObject.transform.position;
                                    GameObject scoreFeedbackProv = (GameObject)GameObject.Instantiate(scoreFeedback);
                                    scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[0];
                                    scoreFeedbackProv.transform.position = hit.collider.gameObject.transform.position;
                                    scoreFeedbackProv.animation.Play("@ScoreFeedback");
                                    multiply = 1;
                                    scoreScript.PlusScore(10, multiply);
                                }
                                else
                                {
                                    if (randomIncognit == 1)
                                    {
                                        particleGreen2 = (GameObject)GameObject.Instantiate(particleGreen);
                                        particleGreen2.transform.position = hitObject.transform.position;
                                        if (provisorio == "red" || provisorio == "blue" || provisorio == "yellow" || provisorio == "green" || provisorio != null)
                                        {
                                            hitObject.Idballoon = provisorio;
                                        }
                                        else
                                        {
                                            GameObject scoreFeedbackProv = (GameObject)GameObject.Instantiate(scoreFeedback);
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[0];
                                            scoreFeedbackProv.transform.position = hit.collider.gameObject.transform.position;
                                            scoreFeedbackProv.animation.Play("@ScoreFeedback");
                                            multiply = 1;
                                            scoreScript.PlusScore(10, multiply);
                                        }
                                    }
                                    else
                                    {
                                        if (randomIncognit == 2)
                                        {
                                            soundScript.PlaySound(31, false, 0.7f);
                                            GameObject particleBoom1 = (GameObject)GameObject.Instantiate(particleBoom);
                                            particleBoom1.transform.position = hitObject.transform.position;
                                            for (int i = hitObject.arrayList.Length - 1; 0 <= i; i--)
                                            {
                                                if (hitObject.arrayList != null)
                                                {
                                                    Destroy(hitObject.arrayList[i].gameObject);
                                                    scoreScript.SurvivorDestroyed();
                                                }
                                            }
                                            scoreScript.PlusScore(-10, multiply);
                                        }
                                    }
                                }
                            }
                            if (gameStarted || survivorMode)
                            {
                                if (hitObject.Idballoon == "incognit" && randomIncognit == 2)
                                {
                                    particleGreen2.renderer.material.mainTexture = redTxt;
                                }
                                else
                                {
                                    particleGreen2.renderer.material.mainTexture = greenTxt;
                                }
                            }
                            Destroy(hit.collider.gameObject.transform.root.gameObject, 0.1f);
                        }
                        if (hitObject.Idballoon == "red" || hitObject.Idballoon == "blue" || hitObject.Idballoon == "green" || hitObject.Idballoon == "yellow")
                        {
                            if (gameStarted || survivorMode)
                            {
                                if (provisorio == "")
                                {

                                    GameObject scoreFeedbackProv = (GameObject)GameObject.Instantiate(scoreFeedback);
                                    scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[0];
                                    scoreFeedbackProv.transform.position = hit.collider.gameObject.transform.position;
                                    scoreFeedbackProv.animation.Play("@ScoreFeedback");
                                    multiply = 1;
                                    provisorio = hitObject.Idballoon;
                                    scoreScript.PlusScore(10, multiply);
                                }
                                else
                                {
                                    if (provisorio == hitObject.Idballoon)
                                    {
                                        GameObject scoreFeedbackProv = (GameObject)GameObject.Instantiate(scoreFeedback);
                                        scoreFeedbackProv.transform.position = hit.collider.gameObject.transform.position;
                                        scoreFeedbackProv.animation.Play("@xScore");
                                        multiply++;

                                        if (multiply == 2)
                                        {

                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[1];
                                        }
                                        if (multiply == 3)
                                        {
                                            soundScript.PlaySound(22, false, 1);
                                            GameObject feedBack = (GameObject)GameObject.Instantiate(feedback[0]);
                                            feedBack.transform.position = feedbackPos.transform.position;
                                            this.animation.Play("@CameraShakeLight");
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[2];
                                        }
                                        if (multiply == 4)
                                        {
                                            this.animation.Play("@CameraShakeLight");
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[3];
                                        }
                                        if (multiply == 5)
                                        {
                                            soundScript.PlaySound(23, false, 1);
                                            GameObject great = (GameObject)GameObject.Instantiate(feedback[1]);
                                            great.transform.position = feedbackPos.transform.position;
                                            this.animation.CrossFade("@CameraShakingLight");
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[4];
                                        }
                                        if (multiply == 6)
                                        {
                                            this.animation.CrossFadeQueued("@CameraShakingLight");
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[5];
                                        }
                                        if (multiply == 7)
                                        {
                                            soundScript.PlaySound(28, false, 1);
                                            GameObject awesome = (GameObject)GameObject.Instantiate(feedback[2]);
                                            awesome.transform.position = feedbackPos.transform.position;
                                            this.animation.CrossFade("@CameraShakingHeavy");
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[6];
                                        }
                                        if (multiply == 8)
                                        {
                                            this.animation.CrossFade("@CameraShakingHeavy");
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[7];
                                        }
                                        if (multiply == 9)
                                        {
                                            this.animation.CrossFade("@CameraShakingHeavy");
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[8];
                                        }
                                        if (multiply >= 10)
                                        {
                                            soundScript.PlaySound(29, false, 1);
                                            GameObject perfect = (GameObject)GameObject.Instantiate(feedback[3]);
                                            perfect.transform.position = feedbackPos.transform.position;
                                            this.animation.CrossFade("@CameraShakingSuperHeavy");
                                            multiply = 10;
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[9];
                                        }
                                        scoreScript.PlusScore(10, multiply);
                                    }
                                    else
                                    {
                                        if (provisorio != hitObject.Idballoon)
                                        {
                                            provisorio = hitObject.Idballoon;

                                            this.animation.CrossFade("@CameraIdle");
                                            GameObject scoreFeedbackProv = (GameObject)GameObject.Instantiate(scoreFeedback);
                                            scoreFeedbackProv.renderer.material.mainTexture = scoreFeedbackTextures[0];
                                            scoreFeedbackProv.transform.position = hit.collider.gameObject.transform.position;
                                            scoreFeedbackProv.animation.Play("@ScoreFeedback");
                                            multiply = 1;
                                            scoreScript.PlusScore(10, multiply);
                                        }
                                    }
                                }

                            }
                        }
                        Destroy(hit.collider.gameObject.transform.root.gameObject);
                    }
                    ///BalloonsEnd
                }
            }
        }
        else
        {
            //I do an else cause if pause is true i cant cast ray, so the only things that i can catch we my ray in pause is one of the optionsButtons
            //OptionsSelection
            if (Input.GetMouseButtonDown(0))
            {
                Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit))
                {
                    buttonPressed = hit.collider.gameObject.GetComponent<ButtonId>();
                    if (buttonPressed != null)
                    {
                        if (buttonPressed.id == "pause")
                        {
                            pause = !pause;
                        }

                        if (buttonPressed.id == "restart")
                        {
                            pause = false;
                            soundScript.PlaySound(19, false, 1f);
                            Reset();
                        }
                        if (buttonPressed.id == "toMenu")
                        {
                            pause = false;
                            soundScript.PlaySound(19, false, 1f);
                            level = 0;
                            once = false;
                            gameStarted = false;
                            survivorMode = false;
                            ballonManagerScript.timerEnd = 5;
                            entireMenu.animation.Play("@LoadingToLevels");
                            Reset();
                        }
                        if (buttonPressed.id == "sound")
                        {
                            soundOnOff = !soundOnOff;
                        }
                    }
                }
            }
        }

        //Loadings (Levels or Survivor)
        if (loadingSurvivor)
        {
            if (waiting < 3)
            {
                waiting += Time.deltaTime;
            }
            else
            {
                //I show a little help or feedback about the special balloon-how to play
                if (!onceHelp)
                {
                    help1 = (GameObject)GameObject.Instantiate(help);
                    help1.transform.position = helpPos.position;
                    help1.renderer.material.mainTexture = helpTxt[9];
                    onceHelp = true;
                }
                //Do i pressed the ok button of the help? Yes-Get ready to play
                if (buttonPressed.id == "ok")
                {
                    soundScript.PlaySound(19, false, 1f);
                    prepare = (GameObject)GameObject.Instantiate(feedback[4]);
                    prepare.transform.position = feedbackPos.transform.position;
                    help1.animation.Play("@HelpOut");
                    Destroy(help1.gameObject, 1);
                    Destroy(clouds.gameObject);
                    clouds = (GameObject)GameObject.Instantiate(menuDeco);
                    clouds.transform.position = cloudsPos.position;
                    waiting = 0;
                    scoreScript.survivorEnd = 0;
                    loadingSurvivor = false;
                    survivorMode = true;
                }
            }
        }
        if (loading)
        {
            if (waiting < 3)
            {
                waiting += Time.deltaTime;
            }
            else
            {
                //I show a little help or feedback about the special balloon-how to play (Depending the level)
                if (level == 1 || level == 5||level==10||level==15||level==16||level==20||level==25||level==30||level==35)
                {
                    if (!onceHelp)
                    {
                        help1 = (GameObject)GameObject.Instantiate(help);
                        help1.transform.position = helpPos.position;
                        if (level == 1)
                        {
                            help1.renderer.material.mainTexture = helpTxt[0];
                        }
                        if (level == 5)
                        {
                            help1.renderer.material.mainTexture = helpTxt[1];
                        }
                        if (level == 10)
                        {
                            help1.renderer.material.mainTexture = helpTxt[2];
                        }
                        if (level == 15)
                        {
                            help1.renderer.material.mainTexture = helpTxt[3];
                        }
                        if (level == 16)
                        {
                            help1.renderer.material.mainTexture = helpTxt[6];
                        }
                        if (level == 20)
                        {
                            help1.renderer.material.mainTexture = helpTxt[4];
                        }
                        if (level == 25)
                        {
                            help1.renderer.material.mainTexture = helpTxt[5];
                        }
                        if (level == 30)
                        {
                            help1.renderer.material.mainTexture = helpTxt[7];
                        }
                        if (level == 35)
                        {
                            help1.renderer.material.mainTexture = helpTxt[8];
                        }
                        onceHelp = true;
                    }
                    //Do i pressed the ok button of the help? Yes-Get ready to play
                    if (buttonPressed.id == "ok")
                    {
                        soundScript.PlaySound(19, false, 1f);
                        prepare = (GameObject)GameObject.Instantiate(feedback[4]);
                        prepare.transform.position = feedbackPos.transform.position;
                        help1.animation.Play("@HelpOut");
                        Destroy(help1.gameObject, 1);
                        Destroy(clouds.gameObject);
                        clouds = (GameObject)GameObject.Instantiate(menuDeco);
                        clouds.transform.position = cloudsPos.position;
                        waiting = 0;
                        scoreScript.totalBallonsDestroyed = 0;
                        loading = false;
                        gameStarted = true;
                    }
                }
                else
                {
                    prepare = (GameObject)GameObject.Instantiate(feedback[4]);
                    prepare.transform.position = feedbackPos.transform.position;
                    Destroy(clouds.gameObject);
                    clouds = (GameObject)GameObject.Instantiate(menuDeco);
                    clouds.transform.position = cloudsPos.position;
                    waiting = 0;
                    scoreScript.totalBallonsDestroyed = 0;
                    loading = false;
                    gameStarted = true;
                }
            }
        }

        //When the menu can be seen?
        if (gameStarted||survivorMode)
        {
            soundInMenu.renderer.enabled = false;
            soundInMenu.collider.enabled = false;
            if (!scoreScript.showingScore)
            {
                pauseGo.renderer.enabled = true;
                pauseGo.collider.enabled = true;
            }
            else
            {
                pauseGo.renderer.enabled = false;
                pauseGo.collider.enabled = false;
            }
            soundScript._channels[0].mute = true;

            if (!pause && !soundOnOff)
            {
                soundScript._channels[1].volume = 0.1f;
            }
            else
            {
                soundScript._channels[1].volume = 0;
            }

            entireMenu.SetActiveRecursively(false);
        }
        else
        {
            soundInMenu.renderer.enabled = true;
            soundInMenu.collider.enabled = true;
            pauseGo.renderer.enabled = false;
            pauseGo.collider.enabled = false;
            if (!onceSound)
            {
                onceSound = true;
            }

            if (!pause&&!soundOnOff)
            {
                soundScript._channels[0].volume = 0.1f;
            }
            soundScript._channels[1].volume = 0;

            entireMenu.SetActiveRecursively(true);
        }
    }
예제 #34
0
 // Start is called before the first frame update
 void Start()
 {
     bombScript            = gameObject.GetComponent <BombScript>();
     DrawAndSetTilesScript = gameObject.GetComponent <DrawAndSetTiles>();
 }