Beispiel #1
0
    public void SliceProcess(Vector3 direction)
    {
        if (!isSliced)
        {
            this.isSliced = true;

            List <Sprite> sprites = DivideCurrentSpriteIntoPartsByWidth(2);
            Destroy(gameObject);

            //TOFIX: Make method
            SlicedPart left  = Instantiate(slicedPartPrefab, this.gameObject.transform.position, this.gameObject.transform.rotation);
            SlicedPart right = Instantiate(slicedPartPrefab, this.gameObject.transform.position, this.gameObject.transform.rotation);

            PhysicalObjectManager.GetInstance().Add(left);
            PhysicalObjectManager.GetInstance().Add(right);

            left.SetSprite(sprites[0]);
            right.SetSprite(sprites[1]);

            left.AddVelocity(Quaternion.Euler(0, 0, 90) * direction);
            right.AddVelocity(Quaternion.Euler(0, 0, -90) * direction);

            SlicingFruitEffect effect = Instantiate(slicingEffectPrefab, this.gameObject.transform.position, this.gameObject.transform.rotation);

            effect.SetColor(FruitColor);
            effect.ShowEffects();

            playerController.AddScore(playerController.ScoreConfiguration.AddScoreForFruit);
            playerController.SetLastTimeFruitSliced(Time.realtimeSinceStartup);
        }
    }
Beispiel #2
0
    private void SliceProcess()
    {
        if (!isSliced)
        {
            playerController.AddHealth(playerController.HealthConfiguration.AddHealthForSlicingBomb);

            foreach (Block item in BlockManager.GetInstance().GetAll())
            {
                item.DisableSlice();
            }

            foreach (PhysicalObject item in PhysicalObjectManager.GetInstance().GetAll())
            {
                Vector3 distance = item.transform.position - this.transform.position;
                item.AddVelocity(distance * _velocityPerDistance);
            }


            Explode();
            isSliced = true;
        }
    }
Beispiel #3
0
    private IEnumerator SpawnPackOfBlocks(int countBlocks)
    {
        int bombsCount  = (int)Mathf.Lerp(0, countBlocks, bombCountPercentageOfPack);
        int heartsCount = playerController.HealthConfiguration.MaxHealth - playerController.GetHealth();

        while (countBlocks > 0)
        {
            Block block = ChooseZoneSpawnerByPriority().SpawnBlock(GetRandomBlock());
            BlockManager.GetInstance().Add(block);
            PhysicalObjectManager.GetInstance().Add(block);
            --countBlocks;
            if (bombsCount > 0 && Random.Range(0f, 1f) <= spawnBombChance)
            {
                BlockManager.GetInstance().Add(ChooseZoneSpawnerByPriority().SpawnBlock(bomb));
                --bombsCount;
            }
            if (heartsCount > 0 && Random.Range(0f, 1f) <= spawnHeartChance)
            {
                BlockManager.GetInstance().Add(ChooseZoneSpawnerByPriority().SpawnBlock(heart));
                --heartsCount;
            }
            yield return(new WaitForSeconds(LerpByDifficulty(maxIntervalBlock, minIntervalBlock)));
        }
    }
Beispiel #4
0
 private void OnDestroy()
 {
     PhysicalObjectManager.GetInstance().Remove(this);
 }
Beispiel #5
0
 protected virtual void OnDestroy()
 {
     BlockManager.GetInstance().Remove(this);
     PhysicalObjectManager.GetInstance().Remove(this);
 }