Example #1
0
    private void Awake()
    {
        _movement  = GetComponent <OrbMovement>();
        _combining = GetComponent <OrbCombining>();

        //DEBUG
        Transform fakeAnchor = new GameObject("FakeOrbAnchor").transform;

        fakeAnchor.position = transform.position;
        Activate(fakeAnchor);
    }
    void FireOrb(float angle)
    {
        Vector3     spawnPosition = transform.position;
        OrbMovement orbMovement   = Instantiate(_orbPrefab, spawnPosition, Quaternion.identity, transform.parent).GetComponent <OrbMovement>();

        orbMovement.MoveAtDirection(
            new Vector2(
                Mathf.Cos(angle),
                Mathf.Sin(angle)
                )
            );
    }
    void Fire()
    {
        if (_audioSource != null)
        {
            _audioSource.Play();
        }

        Vector2     fireDirection = GetAttackDirection();
        Vector3     spawnPosition = transform.position + ((Vector3)fireDirection * .5f);
        OrbMovement orbMovement   = Instantiate(_orbPrefab, spawnPosition, Quaternion.identity, transform.parent).GetComponent <OrbMovement>();

        orbMovement.MoveAtDirection(fireDirection);
    }