Пример #1
0
 // Called once upon activation.
 public void FakeStart()
 {
     appliedObjectHealth = GetComponent<Health>();
     appliedObjectMovement = GetComponent<MovementGeneric>();
     // Individual buff procedures.
     switch(buffID)
     {
         case 1:		// Damage HP
             appliedObjectHealth.Damage(param, magnitude);
             break;
         case 2:     // Modify MaxHP
             appliedObjectHealth.maxHP += magnitude;
             break;
         case 3:     // Modify Resistance
             appliedObjectHealth.ModResistance(param, magnitude);
             break;
         case 4:     // Knockback, only has effect upon start. tickingCoefficient controls the decay for this one.
             Vector3 knockDir = Vector3.zero;
             if (this.gameObject == creator)
             {
                 // This is for self-knockback effects. They always go backwards when activated.
                 Debug.Log("Creator and Target are the same");
                 knockDir = -1 * transform.forward;
             }
             else
             {
                 knockDir = transform.position - creator.transform.position;
                 knockDir.Normalize();
             }
             if (appliedObjectMovement != null)
                 appliedObjectMovement.Knockback(knockDir, magnitude, tickingCoefficient);
             break;
         case 5:     // Script. This will apply a script with name of the param field.
                     //Scripts are responsible for cleaning up after themselves!
             Type a = Type.GetType(param);
             gameObject.AddComponent(a);
             break;
         case -1:	// None
             break;
         default:
             Debug.LogError("A buff application has defaulted. The buff's name is: " + buffName);
             break;
     }
 }