Beispiel #1
0
        public void Update(GameTime gameTime)
        {
            ComponentManager cm = ComponentManager.GetInstance();

            foreach (var entity in cm.GetComponentsOfType <SkillComponent>())
            {
                CooldownComponent cd             = cm.GetComponentForEntity <CooldownComponent>(entity.Key);
                SkillComponent    skillComponent = (SkillComponent)entity.Value;
                foreach (int entityUser in skillComponent.UsingEntities)
                {
                    if (cm.HasEntityComponent <EnergyComponent>(entityUser))
                    {
                        EnergyComponent energyComponent = cm.GetComponentForEntity <EnergyComponent>(entityUser);

                        if (skillComponent.EnergyCost < energyComponent.Current && cd.CooldownTimer <= 0)
                        {
                            skillComponent.Use(entityUser, 0);
                            energyComponent.Current -= skillComponent.EnergyCost;
                            cd.CooldownTimer         = cd.Cooldown;
                        }
                    }
                }
                skillComponent.UsingEntities.Clear();
            }
        }
Beispiel #2
0
 public UsableData(UsableData data)
 {
     Cooldown = new CooldownComponent(data.Cooldown.Type, data.Cooldown.Value);
     Effects  = new List <AbilityEffect>();
     for (int i = 0; i < data.Effects.Count; i++)
     {
         Effects.Add(data.Effects[i]);
     }
 }
Beispiel #3
0
 public UsableData(TimeType time, int cooldown, List <AbilityEffect> effects)
 {
     Cooldown = new CooldownComponent(time, cooldown);
     Effects  = new List <AbilityEffect>();
     for (int i = 0; i < effects.Count; i++)
     {
         Effects.Add(effects[i]);
     }
 }
 private void InitBuiltinComponents()
 {
     Base      = ZFramework.Runtime.GameEntry.GetComponent <BaseComponent>();
     Event     = ZFramework.Runtime.GameEntry.GetComponent <EventComponent>();
     Network   = ZFramework.Runtime.GameEntry.GetComponent <NetworkComponent>();
     Fsm       = ZFramework.Runtime.GameEntry.GetComponent <FsmComponent>();
     Setting   = ZFramework.Runtime.GameEntry.GetComponent <SettingComponent>();
     UI        = ZFramework.Runtime.GameEntry.GetComponent <UIComponent>();
     DateTable = ZFramework.Runtime.GameEntry.GetComponent <DateTableComponent>();
     Resource  = ZFramework.Runtime.GameEntry.GetComponent <ResourceComponent>();
     Cooldown  = ZFramework.Runtime.GameEntry.GetComponent <CooldownComponent>();
 }
Beispiel #5
0
        public void Update(GameTime gameTime)
        {
            ComponentManager cm = ComponentManager.GetInstance();

            foreach (var entity in cm.GetComponentsOfType <CooldownComponent>())
            {
                CooldownComponent cd = (CooldownComponent)entity.Value;
                if (cd.CooldownTimer > 0)
                {
                    cd.CooldownTimer -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
            }
        }
Beispiel #6
0
        protected override void SetOwner(Blaster owner)
        {
            Owner = owner;

            Owner.Spaceship.WeaponSet += OnWeaponSet;

            foreach (IWeaponComponent weaponComponent in Owner.WeaponComponents)
            {
                if (weaponComponent is CooldownComponent)
                {
                    _cooldownComponent = weaponComponent as CooldownComponent;
                    _cooldownComponent.UpdateCooldown += OnUpdateCooldown;
                }
            }
        }
        private void Update()
        {
            if (!cooldownComponent)
            {
                int id = uiArtifactCooldownComponent.id;
                ArtifactComponent artifactUsingComponent =
                    FindObjectsOfType <ArtifactComponent>().FirstOrDefault(x => x.id == id);
                if (artifactUsingComponent)
                {
                    cooldownComponent = artifactUsingComponent.gameObject.GetComponent <CooldownComponent>();
                }
                return;
            }

            var currentTime = Time.realtimeSinceStartup;

            float fill = 1;

            if (!cooldownComponent.canUse)
            {
                fill = (currentTime - cooldownComponent.last) / cooldownComponent.cooldown;
            }
            uiArtifactCooldownComponent.cooldownImage.fillAmount = fill;
        }
Beispiel #8
0
 public UsableData()
 {
     Cooldown = new CooldownComponent(TimeType.None, 0);
     Effects  = new List <AbilityEffect>();
 }