Exemplo n.º 1
0
        /// Creates and returns a deep clone of this component
        public object clone()
        {
            AbilityComponent        copy     = MemberwiseClone() as AbilityComponent;
            List <AbilityComponent> children = new List <AbilityComponent>();

            if (AnimationAsset != null)
            {
                copy.AnimationAsset =
                    AnimationAsset.clone() as GameAsset <SpriteAnimation>;
            }

            if (ProjectileAsset != null)
            {
                copy.ProjectileAsset =
                    ProjectileAsset.clone() as GameAsset <Projectile>;
            }

            if (EffectAsset != null)
            {
                copy.EffectAsset =
                    EffectAsset.clone() as GameAsset <AbilityEffect>;
            }

            AbilityComponent child;

            Children.ForEach(orig => {
                child        = orig.clone() as AbilityComponent;
                child.Parent = copy;
                children.Add(child);
            });

            copy.Children = children;
            return(copy);
        }
Exemplo n.º 2
0
        /// Loads any required ressources for this components
        /// animation and projectile as well as for its children
        public void load(ContentManager content)
        {
            if (AnimationAsset != null)
            {
                AnimationAsset.load(content);
            }

            if (ProjectileAsset != null)
            {
                ProjectileAsset.load(content);
            }

            if (EffectAsset != null)
            {
                EffectAsset.load(content);
            }

            if (ExecutionSoundFile != null)
            {
                ExecutionSound = content.Load <SoundEffect>(ExecutionSoundFile);
            }

            if (Animation != null)
            {
                Animation.load(content);
            }
            if (UserAnimation != null)
            {
                UserAnimation.load(content);                       // TODO check why this load is necessary when loading a save game
            }
            if (Projectile != null)
            {
                Projectile.load(content);
            }
            if (Effect != null)
            {
                Effect.load(content);
            }

            Creature user;

            if ((user = Ability.User as Creature) != null)
            {
                if (UserAnimations.ContainsKey(user.Name))
                {
                    UserAnimations[user.Name].load(content);
                    UserAnimation = UserAnimations[user.Name].Object as SpriteAnimation;
                }
            }

            Children.ForEach(child => {
                child.Parent = this;
                child.load(content);
            });
        }
Exemplo n.º 3
0
    public void Initialize(ProjectileAsset asset)
    {
        projectile = asset;

        MovementSpeed = asset.movementSpeed;

        Mass       = asset.mass;
        UseGravity = asset.useGravity;

        ProjectileImpactParticles = asset.projectileImpactParticles;

        OnProjectileInstantiate();
    }