public override IEnumerator Move(float moveDuration, float waitDuration, Vector3 targetPos, GameController.Direction direction = GameController.Direction.None)
    {
        if (inProgress)
        {
            yield break;
        }
        inProgress = true;
        animator.SetInteger("Direction", (int)direction);
        boomerang.GetComponent <Animator>().SetInteger("Direction", (int)direction);
        float   initial_time = Time.time;
        float   progress     = (Time.time - initial_time) / moveDuration;
        Vector3 initialPos   = t.position;

        while (progress < 1.0f)
        {
            progress   = (Time.time - initial_time) / moveDuration;
            t.position = Vector3.Lerp(initialPos, targetPos, progress);

            yield return(null);
        }
        yield return(new WaitForSeconds(waitDuration));

        if (Random.value <= attackProbability)
        {
            animator.speed = 0f;
            yield return(StartCoroutine(AnimateAttack(direction)));

            animator.speed = 1f;
        }
        inProgress = false;
    }
示例#2
0
    public StateBoomerangForward(PlayerControl _p, Boomerang _b, float _speed)
    {
        b     = _b;
        speed = _speed;

        p = _p;
        if (p.current_direction == Direction.NORTH)
        {
            direction_offset = new Vector3(0, 1, 0);
        }
        else if (p.current_direction == Direction.EAST)
        {
            direction_offset = new Vector3(1, 0, 0);
        }
        else if (p.current_direction == Direction.SOUTH)
        {
            direction_offset = new Vector3(0, -1, 0);;
        }
        else if (p.current_direction == Direction.WEST)
        {
            direction_offset = new Vector3(-1, 0, 0);
        }

        b.GetComponent <Rigidbody>().velocity = direction_offset * speed;
    }
示例#3
0
    //Changed this

    public StateBoomerangReturning(PlayerControl _p, Boomerang _b, float _speed, GameObject _pickedUpObject = null) {
        b = _b;
        speed = _speed;
        p = _p;
        pickedUpObject = _pickedUpObject;

        b.GetComponent<BoxCollider>().isTrigger = true;
    }
示例#4
0
 public void boomerangShoot(Vector2 direction)
 {
     DecreaseDurability(mode2Option.minusDurability);
     Boomerang = Instantiate(BoomerangPrefab, ShotPosition.position, Quaternion.identity);
     Boomerang.GetComponent <Rigidbody2D>().velocity = direction * 20f;
     Boomerang.GetComponent <Boomerang>().playerNo   = equipPlayer.playerNo;
     Boomerang.GetComponent <Boomerang>().direction  = direction;
 }
示例#5
0
    //Changed this

    public StateBoomerangReturning(PlayerControl _p, Boomerang _b, float _speed, GameObject _pickedUpObject = null)
    {
        b              = _b;
        speed          = _speed;
        p              = _p;
        pickedUpObject = _pickedUpObject;

        b.GetComponent <BoxCollider>().isTrigger = true;
    }
示例#6
0
    // Start is called before the first frame update
    void Start()
    {
        //Get Components
        animator = GetComponent <Animator>();
        rb       = GetComponent <Rigidbody2D>();

        target      = new GameObject();
        shootTarget = new GameObject();
        shootTarget.AddComponent <BoxCollider2D>();
        shootTarget.GetComponent <BoxCollider2D>().size = new Vector2(0.5f, 0.5f);
        shootTarget.AddComponent <PlayerTarget>();
        shootTarget.GetComponent <PlayerTarget>().playerNumber = playerNumber;
        shootTarget.GetComponent <BoxCollider2D>().isTrigger   = true;
        colors = new List <Color32>();
        foreach (SpriteRenderer limb in limbs)
        {
            colors.Add(limb.color);
        }

        foreach (Player player in FindObjectsOfType <Player>())
        {
            Physics2D.IgnoreCollision(player.GetComponent <BoxCollider2D>(), GetComponent <BoxCollider2D>());
            Physics2D.IgnoreCollision(player.GetComponent <BoxCollider2D>(), thrownBoomerang.GetComponent <BoxCollider2D>());
            Physics2D.IgnoreCollision(player.thrownBoomerang.GetComponent <BoxCollider2D>(), GetComponent <BoxCollider2D>());
            Physics2D.IgnoreCollision(player.thrownBoomerang.GetComponent <BoxCollider2D>(), thrownBoomerang.GetComponent <BoxCollider2D>());
        }

        maxHealth = health;

        thrownBoomerang            = Instantiate(thrownBoomerang.gameObject).GetComponent <Boomerang>();
        thrownBoomerang.parentHand = shoulder;
        thrownBoomerang.parent     = GetComponent <Player>();

        if (type == 1)
        {
            armsAnimator.speed = 1.25f;
        }
        else if (type == 3)
        {
            armsAnimator.speed = 2f;
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     animator  = GetComponent <Animator>();
     t         = GetComponent <Transform>();
     boomerang = Instantiate(boomerangPrefab, t.position, Quaternion.identity);
     boomerang.transform.SetParent(t, false);
     boomerang.GetComponent <InputToSwordAnimator>().enabled = false;
     boomerang.isPlayer = false;
     animator.speed     = 1f;
     boomerang.gameObject.SetActive(true);
 }
示例#8
0
    public void Attack(Movement movement, Action onFinished)
    {
        Boomerang bmrg = Instantiate(boomerang, this.transform);

        bmrg.OnThrown(
            movement.currentBodyDirection == Movement.BodyDirection.Right,
            () =>
        {
            onFinished.Invoke();
        }
            );

        //出現した瞬間自身と衝突して消滅するのを回避、かなりその場しのぎ
        DOVirtual.DelayedCall(0.2f, () => bmrg.GetComponent <Collider2D>().enabled = true);
    }
示例#9
0
    public StateBoomerangForward(PlayerControl _p, Boomerang _b, float _speed) {
        b = _b;
        speed = _speed;

        p = _p;
        if (p.current_direction == Direction.NORTH) {
            direction_offset = new Vector3(0, 1, 0);
        } else if (p.current_direction == Direction.EAST) {
            direction_offset = new Vector3(1, 0, 0);
        } else if (p.current_direction == Direction.SOUTH) {
            direction_offset = new Vector3(0, -1, 0);;
        } else if (p.current_direction == Direction.WEST) {
            direction_offset = new Vector3(-1, 0, 0);
        }

        b.GetComponent<Rigidbody>().velocity = direction_offset * speed;
    }
示例#10
0
 // Method for boomerang input
 private void Boomerang()
 {
     boomerang.Shoot();                                   // Starts the boomerang update script
     boomerang.GetComponent <Renderer>().enabled = false; // Renders the boomerang
     boomerang.trail.enabled = false;                     // Enables trail effect
 }