Esempio n. 1
0
    //public void Die()
    //{
    //    for (int i = 0; i < AttackedList.Count; i++)
    //    {
    //        CharactorCtrl attackedCharac = AttackedList[i].GetComponent<CharactorCtrl>();

    //        attackedCharac.attackTarget = null;
    //    }

    //    m_SpawnBase_Team.RemoveMonster(this);
    //    animator.SetTrigger("isDie");
    //    Destroy(this.gameObject, DeadAnimTime);
    //}

    public IEnumerator Die()
    {
        //1
        //attackTarget.GetComponent<CharactorCtrl>().AttackedList.Remove(this.gameObject);

        for (int i = 0; i < AttackedList.Count; i++)
        {
            CharactorCtrl attackedCharac = AttackedList[i].GetComponent <CharactorCtrl>();

            attackedCharac.attackTarget = null;

            //2
            if (attackedCharac.AttackedList.Contains(this.gameObject))
            {
                attackedCharac.AttackedList.Remove(this.gameObject);
            }
        }

        m_SpawnBase_Team.RemoveMonster(this);
        animator.SetTrigger("isDie");

        yield return(new WaitForSeconds(DeadAnimTime));

        if (this.gameObject.tag == "Enemy")
        {
            gameMgr.Gold += gold;
        }

        Destroy(this.gameObject);
    }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     StartPosition = transform.position;
     nowDir        = EnemyDir.Right;
     E_animator    = GetComponent <Animator>();
     E_body        = GetComponent <Rigidbody2D>();
     charaview     = GameObject.Find("UI").transform.Find("Canvas").Find("Charactor").GetComponent <CharactorCtrl>();
 }
Esempio n. 3
0
    private IEnumerator Attack()
    {
        atkCoolTime = skillCoolTime;

        animator.SetBool("isAttack", true);

        CharactorCtrl attackedCharac = attackTarget.GetComponent <CharactorCtrl>();

        if (!attackedCharac.AttackedList.Contains(this.gameObject))
        {
            attackedCharac.AttackedList.Add(this.gameObject);
        }

        while (true)
        {
            //다른 캐릭터에 의해 제거
            if (attackTarget == null)
            {
                ChangeState(State.Move);
                break;
            }

            //공격범위 벗어남
            float distance = Mathf.Abs(attackTarget.transform.position.x - this.transform.position.x);
            if (distance > attackRange)
            {
                attackTarget = null;
                ChangeState(State.Move);
                break;
            }

            ////공격
            //if(attackTarget != null)
            //    attackTarget.GetComponent<CharactorCtrl>().Hit(atk);

            ////공격 쿨타임
            //yield return new WaitForSeconds(atkSpeed);

            if (attackTarget != null)
            {
                atkCoolTime -= Time.deltaTime;
                if (atkCoolTime <= 0f)
                {
                    AttackAct();

                    atkCoolTime = skillCoolTime;
                }

                //애니메이션 속도 조절(추후 레벨당 공속 증가 있을 시)
                //https://wergia.tistory.com/41

                //공격범위 벗어났을 때 하고있던 공격 마무리? or 캔슬
                //마무리 시 해당 함수로 "공격범위 벗어남" 이동
            }

            yield return(null);
        }
    }
Esempio n. 4
0
 public void RemoveMonster(CharactorCtrl p_RemoveCharacter)
 {
     if (m_listCharCtrl_Use.Contains(p_RemoveCharacter))
     {
         m_listCharCtrl_Use.Remove(p_RemoveCharacter);
         //p_RemoveCharacter.gameObject.SetActive(false);
         //Destroy(p_RemoveCharacter.gameObject);
     }
 }
Esempio n. 5
0
    public void OnButtonPress(int nIndex)
    {
        CharactorCtrl charCtrl = m_listCharacterPrefabList[nIndex];

        charCtrl.SetStat(m_listCharacterPrefabList[nIndex].gameObject.name);

        if (gameMgr.Gold >= charCtrl.price)
        {
            gameMgr.Gold -= charCtrl.price;
            SpawnMoster(nIndex, true);
        }
    }
Esempio n. 6
0
    // [Header("玩家重力控制")]
    //public float gravity;

    void Start()
    {
        ItemEquipView = GameObject.Find("Canvas").transform.Find("Bag").Find("EquipItem").GetComponent <ItemEquip>();
        charaview     = GameObject.Find("Canvas").transform.Find("Charactor").GetComponent <CharactorCtrl>();
        P_animator    = GetComponent <Animator>();
        P_body        = GetComponent <Rigidbody2D>();
        p_au          = GetComponent <AudioSource>();
        HitAU         = transform.Find("AttackEffect").GetComponent <AudioSource>();
        movement      = 0;
        jumpHight     = 10.0f;
        speed         = 5.0f;
        FlashDis      = 8.0f;
        isFlash       = false;
        isInput       = true;
        nowDir        = playDir.Right;
        attackEffect  = transform.Find("AttackEffect").gameObject;
        ReadCharaterItem();
    }
Esempio n. 7
0
    public override void SpawnMoster(int nIndex, bool bFlagMyTeam)
    {
        SOFile_MonsterSpawn p_SOFile_MonsterSpawn = m_listSOFile_MonsterSpawn[nIndex];

        GameObject p_SpawnMonster = Instantiate(p_SOFile_MonsterSpawn.characterCtrl.gameObject);
        Vector3    p_VecCharScale = p_SpawnMonster.transform.localScale;

        p_VecCharScale.x *= -1;
        p_SpawnMonster.transform.localScale = p_VecCharScale;
        p_SpawnMonster.tag = bFlagMyTeam ? "Player" : "Enemy";
        p_SpawnMonster.transform.position = spawnPos.position;

        CharactorCtrl nCharacterCtrl = p_SpawnMonster.GetComponent <CharactorCtrl>();

        if (nCharacterCtrl != null)
        {
            nCharacterCtrl.SetupSpawnBase(this, m_SpawnBaseOtherSide);
            nCharacterCtrl.SetStat(p_SOFile_MonsterSpawn.characterCtrl.gameObject.name);
            m_listCharCtrl_Use.Add(nCharacterCtrl);
        }
    }
Esempio n. 8
0
    public override void SpawnMoster(int nIndex, bool bFlagMyTeam)
    {
        GameObject p_SpawnMonster = Instantiate(m_listCharacterPrefabList[nIndex].gameObject);
        Vector3    p_VecCharScale = p_SpawnMonster.transform.localScale;

        if (bFlagMyTeam == false)
        {
            p_VecCharScale.x *= -1;
            p_SpawnMonster.transform.localScale = p_VecCharScale;
        }
        p_SpawnMonster.tag = bFlagMyTeam ? "Player" : "Enemy";
        p_SpawnMonster.transform.position = spawnPos.position;

        CharactorCtrl nCharacterCtrl = p_SpawnMonster.GetComponent <CharactorCtrl>();

        if (nCharacterCtrl != null)
        {
            nCharacterCtrl.SetupSpawnBase(this, m_SpawnBaseOtherSide);
            nCharacterCtrl.SetStat(m_listCharacterPrefabList[nIndex].gameObject.name);
            m_listCharCtrl_Use.Add(nCharacterCtrl);
        }
        StartCoroutine(CheckSpawnCoolTime(nIndex, nCharacterCtrl.spawnCoolTime));
    }