public IEnumerator KillBoss()
    {
        yield return(new WaitForSeconds(1));

        DataManager.instance.SetupFinishedGameMessage();

        BatController bat = player.GetComponent <BatController>();

        bat.moveSpeed = 0;

        Camera.main.GetComponent <CameraMovement>().target = spiderBoss.transform;

        yield return(new WaitForSeconds(2));

        spiderBossObject.SetActive(false);

        yield return(new WaitForSeconds(1));

        Camera.main.GetComponent <CameraMovement>().target = bat.transform;

        UIManager.instance.fadeScreenAnim.SetTrigger("FadeOut");

        yield return(new WaitForSeconds(3.5f));

        SceneManager.LoadScene("Ending");
    }
Example #2
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        // Give damage
        BatController giveDamage = collision.collider.GetComponent <BatController>();

        //BatController giveDamage = player.GetComponent<BatController>();
        giveDamage.takedamage(enemyDamage);
    }
Example #3
0
 private void Awake()
 {
     controller                 = GetComponent <BatController>();
     state                      = GetComponent <BatState>();
     body                       = GetComponent <Rigidbody>();
     initialPosition            = transform.position;
     timeToRespawnImage.enabled = false;
 }
Example #4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #5
0
    public void InitLine(BatController c, Vector2 p1, Vector2 p2)
    {
        controller = c;

        point1 = p1;
        point2 = p2;

        point1Original = p1;
        point2Original = p2;

        vl = controller.CreateLine(p1, p2);
    }
    public IEnumerator AttackPlayer()
    {
        BatController bat = player.GetComponent <BatController>();

        bossAnim.SetTrigger("pGrab");
        yield return(new WaitForSeconds(0.75f));

        if (isGrabbable && bat.canGetHit)
        {
            if (Vector3.Distance(bat.transform.position, spiderSecondCheckTriggerRight.position) < Vector3.Distance(bat.transform.position, spiderSecondCheckTriggerLeft.position))
            {
                grabbedPlayedRight = true;
            }
            else
            {
                grabbedPlayedLeft = true;
            }

            audioSource.clip = spiderSounds[Random.Range(0, spiderSounds.Count)];
            audioSource.Play();

            bossAnim.SetTrigger("pPlayerCaught");
            bossAnim.SetBool("bEat", true);
            bat.GetComponent <Rigidbody2D>().simulated = false;
        }
        else
        {
            yield break;
        }

        yield return(new WaitForSeconds(3.5f));

        audioSource.clip = spiderSounds[Random.Range(0, spiderSounds.Count)];
        audioSource.Play();

        GameManager.instance.SubtractLive();
        Camera.main.transform.GetComponent <CameraShake>().Shake(shakeDuration, shakeX, shakeY, shakeZ, shakeRotate, shakeSpeed);
        StartCoroutine(bat.HitInvinsibility(2));

        yield return(new WaitForSeconds(1f));

        grabbedPlayedRight = false;
        grabbedPlayedLeft  = false;

        bossAnim.SetBool("bEat", false);
        bat.GetComponent <Rigidbody2D>().simulated = true;

        if (isInEatRange)
        {
            StartCoroutine(AttackPlayer());
        }
    }
Example #7
0
    // Use this for initialization
    void Start()
    {
        controller = GameObject.Find("cam_main").GetComponent <BatController>();

        barPos    = transform.position;
        barEnergy = new VectorLine[2];

        for (int i = 0; i < barEnergy.Length; i++)
        {
            barEnergy[i] = controller.CreateLine(barPos + Vector3.down * (float)i * spread,
                                                 barPos + Vector3.right * width + Vector3.down * (float)i * spread);
        }
    }
Example #8
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.layer == 11)
        {
            OrcController Orc = other.gameObject.GetComponent <OrcController>();
            Orc.Die();
        }

        if (other.gameObject.layer == 12)
        {
            //kill creature
            BatController Bat = other.gameObject.GetComponent <BatController>();
            Bat.Die();
        }
    }
Example #9
0
    // Use this for initialization
    public void InitSprite()
    {
        controller = GameObject.Find("cam_main").GetComponent <BatController>();
        Load();

        int vlLength = (int)(lines.Count / 2);

        vl = new BatVector[vlLength];

        for (int i = 0; i < vlLength; i++)
        {
            vl[i] = new BatVector();
            vl[i].InitLine(controller, lines[i * 2], lines[i * 2 + 1]);
        }
    }
Example #10
0
    // Use this for initialization
    void Start()
    {
        controller = GameObject.Find("cam_main").GetComponent <BatController>();

        Destroy(this.GetComponent <SpriteRenderer> ());

        Vector3 multiply = this.transform.localScale;

        p1 = new Vector2(p1.x * multiply.x, p1.y * multiply.y);
        p2 = new Vector2(p2.x * multiply.x, p2.y * multiply.y);

        vl = controller.CreateLine(this.transform.position + (Vector3)p1,
                                   this.transform.position + (Vector3)p2);

        this.transform.localScale = Vector3.one;
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        //Check the provided Collider2D parameter other to see if it is tagged "PickUp", if it is...
        if (other.gameObject.CompareTag("Button"))
        {
            other.gameObject.SetActive(false);
            SceneManager.LoadScene("Boss");
        }

        if ((other.gameObject.layer == 8 || other.gameObject.layer == 11 || other.gameObject.layer == 12 || other.gameObject.layer == 13) && rb2d.velocity.y < -1f)
        {
            animator.SetBool("IsJumping", false);
            //JumpPossible = true;
        }

        if (other.gameObject.layer == 11) //orc
        {
            //kill creature
            source.PlayOneShot(attacksound);
            OrcController Orc = other.gameObject.GetComponent <OrcController>();
            Orc.Die();
        }

        if (other.gameObject.layer == 11 && !(rb2d.velocity.y < -4f)) //orc
        {
            SceneManager.LoadScene("Dead");
        }


        if (other.gameObject.CompareTag("bat")) //bat
        {
            //kill creature
            source.PlayOneShot(attacksound);
            BatController Bat = other.gameObject.GetComponent <BatController>();
            Bat.Die();
        }

        if (other.gameObject.layer == 17) //deadzone
        {
            SceneManager.LoadScene("Dead");
        }

        if (other.gameObject.layer == 18) //meteor
        {
            SceneManager.LoadScene("Dead");
        }
    }
Example #12
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player"))   //dont want to attack particles please :)
        // Attack animation

        //Debug.Log(other);

        // Give damage
        {
            BatController giveDamage = other.gameObject.GetComponent <BatController>();
            //BatController giveDamage = player.GetComponent<BatController>();

            GetComponent <Animator>().Play("snake bite");

            giveDamage.takedamage(enemyDamage);
        }
    }
Example #13
0
    void Start()
    {
        controller = GameObject.Find("cam_main").GetComponent <BatController>();

        Destroy(this.GetComponent <SpriteRenderer> ());

        Vector3 multiply = this.transform.localScale;

        myTransform = this.transform;

        p  = new Vector2(0.0f, -multiply.y);
        p1 = new Vector2(multiply.x * -0.5f, 0.0f);
        p2 = new Vector2(multiply.x * 0.5f, 0.0f);

        vl[0] = controller.CreateLine(Vector2.zero, Vector2.zero);
        vl[1] = controller.CreateLine(Vector2.zero, Vector2.zero);

        this.transform.localScale = Vector3.one;
    }
    // Start is called before the first frame update
    void Start()
    {
        spriteRenderer = GetComponent <SpriteRenderer>();

        Ballista         = GetComponent <Ballista>();
        Bat              = GetComponent <BatController>();
        BoundTrap        = GetComponent <BoundTrapController>();
        Bush             = GetComponent <BushController>();
        Button           = GetComponent <ButtonController>();
        Crocodile        = GetComponent <CrocodileController>();
        Drop             = GetComponent <DropController>();
        FallingPlataform = GetComponent <FallingPlataform>();
        //Pajaro = GameObject.FindGameObjectsWithTag("").GetComponent<ButtonController>();
        Mole       = GetComponent <MoloController>();
        Mushroom   = GetComponent <MushroomController>();
        Rat        = GetComponent <RatController>();
        Rock       = GetComponent <RockController>();
        RotateTrap = GetComponent <RotateTrapController>();
        Spawner    = GetComponent <Spawner>();
        Spikes     = GetComponent <SpikesController>();
        Thorms     = GetComponent <ThormsController>();
        Trap       = GetComponent <TrapController>();

        spriteRenderer.enabled = false;
        //Ballista.enabled = false;
        Bat.enabled              = false;
        BoundTrap.enabled        = false;
        Bush.enabled             = false;
        Button.enabled           = false;
        Crocodile.enabled        = false;
        Drop.enabled             = false;
        FallingPlataform.enabled = false;
        //Pajaro.enabled = false;
        Mole.enabled       = false;
        Mushroom.enabled   = false;
        Rat.enabled        = false;
        Rock.enabled       = false;
        RotateTrap.enabled = false;
        Spawner.enabled    = false;
        Spikes.enabled     = false;
        Thorms.enabled     = false;
        Trap.enabled       = false;
    }
Example #15
0
    // Use this for initialization
    void Start()
    {
        // スクリプトを取得
        this.ballController = GameObject.Find("Ball").GetComponent <BallController>();
        this.batController  = GameObject.Find("Bat").GetComponent <BatController>();

        // タイトルのオブジェクトを取得
        this.titleObject = GameObject.Find("TitleText");
        this.ruleImage   = GameObject.Find("Rule").GetComponent <Image>();

        // ゲームオーバーのオブジェクトを取得
        this.gameoverObject = GameObject.Find("GameOverText");

        // UIのオブジェクトを取得
        this.UIBallCountBoard = GameObject.Find("UIBackGround");
        this.UIFirstBase      = GameObject.Find("FirstBase").GetComponent <Image>();
        this.UISecondBase     = GameObject.Find("SecondBase").GetComponent <Image>();
        this.UIThirdBase      = GameObject.Find("ThirdBase").GetComponent <Image>();
        this.UIStrikeCount1   = GameObject.Find("StrikeCount_1").GetComponent <Image>();
        this.UIStrikeCount2   = GameObject.Find("StrikeCount_2").GetComponent <Image>();
        this.UIOutCount1      = GameObject.Find("OutCount_1").GetComponent <Image>();
        this.UIOutCount2      = GameObject.Find("OutCount_2").GetComponent <Image>();
        this.UIScoreText      = GameObject.Find("ScoreText").GetComponent <Text>();
        this.UIHitText        = GameObject.Find("HitText").GetComponent <Text>();

        // 画像の読み込み
        this.baseImage           = Resources.Load <Sprite>("base");
        this.runnerOnBaseImgae   = Resources.Load <Sprite>("runnerOnBase");
        this.strikeCountOffImage = Resources.Load <Sprite>("strikeLampOff");
        this.strikeCountOnImage  = Resources.Load <Sprite>("strikeLampOn");
        this.outCountOffImage    = Resources.Load <Sprite>("outLampOff");
        this.outCountOnImage     = Resources.Load <Sprite>("outLampOn");


        // ルール画像を非表示
        this.ruleImage.enabled = false;
        // ゲームオーバーの文字を非表示
        this.gameoverObject.SetActive(false);
        // ボールカウントUIを非表示
        this.UIBallCountBoard.SetActive(false);
    }
    private void Update()
    {
        if (canAggro)
        {
            BatController bat = GameObject.FindWithTag("Player").GetComponent <BatController>();
            if (bat.GetComponent <Rigidbody2D>().simulated == true)
            {
                Vector3 offset = new Vector3(BossBattleManager.bsm.target.position.x - spiderRotate.localPosition.x, BossBattleManager.bsm.target.position.y - spiderRotate.localPosition.y, 0);
                float   angle  = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg;
                spiderRotate.rotation = Quaternion.Euler(0, 0, angle - 90);
            }
        }

        if (grabbedPlayedRight)
        {
            player.transform.position = spiderSecondCheckTriggerRight.position;
        }
        if (grabbedPlayedLeft)
        {
            player.transform.position = spiderSecondCheckTriggerLeft.position;
        }
    }
Example #17
0
    private void Sinh()
    {
        //Vị trí sinh
        Vector3 pos = new Vector3(transform.position.x, 0, 0);

        pos.y = Random.Range(down.position.y, up.position.y);
        GameObject bat = (GameObject)Instantiate(bat_2, pos, Quaternion.identity);


        //tính đường đi
        BatController controller = bat.GetComponent <BatController>();
        int           index      = Random.Range(0, LevelController.Instance.Paths.Count);

        Vector3[] basePath = LevelController.Instance.Paths[index];
        Vector3[] path     = new Vector3[basePath.Length];
        Vector3   offset   = pos - basePath[0];

        for (int j = 0; j < basePath.Length; j++)
        {
            path[j] = basePath[j] + offset;
        }
        controller.SetUp(path, LevelController.Instance.Speed, FlyType.THANG, 0);
    }
    private IEnumerator StartFight()
    {
        BatController bat             = GameObject.FindWithTag("Player").GetComponent <BatController>();
        float         playerMoveSpeed = bat.moveSpeed;

        bat.moveSpeed = 0;

        Camera.main.GetComponent <CameraMovement>().target = spiderBoss.transform;

        yield return(new WaitForSeconds(2));

        audioSource.clip = spiderSounds[Random.Range(0, spiderSounds.Count)];
        audioSource.Play();
        bossmusic.Play();
        normalmusic.Stop();
        bossHpObject.SetActive(true);

        yield return(new WaitForSeconds(1));

        Camera.main.GetComponent <CameraMovement>().target = bat.transform;
        bat.moveSpeed = playerMoveSpeed;
        canAggro      = true;
    }
	void Awake()
	{
		bat = GetComponentInParent<BatController> ();
	}
Example #20
0
 void OnEnable()
 {
     point       = null;
     bController = GetComponent <BatController>();
 }
Example #21
0
 private void Start()
 {
     playerCtr = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterControl2>();
     batCtr    = transform.parent.GetComponent <BatController>();
     Animators = GameObject.FindGameObjectWithTag("Player").GetComponent <Animator>();
 }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("PlayerProjectile") || other.gameObject.CompareTag("BouncerBullet") || other.gameObject.CompareTag("Explosion"))
        {
            float dmgValue;

            if (other.gameObject.CompareTag("Explosion"))
            {
                dmgValue = 6;
            }
            else
            {
                dmgValue = other.gameObject.GetComponent <Projectile>().dmgValue;
            }

            robot = GetComponentInParent <RobotController>();
            boss  = GetComponentInParent <BossController>();
            bat   = GetComponentInParent <BatController>();
            ghost = GetComponentInParent <GhostController>();

            // Robot Damage
            if (robot != null && !robot.dead)
            {
                if (Perks.lifesteal)
                {
                    DudeController.currentHealth += .1f * dmgValue;
                    DudeController.currentHealth  = Mathf.Clamp(DudeController.currentHealth, 0, DudeController.maxHealth);
                    UIHealthbar.instance.SetValue(DudeController.currentHealth / (float)DudeController.maxHealth);
                }

                if (robot.dead)
                {
                    return;
                }

                robot.Damage(dmgValue);
            }

            if (ghost != null && !ghost.dead)
            {
                if (Perks.lifesteal)
                {
                    DudeController.currentHealth += .1f * dmgValue;
                    DudeController.currentHealth  = Mathf.Clamp(DudeController.currentHealth, 0, DudeController.maxHealth);
                    UIHealthbar.instance.SetValue(DudeController.currentHealth / (float)DudeController.maxHealth);
                }

                if (ghost.dead)
                {
                    return;
                }

                ghost.Damage(dmgValue);
            }

            // Boss Damage
            if (boss != null)
            {
                if (Perks.lifesteal)
                {
                    DudeController.currentHealth += .1f * dmgValue;
                    DudeController.currentHealth  = Mathf.Clamp(DudeController.currentHealth, 0, DudeController.maxHealth);
                    UIHealthbar.instance.SetValue(DudeController.currentHealth / (float)DudeController.maxHealth);
                }

                if (boss.dead)
                {
                    GetComponent <BoxCollider2D>().enabled = false;
                    return;
                }

                boss.Damage(dmgValue);
            }

            // Bat Damage
            if (bat != null)
            {
                if (Perks.lifesteal)
                {
                    DudeController.currentHealth += .1f * dmgValue;
                    DudeController.currentHealth  = Mathf.Clamp(DudeController.currentHealth, 0, DudeController.maxHealth);
                    UIHealthbar.instance.SetValue(DudeController.currentHealth / (float)DudeController.maxHealth);
                }

                if (bat.dead)
                {
                    GetComponent <BoxCollider2D>().enabled = false;
                    return;
                }

                bat.Damage(dmgValue);
            }
        }

        if (other.gameObject.CompareTag("PlayerProjectile"))
        {
            Destroy(other.gameObject);
        }
    }
Example #23
0
 void Start()
 {
     anim.InitSprites();
     controller = GameObject.Find("cam_main").GetComponent <BatController>();
 }