示例#1
0
    public override void StartTouch(SceneControl.TouchEvent args)
    {
        // Now, what have we targeted from this click (if anything)
        Ray        r = Camera.main.ScreenPointToRay(args.currentPosition);
        RaycastHit r_hit;

        // DID we point to anything from the touch?
        if (Physics.Raycast(r, out r_hit, Mathf.Infinity))
        {
            GameObject zai = globalEvents.manaControllerService.RequestBuyZombie(r_hit.point, new Quaternion());
            if (zai != null)
            {
                zombieAI ai = zai.GetComponent <zombieAI>();
                if (ai != null)
                {
                    ai.Start();
                }

                if (zombieAppearanceEffect != null)
                {
                    GameObject go = Instantiate(zombieAppearanceEffect, r_hit.point, Quaternion.Euler(-90.0f, 0.0f, 0.0f)) as GameObject;
                    Destroy(go, go.GetComponent <ParticleSystem>().duration);
                }
            }
        }
    }
示例#2
0
    protected void requestZombieCreationFast()
    {
        GameObject gObj = globalEvents.characterCreator.createFastZombie(gameObject.transform.position, Quaternion.Euler(0, 0, 0));
        zombieAI   zAI  = gObj.GetComponent <zombieAI>();

        if (zAI != null)
        {
            zAI.MakeFastZombie();
        }
    }
示例#3
0
    public GameObject createFastZombie(Vector3 position, Quaternion rotation)
    {
        GameObject gObj   = createZombie(position, rotation);
        zombieAI   zombie = gObj.GetComponent <zombieAI>();

        if (zombie != null)
        {
            zombie.MakeFastZombie();
        }
        return(gObj);
    }
示例#4
0
    public zombieAI createFastZombie()
    {
        GameObject spawn = getRandomSpawn();

        // if no such object found randomly, get out of loop
        if (spawn == null)
        {
            return(null);
        }

        zombieAI fz = createZombie(gs.RandomVectorInBounds(spawn), q).GetComponent <zombieAI>();

        fz.MakeFastZombie();
        return(fz);
    }
示例#5
0
    // this is public so can be invoked by click on the graveyard
    public void CreateZombie()
    {
        // if not enough time passed, don't generate a new one
        if (timeSinceLastSpawn < zombieSpawnInterval)
        {
            return;
        }

        timeSinceLastSpawn = 0;


        Quaternion lightningAngle = Quaternion.Euler(-90, 0, 0);

        if (globalEvents.manaControllerService.CanIBuyAZombie())
        {
            // time to generate a new zombie
            float x = Random.Range(gameObject.GetComponent <Collider>().bounds.min.x, gameObject.GetComponent <Collider>().bounds.max.x);
            float z = Random.Range(gameObject.GetComponent <Collider>().bounds.min.z, gameObject.GetComponent <Collider>().bounds.max.z);

            Vector3    spawnLocation = new Vector3(x, transform.position.y, z);
            Quaternion r             = Quaternion.Euler(0, 0, 0);
            zombieAI   zombie        = globalEvents.manaControllerService.RequestBuyZombie(spawnLocation, r).GetComponent <zombieAI>();
            if (zombie != null)
            {
                GameObject lightning = (GameObject)GameObject.Instantiate(summonZombieEffect, spawnLocation, lightningAngle);

                Destroy(lightning, 2f);
            }

            //if multiplier is set, spawn additional free zombies
            for (int i = 1; i <= zombieMultiplier; i++)
            {
                float new_x = Random.Range(gameObject.GetComponent <Collider>().bounds.min.x, gameObject.GetComponent <Collider>().bounds.max.x);
                float new_z = Random.Range(gameObject.GetComponent <Collider>().bounds.min.z, gameObject.GetComponent <Collider>().bounds.max.z);

                Vector3 new_spawnLocation = new Vector3(new_x, transform.position.y, new_z);

                globalEvents.characterCreator.createZombie(new_spawnLocation, r);
                GameObject new_lightning = (GameObject)GameObject.Instantiate(summonZombieEffect, new_spawnLocation, lightningAngle);

                Destroy(new_lightning, 2f);
            }
        }
        timeSinceLastSpawn = 0;
    }
示例#6
0
    public void detonate()
    {
        Vector2 explosionPosition = transform.position;
        float   explosionRadius   = 2;

        Collider2D[] colliders = Physics2D.OverlapCircleAll(explosionPosition, explosionRadius);
        Debug.Log(colliders.Length);

        for (int i = 0; i < colliders.Length; i++)
        {
            if (colliders[i].tag == "Enemy")
            {
                zombiePointer = colliders[i].GetComponent <zombieAI>();
                zombiePointer.changeHealth(85);
            }
            if (colliders[i].tag == "Corpse")
            {
                Destroy(colliders[i].gameObject);
            }
        }
        //var cloneBomb = Instantiate(bombPreFab, transform.position, Quaternion.identity);
        Destroy(gameObject);
    }
示例#7
0
 public PatrolState(zombieAI enemy)
 {
     myEnemy = enemy;
 }
示例#8
0
 public AttackState(zombieAI enemy)
 {
     myEnemy = enemy;
 }