コード例 #1
0
    void SetAttackPoint()
    {
        // Set the ranges
        attackPointLeft  = new Vector2(transform.position.x - attackRange - 0.3f, transform.position.y);
        attackPointRight = new Vector2(transform.position.x + attackRange + 0.3f, transform.position.y);
        attackPointUp    = new Vector2(transform.position.x, transform.position.y + attackRange);
        attackPointDown  = new Vector2(transform.position.x, transform.position.y - attackRange);



        if (transform.tag == "Player")
        {
            playerIsLooking = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>().looking;

            switch (playerIsLooking)
            {
            default: throw new System.Exception("looking in unknown direction");

            case PlayerMovement.Looking.Up: attackPoint = attackPointUp; break;

            case PlayerMovement.Looking.Down: attackPoint = attackPointDown; break;

            case PlayerMovement.Looking.Left: attackPoint = attackPointLeft; break;

            case PlayerMovement.Looking.Right: attackPoint = attackPointRight; break;
            }
        }
    }
コード例 #2
0
    public void Update()
    {
        playerIsLooking = GameObject.FindGameObjectWithTag("Player")
                          .GetComponent <PlayerMovement>()
                          .playerIsLooking();

        var GS = GameObject.Find("GameManager").GetComponent <GameManager>();

        if (rangedWeaponEquipped == true && GS.getArrowCount() > 0)
        {
            if (Time.time > rangedCooldown + rangedAttackDelay)
            {
                canShoot       = true;
                rangedCooldown = Time.time;
            }
        }
        SetCurrentSprite();
        GetCurrentSprite();

        mouseClickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        if (Input.GetMouseButtonDown(0))
        {
            Attack();
        }
    }
コード例 #3
0
    void Start()
    {
        itemName     = "Gold Bow";
        damage       = 25;
        attackDelay  = 1.0f;
        speed        = 10;
        player       = GameObject.Find("Player");
        playerCombat = player.GetComponent <PlayerCombat>();

        playerIsLooking = GameObject.Find("Player")
                          .GetComponent <PlayerMovement>()
                          .playerIsLooking();
    }
コード例 #4
0
    public void KnockBack(PlayerMovement.Looking direction)
    {
        var knockDirection = "";

        if (direction == PlayerMovement.Looking.Left)
        {
            knockDirection = "Left";
        }
        if (direction == PlayerMovement.Looking.Right)
        {
            knockDirection = "Right";
        }
        if (direction == PlayerMovement.Looking.Up)
        {
            knockDirection = "Up";
        }
        if (direction == PlayerMovement.Looking.Down)
        {
            knockDirection = "Down";
        }

        StartCoroutine(Knock(knockDirection));
    }
コード例 #5
0
 void Update()
 {
     playerIsLooking = player.GetComponent <PlayerMovement>().playerIsLooking();
 }