コード例 #1
0
 // Use this for initialization
 void Start()
 {
     m_KingController            = GameObject.FindGameObjectWithTag("MainCharacterController");
     m_PlayerScript              = m_KingController.GetComponent <KingController> ();
     m_HealthControllerScript    = m_KingController.GetComponent <HealthController> ();
     m_PlayerParticleSystem      = GameObject.FindGameObjectWithTag("HealthParticaleAnimation").GetComponent <ParticleSystem> ();
     m_PlayerParticalAudioSource = GameObject.FindGameObjectWithTag("HealthParticaleAnimation").GetComponent <AudioSource> ();
 }
コード例 #2
0
    IEnumerator GroundPound()
    {
        if (timers.transform.GetChild(3).gameObject.GetComponent <TimerController>().CanAttack())
        {
            // Start Attacking
            timers.transform.GetChild(3).gameObject.GetComponent <TimerController>().Reset();
            isAttacking = true;
            // Animate Jump
            soundManager.PlaySound(soundManager.jump);
            shield.SetActive(false);
            weapon.SetActive(true);
            playerAnimator.SetTrigger("Jump");
            yield return(new WaitForSeconds(0.5f));

            shadow.SetActive(true);
            // Animate Ground Pound
            soundManager.PlaySound(soundManager.groundPound);
            Instantiate(particles, transform);
            // Damage Enemies
            Collider2D[] results = new Collider2D[8];
            groundPoundCollider.OverlapCollider(contactFilter, results);
            foreach (Collider2D col in results)
            {
                if (col != null)
                {
                    EnemyController enemy = col.gameObject.GetComponent <EnemyController>();
                    if (enemy != null)
                    {
                        StartCoroutine(enemy.TakeDamage(attack * 3));
                        if (IsOgreStrength())
                        {
                            StartCoroutine(enemy.PoisonDamage());
                        }
                    }
                    KingController king = col.gameObject.GetComponent <KingController>();
                    if (king != null)
                    {
                        StartCoroutine(king.TakeDamage(attack * 3));
                        if (IsOgreStrength())
                        {
                            StartCoroutine(king.PoisonDamage());
                        }
                    }
                }
            }
            // Stop Attacking
            questManager.Event("Ground Pound", "Use", true);
            yield return(new WaitForSeconds(1));

            shadow.SetActive(false);
            StopBounce();
            isAttacking = false;
        }
    }
コード例 #3
0
    IEnumerator SpinAttack()
    {
        if (timers.transform.GetChild(2).gameObject.GetComponent <TimerController>().CanAttack())
        {
            // Start Attacking
            timers.transform.GetChild(2).gameObject.GetComponent <TimerController>().Reset();
            isAttacking = true;
            // Animate Spin Attack
            soundManager.PlaySound(soundManager.spinAttack);
            shield.SetActive(false);
            weapon.SetActive(true);
            weaponAnimator.SetTrigger("Spin");
            // Damage Enemies
            Collider2D[] results = new Collider2D[5];
            spinAttackCollider.OverlapCollider(contactFilter, results);
            foreach (Collider2D col in results)
            {
                if (col != null)
                {
                    EnemyController enemy = col.gameObject.GetComponent <EnemyController>();
                    if (enemy != null)
                    {
                        StartCoroutine(TakeKnockback(enemy.transform.position));
                        StartCoroutine(enemy.TakeDamage(attack * 2));
                        if (IsOgreStrength())
                        {
                            StartCoroutine(enemy.PoisonDamage());
                        }
                    }
                    KingController king = col.gameObject.GetComponent <KingController>();
                    if (king != null)
                    {
                        StartCoroutine(TakeKnockback(king.transform.position));
                        StartCoroutine(king.TakeDamage(attack * 2));
                        if (IsOgreStrength())
                        {
                            StartCoroutine(king.PoisonDamage());
                        }
                    }
                }
            }
            yield return(new WaitForSeconds(0.5f));

            // Stop Attacking
            questManager.Event("Spin Attack", "Use", true);
            StopBounce();
            isAttacking = false;
        }
    }
コード例 #4
0
ファイル: BoardController.cs プロジェクト: gndw/emvici-chess
        public void SetChessmanOnBoard(BoardDataModel boardDataModel)
        {
            _chessmans.ForEach((cc) => cc.Destroy());
            _chessmans.Clear();
            foreach (var data in boardDataModel.Data)
            {
                IChessmanController icc;
                switch (data.Value.Type)
                {
                case ChessmanType.Pawn:
                    icc = new PawnController();
                    break;

                case ChessmanType.Rook:
                    icc = new RookController();
                    break;

                case ChessmanType.Knight:
                    icc = new KnightController();
                    break;

                case ChessmanType.Bishop:
                    icc = new BishopController();
                    break;

                case ChessmanType.Queen:
                    icc = new QueenController();
                    break;

                case ChessmanType.King:
                    icc = new KingController();
                    break;

                default:
                    throw new System.NotImplementedException();
                }
                icc.Init(_prefabController, _view.GetBoardPosition, _view.GetFacingDirection, data.Key, data.Value.ColorType);
                icc.OnChessmanSelected += () => OnChessmanSelected?.Invoke(icc.GetChessmanType(), icc.GetChessmanColorType(), icc.GetBoardCoord());
                _chessmans.Add(icc);
            }
        }
コード例 #5
0
 void Start()
 {
     KingController = GetComponent <KingController>();
     KingAnimator   = GetComponent <Animator>();
 }
コード例 #6
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Item") && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            if (!other.gameObject.name.Equals("Coin"))
            {
                ScoreManager.AddCollection(1);
                if ((inventory.Count == 6 && !playerDisciplines.Contains("Collection")) ||
                    (inventory.Count == 8 && playerDisciplines.Contains("Collection")))
                {
                    uiManager.InvFull(other.transform.position);
                }
            }
            // Check item
            switch (other.name)
            {
            // Coin
            case "Coin":
                soundManager.PlaySound(soundManager.coin);
                Destroy(other.gameObject);
                playerCoins++;
                uiManager.SetCoins(playerCoins);
                questManager.Event("coin", "Collect", true);
                break;

            // Scroll
            case "Scroll":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Scroll", inventory.Count);
                    AddItem("Scroll");
                    if (questManager.Event("Find the scroll", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;

            // Key
            case "Key":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Key", inventory.Count);
                    AddItem("Key");
                }
                break;

            // Boss Key
            case "Boss Key":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.win);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Boss Key", inventory.Count);
                    AddItem("Boss Key");
                }
                else
                {
                    uiManager.RemoveItem(inventory.Count - 1);
                    inventory.RemoveAt(inventory.Count - 1);
                    soundManager.PlaySound(soundManager.win);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Boss Key", inventory.Count);
                    AddItem("Boss Key");
                }
                break;

            // Potion
            case "Wigg's Brew":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Wigg's Brew", inventory.Count);
                    AddItem("Wigg's Brew");
                    if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") &&
                        inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") &&
                        questManager.Event("Bring all four potions to Wigg", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;

            case "Liquid Luck":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Liquid Luck", inventory.Count);
                    AddItem("Liquid Luck");
                    if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") &&
                        inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") &&
                        questManager.Event("Bring all four potions to Wigg", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;

            case "Ogre's Strength":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Ogre's Strength", inventory.Count);
                    AddItem("Ogre's Strength");
                    if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") &&
                        inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") &&
                        questManager.Event("Bring all four potions to Wigg", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;

            case "Elixir of Speed":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Elixir of Speed", inventory.Count);
                    AddItem("Elixir of Speed");
                    if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") &&
                        inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") &&
                        questManager.Event("Collect all four potions", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;
            }
        }
        else if (other.gameObject.CompareTag("Enemy") && other is CircleCollider2D && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            // Take damage
            EnemyController enemyController = other.gameObject.GetComponent <EnemyController>();
            if (enemyController != null && enemyController.health > 0)
            {
                int enemyAttack = other.gameObject.GetComponent <EnemyController>().GetAttack();
                StartCoroutine(TakeDamage(enemyAttack));
            }
        }
        else if (other.gameObject.CompareTag("King") && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            // Take damage
            KingController kingController = other.gameObject.GetComponent <KingController>();
            if (kingController != null && kingController.isActiveAndEnabled && kingController.health > 0)
            {
                int kingAttack = other.gameObject.GetComponent <KingController>().GetAttack();
                StartCoroutine(TakeDamage(kingAttack));
            }
        }
        else if (other.gameObject.name.Equals("Spikes") && GetComponent <BoxCollider2D>().IsTouching(other) && other.gameObject.GetComponent <Animator>() != null && other.gameObject.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime < 0.17f)
        {
            // Take damage
            if (!IsBouncing())
            {
                StartCoroutine(TakeDamage(1));
            }
            // Bounce off the spikes
            body.AddForce(Vector2.up * 100);
            isBouncing = true;
            Invoke("StopBounce", 0.2f);
        }
        else if (other.gameObject.name.Equals("Spikes") && GetComponent <BoxCollider2D>().IsTouching(other) && !other.gameObject.GetComponent <SpriteRenderer>().sprite.name.Equals("floor_spikes_anim_f0"))
        {
            // Take damage
            if (!IsBouncing())
            {
                StartCoroutine(TakeDamage(1));
            }
            // Bounce off the spikes
            body.AddForce(Vector2.up * 100);
            isBouncing = true;
            Invoke("StopBounce", 0.2f);
        }
        else if (other.gameObject.CompareTag("Projectile") && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            Destroy(other);
            // Take damage
            StartCoroutine(TakeDamage(1));
        }
        else if (other.gameObject.CompareTag("Collider") && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            ScoreManager.AddExploration(1);
            questManager.Event("room", "Explore", true);
            Destroy(other.gameObject);
        }
    }