示例#1
0
    public IEnumerator GrowingProjectile()
    {
        Vector2    maxScale = projectile.transform.localScale;
        GameObject go       = Instantiate(projectile, projectileSpawnPoint.position, projectileSpawnPoint.rotation);

        Rigidbody2D body = go.GetComponent <Rigidbody2D>();

        if (body)
        {
            Destroy(body);
        }

        Projectile proj = go.GetComponent <Projectile>();

        if (proj)
        {
            Destroy(proj);
        }

        ParticleProjectile particleProj = go.GetComponent <ParticleProjectile>();

        if (particleProj)
        {
            Destroy(particleProj);
        }

        Destroy(go, abilityDuration);
        go.transform.localScale = Vector2.zero;
        Vector2 scale = go.transform.localScale;

        while (scale.x < maxScale.x)
        {
            if (!go)
            {
                yield break;
            }

            scale = new Vector2(scale.x + Time.fixedDeltaTime, scale.y + Time.fixedDeltaTime);
            go.transform.localScale = scale;
            yield return(new WaitForFixedUpdate());
        }
    }
示例#2
0
    void GetEnemyComponents()
    {
        NavAgent        = GetComponent <NavMeshAgent> ();
        WaypointScript  = GetComponent <SWS.navMove> ();
        GameLogicObject = GameObject.FindGameObjectWithTag("GameLogic");
        PlayerPosition  = GameObject.FindGameObjectWithTag("Player").transform;
        AnimController  = GetComponent <Animator> ();

        GameLogicScript    = GameLogicObject.GetComponent <GameLogic> ();
        ParticleProjectile = GetComponentInChildren <ParticleProjectile> ();

        GetProjectileOrigin();

        Debug.Assert(NavAgent != null, "No Navmesh agent assigned to enemy");
        Debug.Assert(WaypointScript != null, "No waypointsript assigned to enemy");
        Debug.Assert(GameLogicObject != null, "No GameLogic tag found in enemy");
        Debug.Assert(PlayerPosition != null, "Player position is null");
        Debug.Assert(AnimController != null, "No animator controller assigned");

        Debug.Assert(ParticleProjectile != null, "ParticleProjectile is null");
    }
示例#3
0
    void FireProjectile()
    {
        ParticleProjectile pe = (ParticleProjectile)Instantiate(ParticleProjectile, ProjectileOrigin.transform.position, transform.rotation);

        pe.TurnOnCollider();
        Rigidbody ProjectileClone = pe.GetComponent <Rigidbody> ();


        //new particle method
        ProjectileClone.transform.LookAt(PlayerPosition);
        ProjectileClone.velocity = ProjectileClone.transform.forward * ProjectileSpeed;         //will always launch at player regardless of where the enemy faces
        ProjectileTimer          = 0;


        /*
         * Rigidbody ProjectileClone = (Rigidbody) Instantiate(ProjectileRigidBody, ProjectileOrigin.transform.position, transform.rotation);
         * ProjectileClone.transform.LookAt (PlayerPosition);
         *
         *
         * ProjectileClone.velocity = ProjectileClone.transform.forward * ProjectileSpeed; //will always launch at player regardless of where the enemy faces
         * ProjectileTimer = 0;
         */
    }