Exemplo n.º 1
0
    private IEnumerator create_damage_num(int _iDamage, float _fDelay, Color _damage_color)
    {
        yield return(new WaitForSeconds(_fDelay));

        const float DAMAGE_VECTOR_BASE  = 0.2f;
        const float DAMAGE_VECTOR_SWING = 0.1f;

        Quaternion rot = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
        GameObject obj = Instantiate(m_prefDamageText, Vector3.zero, rot, m_goRootDamageText.transform) as GameObject;

        obj.SetActive(true);
        obj.transform.localPosition = Vector3.zero;
        //obj.GetComponent<Animator>().SetInteger("damage_level", 1);

        //Debug.Log(iDamage);
        obj.GetComponent <TMPro.TextMeshPro>().text  = _iDamage.ToString();
        obj.GetComponent <TMPro.TextMeshPro>().color = _damage_color;

        Vector2 dir = new Vector2(
            DAMAGE_VECTOR_BASE + (UtilRand.GetRange(DAMAGE_VECTOR_SWING) - DAMAGE_VECTOR_SWING * 0.5f),
            1.0f + (UtilRand.GetRange(DAMAGE_VECTOR_SWING) + DAMAGE_VECTOR_SWING * 0.5f));

        obj.GetComponent <Rigidbody2D>().AddForce(200f * dir);

        Destroy(obj, 2);
    }
Exemplo n.º 2
0
    /*
     * private void Start()
     * {
     *      m_rb.AddForce(100.0f * new Vector2(
     *              true ? 1.0f : -1.0f * UtilRand.GetRange(1.0f, 0.5f),
     *              UtilRand.GetRange(2.0f, 1.5f)));
     * }
     */

    public void Initialize(int _iNum, bool _bIsRight)
    {
        m_txtNum.text = _iNum.ToString();
        m_rb.AddForce(UtilRand.GetRange(120.0f, 80.0f) * new Vector2(
                          _bIsRight ? 1.0f : -1.0f * UtilRand.GetRange(0.75f, 0.5f),
                          UtilRand.GetRange(2.0f, 1.5f)));

        Destroy(gameObject, 2.0f);
    }
Exemplo n.º 3
0
    public Vector3 GetMovePos()
    {
        float fX = UtilRand.GetRange(1.0f);
        float fY = UtilRand.GetRange(1.0f);

        Vector3 v3X = Define.CELL_X_DIR * fX * m_iSize;
        Vector3 v3Y = Define.CELL_Y_DIR * fY * m_iSize;

        return(v3X + v3Y);
    }
Exemplo n.º 4
0
    //public DataTargetParam m_targetParam;

    private Vector3 getRandomPos(float _fRangeMinX, float _fRangeMaxX, float _fRangeMinY, float _fRangeMaxY)
    {
        Vector3 ret = new Vector3();

        float fX = UtilRand.GetRange(_fRangeMaxX, _fRangeMinX);
        float fY = UtilRand.GetRange(_fRangeMaxY, _fRangeMinY);

        ret = new Vector3(fX, fY, 0.0f);
        return(ret);
    }
Exemplo n.º 5
0
    private Vector3 getRandomPos()
    {
        Vector3 ret = new Vector3();

        float fX = UtilRand.GetRange(m_Config.ReadFloat("xmax"), m_Config.ReadFloat("xmin"));
        float fY = UtilRand.GetRange(m_Config.ReadFloat("ymax"), m_Config.ReadFloat("ymin"));

        ret = new Vector3(fX, fY, 0.0f);

        return(ret);
    }
Exemplo n.º 6
0
    public void Damage(int _iAttack, string _strAttribute)
    {
        // 減るHPがないときはダメージを受けない

        //Debug.Log(string.Format("hp={0} is_dead={1}", DataManager.Instance.dataChara.is_dead, DataManager.Instance.dataChara.hp));
        if (DataManager.Instance.dataChara.hp < 0 || DataManager.Instance.dataChara.is_dead)
        {
            return;
        }

        const float DAMAGE_VECTOR_BASE  = -0.2f;
        const float DAMAGE_VECTOR_SWING = 0.1f;

        /*
         * float fDamage = (float)(_iAttack * _iAttack) / (float)DataManager.Instance.dataChara.defence * (DAMAGE_RATE + (UtilRand.GetRange(DAMAGE_SWING) - DAMAGE_SWING * 0.5f));
         * fDamage *= Defines.GetAttributeRate(DataManager.Instance.dataChara.attribute_defence, _strAttribute);
         * if (fDamage < 1.0f)
         * {
         *      fDamage = 1.0f;
         * }
         * int iDamageResult = (int)fDamage;
         */

        int iDamageResult = CalcDamage.Damage(_iAttack, _strAttribute, DataManager.Instance.dataChara.defence, DataManager.Instance.dataChara.attribute_defence);

        //Debug.Log(string.Format("chara attack={0} defence={1}", _iAttack, DataManager.Instance.dataChara.defence));

        Defines.ATTRIBUTE_CONDITION condition = Defines.GetAttributeCondition(DataManager.Instance.dataChara.attribute_defence, _strAttribute);
        Color damage_color = Defines.GetAttributeDamageColor(condition);


        //Debug.Log("player damage :" + iDamageResult.ToString());
        Quaternion rot = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
        GameObject obj = Instantiate(m_prefDamageText, Vector3.zero, rot, m_goRootDamageText.transform) as GameObject;

        obj.SetActive(true);
        obj.transform.localPosition = Vector3.zero;
        //obj.GetComponent<Animator>().SetInteger("damage_level", 1);
        obj.GetComponent <TMPro.TextMeshPro>().text  = iDamageResult.ToString();
        obj.GetComponent <TMPro.TextMeshPro>().color = damage_color;

        Vector2 dir = new Vector2(
            DAMAGE_VECTOR_BASE - (UtilRand.GetRange(DAMAGE_VECTOR_SWING) + DAMAGE_VECTOR_SWING * 0.5f),
            1.0f + (UtilRand.GetRange(DAMAGE_VECTOR_SWING) + DAMAGE_VECTOR_SWING * 0.5f));

        obj.GetComponent <Rigidbody2D>().AddForce(200f * dir);
        Destroy(obj, 2);
        DataManager.Instance.dataChara.hp -= iDamageResult;
        GameMain.Instance.BattleLog(string.Format("<color=red>{0}</color>のダメージを受けた!", iDamageResult));
    }
Exemplo n.º 7
0
    public bool Heal(int _iHeal)
    {
        bool bRet = DataManager.Instance.dataChara.hp < DataManager.Instance.dataChara.hp_max;

        // HPが0以下の場合も回復出来ず
        if (DataManager.Instance.dataChara.hp <= 0)
        {
            bRet = false;
        }

        if (bRet == false)
        {
            return(false);
        }

        const float HEAL_RATE  = 1.0f;
        const float HEAL_SWING = 0.05f;
        float       fHeal      = (float)(_iHeal) * (HEAL_RATE + (UtilRand.GetRange(HEAL_SWING) - HEAL_SWING * 0.5f));
        int         iHeal      = (int)fHeal;

        DataManager.Instance.dataChara.hp += iHeal;
        if (DataManager.Instance.dataChara.hp_max < DataManager.Instance.dataChara.hp)
        {
            DataManager.Instance.dataChara.hp = DataManager.Instance.dataChara.hp_max;
        }

        Quaternion rot = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
        GameObject num = Instantiate(m_prefRecoverNum.gameObject, gameObject.transform.position + new Vector3(0.0f, 0.0f, 0.0f), rot, GameMain.Instance.m_goStage.transform) as GameObject;

        num.SetActive(true);

        num.GetComponent <RecoverNum>().Initialize(iHeal);

        GameObject effect = Instantiate(m_prefHealEffect, gameObject.transform.position + new Vector3(0.0f, 0.75f, 0.0f), rot, GameMain.Instance.m_goStage.transform) as GameObject;

        effect.SetActive(true);

        Destroy(num, 2.0f);
        Destroy(effect, 2.0f);

        return(true);
    }
Exemplo n.º 8
0
    public bool Eat(int _iEat)
    {
        bool bRet = DataManager.Instance.dataChara.hunger < DataManager.Instance.dataChara.hunger_max;

        if (bRet == false)
        {
            return(false);
        }

        const float EAT_RATE  = 1.0f;
        const float EAT_SWING = 0.05f;
        float       fEat      = (float)(_iEat) * (EAT_RATE + (UtilRand.GetRange(EAT_SWING) - EAT_SWING * 0.5f));
        int         iEat      = (int)fEat;

        if (DataManager.Instance.dataChara.hunger_max < DataManager.Instance.dataChara.hunger + iEat)
        {
            DataManager.Instance.dataChara.hunger = DataManager.Instance.dataChara.hunger_max;
        }
        else
        {
            DataManager.Instance.dataChara.hunger += iEat;
        }

        Quaternion rot = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
        GameObject num = Instantiate(m_prefRecoverNum.gameObject, gameObject.transform.position + new Vector3(0.0f, 0.0f, 0.0f), rot, GameMain.Instance.m_goStage.transform) as GameObject;

        num.SetActive(true);
        RecoverNum script =  num.GetComponent <RecoverNum>();

        script.Initialize(iEat);
        script.m_txtNum.color = Color.yellow;
        GameObject effect = Instantiate(m_prefEatEffect, gameObject.transform.position + new Vector3(0.0f, 0.75f, 0.0f), rot, GameMain.Instance.m_goStage.transform) as GameObject;

        effect.SetActive(true);
        Destroy(num, 2.0f);
        Destroy(effect, 2.0f);

        return(true);
    }
Exemplo n.º 9
0
    static public int Damage(int _iAttack, string _sttAttributeAttack, int _iDefence, string _strAttributeDefence)
    {
        int iResult = 0;

        float fDamage = (float)(_iAttack * _iAttack) / (float)_iDefence * (DAMAGE_RATE + (UtilRand.GetRange(DAMAGE_SWING) - DAMAGE_SWING * 0.5f));

        fDamage *= Defines.GetAttributeRate(_strAttributeDefence, _sttAttributeAttack);
        if (fDamage < 1.0f)
        {
            fDamage = 1.0f;
        }
        iResult = (int)fDamage;

        return(iResult);
    }
Exemplo n.º 10
0
    public void Update()
    {
        bool bInit = false;

        if (m_eStepPre != m_eStep)
        {
            m_eStepPre = m_eStep;
            bInit      = true;
        }

        switch (m_eStep)
        {
        case STEP.IDLE:
            if (bInit)
            {
                AnimationIdol(true);
                m_fTimer = 0.0f;

                m_fTimerIdleWait = UtilRand.GetRange(4.0f, 2.0f);
            }
            m_fTimer += Time.deltaTime;
            if (m_fTimerIdleWait < m_fTimer)
            {
                m_eStep = STEP.MOVE;
            }
            update_idle(bInit);
            break;

        case STEP.MOVE:
            if (bInit)
            {
                m_fTimer = 0.0f;

                m_bIsEndTween = false;
                Vector3       target = GetMovePos();
                TweenPosition tp     = TweenPosition.Begin(gameObject, 1.0f, target);
                EventDelegate.Set(tp.onFinished, EndTween);

                if (myTransform.localPosition.x < target.x)
                {
                    m_sprIcon.transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
                }
                else
                {
                    m_sprIcon.transform.localScale = Vector3.one;
                }
            }
            AnimationMove(bInit);
            if (m_bIsEndTween)
            {
                m_eStep = STEP.IDLE;
            }
            m_fTimer += Time.deltaTime;
            if (3.0f < m_fTimer)
            {
                m_eStep = STEP.IDLE;
            }
            break;

        case STEP.EAT:
            if (bInit)
            {
                m_fTimer = 0.0f;
                createMeal();
            }

            AnimationEat(bInit, 0);
            m_fTimer += Time.deltaTime;
            if (3.0f < m_fTimer)
            {
                m_eStep = STEP.IDLE;

                Release(m_goMeal);
            }
            break;

        case STEP.MAX:
        default:
            break;
        }
    }