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 ProjectileParams GetProjectileParams(string unitKey, float projectileDamage, Transform parent)
        {
            ProjectileParams pParams = null;

            if (_unitProjectileInfoDictionary.ContainsKey(unitKey))
            {
                pParams = GetProjectileParam(_unitProjectileInfoDictionary[unitKey]);
                pParams._projectileDamage = projectileDamage;
                pParams._parent           = parent;
            }
            return(pParams);
        }
Ejemplo n.º 3
0
 private static ProjectileParams GetProjectileParam(ProjectileParams projectileParams)
 {
     return(new ProjectileParams
     {
         _enemyType = projectileParams._enemyType,
         _motionType = projectileParams._motionType,
         _projectilePrefabPath = projectileParams._projectilePrefabPath,
         _projectileRadius = projectileParams._projectileRadius,
         _projectileSpeed = projectileParams._projectileSpeed,
         _projectileType = projectileParams._projectileType,
         _shouldAccelerate = projectileParams._shouldAccelerate
     });
 }
Ejemplo n.º 4
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);
        }