void Update()
    {
        if (gameStarted == false)
        {
            //transform.position = Vector3.MoveTowards(transform.position, player.transform.position, Time.deltaTime * 5);
        }

        if (gameStarted == true)
        {
            transform.position = Vector3.MoveTowards(transform.position, player.transform.position, Time.deltaTime * movmentSpeed);

            if (timer <= 0)
            {
                movmentSpeed += 0.001f;
            }

            transform.position = new Vector3(player.transform.position.x, transform.position.y, -1);

            timer -= Time.deltaTime;

            if (player.position.y < transform.position.y + 2)
            {
                CS_Notify.Send(this, "ChangeStage");
                CS_Notify.Unregister(this, "EnemyBoatStart");
                gameStarted = false;
            }
        }
    }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     manager     = GameObject.Find("GameManager").GetComponent <CS_Gamemanager>();
     gameManager = FindObjectOfType <CS_Gamemanager>();
     Movement    = GameObject.FindGameObjectWithTag("Player").GetComponent <CS_Player_Movment>();
     movement    = GameObject.FindGameObjectWithTag("Player").GetComponent <movment>();
     CS_Notify.Register(this, "BiggerCoins");
     CS_Notify.Register(this, "ShotCoins");
 }
Beispiel #3
0
    void Start()
    {
        leftOarScript  = GameObject.Find("LeftOars").GetComponent <CS_OarLeftScript>();
        rightOarScript = GameObject.Find("RightOars").GetComponent <CS_OarRightScript>();

        CS_Notify.Register(this, "StartGame");
        CS_Notify.Register(this, "StopMoving");
        CS_Notify.Register(this, "MovementUpgrade");
    }
Beispiel #4
0
 void Start()
 {
     CS_Notify.Register(this, "ChangeStage");
     playerScript = player.GetComponent <CS_Player_Movment>();
     ChangeStage();
     progressPlayer.localPosition = new Vector3(progressPlayer.localPosition.x, -300, progressPlayer.localPosition.z);
     progressEnemy.localPosition  = new Vector3(progressEnemy.localPosition.x, -300, progressEnemy.localPosition.z);
     lastPlayerY = player.transform.position.y;
     lastEnemyY  = tempEnemy.transform.position.y;
 }
Beispiel #5
0
 void Update()
 {
     if (biggerCoins == true)
     {
         CS_Notify.Send(this, "BiggerCoins");
     }
     if (shotCoins == true)
     {
         CS_Notify.Send(this, "ShotCoins");
     }
 }
Beispiel #6
0
 public void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "CannonBall")
     {
         hp--;
         Destroy(collision.gameObject);
     }
     if (hp == 0)
     {
         Debug.Log("ej");
         CS_Notify.Send(this, "PowerUp");
         Destroy(this.gameObject);
     }
 }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        CS_Notify.Register(this, "StartTimer");
        pl              = GameObject.FindGameObjectWithTag("Player").GetComponent <CS_Player>();
        timeToDie       = 300f;
        timerHasStarted = false;
        timeToBlink     = false;
        csPB            = GameObject.Find("ProgressBar").GetComponent <CS_PrograssBar>();
        csGTTIP         = GameObject.Find("GTTI prompt").GetComponent <CS_GTTIPrompt>();
        foreach (Transform child in this.transform)
        {
            if (child.tag == ("Text"))
            {
                dCounter.Add(child.GetComponent <Text>());
            }
        }
        for (int i = 0; i < dCounter.Count; i++)
        {
            dCounter[i].text = "";
        }


        foreach (Transform child in this.transform)
        {
            if (child.tag == "Image")
            {
                images.Add(child);
            }
        }
        foreach (Transform child in this.transform)
        {
            if (child.tag == "Arrow")
            {
                arrows.Add(child);
            }
        }
        for (int i = 0; i < images.Count; i++)
        {
            images[i].GetComponent <Image>().enabled = false;
        }
        for (int i = 0; i < arrows.Count; i++)
        {
            arrows[i].GetComponent <Image>().enabled = false;
        }
    }
Beispiel #8
0
    void Start()
    {
        coins            = GameObject.Find("GameManager").GetComponent <CS_Gamemanager>();
        rend             = this.gameObject.GetComponent <SpriteRenderer>();
        whichDamagePoint = 0;
        CS_Notify.Register(this, "EndGame");
        deathAnimation = GetComponent <Animator>();

        foreach (Transform child in this.transform)
        {
            if (child.tag == "Damage")
            {
                damagePoints.Add(child);
                child.GetComponent <ParticleSystem>().Stop();
            }
        }
        highScoreInput = GameObject.Find("HighScoreInput");
        highScoreInput.SetActive(false);
    }
Beispiel #9
0
    private void Update()
    {
        if (start == true)
        {
            if (main.orthographicSize > 10)
            {
                main.orthographicSize = main.orthographicSize - 8 * Time.deltaTime;
            }
            else
            {
                main.transform.position = Vector3.MoveTowards(main.transform.position, new Vector3(player.position.x, player.position.y + 3, -10), Time.deltaTime * 8);
            }

            if (main.transform.position == new Vector3(player.position.x, player.position.y + 3, -10))
            {
                CS_Notify.Send(this, "StartGame");
                //CS_Notify.Send(this, "EnemyBoatStart");
                start = false;
            }
        }



        if (zoomOut == true)
        {
            if (main.transform.position.y >= 489)
            {
                zoomOut = false;
                CS_Notify.Send(this, "StopMoving");
                CS_Notify.Send(this, "EndGame");
            }
            else
            {
                if (main.orthographicSize < 14)
                {
                    main.orthographicSize = main.orthographicSize + 5 * Time.deltaTime;
                }

                main.transform.position = Vector3.MoveTowards(main.transform.position, new Vector3(playerX, 489, -10), Time.deltaTime * 8);
            }
        }
    }
Beispiel #10
0
    public void ChangeStage()
    {
        if (battleStage == true)
        {
            CS_Notify.Send(this, "StopMoving");
            spawnIn = true;
            clouds.transform.position = new Vector3(player.transform.position.x - 100, player.transform.position.y, player.transform.position.z - 3);
            tempClouds = Instantiate <GameObject>(clouds);
            Rigidbody2D tempRb = tempClouds.GetComponent <Rigidbody2D>();
            tempRb.velocity = transform.right * 30;
            travleStage     = true;
            battleStage     = false;
            progressbar.SetActive(true);
            wave++;
            playerScript.enabled = false;
        }
        else if (travleStage == true)
        {
            CS_Notify.Send(this, "StopMoving");
            spawnIn = true;
            clouds.transform.position = new Vector3(player.transform.position.x - 100, player.transform.position.y, player.transform.position.z - 3);
            tempClouds = Instantiate <GameObject>(clouds);
            Rigidbody2D tempRb = tempClouds.GetComponent <Rigidbody2D>();
            tempRb.velocity = transform.right * 30;
            battleStage     = true;
            travleStage     = false;
            progressbar.SetActive(false);
            playerScript.enabled = false;
        }
        else if (battleStage == false && travleStage == false)
        {
            CS_Notify.Send(this, "TurnOnWorldSpawn");
            if (wave == 0)
            {
                tempEnemy = Instantiate(meduimEnemyTravel, new Vector3(player.transform.position.x, player.transform.position.y - 20, player.transform.position.z), new Quaternion(0, 0, 0, 0));
            }

            travleStage = true;
        }
    }
Beispiel #11
0
    public void death()
    {
        dead = true;
        CS_Notify.Send(this, "StopMoving");
        CapsuleCollider2D collider = GetComponent <CapsuleCollider2D>();

        collider.enabled = false;
        CS_Player_Movment movment = GetComponent <CS_Player_Movment>();

        movment.enabled = false;
        CS_Player_Cannons cannons = GetComponent <CS_Player_Cannons>();

        cannons.enabled = false;

        for (int inde = 0; inde < playerSprites.Length; inde++)
        {
            playerSprites[inde].gameObject.SetActive(false);
        }
        deathAnimation.enabled = true;
        coins.CalculateFinalScore();

        StartCoroutine(onDeath());
    }
Beispiel #12
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "CannonBallEnemy")
     {
         playerpos    = this.gameObject.transform.position;
         gotHit       = true;
         activateLife = true;
         ActivateDamagePoints();
         hp--;
         impactHit.Play();
         StartCoroutine(damageFeedback());
     }
     if (collision.gameObject.tag == "End")
     {
         ended = true;
         coins.CalculateFinalScore();
         CS_Notify.Send(this, "ZoomOut");
     }
     if (hp <= 0)
     {
         death();
     }
 }
Beispiel #13
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            if (powerUp == 1)
            {
                CS_Notify.Send(this, "MovementUpgrade");
            }
            if (powerUp == 2)
            {
                CS_Notify.Send(this, "CannonUpgrad");
            }
            if (powerUp == 3)
            {
                CS_Notify.Send(this, "BiggerCoinsTrue");
            }
            if (powerUp == 4)
            {
                CS_Notify.Send(this, "ShotCoinsTrue");
            }

            Destroy(this.gameObject);
        }
    }
Beispiel #14
0
    void Update()
    {
        if (player.transform.position.y >= 100 && startSpawnTile == false)
        {
            startSpawnTile = true;
            CS_Notify.Send(this, "StartTimer");
        }
        if (startSpawnTile == true)
        {
            if (player.transform.position.x > playerTileX + 5)
            {
                if (checkLine(line + 2) == false)
                {
                    addLine(line + 2);
                    //instansModuals(lineIndex, tile - 2, tile + 2);
                }
            }
            if (player.transform.position.x > playerTileX + 13)
            {
                line++;
                playerTileX += 26f;
                //if (tile >= 0 && tile <= 14)
                //{
                //    if (lines[getLinePlace(line + 1)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line + 1), tile - 2, tile + 2);
                //        instansModuals(getLinePlace(line + 2), tile - 2, tile + 2);
                //    }
                //}
            }
            if (player.transform.position.x < playerTileX - 5)
            {
                if (checkLine(line - 2) == false)
                {
                    addLine(line - 2);
                    //instansModuals(lineIndex, tile - 2, tile + 2);
                }
            }
            if (player.transform.position.x < playerTileX - 13)
            {
                line--;
                playerTileX -= 26f;
                //if (tile >= 0 && tile <= 14)
                //{
                //    if (lines[getLinePlace(line - 1)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line - 1), tile - 2, tile + 2);
                //        instansModuals(getLinePlace(line - 2), tile - 2, tile + 2);
                //    }
                //}
            }
            if (player.transform.position.y > playerTileY + 13)
            {
                playerTileY += 26f;

                //instansModuals(getLinePlace(line), tile, tile + 1);
                //instansModuals(getLinePlace(line + 1), tile, tile + 1);
                //instansModuals(getLinePlace(line - 1), tile, tile + 1);
                //instansModuals(getLinePlace(line + 2), tile, tile + 1);
                //instansModuals(getLinePlace(line - 2), tile, tile + 1);
                tile++;
                CS_Notify.Send(this, "NextTile");

                //if (tile >= 0 && tile <= 14)
                //{

                //    if (lines[getLinePlace(line)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line), tile, tile + 2);
                //    }
                //    if (lines[getLinePlace(line + 1)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line + 1), tile, tile + 2);
                //    }
                //    if (lines[getLinePlace(line - 1)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line - 1), tile, tile + 2);
                //    }
                //    if (lines[getLinePlace(line + 2)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line + 2), tile, tile + 2);
                //    }
                //    if (lines[getLinePlace(line - 2)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line - 2), tile, tile + 2);
                //    }
                //}
            }

            if (player.transform.position.y < playerTileY)
            {
                //instansModuals(getLinePlace(line), tile, tile - 1);
                //instansModuals(getLinePlace(line + 1), tile, tile - 1);
                //instansModuals(getLinePlace(line - 1), tile, tile - 1);
                //instansModuals(getLinePlace(line + 2), tile, tile - 1);
                //instansModuals(getLinePlace(line - 2), tile, tile - 1);

                //if (tile >= 0 && tile <= 14)
                //{

                //    if (lines[getLinePlace(line)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line), tile, tile - 1);
                //    }
                //    if (lines[getLinePlace(line + 1)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line + 1), tile, tile - 1);
                //    }
                //    if (lines[getLinePlace(line - 1)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line - 1), tile, tile - 1);
                //    }
                //    if (lines[getLinePlace(line + 2)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line + 2), tile, tile - 1);
                //    }
                //    if (lines[getLinePlace(line - 2)].GetHasSpawned(tile) == false)
                //    {
                //        instansModuals(getLinePlace(line - 2), tile, tile - 1);
                //    }
                //}
            }
            if (tile >= 0 && tile < 14)
            {
                if (lines[getLinePlace(line)].GetHasSpawned(tile) == false)
                {
                    instansModuals(getLinePlace(line), tile, tile);
                }
                if (lines[getLinePlace(line)].GetHasSpawned(tile + 1) == false)
                {
                    instansModuals(getLinePlace(line), tile, tile + 1);
                }
                if (lines[getLinePlace(line)].GetHasSpawned(tile + 2) == false)
                {
                    instansModuals(getLinePlace(line), tile, tile + 2);
                }


                if (lines[getLinePlace(line + 1)].GetHasSpawned(tile) == false)
                {
                    instansModuals(getLinePlace(line + 1), tile - 1, tile);
                }
                if (lines[getLinePlace(line + 1)].GetHasSpawned(tile) == false)
                {
                    instansModuals(getLinePlace(line + 1), tile, tile);
                }
                if (lines[getLinePlace(line + 1)].GetHasSpawned(tile + 1) == false)
                {
                    instansModuals(getLinePlace(line + 1), tile, tile + 1);
                }
                if (lines[getLinePlace(line + 1)].GetHasSpawned(tile + 2) == false)
                {
                    instansModuals(getLinePlace(line + 1), tile, tile + 2);
                }

                if (lines[getLinePlace(line - 1)].GetHasSpawned(tile - 1) == false)
                {
                    instansModuals(getLinePlace(line - 1), tile - 1, tile);
                }
                if (lines[getLinePlace(line - 1)].GetHasSpawned(tile) == false)
                {
                    instansModuals(getLinePlace(line - 1), tile, tile);
                }
                if (lines[getLinePlace(line - 1)].GetHasSpawned(tile + 1) == false)
                {
                    instansModuals(getLinePlace(line - 1), tile, tile + 1);
                }
                if (lines[getLinePlace(line - 1)].GetHasSpawned(tile + 2) == false)
                {
                    instansModuals(getLinePlace(line - 1), tile, tile + 2);
                }
            }


            for (int lineIndex = 0; lineIndex < lines.Count; lineIndex++)
            {
                for (int tileIndex = 0; tileIndex < lines[lineIndex].tiles.Count; tileIndex++)
                {
                    if (player.transform.position.y >= lines[lineIndex].GetPosY(tileIndex) + 40)
                    {
                        Destroy(lines[lineIndex].tiles[tileIndex].tile);
                        lines[lineIndex].tiles[tileIndex].hasSpawned = false;
                    }
                }
            }

            for (int lineIndex = 0; lineIndex < lines.Count; lineIndex++)
            {
                for (int tileIndex = 0; tileIndex < lines[lineIndex].tiles.Count; tileIndex++)
                {
                    if (player.transform.position.x >= lines[lineIndex].GetPosX(tileIndex) + 50 || player.transform.position.x <= lines[lineIndex].GetPosX(tileIndex) - 50)
                    {
                        Destroy(lines[lineIndex].tiles[tileIndex].tile);
                        lines[lineIndex].tiles[tileIndex].hasSpawned = false;
                    }
                }
            }

            if (player.transform.position.y >= 180)
            {
                Destroy(startTile.gameObject);
            }
        }
    }
Beispiel #15
0
 void Start()
 {
     CS_Notify.Register(this, "ChangeToArenaCamera");
     CS_Notify.Register(this, "ZoomOut");
     cameraScript = main.GetComponent <CS_Camera_Movment>();
 }
 void Start()
 {
     CS_Notify.Register(this, "EnemyBoatStart");
     player = GameObject.Find("Player").GetComponent <Transform>();
 }
Beispiel #17
0
 void Start()
 {
     CS_Notify.Register(this, "BiggerCoinsTrue");
     CS_Notify.Register(this, "ShotCoinsTrue");
 }
Beispiel #18
0
 void Start()
 {
     appearTimes = 0;
     CS_Notify.Register(this, "NextTile");
     position = player.position;
 }
Beispiel #19
0
 void Start()
 {
     CS_Notify.Register(this, "StartGame");
     CS_Notify.Register(this, "StopMoving");
     rb = GetComponent <Rigidbody2D>();
 }
Beispiel #20
0
    void Update()
    {
        if (tempClouds != null)
        {
            if (tempClouds.transform.position.x > player.transform.position.x)
            {
                if (spawnIn == true)
                {
                    if (battleStage == true)
                    {
                        CS_Notify.Send(this, "TurnOffWorldSpawn");
                        CS_Notify.Send(this, "ChangeToArenaCamera");
                        tempClouds.transform.position   = new Vector3(tempClouds.transform.position.x, 3, tempClouds.transform.position.z);
                        arenas[wave].transform.position = new Vector3(0, 0, 0);
                        tempArena = Instantiate <GameObject>(arenas[wave]);
                        Quaternion playerRotation = player.transform.rotation;
                        playerRotation.z          = -1;
                        player.transform.rotation = playerRotation;
                        player.transform.position = new Vector3(-10, 3, 0);
                        spawnIn = false;
                        Destroy(tempEnemy);
                        if (wave == 0)
                        {
                            tempEnemy = Instantiate <GameObject>(meduimEnemyBattel);
                            tempEnemy.transform.position = new Vector3(40, 3, 0);
                        }
                        if (wave == 1)
                        {
                            tempEnemy = Instantiate <GameObject>(largeEnemeyBattel);
                            tempEnemy.transform.position = new Vector3(40, 3, 0);
                        }
                    }

                    if (travleStage == true)
                    {
                        CS_Notify.Send(this, "MovePlayer");
                        CS_Notify.Send(this, "TurnOnWorldSpawn");
                        CS_Notify.Send(this, "ChangeToTravelCamera");
                        player.transform.rotation = new Quaternion(0, 0, 0, 0);
                        spawnIn = false;
                        if (tempEnemy != null)
                        {
                            Destroy(tempEnemy.gameObject);
                        }

                        Destroy(tempArena.gameObject);
                        if (wave == 1)
                        {
                            tempEnemy   = Instantiate(largeEnemeyTravel, new Vector3(player.transform.position.x, player.transform.position.y - 30, player.transform.position.z), new Quaternion(0, 0, 0, 0));;
                            lastPlayerY = player.transform.position.z;
                        }
                    }
                }
            }
            if (tempClouds.transform.position.x > player.transform.position.x + 150)
            {
                Destroy(tempClouds);
                if (battleStage == true)
                {
                    CS_Enemy_Battel script = tempEnemy.GetComponent <CS_Enemy_Battel>();
                    script.enabled       = true;
                    playerScript.enabled = true;
                }
                if (travleStage == true)
                {
                    CS_Notify.Send(this, "EnemyBoatStart");
                    playerScript.enabled = true;
                }
            }
        }

        float playerYPos = player.transform.position.y;

        if (playerYPos - lastPlayerY >= 1)
        {
            progressPlayer.localPosition = new Vector3(progressPlayer.localPosition.x, progressPlayer.localPosition.y + 1f, progressPlayer.localPosition.z);
            lastPlayerY = player.transform.position.y;
        }

        if (tempEnemy != null)
        {
            float enemyYPos = tempEnemy.transform.position.y;
            if (enemyYPos - lastEnemyY >= 1)
            {
                progressEnemy.localPosition = new Vector3(progressEnemy.localPosition.x, progressEnemy.localPosition.y + 0.8f, progressEnemy.localPosition.z);
                lastEnemyY = tempEnemy.transform.position.y;
            }
        }
    }
Beispiel #21
0
 void Start()
 {
     CS_Notify.Register(this, "CannonUpgrad");
 }