public void OnBlockAttached(FallingBlock fallingBlock)
        {
            animator.SetTrigger(wheatDroppedAnimHash);
            ++AttachedBlocksCounter;

            lethalRange.DestroyEntitiesInRange();
        }
Example #2
0
        // invoked by animator events
        void ThrowRock(int rockIndex)
        {
            var rockToThrow = projectiles.ElementAtOrDefault(rockIndex);

            if (rockToThrow == null)
            {
                var spawnSlot = spawnSlots.ElementAtOrDefault(rockIndex);
                if (spawnSlot != null)
                {
                    var spawnedProjectile = Instantiate(rockPrefab, spawnSlot.transform)
                                            .GetComponent <CatapultRock>();

                    projectiles.Add(spawnedProjectile);
                    //thisAudioSource.clip = SoundManager.Instance.CatapultShot;
                    //thisAudioSource.PlayOneShot(SoundManager.Instance.CatapultShot);
                }
            }

            if (parentBlock == null)
            {
                parentBlock = GetComponentInParent <FallingBlock>();
            }

            if (rockToThrow != null && parentBlock != null)
            {
                rockToThrow.Launch(parentBlock.transform.right);
                projectiles.Remove(rockToThrow);
            }
        }
Example #3
0
        void OnAnyBlockSpawned(FallingBlock fallingBlock)
        {
            if (currentFallingBlock != null)
            {
                return;
            }

            currentFallingBlock            = fallingBlock;
            currentFallingBlock.IsSelected = true;
        }
Example #4
0
        void OnAnyBlockPlaced(FallingBlock fallingBlock)
        {
            if (currentFallingBlock != fallingBlock)
            {
                return;
            }

            currentFallingBlock.IsSelected = false;
            currentFallingBlock            = null;

            shouldSpawnNextBlock = true;
        }
Example #5
0
 void Awake()
 {
     animator        = GetComponent <Animator>();
     thisAudioSource = GetComponent <AudioSource>();
     parentBlock     = GetComponentInParent <FallingBlock>();
 }