示例#1
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag != "Tumbleweed")
        {
            return;
        }

        var t = col.gameObject.GetComponent <TumbleweedScript>();

        AkSoundEngine.PostEvent("Damage", gameObject);

        //todo:当たった草の状態でダメージ量を変化させる
        ScoreManager.I.hitCount = ScoreManager.I.hitCount + 1;
        if (t.tumbleweedType == TumbleweedScript.Type.Fire)
        {
            Damage(15);
            if (effect != null)
            {
                effect.SetActive(true);
            }
            KKUtilities.Delay(damageTime, () =>
            {
                if (effect != null)
                {
                    effect.SetActive(false);
                }
            }, this);
        }
        else
        {
            Damage(5);
        }
    }
示例#2
0
    public void PresentCoin(int coinNum, Vector3 origin, int startCoinNum, System.Action callback)
    {
        float popingDuration = 0.5f;
        float earnDuration   = 0.75f;
        int   showCoinNum    = Mathf.RoundToInt(coinNum * 0.1f);

        showCoinNum = Mathf.Min(15, showCoinNum);
        var maxDelayFrame = 0;

        for (int i = 0; i < showCoinNum; i++)
        {
            maxDelayFrame = 2 * i;
            StartCoroutine(KKUtilities.DelayFrame(maxDelayFrame, () => StartCoroutine(EarnCoinAnimation(origin, popingDuration, earnDuration))));
        }

        float delay    = popingDuration + earnDuration - 0.25f;
        float duration = 0.08f * showCoinNum;

        StartCoroutine(KKUtilities.Delay(delay, () =>
        {
            CountUpText(startCoinNum, startCoinNum + coinNum, duration);
        }, false));

        this.DelayFrame(maxDelayFrame, () =>
        {
            this.Delay(popingDuration + earnDuration, () => callback.SafeInvoke());
        });
    }
示例#3
0
    void Update()
    {
        if (stateController.CurrentState == PlayerState.Dead)
        {
            return;
        }

        leftStick  = MyInputManager.GetAxis(MyInputManager.Axis.LeftStick);
        movement.x = leftStick.x;
        //movement.z = leftStick.y;
        movement.y = 0.0f;

        //todo:z軸に勝手に移動?
        movement.z = 1.0f;

        movement *= moveSpeed * Time.deltaTime;

        //ジャンプ
        if (MyInputManager.GetButtonDown(MyInputManager.Button.A))
        {
            if (stateController.CurrentState == PlayerState.OnGround)
            {
                ActionJump();
            }
        }

        switch (stateController.CurrentState)
        {
        case PlayerState.Jump:
            movement        *= 0.4f;
            inerVec         *= 1.01f;
            m_body.velocity += inerVec * Time.deltaTime;
            if (m_transform.position.y - oldPosition.y < 0)
            {
                stateController.CurrentState = PlayerState.Fall;
            }
            break;

        case PlayerState.Fall:
            movement        *= 0.4f;
            inerVec         *= 1.01f;
            m_body.velocity += inerVec * Time.deltaTime;
            if (IsNearGround())
            {
                AkSoundEngine.PostEvent("Footsteps", gameObject);

                m_animator.SetTrigger("Landing");
                stateController.CurrentState = PlayerState.Land;
            }
            break;

        case PlayerState.Land:
            movement *= 0.8f;
            KKUtilities.Delay(landingTime, () => stateController.CurrentState = PlayerState.OnGround, this);
            break;
        }

        oldPosition = m_transform.position;
    }
示例#4
0
    public void PlayShortAnimation(int coinNum, Vector3 origin, float popingDuration = 0.5f)
    {
        for (int i = 0; i < coinNum; i++)
        {
            StartCoroutine(KKUtilities.Delay(0.1f * i, () => StartCoroutine(EarnCoinShortAnimation(origin, popingDuration)), false));
        }

        int startCoinNum = MyUserDataManager.Instance.CurrentCoinNum;

        StartCoroutine(KKUtilities.Delay(popingDuration, () => CountUpText(startCoinNum, startCoinNum + coinNum, 0.5f), false));
        MyUserDataManager.Instance.EarnCoin(coinNum);
    }
示例#5
0
    void Start()
    {
        inputField.onEndEdit.AddListener((text) =>
        {
            KKUtilities.Delay(1, () => inputField.interactable = false, this);
        });
        OnClick.AddListener(() =>
        {
            inputField.interactable = true;

            inputField.Select();
        });
    }
    public void ChangeState(int index, float waitTime = 0.0f)
    {
        if (currentState != null)
        {
            currentState.Exit();
        }
        if (waitTime == 0.0f)
        {
            currentState = FindState(index);
            return;
        }

        StartCoroutine(KKUtilities.Delay(waitTime, () =>
        {
            currentState = FindState(index);
        }));
    }
示例#7
0
    public void Damage(int point)
    {
        if (isInvicible)
        {
            return;
        }

        m_Animator.SetTrigger("Damaged");
        hpGauge.Value = hpGauge.Value - point;
        isInvicible   = true;

        KKUtilities.Delay(invincibleTime, () => isInvicible = false, this);
        StartCoroutine(DamageEffect());
        if (hpGauge.Value == 0)
        {
            stateController.CurrentState = PlayerState.Dead;
        }
    }
    void OnCollisionEnter(Collision col)
    {
        if (isDamage)
        {
            return;
        }
        if (col.gameObject.tag != "Tumbleweed")
        {
            return;
        }
        Debug.Log("hit tumbleweed");
        TumbleweedScript t = col.gameObject.GetComponent <TumbleweedScript> ();

        if (t.tumbleweedType == TumbleweedScript.Type.Normal)
        {
            return;
        }

        isDamage = true;
        m_animator.SetTrigger("Damaged");
        if (effects != null)
        {
            for (int i = 0; i < effects.Length; i++)
            {
                effects[i].SetActive(true);
            }
        }

        KKUtilities.Delay(damageTime, () => {
            if (effects != null)
            {
                for (int i = 0; i < effects.Length; i++)
                {
                    effects[i].SetActive(false);
                }
            }
            isDamage = false;
        }, this);
    }