Beispiel #1
0
    protected virtual IEnumerator Claw()
    {
        int     dir       = PlayerStatus.instance.transform.position.x >= transform.position.x ? 0 : 1;
        Vector2 attackPos = (dir == 0 ? clawPos[0] : clawPos[1]) + (Vector2)transform.position;

        GameObject nowClaw    = Instantiate(claw, attackPos, Quaternion.identity);
        ClawAttack clawAttack = nowClaw.GetComponent <ClawAttack>();

        clawAttack.AttackPos  = attackPos;
        clawAttack.AttackSize = clawSize;
        clawAttack.Direction  = dir == 0 ? ClawDirection.Right : ClawDirection.Left;

        yield return(new WaitForSeconds(3f));

        dir       = PlayerStatus.instance.transform.position.x >= transform.position.x ? 0 : 1;
        attackPos = (dir == 0 ? clawPos[0] : clawPos[1]) + (Vector2)transform.position;

        nowClaw               = Instantiate(claw, attackPos, Quaternion.identity);
        clawAttack            = nowClaw.GetComponent <ClawAttack>();
        clawAttack.AttackPos  = attackPos;
        clawAttack.AttackSize = clawSize;
        clawAttack.Direction  = dir == 0 ? ClawDirection.Right : ClawDirection.Left;

        StartCoroutine(NextPattern());
    }
Beispiel #2
0
    private void Claw(int i)
    {
        Vector2    attackPos  = clawPos[i] + (Vector2)transform.position;
        GameObject nowClaw    = Instantiate(claw, attackPos, Quaternion.identity);
        ClawAttack clawAttack = nowClaw.GetComponent <ClawAttack>();

        clawAttack.AttackPos  = attackPos;
        clawAttack.AttackSize = clawSize;
        clawAttack.Direction  = (attackPos.x >= transform.position.x) ? ClawDirection.Right : ClawDirection.Left;
    }