Ejemplo n.º 1
0
        //===========================================================================================
        //	Projectile Factory Method
//        private static Type GetUnitFromFactory(ProjectileType projectileType)
//        {
//            switch (projectileType)
//            {
//                case ProjectileType.Splash:
//                    return typeof(SplashProjectile);
//                default :
//                    return typeof(SingleTargetProjectile);
//            }
//        }
        //===========================================================================================



        //===========================================================================================
        //	Instantiation code for projectile objects
        public static UnitProjectile Instantiate(Transform target, ProjectileParams projectileParams)
        {
            if (target == null)
            {
                return(null);
            }

            //GameObject projectileObject = GameObject.Instantiate(Resources.Load(projectileParams._projectilePrefabPath)) as GameObject;
            GameObject     Prefab           = Resources.Load <GameObject>(Constants.PROJECTILES_PREFAB_PATH + "Bullet");
            GameObject     projectileObject = ObjectPool.Spawn(Prefab);
            UnitProjectile unitProjectile   = projectileObject.AddComponent <UnitProjectile>();

//			unitProjectile.transform.position = projectileParams._parent.position;
//			unitProjectile.transform.position = new Vector3(unitProjectile.transform.position.x, 0.5f, unitProjectile.transform.position.z); //offset from ground :s
            unitProjectile._damage           = projectileParams._projectileDamage;
            unitProjectile._type             = projectileParams._enemyType;
            unitProjectile._radius           = projectileParams._projectileRadius;
            unitProjectile._motionType       = projectileParams._motionType;
            unitProjectile._parent           = projectileParams._parent;
            unitProjectile._speed            = projectileParams._projectileSpeed;
            unitProjectile._shouldAccelerate = projectileParams._shouldAccelerate;
            unitProjectile._target           = target;
            unitProjectile._projectileType   = projectileParams._projectileType;
            unitProjectile.OnHitSound        = projectileParams.OnHitSound;
            unitProjectile.Fire();
            return(unitProjectile);
        }
Ejemplo n.º 2
0
        //===========================================================================================


        //===========================================================================================
        //
        public static UnitProjectile Instantiate(Vector3 target, ProjectileParams projectileParams)
        {
            GameObject     Prefab           = Resources.Load(Constants.PROJECTILES_PREFAB_PATH + "Bullet") as GameObject;
            GameObject     projectileObject = ObjectPool.Spawn(Prefab);
            UnitProjectile unitProjectile   = projectileObject.AddComponent <UnitProjectile>();

            unitProjectile._damage           = projectileParams._projectileDamage;
            unitProjectile._type             = projectileParams._enemyType;
            unitProjectile._radius           = projectileParams._projectileRadius;
            unitProjectile._motionType       = projectileParams._motionType;
            unitProjectile._parent           = projectileParams._parent;
            unitProjectile._speed            = projectileParams._projectileSpeed;
            unitProjectile._shouldAccelerate = projectileParams._shouldAccelerate;
            unitProjectile.gotoPos           = target;
            unitProjectile._projectileType   = projectileParams._projectileType;
            unitProjectile.OnHitSound        = projectileParams.OnHitSound;
            unitProjectile.Fire();
            return(unitProjectile);
        }