Vector3 FindDropLocation()
    {
        Vector3 enemyPosition = transform.position;

        Vector3 clampedLocation = new Vector3(Mathf.Round(enemyPosition.x), 0f, Mathf.Round(enemyPosition.z));

        foreach (Vector3 pos in raycastLocations)
        {
            RaycastHit Hit;
            Vector3    origin = clampedLocation + pos;
            origin.y = 2f;
            if (Physics.Raycast(origin, Vector3.down, out Hit, 1f, raycastMask))
            {
                if (Hit.collider.GetComponent <RockCell>() != null || Hit.collider.GetComponent <PoisonCell>() != null)
                {
                    continue;
                }

                PlantCell plant = Hit.collider.GetComponent <PlantCell>();
                if (plant != null && !plant.IsPlantGrown())
                {
                    Destroy(Hit.collider.gameObject);
                }
            }
            return(clampedLocation + pos);
        }
        return(new Vector3(0f, 5f, 0f));
    }
Exemple #2
0
    public override void SetCellContent(UICell cell, int row)
    {
        PlantCell plantCell = cell.GetComponent <PlantCell>();

        if (plantCell != null)
        {
            plantCell.rowNumber = row;
            plantCell.SetContent(puts[row]);
        }
    }
Exemple #3
0
    public void ConsumePlant(PlantCell plant)
    {
        targetPlant     = plant;
        bConsumingPlant = true;
        anim.SetBool("Eating", true);
        Invoke("GrowStronger", PlantConsumptionTime);
        RuntimeManager.PlayOneShot("event:/SFX/Enemys/enemy_eatingplants", Vector3.zero);

        eatFX = Instantiate(spawner.enemyEatFX, transform.position, Quaternion.identity);
    }
Exemple #4
0
    void GrowStronger()
    {
        if (eatFX != null)
        {
            Destroy(eatFX.gameObject);
        }
        bConsumedPlant = true;
        RuntimeManager.PlayOneShot("event:/SFX/Enemys/enemy_transformation", Vector3.zero);
        enemyObject.SetActive(false);
        strongEnemyObject.SetActive(true);
        transform.GetComponent <EnemyHealth>().GrowBigger();
        anim = strongAnim;
        Destroy(targetPlant.gameObject);
        targetPlant = null;
        Invoke("FinishGrowing", 1f);

        Transform particles = Instantiate(spawner.enemyTransformFX, transform.position, Quaternion.identity);

        Destroy(particles.gameObject, 1f);
    }
    void Fire()
    {
        if (currItemType == ItemHeldType.Weapon)
        {
            if (attackNumber < 3)
            {
                if (directionWhileAttacking != Vector3.zero)
                {
                    lastMoveDir = directionWhileAttacking;

                    rotationZ = calcZ(new Vector3(lastMoveDir.x, lastMoveDir.z, 0));
                    Debug.Log("Now rotationZ is " + rotationZ);
                    canvasRotTransf.rotation  = Quaternion.Euler(0, 0, rotationZ);
                    regularRotTransf.rotation = Quaternion.Euler(0, rotationZ, 0);
                }
                currWalkSpeed   = walkSpeed * speedAttackMultiplier;
                startFireTarget = Time.time;
                inputDisabled   = true;
                attackNumber++;
                if (attackNumber == 3)
                {
                    RuntimeManager.PlayOneShot("event:/SFX/Main Char/attack_heavy", Vector3.zero);
                }
                else
                {
                    RuntimeManager.PlayOneShot("event:/SFX/Main Char/attack_normal", Vector3.zero);
                }

                anim.Play("ANIM_Hero_Attack0" + attackNumber + "_EDIT", -1, 0f);
            }
        }
        else if (currItemType == ItemHeldType.Seed)
        {
            GridCell myCell = myCellTargetting.getCurrentCell();
            if (myCell != null)
            {
                if (!myCell.hasChildTransform(true))
                {
                    if (seedsNr > 0)
                    {
                        seedsNr--;
                        RuntimeManager.PlayOneShot("event:/SFX/UI/seed_plant", Vector3.zero);
                        GameObject go = Instantiate(PlantObj, myCell.transform);
                        myCell.assignChildTransform(go.transform);
                        setUI();
                    }
                    else
                    {
                        //RuntimeManager.PlayOneShot("event:/SFX/UI/seed_plant", Vector3.zero);
                    }
                }
                else
                {
                    PlantCell pc = myCell.getChildTransform().GetComponent <PlantCell>();
                    if (pc != null)
                    {
                        if (pc.isRipe())
                        {
                            RuntimeManager.PlayOneShot("event:/SFX/UI/flower_pickup", Vector3.zero);
                            seedsNr += 3;
                            Destroy(pc.gameObject);
                            myCell.removeTargeted();
                        }
                        else if (pc.isTowerAndNeedsAmmo() && seedsNr > 0)
                        {
                            pc.reload();
                            seedsNr--;
                        }
                        setUI();
                    }
                }
            }
        }
    }