Ejemplo n.º 1
0
    //Initialise la trajectoire du boulet
    public void Initialize(Vector3 targetPosition, Vector3 originPosition)
    {
        this.originPosition = originPosition;                  //Initialisation du point d'origine

        distX = targetPosition.x - transform.position.x;       //Initialisation de la distance a parcourir selon l'axe X
        float distY = targetPosition.y - transform.position.y; //Initialisation de la distance a parcourir selon l'axe Y

        //Placement des points vises dans le repere
        float x2 = distX, y2 = distY;
        float x1 = x2 / 2, y1;

        // ==== Calcul de la trajectoire ===== //

        if (distX == 0)                      //Cas particulier : on tire seulement sur l'axe Y (pratiquement jamais utilise donc)
        {
            Advance = QuadraticWithoutXMove; //Choix de la fonction de trajectoire a utiliser
            x1      = 0.5f;
            x2      = 1;

            if (distY == 0)
            {
#if UNITY_EDITOR
                Debug.LogError("Weapon shot at its own position, should not be possible.");
#endif
                Destroy(gameObject);
            }

            if (distY > 0)
            {
                y1 = y2;
            }
            else
            {
                y1 = 0;
            }
        }
        else
        {
            if (distY > 0)
            {
                y1 = y2;
            }
            else if (distY < 0)
            {
                y1 = 0;
            }
            else
            {
                y1 = x1; //i.e. = x2 / 2;
            }

            Advance = QuadraticMove; //Choix de la fonction de trajectoire a utiliser
        }

        //Calcul des parametres de la fonction quadratique
        a = (y2 / x2 / x2 - y1 / x1 / x2) * (1 / (1 - x1 / x2));
        b = y1 / x1 - a * x1;

        gameObject.SetActive(true); //On active le boulet
    }
Ejemplo n.º 2
0
 public Form1()
 {
     InitializeComponent();
     adv                  = threadedAdvance;
     display              = ntdisplay;
     worldImage           = new Bitmap(1000, 1000);
     worldBox.MouseWheel += new MouseEventHandler(worldBox_MouseWheel);
     world                = new bool[worldlength, worldlength];
     newworld             = new bool[worldlength, worldlength];
     populationLabel.Text = String.Format("Population: {0} - Generation: {1} - World size: {2}x{2}",
                                          getPop(), steps, worldlength);
 }
Ejemplo n.º 3
0
 private void threadedToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (threadedToolStripMenuItem.Checked)
     {
         threadedToolStripMenuItem.Checked = false;
         adv = advance;
     }
     else
     {
         threadedToolStripMenuItem.Checked = true;
         adv = threadedAdvance;
     }
 }