Example #1
0
    ///////////////////////////////////////////////////////////////////////////////////////////////
    // get database on the current scene
    // load list of the monsterFX from database
    // load list of the monster from database
    // CHEAT : maybe action load take some time, create an invoke function to do something with data
    void Start()
    {
        m_goTextDamage = gameObject.GetComponentInChildren <Text>().gameObject;
        GameObject _dbDatabaseOfScene = GameObject.Find("database");

        m_dbMonsterFXList      = _dbDatabaseOfScene.GetComponent <monsterFx>();
        m_dbMonsterList        = _dbDatabaseOfScene.GetComponent <monster>();
        m_animatorCameraSkaing = GameObject.FindGameObjectWithTag("CameraShaking").GetComponent <Animator>();
        Invoke("LoadProperties", 0.1f);
    }
Example #2
0
    ///////////////////////////////////////////////////////////////////////////////////////////////
    // set 'false' to 'start' parameter of the animator, SO the monster will do action idle, after action appear finished
    // load and set 'Player' tranform as the target of the monster
    // check in the monster list to find databases of the monster and monsterFX via ID of the monster and ID of the monsterFX
    // release monster list and monsterFX list after get data
    // load all data we need from db to variables (via db construction)
    // if the monster has timelife, set 'Destroy' method to the monster with a delay equal to monster's timelife, SO it will be die after it's timelife
    void LoadProperties()
    {
        m_animatorController.SetBool("isAppeared", false);
        m_tfTarget = GameObject.FindGameObjectWithTag("Player").transform;

        foreach (var _aMonsterFX in m_dbMonsterFXList.Player.MonsterFxList)
        {
            if (m_nID == _aMonsterFX.IdMonsterFX)
            {
                m_dbMonsterFX = _aMonsterFX;
                break;
            }
        }
        foreach (var _aMonster in m_dbMonsterList.Player.MonsterDbList)
        {
            if (m_nID == _aMonster.IdMonster)
            {
                m_dbMonster = new MonsterDb(_aMonster);
                break;
            }
        }

        m_dbMonsterFXList = null;
        m_dbMonsterList   = null;

        m_nMonsterType   = m_dbMonster.MonterType;
        m_nScore         = m_dbMonster.Score;
        m_fTimeLife      = m_dbMonster.TimeLife;
        m_fMaxHP         = (float)m_dbMonster.HpDefault;
        m_fMovementSpeed = m_dbMonster.MoveSpeed;
        m_fDelayAttack   = m_dbMonster.delayAtk;
        m_nDamageType    = m_dbMonster.DameType;
        m_arATKList      = m_dbMonster.ATKList;
        m_fRateDodge     = m_dbMonster.RateDodge;
        m_fRateDrop      = m_dbMonster.RateDrop;
        m_fMCRegen       = m_dbMonster.MCRegen;
        m_oMonsterEsc    = m_dbMonster.ESC;
        m_arDropList     = m_dbMonster.Droplist;

        foreach (ATK _oTempAttack in m_arATKList)
        {
            if (_oTempAttack.RankATK == 1)
            {
                m_fAttack1Rate = _oTempAttack.Rate;
            }
            if (_oTempAttack.RankATK == 2)
            {
                m_fAttack2Rate = _oTempAttack.Rate;
            }
            if (_oTempAttack.RankATK == 3)
            {
                m_fAttack3Rate = _oTempAttack.Rate;
            }
        }

        m_fCurrentHP  = m_fMaxHP;
        m_fLeftLimit  = Camera.main.GetComponent <CameraFollow>().StartLook + 2.0f;
        m_fRightLimit = Camera.main.GetComponent <CameraFollow>().EndLook + Camera.main.orthographicSize * 2.0f - 3.0f;

        // LOG : check if rate attack of the monster is wrong
        //if (m_fRateATK1 + m_fRateATK2 + m_fRateATK3 != 1.0f) {
        //    Debug.Log("Attack rates of the monster is wrong!");
        //}

        m_fMoveCycle      = Random.Range(1.0f, 4.0f);
        m_fBreakTimeCycle = Random.Range(1.0f, 2.0f);

        if (m_fTimeLife > 0.0f)
        {
            Invoke("ExplodeBeforeDie", m_fTimeLife);
        }

        m_bDataLoaded = true;
    }