コード例 #1
0
    //範囲内に敵がいたら攻撃
    //武器の耐久値の減少
    public void Attack(GameObject other)
    {
        //if (!isAttack) { return; }
        //DownDurable();
        if (weaponNumber < 3 || weaponNumber == 5)
        {
            Player_SoundManager.instance.PlaySE_player(weaponNumber);
        }
        if (playerStatus.NowWeaponID == 5 && other.tag == "Enemy")
        {
            weaponAtaccks = cymbals.GetComponent <WeaponAtaccks>();
            weaponAtaccks.AbnormalAttaks(weaponNumber, other);
        }
        if (other.tag == "Enemy")
        {
            other.GetComponent <EnemyController>().Damage(playerStatus.PlayerAttack());
        }

        if (playerStatus.NowWeaponID == 2)
        {
            Debug.Log("Call!!! = " + other.gameObject.name);
            //切って橋にする木のタグ
            if (other.tag == "Tree")
            {
                other.GetComponent <CutTreeController>().SetFallFlag = true;
            }
        }
        isAttack = false;
    }
コード例 #2
0
    void Update()
    {
        if (!moveFlag)
        {
            return;
        }
        //合成画面を開く
        if (Input.GetKeyDown(KeyCode.Tab) || Input.GetButtonDown("Triangle") && synthesisGUI.activeSelf == false)
        {
            synthesisGUI.SetActive(!synthesisGUI.activeSelf);
            if (synthesisGUI.activeSelf == true)
            {
                Time.timeScale = 0.0f;
                this.GetComponent <MatlManager>().HaveCrystal();
                this.GetComponent <WeaponManager>().HaveWeapon();
            }
        }
        //合成画面を閉じる
        if (Input.GetButtonDown("Cross") && synthesisGUI.activeSelf == true)
        {
            if (synthesisBoxes.GetComponent <SynthesisController>().EndFlag)
            {
                return;
            }
            synthesisGUI.SetActive(!synthesisGUI.activeSelf);
            Time.timeScale = 1.0f;
            resetFlag      = false;
        }


        //合成の操作
        if (synthesisGUI.activeSelf == true)
        {
            SynthesisController synthesisCtrl = synthesisBoxes.GetComponent <SynthesisController>();
            //素材クリスタルを右に移動
            if (Input.GetAxisRaw("CrossKey_H") > 0 && lastSelect == 0 && synthesisCtrl.EndFlag == false ||
                Input.GetKeyDown(KeyCode.RightArrow))
            {
                matlButton.GetComponent <MatlSelect>().MoveRightFlag = true;
            }
            //素材クリスタルを左に移動
            if (Input.GetAxisRaw("CrossKey_H") < 0 && lastSelect == 0 && synthesisCtrl.EndFlag == false ||
                Input.GetKeyDown(KeyCode.LeftArrow))
            {
                matlButton.GetComponent <MatlSelect>().MoveLeftFlag = true;
            }
            //合成ボタン
            if (Input.GetKeyDown(KeyCode.P) || Input.GetButtonDown("Square"))
            {
                synthesisCtrl.EndFlag = true;
            }
            //リセット
            if (Input.GetButtonDown("Triangle"))
            {
                if (synthesisBoxes.GetComponent <SynthesisController>().EndFlag)
                {
                    return;
                }
                if (resetFlag)
                {
                    synthesisCtrl.ResetCrystal();
                }
            }
            lastSelect = Input.GetAxisRaw("CrossKey_H");
            if (resetFlag == false)
            {
                resetFlag = true;
            }
        }

        if (Time.timeScale == 0)
        {
            return;
        }

        //武器切り替え
        if (Input.GetButtonDown("R1") && attackFlag || Input.GetKeyDown(KeyCode.L))
        {
            WeaponChangeRight();
        }
        if (Input.GetButtonDown("L1") && attackFlag || Input.GetKeyDown(KeyCode.K))
        {
            WeaponChangeLeft();
        }

        //槍を投げる(通常攻撃じゃない)
        if (secondSpearPreventFlag && weaponNumber == 1 && Input.GetButtonDown("R2") || Input.GetKeyDown(KeyCode.O))
        {
            playerAnime.SetTrigger(key_SpearThrow);
            spearThrowTimeFlag     = true;
            secondSpearPreventFlag = false;
        }
        // 槍を投げる
        if (spearThrowTimeFlag)
        {
            spearThrowTime -= Time.deltaTime;
            if (spearThrowTime <= 0)
            {
                weaponAtaccks = spear.transform.GetChild(0).GetComponent <WeaponAtaccks>();
                weaponAtaccks.AbnormalAttaks(weaponNumber, null);
                spearThrowTimeFlag = false;
                spearThrowTime     = max_spearThrowTime;
            }
        }


        if (weaponNumber == 3)
        {
            if (Input.GetButton("Circle"))
            {
                // shildFlagがtrueの時はダメージを受けない
                attackFlag = false;
                shildFlag  = true;
                playerAnime.SetBool(key_ShildAttack, true);
                playerAnime.SetBool(key_ShildLoop, true);
                barrier.SetActive(true);
            }

            if (Input.GetButtonUp("Circle"))
            {
                shildFlag = false;
                playerAnime.SetBool(key_ShildAttack, false);
                playerAnime.SetBool(key_ShildLoop, false);
                DownDurable();
                attackFlag = true;
                barrier.GetComponent <ShieldFade>().SetEndEffect();
            }
        }

        //攻撃
        if ((Input.GetButtonDown("Circle")) && weaponNumber != 3 && attackFlag)
        {
            isAttack   = true;
            attackFlag = false;
            playerAnime.SetTrigger(key_Attack);
            GetComponent <weapon_collider>().SetCollider_Flag = true;
        }
    }