Пример #1
0
 // Use this for initialization
 protected virtual void Awake()
 {
     character             = GetComponentInParent <Character>();
     movement              = GetComponent <ShipMovement>();
     shooting              = GetComponent <ShootBomb>();
     shipSprite            = GetComponentInChildren <SpriteRenderer>();
     smokeParticles        = transform.Find("SmokeParticleSystem").GetComponent <ParticleSystem>();
     healthPickupParticles = transform.Find("HealthPickupParticleSystem").GetComponent <ParticleSystem>();
 }
Пример #2
0
    void FireBomb()
    {
        curBomb = Instantiate(bombPrefab, transform.position, new Quaternion()) as Bomb;
        PhysicsObj bombPhysics = curBomb.GetComponent <PhysicsObj>();

        //Set the owner of the fired bomb
        curBomb.owningPlayer = thisPlayer.playerEnum;

        //Set the initial speed of the fired bomb
        float   speed        = Random.Range(minSpeed, maxSpeed);
        Vector3 aimDirection = ShootBomb.ApplySpread(transform.up, bombSpread);

        bombPhysics.velocity = speed * aimDirection;
    }
Пример #3
0
    void CmdDoFire(int weapon, bool stationary)    //float rx, float ry, float rz
    {
        GameObject shot;

        if (weapon == 0)
        {
            Vector3 offset = Vector3.zero;

            if (shoot.gameObject.name.Equals("Mine"))
            {
                offset = shooter.forward * -2.5f + shooter.up * -2f;
            }
            else if (shoot.gameObject.name.Equals("shoot"))
            {
                if (!stationary)
                {
                    offset = shooter.forward * 8.5f;
                }
            }

            if (scriptClass.vehicleTypeClass == 0)
            {
                offset += -shooter.right * 2f;
                shot    = (GameObject)Instantiate(shoot, shooter.position + offset, shooter.rotation);              //Quaternion.Euler(rx, ry, rz)
                if (gameObject.CompareTag("VehicleTeam0"))
                {
                    shot.tag   = "BulletTeam0";
                    shot.layer = 8;
                }
                else if (gameObject.CompareTag("VehicleTeam1"))
                {
                    shot.tag   = "BulletTeam1";
                    shot.layer = 9;
                }
                NetworkServer.Spawn(shot);

                offset += shooter.right * 4f;
                shot    = (GameObject)Instantiate(shoot, shooter.position + offset, shooter.rotation);              //Quaternion.Euler(rx, ry, rz)
                if (gameObject.CompareTag("VehicleTeam0"))
                {
                    shot.tag   = "BulletTeam0";
                    shot.layer = 8;
                }
                else if (gameObject.CompareTag("VehicleTeam1"))
                {
                    shot.tag   = "BulletTeam1";
                    shot.layer = 9;
                }
                NetworkServer.Spawn(shot);
            }
            else
            {
                shot = (GameObject)Instantiate(shoot, shooter.position + offset, shooter.rotation);                 //Quaternion.Euler(rx, ry, rz)
                if (gameObject.CompareTag("VehicleTeam0"))
                {
                    shot.tag   = "BulletTeam0";
                    shot.layer = 8;
                }
                else if (gameObject.CompareTag("VehicleTeam1"))
                {
                    shot.tag   = "BulletTeam1";
                    shot.layer = 9;
                }
                NetworkServer.Spawn(shot);
            }
        }
        else if (weapon == 1)
        {
            Vector3 offset = Vector3.zero;

            if (shootSecond.name.Equals("Laser"))
            {
                offset = 10f * shooter.transform.forward;
            }

            shot = (GameObject)Instantiate(shootSecond, shooter.position + offset, shooter.rotation);             //Quaternion.Euler(rx, ry, rz)
            if (gameObject.CompareTag("VehicleTeam0"))
            {
                shot.tag = "BulletTeam0";
                //if (shootSecond.name.Equals ("Laser"))
                shot.layer = 8;
            }
            else if (gameObject.CompareTag("VehicleTeam1"))
            {
                shot.tag = "BulletTeam1";
                //if (shootSecond.name.Equals ("Laser"))
                shot.layer = 9;
            }
            if (shootSecond.gameObject.name.Equals("Bomb"))
            {
                ShootBomb bombScript = shot.GetComponent <ShootBomb> ();

                bombScript.speedVehicle = controller.body.velocity.magnitude;
            }

            NetworkServer.Spawn(shot);
        }
        //Physics.IgnoreCollision(GetComponent<Collider>(), shot.GetComponent<Collider>());
    }