Exemple #1
0
    void OnCollisionEnter(Collision collision)
    {
        var hit = collision.gameObject;

        ShipController sc = hit.GetComponent <ShipController> ();

        if (sc != null)
        {
            sc.SetAcceleration(sc.AccelerateForce * 2);
        }

        if (hit.tag == "Player" && hit.GetComponent <IMAI>() == null)
        {
            PhotonNetwork.player.AddScore(score);
        }
        else if (hit.GetComponent <IMAI>() != null)
        {
            hit.GetComponent <IMAI>().score += 5;
        }

        NetworkBullet networkBullet = hit.GetComponent <NetworkBullet> ();

        if (networkBullet != null)
        {
            PhotonView bulletpv = networkBullet.GetComponent <PhotonView> ();

            if (bulletpv != null)
            {
                if (bulletpv.isMine && bulletpv.GetComponent <IMAIBULLET>().ai == false)
                {
                    PhotonNetwork.player.AddScore(score * 2);
                }
            }
        }

        DestroyRegion(gameObject);
    }
Exemple #2
0
        protected override void Update(float deltaTime)
        {
            if (StateInfo != null)
            {
                // Sync our server transform with the client's reported position
                Vector3 clientPosition = new Vector3(ClientSnapshot.X, ClientSnapshot.Y, ClientSnapshot.Z);
                if (movementAnim.Target != clientPosition)
                {
                    movementAnim.SetTarget(clientPosition);
                }

                movementAnim.Step(deltaTime * 30f);

                Transform.Position = movementAnim.Value;

                // Sync our server camera with the client's
                camera.Yaw   = ClientSnapshot.CamYaw;
                camera.Pitch = ClientSnapshot.CamPitch;

                Gun  gun             = ItemManager.SelectedItem as Gun;
                bool reloadingBefore = gun != null && gun.IsReloading;

                // Update item in hand
                ItemManager.Update(false, false, false, false, ClientSnapshot.Reload, deltaTime);

                if (gun != null && gun.IsReloading && !reloadingBefore)
                {
                    reloaded = true;
                }

                // Only process bullets if the player is alive
                if (Health > 0)
                {
                    while (bulletsToFire.Count > 0)
                    {
                        // Attempt to fire client bullet
                        NetworkBullet bullet = bulletsToFire.Dequeue();

                        camera.Pitch    = bullet.CameraPitch;
                        camera.Yaw      = bullet.CameraYaw;
                        camera.Position = bullet.Origin;
                        camera.Update(deltaTime);

                        LastBulletDeltaTime = (Environment.TickCount - bullet.CreatedAt) + bullet.Ticks;

                        ItemManager.TryInvokePrimaryFire();
                    }
                }

                // Handle the client dropping intel
                if (ClientSnapshot.DropIntel)
                {
                    DropIntel();
                }

                // Handle the player falling off the map
                if (Transform.Position.Y < -200)
                {
                    this.Damage(100, "The Void");
                }

                // Process refresh cooldown
                if (refreshCooldown > 0)
                {
                    refreshCooldown -= deltaTime;
                }

                // Update our "fake" camera
                camera.Position = Transform.Position + new Vector3(0, Size.Y / 2f - 1.1f, 0);
                camera.Update(deltaTime);

                // Save the current transform for future rollbacks
                StoreCurrentTransform();
            }

            base.Update(deltaTime);
        }