Пример #1
0
    // run SelectWeponBox.cs
    public void SelectedSword(GameObject wepon)
    {
        isSelected = true;
        //hide popup

        FirstPersonControl firstPersonControl = GameObject.Find("First Person Controller").GetComponent <FirstPersonControl> ();

        firstPersonControl.ActiveSword();


        if (FirstPersonControl.VR)
        {
        }
        else
        {
            HandControl.rightGraphicsModel = null;
            HandControl.leftGraphicsModel  = null;
        }


        Stan.StartWand();

        Stan.playMovingSound();
        StartCoroutine(Moving(5F));

        sword.gameObject.SetActive(true);
        wepon.transform.parent = sword.transform;

        LeanTween.cancel(wepon);
        LeanTween.scale(wepon, new Vector3(1, 1, 1), 3.0f).setEase(LeanTweenType.easeOutQuad);
        LeanTween.rotateLocal(wepon, new Vector3(0, 180, 180), 3.0f).setEase(LeanTweenType.easeOutQuad);
        LeanTween.moveLocal(wepon, new Vector3(0, 0, 0), 3.0f).setEase(LeanTweenType.easeOutQuad);
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        anim = GetComponent <Animator>();

        Player = GameObject.Find("First Person Controller").GetComponent <FirstPersonControl> ();
        Debug.Log(Player);
    }
Пример #3
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         Player = other.gameObject.GetComponent <FirstPersonControl>();
         anim.SetBool("on", true);
         anim2.SetBool("on", true);
     }
 }
 private void Awake()
 {
     gameObject.name = "Player(Mine)";
     localPlayer     = this;
     layerMask       = -33025;
     if (cam == null)
     {
         cam = Camera.main;
     }
     //mainMenu = cam.GetComponent<menu>();
 }
Пример #5
0
 // Use this for initialization
 private void Start()
 {
     m_CharacterController = GetComponent <CharacterController>();
     m_Control             = GetComponent <FirstPersonControl>();
     //m_Camera = Camera.main;
     //m_OriginalCameraPosition = m_Camera.transform.localPosition;
     //m_FovKick.Setup(m_Camera);
     //m_HeadBob.Setup(m_Camera, m_StepInterval);
     m_StepCycle   = 0f;
     m_NextStep    = m_StepCycle / 2f;
     m_Jumping     = false;
     m_AudioSource = GetComponent <AudioSource>();
     m_MouseLook.Init(transform, cameraVisual.transform);
 }
Пример #6
0
    void Start()
    {
        CharControl  = GetComponent <CharacterController> ();
        animator     = GetComponent <Animator> ();
        Player       = GameObject.Find("First Person Controller").GetComponent <FirstPersonControl> ();
        audio        = GetComponent <AudioSource> ();
        faceRenderer = face.GetComponent <Renderer> ();

        if (hitEye)
        {
            LeanTween.alpha(hitEye, 0, 0.01f);
            hitEye.gameObject.SetActive(true);
        }
    }
Пример #7
0
    public void SetBeingHeld(bool held, FirstPersonControl firstPersonControl)
    {
        PickupObject component = transform.GetComponent <PickupObject>();

        component.beingHeld = held;
        if (held)
        {
            //armHoldingObject = gameObject;
            //playerHolding = transform.GetComponent<FirstPersonControl>();
            playerHolding     = firstPersonControl;
            lastPlayerHolding = playerHolding;
        }
        else
        {
            armHoldingObject = null;
            playerHolding    = null;
        }
    }
Пример #8
0
    IEnumerator Moving(float waitTime)
    {
        yield return(new WaitForSeconds(waitTime));

        isMoving = true;

        FirstPersonControl firstPersonControl = GameObject.Find("First Person Controller").GetComponent <FirstPersonControl> ();

        firstPersonControl.ActiveSword();


        CubeStanCd.GetComponent <Collider> ().enabled = true;

        BGM bgm = GameObject.Find("BGM").GetComponent <BGM> ();

        bgm.Play2();

        popupBox.Deactive();
    }
Пример #9
0
    /*private void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
     * {
     *  if (stream.isWriting)
     *  {
     *      Vector3 vector = new Vector3(lastDrawPos.x, lastDrawPos.y, 0f);
     *      stream.Serialize(ref vector);
     *  }
     *  else
     *  {
     *      Vector3 zero = Vector3.zero;
     *      stream.Serialize(ref zero);
     *      lastDrawPos = new Vector2(zero.x, zero.y);
     *  }
     * }*/

    public void SetLastDraw(GameObject playerID, Vector3 lastDraw3)
    {
        FirstPersonControl component = playerID.GetComponent <FirstPersonControl>();

        component.lastDrawPosition = new Vector2(lastDraw3.x, lastDraw3.y);
    }
Пример #10
0
    private void DrawOnTexture(GameObject callingPlayer, GameObject targetTransform, int brushSize)
    {
        FirstPersonControl component = callingPlayer.GetComponent <FirstPersonControl>();
        Texture2D          texture2D = targetTransform.GetComponent <MeshRenderer>().material.GetTexture("_Drawing") as Texture2D;

        //DrawTexture component2 = targetTransform.GetComponent<DrawTexture>();
        Color[] array = new Color[25];
        for (int i = 0; i < 25; i++)
        {
            array[i] = Color.black;
            //array[i] = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
        }
        if (component.lastDrawPosition != Vector2.zero)
        {
            Vector2 vector    = new Vector2(component.lastDrawPosition.x - lastDrawPosition.x, component.lastDrawPosition.y - lastDrawPosition.y);
            float   magnitude = vector.magnitude;

            /*if (magnitude > 3f)
             * {
             *  float num = Mathf.Round(magnitude / 3f);
             *  int num2 = 0;
             *  while ((float)num2 < num)
             *  {
             *      //texture2D.SetPixels((int)Mathf.Lerp(component.lastDrawPosition.x, lastDrawPosition.x, (float)num2 / num), (int)Mathf.Lerp(component.lastDrawPosition.y, lastDrawPosition.y, (float)num2 / num), brushSize, brushSize, array);
             *
             *      //texture2D.SetPixels((int)Mathf.Lerp(
             *      //    Mathf.Clamp(component.lastDrawPosition.x + 320, 40,512),
             *      //    lastDrawPosition.x, num2 / num), (int)Mathf.Lerp(
             *      //        Mathf.Clamp(component.lastDrawPosition.y + 128, 0, 256),
             *      //        lastDrawPosition.y, num2 / num), brushSize, brushSize, array);
             *
             *      num2++;
             *  }
             *  texture2D.Apply();
             * }*/
            // Point
            //texture2D.SetPixels((int)Mathf.Clamp(component.lastDrawPosition.x / 1.35f + 348, 234, 460), (int)Mathf.Clamp(component.lastDrawPosition.y / 1.35f + 122, 0, 272), brushSize, brushSize, array);
            if (!isFirstStep)
            {
                lastDrawPosition = component.lastDrawPosition;
                isFirstStep      = true;
            }
            float num  = Mathf.Round(magnitude / 3f);
            int   num2 = 0;
            while (num2 < num)
            {
                texture2D.SetPixels((int)Mathf.Clamp(
                                        Mathf.Lerp(component.lastDrawPosition.x, lastDrawPosition.x, num2 / num) / 1.35f + 348
                                        , 234, 460), (int)Mathf.Clamp(
                                        Mathf.Lerp(component.lastDrawPosition.y, lastDrawPosition.y, num2 / num) / 1.35f + 122
                                        , 0, 272), brushSize, brushSize, array);

                num2++;
            }

            // Liner

            /*texture2D.SetPixels((int)Mathf.Clamp(
             *  Mathf.Lerp(component.lastDrawPosition.x, lastDrawPosition.x, 2) / 1.35f + 348
             *  , 234, 460), (int)Mathf.Clamp(
             *      Mathf.Lerp(component.lastDrawPosition.y, lastDrawPosition.y, 2) / 1.35f + 122
             *      , 0, 272), brushSize, brushSize, array);*/
            lastDrawPosition = component.lastDrawPosition;
        }
        //component.lastDrawPosition = lastDrawPosition;
        //texture2D.SetPixels(pixelX, pixelY, brushSize, brushSize, array);
        texture2D.Apply();
        //targetTransform.GetComponent<MeshRenderer>().material.SetTexture("_Drawing", texture2D);
    }
Пример #11
0
 void Start()
 {
     firstPersonControl = Player.GetComponent <FirstPersonControl> ();
     anim = Knight.GetComponent <Animator>();
 }
Пример #12
0
    protected override void Initialize()
    {
        _spriteBatch = new SpriteBatch(GraphicsDevice);
        _surface     = new Texture2D(
            _graphics.GraphicsDevice,
            _graphics.PreferredBackBufferWidth,
            _graphics.PreferredBackBufferHeight,
            false,
            SurfaceFormat.Color
            );

        _colorRaster  = new FrameBuffer <int>(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight);
        _depthRaster  = new FrameBuffer <float>(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight);
        _renderer     = new Renderer(_colorRaster, _depthRaster);
        _shadowMapper = new ShadowMapper(256);

        var aspectRatio = _graphics.PreferredBackBufferWidth / (float)_graphics.PreferredBackBufferHeight;

        _camera = new Camera((float)Math.PI / 4, aspectRatio, 1, 500);
        _camera.MoveTo(-5, 8, -22);
        _camera.LookAt(0, 0, 0);

        _firstPersonControl = new FirstPersonControl(_camera);

        var gruntMesh = ContentLoader.ReadModel("grunt.obj");
        var dinoMesh  = ContentLoader.ReadModel("dinorider.obj");
        var planeMesh = BuildPlane(System.Drawing.Color.Blue);

        _scene = new Scene(new BranchNode
        {
            Nodes =
            {
                new BranchNode
                {
                    Nodes =
                    {
                        new LeafNode
                        {
                            LocalTransform = Create(new Vector3(0, -5, 0), Matrix4.Identity, 50),
                            Geometry       = planeMesh
                        },
                        new BranchNode
                        {
                            Nodes =
                            {
                                new LeafNode
                                {
                                    LocalTransform = Matrix4.CreateScale(10, 10, 10),
                                    Geometry       = gruntMesh
                                },
                                new LeafNode
                                {
                                    LocalTransform = Create(new Vector3(-2, 0, 7),
                                                            Matrix4.CreateRotationY(4.6F), 10),
                                    Geometry = dinoMesh
                                },
                                new LeafNode
                                {
                                    LocalTransform = Create(new Vector3(7, 0, 3),
                                                            Matrix4.CreateRotationY(2.3F), 10),
                                    Geometry = gruntMesh
                                }
                            }
                        }
                    }
                }
            }
        });

        base.Initialize();
    }
Пример #13
0
        private void Init(RenderSystemPlatform platform, PresentationParameters pp)
        {
            //Check the platform versioning and create the proper defaults
            OperatingSystem       os = System.Environment.OSVersion;
            IRenderSystemProvider renderSystem;

            switch (platform)
            {
            case RenderSystemPlatform.Direct3D10:
                if (os.Platform != PlatformID.Win32NT)
                {
                    throw new TeslaException("Renderer not available for OS that is running.");
                }
                renderSystem = new Tesla.Direct3D10.Graphics.D3D10RenderSystemProvider();
                Engine.Initialize(renderSystem);
                Engine.Services.AddService(typeof(IWindowProvider), new Tesla.Windows.Core.SWFWindowProvider());
                Engine.Services.AddService(typeof(IKeyboardProvider), new Tesla.Windows.Input.WindowsKeyboardProvider());
                Engine.Services.AddService(typeof(IMouseProvider), new Tesla.Windows.Input.WindowsMouseProvider());
                break;

            /*
             * case RenderSystemPlatform.XNA4:
             * if(os.Platform != PlatformID.Win32NT) {
             *   throw new TeslaException("Renderer not available for OS that is running.");
             * }
             * renderSystem = new Tesla.Xna.Graphics.XNARenderSystemProvider();
             * Engine.Initialize(renderSystem);
             * Engine.Services.AddService(typeof(IWindowProvider), new Tesla.Windows.Core.SWFWindowProvider());
             * Engine.Services.AddService(typeof(IKeyboardProvider), new Tesla.Windows.Input.WindowsKeyboardProvider());
             * Engine.Services.AddService(typeof(IMouseProvider), new Tesla.Windows.Input.WindowsMouseProvider());
             * break;*/
            default:
                throw new TeslaException("Platform not supported");
            }

            //Set renderer/platform
            _renderer   = renderSystem.Renderer;
            _platform   = platform;
            _clearColor = Color.CornflowerBlue;

            //Create the window and the host we'll be running it from
            _window = new Window(pp);
            _window.ClientSizeChanged += new EventHandler(ResizeViewport);
            _host = Engine.Services.GetService <IWindowProvider>().CreateWindowHost(_window);

            //Create the camera
            Camera camera = new Camera(new Viewport(0, 0, _window.ClientBounds.Width, _window.ClientBounds.Height));

            camera.Position = new Vector3(0, 0, 200f);
            camera.LookAt(Vector3.Zero, Vector3.Up);
            camera.SetProjection(45f, 1.0f, 500.0f);
            camera.Update();
            _renderer.CurrentCamera = camera;

            //Setup input
            _inputLayer  = new InputLayer();
            Mouse.Handle = _window.Handle;
            Mouse.SetPosition(pp.BackBufferWidth / 2, pp.BackBufferHeight / 2);
            FirstPersonControl control = new FirstPersonControl(camera, _inputLayer);

            _inputLayer.RegisterTrigger(new InputTrigger(new KeyPressedCondition(Keys.Escape, false),
                                                         new InputAction(delegate(GameTime time) {
                Exit();
            })));

            _inputLayer.RegisterTrigger(new InputTrigger(new KeyPressedCondition(Keys.Space, false),
                                                         new InputAction(delegate(GameTime time) {
                _window.IsFullScreen = !_window.IsFullScreen;
            })));

            _inputLayer.RegisterTrigger(new InputTrigger(new KeyPressedCondition(Keys.N, false),
                                                         new InputAction(delegate(GameTime time) {
                ToggleDebugNormals();
            })));

            _inputLayer.RegisterTrigger(new InputTrigger(new KeyPressedCondition(Keys.B, false),
                                                         new InputAction(delegate(GameTime time) {
                ToggleDebugBounding();
            })));

            _inputLayer.RegisterTrigger(new InputTrigger(new KeyPressedCondition(Keys.M, false),
                                                         new InputAction(delegate(GameTime time) {
                ToggleWireFrame();
            })));

            _inputLayer.RegisterTrigger(new InputTrigger(new KeyPressedCondition(Keys.V, false),
                                                         new InputAction(delegate(GameTime time) {
                ToggleWireFrameSolid();
            })));
            _inputLayer.RegisterTrigger(new InputTrigger(new KeyPressedCondition(Keys.F4, false),
                                                         new InputAction(delegate(GameTime time) {
                ToggleInstructions();
            })));

            //Setup content manager
            switch (platform)
            {
            case RenderSystemPlatform.Direct3D10:
                _content = new ContentManager(new MultiFileResourceLocator(Path.Combine(ResourceUtils.TitlePath, "Content"), Path.Combine(ResourceUtils.TitlePath, "Content//D3D10")));
                _content.RegisterLoader(new Tesla.Direct3D10.Content.Loaders.D3D10EffectLoader());
                break;

            case RenderSystemPlatform.XNA4:
                _content = new ContentManager(new MultiFileResourceLocator(Path.Combine(ResourceUtils.TitlePath, "Content"), Path.Combine(ResourceUtils.TitlePath, "Content//XNA4")));
                //  _content.RegisterLoader(new Tesla.Xna.Content.Loaders.XNAEffectLoader());
                break;
            }
            _content.RegisterLoader(new DDSLoader());
            _content.RegisterLoader(new PNGLoader());
            _content.RegisterLoader(new JPGLoader());
            _content.RegisterLoader(new BMPLoader());
            _content.RegisterLoader(new DXSLoader());
            _content.RegisterLoader(new BMFontLoader());

            //Setup resources for instruction GUI
            _instructionTex = new Texture2D(1, 1);
            _instructionTex.SetData <Color>(new Color[] { Color.Black });

            _spriteBatch       = new SpriteBatch(renderSystem);
            _instructionFont   = _content.Load <SpriteFont>("Fonts//comicsans.fnt");
            _wireFrameSolidMat = ContentManager.Load <Material>("BasicColor.tem").Clone();
            _wireFrameSolidMat.SetRenderState(RasterizerState.CullNoneWireframe);
            _wireFrameSolidMat.SetParameter("DiffuseColor", Color.DarkRed);

            //Create the scene graph
            _rootNode = new Node("Scene");

            //Simple point light
            PointLight pl = new PointLight();

            pl.Attenuate = false;
            pl.Position  = new Vector3(-100, 75, 100);
            pl.Ambient   = Color.Black;
            _rootNode.AddLight(pl);
            LoadContent();
        }
    public void Spawn()
    {
        print("Spawning!");
        Camera.main.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
        Camera.main.transform.position = Vector3.zero;
        Transform transform = /*Network.*/ Instantiate(player, gameObject.transform.position, gameObject.transform.rotation /*, 0*/);

        /*if (PlayerPrefs.GetString("Username") == "Kritz")
         * {
         *  networkView.RPC("SetPlayerTexture", 6, new object[]
         *  {
         *      transform.networkView.viewID,
         *      "Kritz"
         *  });
         * }
         * else
         * {
         *  networkView.RPC("SetPlayerTexture", 6, new object[]
         *  {
         *      transform.networkView.viewID,
         *      Random.Range(1, 8) + "staff"
         *  });
         * }*/
        menu             component  = Camera.main.GetComponent <menu>();
        MouseLook        component2 = Camera.main.GetComponent <MouseLook>();
        FollowGameObject component3 = Camera.main.GetComponent <FollowGameObject>();

        foreach (object obj in transform.transform)
        {
            Transform transform2 = (Transform)obj;
            foreach (object obj2 in transform2.transform)
            {
                Transform transform3 = (Transform)obj2;
                transform3.GetComponent <MeshRenderer>().enabled = false;
            }
            transform2.GetComponent <MeshRenderer>().enabled = false;
        }
        component.enabled     = false;
        component.currentMenu = menu.MenuGUIStates.pauseMenu;
        component2.enabled    = true;
        component3.follow     = transform.gameObject;
        component3.enabled    = true;

        /*transform.networkView.RPC("SetUsername", 6, new object[]
         * {
         *  transform.GetChild(0).FindChild("Username").networkView.viewID,
         *  PlayerPrefs.GetString("Username")
         * });
         * component.networkView.RPC("GetPlayerUsername", 0, new object[]
         * {
         *  Network.player.externalIP,
         *  PlayerPrefs.GetString("Username")
         * });*/
        /*if (PlayerPrefs.GetFloat("sensitivity") == 0f)
         * {
         *  PlayerPrefs.SetFloat("sensitivity", 10f);
         * }
         * component2.sensitivityX = PlayerPrefs.GetFloat("sensitivity");
         * component2.sensitivityY = component2.sensitivityX;*/
        FirstPersonControl component4 = transform.GetComponent <FirstPersonControl>();

        component4.cam = Camera.main;
        Cursor.visible = true;
    }
    private void Update()
    {
        usingRightHandObject = false;
        usingLeftHandObject  = false;
        if (beingHeld)
        {
            if (!control)
            {
                control = GameObject.Find("Player(Mine)").GetComponent <FirstPersonControl>();
            }
            if (Input.GetButton("Fire2") && Input.GetButton("RightHand") && !usingLeftHandObject)
            {
                holdingRightHandObject = true;
                if (Input.GetButton("RightHand") && beingUsed)
                {
                    usingRightHandObject = true;
                }
                if (Input.GetButtonDown("Fire1") && !Input.GetButton("LeftHand"))
                {
                    usingRightHandObject = true;
                    if (beingUsed)
                    {
                        RaycastHit raycastHit;
                        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out raycastHit, 6f, layerMask))
                        {
                            print("Won't exit");
                        }
                        if (raycastHit.transform != transform)
                        {
                            print("Will exit");
                            stopUsingObject = true;
                        }
                    }
                }
            }
            else
            {
                usingRightHandObject   = false;
                holdingRightHandObject = false;
            }
            if (Input.GetButton("Fire1") && Input.GetButton("LeftHand") && !usingRightHandObject)
            {
                holdingLeftHandObject = true;
                if (Input.GetButton("LeftHand") && beingUsed)
                {
                    usingLeftHandObject = true;
                }
                if (Input.GetButtonDown("Fire2") && !Input.GetButton("RightHand"))
                {
                    usingLeftHandObject = true;
                    RaycastHit raycastHit2;
                    if (beingUsed && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out raycastHit2))
                    {
                        if (raycastHit2.transform != transform)
                        {
                            print("Will exit");
                            stopUsingObject = true;
                        }
                        else
                        {
                            print("Won't exit");
                        }
                    }
                }
            }
            else
            {
                usingLeftHandObject   = false;
                holdingLeftHandObject = false;
            }
        }
        if ((usingRightHandObject || usingLeftHandObject) && !beingUsed)
        {
            beingUsed = true;

            /*Camera.main.GetComponent<MouseLook>().enabled = false;
             * Cursor.lockState = CursorLockMode.None;*/
            if (pencil == null)
            {
                GameObject gameObject = Instantiate(pencilPrefab, transform.position, transform.rotation) as GameObject;
                pencil = gameObject.transform;
            }
            else
            {
                pencil.transform.rotation = transform.rotation;
                pencil.transform.position = transform.position;
            }
            control.setObjectCollisions(false /*, gameObject*/);
        }
        if ((stopUsingObject || !beingHeld) && beingUsed)
        {
            beingUsed = false;

            /*Camera.main.GetComponent<MouseLook>().enabled = true;
             * Cursor.lockState = CursorLockMode.Locked;*/
            Destroy(pencil.gameObject);
            if (!GetComponent <Collider>().enabled)
            {
                control.setObjectCollisions(true /*, gameObject*/);
            }
        }
        if (beingUsed)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit raycastHit3;
            if (Physics.Raycast(ray, out raycastHit3, 5f, layerMask))
            {
                pencil.position = raycastHit3.point;
            }
            else
            {
                Vector3 cursorVector = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1.5f);
                cursorVector    = Camera.main.ScreenToWorldPoint(cursorVector);
                pencil.position = cursorVector;
            }
        }
        stopUsingObject = false;
    }