Exemple #1
0
        // -----------------------------------------------------------------------------------
        // Update
        // -----------------------------------------------------------------------------------
        protected override void Update()
        {
            if (Obj.GetGame.paused)
            {
                return;
            }

            UpdateSight();

            //Hit Effect
            if (Time.time - hitTime < 0.5)
            {
                spriteRenderer.color = Color.Lerp(Color.red, Color.white, (Time.time - hitTime) * 2);
            }

            //Status Effect Icon
            StatusTemplate tmp_status = states.GetLatestStatus();

            if (tmp_status != null)
            {
                spriteRendererIcon.SetIcon(tmp_status.icon);
            }
            else
            {
                spriteRendererIcon.RemoveIcon();
            }

            UpdateBehaviour();

            base.Update();
        }
Exemple #2
0
 // -----------------------------------------------------------------------------------
 // TryRemoveStatus
 // try to remove a certain tmpl effect with a optionally specified chance
 // -----------------------------------------------------------------------------------
 public bool TryRemoveStatus(StatusTemplate tmpl, float tmplChance = 1.0f)
 {
     if (tmplChance > 0 && tmpl != null && Random.value <= tmplChance)
     {
         return(RemoveStatus(tmpl));
     }
     return(false);
 }
Exemple #3
0
        // -----------------------------------------------------------------------------------
        // Deactivate
        // -----------------------------------------------------------------------------------
        public virtual void Deactivate()
        {
            SoundController.Play(template.removeSound);

            owner.AdjustProperty(template.OnActivateModifier, -1);

            owner             = null;
            template          = null;
            remainingDuration = 0;
        }
Exemple #4
0
 // -----------------------------------------------------------------------------------
 // Status
 // -----------------------------------------------------------------------------------
 public Status(StatusTemplate tmpl = null, Character ownerobj = null)
 {
     remainingDuration = 0;
     if (tmpl != null)
     {
         template = tmpl;
         owner    = ownerobj;
         Activate();
     }
 }
Exemple #5
0
 // -----------------------------------------------------------------------------------
 // GetHasStatus
 // -----------------------------------------------------------------------------------
 public bool GetHasStatus(StatusTemplate tmpl)
 {
     foreach (Status tmp_tmpl in states)
     {
         if (tmp_tmpl.isValid && tmp_tmpl.template == tmpl)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #6
0
 // -----------------------------------------------------------------------------------
 // RemoveStatus
 // -----------------------------------------------------------------------------------
 public bool RemoveStatus(StatusTemplate tmpl)
 {
     if (tmpl != null && states != null)
     {
         int index = states.FindIndex(i => i.template == tmpl);
         if (index >= 0)
         {
             states[index].Deactivate();
             return(true);
         }
     }
     return(false);
 }
Exemple #7
0
        // -----------------------------------------------------------------------------------
        // TryApplyStatus
        // try to apply a certain tmpl effect with a optionally specified chance
        // -----------------------------------------------------------------------------------
        public bool TryApplyStatus(StatusTemplate tmpl, float tmplChance = 1.0f)
        {
            if (tmpl != null)
            {
                if (owner != null && !tmpl.ignoreResistance)
                {
                    tmplChance -= owner.statistics.Resistance;
                }

                if (tmplChance > 0 && (Random.value <= tmplChance))
                {
                    return(AddStatus(tmpl));
                }
            }
            return(false);
        }
Exemple #8
0
 // -----------------------------------------------------------------------------------
 // AddStatus
 // -----------------------------------------------------------------------------------
 public bool AddStatus(StatusTemplate tmpl)
 {
     if (tmpl != null && states != null)
     {
         RemoveStatus(tmpl);
         int index = states.FindIndex(i => !i.isValid);
         if (index >= 0)
         {
             states[index] = new Status(tmpl, owner);
             if (owner is Player)
             {
                 UIController.Instance.ShowError(tmpl.description.getDescription);
             }
             return(true);
         }
     }
     return(false);
 }