logancberrypie

Particles

Sep 1st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class Particle {
  7.  
  8.     public static List<Particle> Instances = new List<Particle>();
  9.  
  10.     public float[] Displacement = new float[3];
  11.     public float[] InitialVelociy = new float[3];
  12.     public float[] FinalVelocity = new float[3];
  13.     public float[] Acceleration = new float[3];
  14.     public float Time;
  15.     public float[] Position = new float[3];
  16.  
  17.  
  18.     public string[] Key = new string[3] { "00000", "00000", "00000" };
  19.  
  20.     public bool inValidInput;
  21.  
  22.  
  23.     //Property variable link
  24.     private int[] _NumberOfInputs = new int[3];
  25.     public int[] GetNumberOfInputs()
  26.     {
  27.         this.updateNumberOfInputs();
  28.         return _NumberOfInputs;
  29.     }
  30.     public void SetNumberOfInputs(int index , int value)
  31.     {
  32.         _NumberOfInputs[index] = value;
  33.     }
  34.  
  35.     private float mass;
  36.     public float Mass
  37.     {
  38.         get { return mass; }
  39.         set
  40.         {
  41.             if (value >= 0)
  42.             {
  43.                 mass = value;
  44.             }
  45.             else
  46.             {
  47.                 mass = -value;
  48.             }
  49.         }
  50.     }
  51.  
  52.     private float restitution;
  53.     public float Restitution
  54.     {
  55.         get { return restitution; }
  56.         set
  57.         {
  58.             restitution = value;
  59.             MyMaths.Clamp(restitution, 0, 1);
  60.         }
  61.     }
  62.  
  63.     private float radius;
  64.     public float Radius
  65.     {
  66.         get { return radius; }
  67.         set { radius = MyMaths.Magnitude(value); }
  68.     }
  69.  
  70.  
  71.  
  72.     private void updateNumberOfInputs()
  73.     {
  74.         for (int i = 0; i < 3; i++)
  75.         {
  76.             int NumInputs = 0;
  77.             for (int j = 0; j < Key[i].Length; j++)
  78.             {
  79.                 if ((Key[i])[j] == '1')
  80.                 {
  81.                     NumInputs++;
  82.                 }
  83.             }
  84.             SetNumberOfInputs(i, NumInputs);
  85.         }
  86.     }
  87. }
Add Comment
Please, Sign In to add comment