Example #1
0
 public void ShootSpit(Vector3 position, Matrix orientation, float speed)
 {
     SpitBall blast = new SpitBall();
        blast.position = position;
        blast.orientation = orientation;
        blast.speed =  4+speed;
        blast.life = 2.0f;
        Console.WriteLine(position);
        laserBlasts.AddLast(blast);
 }
    void shoot()
    {
        GameObject SpitGo = (GameObject)Instantiate(Spit, firePoint.position, firePoint.rotation);
        SpitBall   spt    = SpitGo.GetComponent <SpitBall>();

        if (spt != null)
        {
            spt.Seek(target);
        }
    }
Example #3
0
    void FireBall()
    {
        // safe guard

        /*if (!spitball)
         *      print ("sadness");
         *      return;*/
        // create new ball
        SpitBall clone = Instantiate(spitball, new Vector2(transform.position.x + 0.7f, transform.position.y + 1.2f), Quaternion.identity) as SpitBall;
        // hide fake ball
        //transform.Find("BallPos").gameObject.SetActive (false);

        // candidate ball moving angle for player 1 (left side one)
        //float angle = Mathf.Deg2Rad * Random.Range (-30, 30);

        float angle    = Mathf.Deg2Rad * 30;
        float addForce = 0.4f;

        if (team == 1)
        {
            angle    = angle * -1;
            addForce = addForce * -1;
            clone.transform.eulerAngles = new Vector3(0, 180, 0);
        }

        // create vector2 for the angle
        Vector2 force = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle));

        // in case of player2, reverse x direction
        // a simple trick to check the player by checking its x position
        //if (transform.position.x > 0)
        //	force.x = -force.x;
        clone.ground = transform.position.y - 1f;

        // apply initial force to rigidbody
        clone.rigidbody.AddForce(force * addForce);

        // reset readytofire variable
        readytofire = false;
    }