Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.B))
        {
            IRifle rifle = new BasicRifle();
            Instantiate(rifle.LoadPart());
            Debug.Log("Basic accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(rifle);
            Instantiate(rifle.LoadPart());
            Debug.Log("WithScope accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithStabilizer(new WithScope(rifle));
            Instantiate(rifle.LoadPart());
            Debug.Log("Stabilizer+Scope accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithSilencer(new WithStabilizer(new WithScope(rifle)));
            Instantiate(rifle.LoadPart());
            Debug.Log("Stabilizer+Scope+Silencer accuracy: "
                      + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            IRifle rifle = new BasicRifle();
            rifle = new InPink(new WithStabilizer
                                   (new WithSilencer(new WithScope(rifle))));
            Instantiate(rifle.LoadPart());
            Debug.Log("Stabilizer+Scope+Silencer in Pink! accuracy: "
                      + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }
    }
Example #2
0
    void Update()
    {
        if (Input.GetKeyDown("b"))
        {
            IRifle rifle = new BasicRifle();
            text.text = "Basic accuracy: " + rifle.GetAccuracy();
            Debug.Log("Basic accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown("s"))
        {
            IRifle rifle = new BasicRifle();
            rifle     = new WithScope(rifle);
            text.text = "WithScope accuracy: " + rifle.GetAccuracy();
            Debug.Log("WithScope Accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown("t"))
        {
            IRifle rifle = new BasicRifle();
            rifle     = new WithScope(new WithStabilizer(rifle));
            text.text = "Stabilizer + Scope Accuracy: " + rifle.GetAccuracy();
            Debug.Log("Stabilizer + Scope Accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown("f"))
        {
            IRifle rifle = new BasicRifle();
            rifle     = new WithMagazine(rifle);
            text.text = "Magazine Accuracy: " + rifle.GetAccuracy();
        }

        if (Input.GetKeyDown("t"))
        {
            IRifle rifle = new BasicRifle();
            rifle     = new WithScope(new WithStabilizer(rifle));
            text.text = "Stabilizer + Scope Accuracy: " + rifle.GetAccuracy();
            Debug.Log("Stabilizer + Scope Accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown("a"))
        {
            IRifle rifle = new BasicRifle();
            rifle     = new WithScope(new WithStabilizer(new WithMagazine(rifle)));
            text.text = "Stabilizer + Scope + Mag Accuracy: " + rifle.GetAccuracy();
            Debug.Log("Stabilizer + Scope + Mag Accuracy: " + rifle.GetAccuracy());
        }
    }
    void Update()
    {
        if (Input.GetKeyDown(Keycode.A))
        {
            IRifle rifle = new BasicRifle();
            Debug.Log("Basic Accurancy: " + rifle.GetAccurancy());
        }

        if (Input.GetKeyDown(Keycode.S))
        {
            IRifle rifle = new WithScope(new BasicRifle());
            Debug.Log("Scope Accurancy: " + rifle.GetAccurancy());
        }

        if (Input.GetKeyDown(Keycode.Z))
        {
            IRifle rifle = new WithScope(new WithStabilizer(new BasicRifle()));
            Debug.Log("Scope + Stabilizer Accurancy: " + rifle.GetAccurancy());
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.B))
        {
            IRifle rifle = new BasicRifle();
            Debug.Log("Basic accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(rifle);
            Debug.Log("WithScope accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(new WithStabilizer(rifle));
            Debug.Log("Stabilizer+Scope accuracy: " + rifle.GetAccuracy());
        }
    }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.B))
        {
            IRifle rifle = new BasicRifle();
            Debug.Log("Basic Accuracy: " + rifle.GetAccuracy());
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(rifle);
            Debug.Log("With Scope Accuracy: " + rifle.GetAccuracy());
        }
        if (Input.GetKeyDown(KeyCode.T))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(new WithStabilzer(rifle));
            Debug.Log("With Stabilzer Accuracy: " + rifle.GetAccuracy());
        }
        if (Input.GetKeyDown(KeyCode.U))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(new WithStabilzer(new WithDotSight(new WithLongBarrel(rifle))));
            Debug.Log("With Everything Accuracy: " + rifle.GetAccuracy());
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithDotSight(rifle);
            Debug.Log("With Dot Sight Accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown(KeyCode.L))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithLongBarrel(rifle);
            Debug.Log("With Long Barrel Accuracy: " + rifle.GetAccuracy());
        }
    }
Example #6
0
        void Update()
        {
            if (Input.GetKeyDown("b"))
            {
                IRifle rifle = new BasicRifle();
                Debug.Log("Rifle has a basic configuration, current accurancy: " + rifle.GetAccuracy());
            }

            if (Input.GetKeyDown("s"))
            {
                IRifle rifle = new BasicRifle();
                rifle = new WithScope(rifle);
                Debug.Log("Rifle is equipped with a scope, current accurancy: " + rifle.GetAccuracy());
            }

            if (Input.GetKeyDown("t"))
            {
                IRifle rifle = new BasicRifle();
                rifle = new WithScope(new WithStabilizer(rifle));
                Debug.Log("Rifle is equipped with a scope and stabilizer, current accurancy: " + rifle.GetAccuracy());
            }
        }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        // Basic Rifle
        if (Input.GetKeyDown("a"))
        {
            IRifle rifle = new BasicRifle();
            Debug.Log("Basic accuracy: " + rifle.GetAccuracy());
            Result.text = "You got: " + rifle.ToString();
        }

        // With Scope and Stabilizer
        if (Input.GetKeyDown("w"))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(new WithStabilizer(rifle));
            Debug.Log("Fancy accuracy: " + rifle.GetAccuracy());
            Result.text = "You got: Fancy Rifle";
        }

        // With Scope
        if (Input.GetKeyDown("s"))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(rifle);
            Debug.Log("+ Scope accuracy: " + rifle.GetAccuracy());
            Result.text = "You got: " + rifle.ToString();
        }

        // With Stabilizer
        if (Input.GetKeyDown("d"))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithStabilizer(rifle);
            Debug.Log("+ Stabilizer accuracy: " + rifle.GetAccuracy());
            Result.text = "You got: " + rifle.ToString();
        }
    }
Example #8
0
    void Update()
    {
        if (Input.GetKeyDown("b"))
        {
            IRifle rifle = new BasicRifle();
            Debug.Log("Basic accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown("s"))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(rifle);
            Debug.Log("Basic accuracy: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown("t"))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(new WithStabilizer(rifle));
            Debug.Log("Stabilizer + Scope: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown("p"))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(new WithSuppressor(rifle));
            Debug.Log("Scope + Suppressor: " + rifle.GetAccuracy());
        }

        if (Input.GetKeyDown("l"))
        {
            IRifle rifle = new BasicRifle();
            rifle = new WithScope(new WithExtendedBarrel(rifle));
            Debug.Log("Scope + Extended Barrel: " + rifle.GetAccuracy());
        }
    }
    // Update is called once per frame
    void Update()
    {
        //Event e = Event.current;
        foreach (KeyCode k in keys)
        {
            if (Input.GetKeyDown(k))
            {
                switch (k)
                {
                case KeyCode.B:

                    IRifle rifle = new BasicRifle(nextPos);

                    if (currentRifle != null)
                    {
                        GameObject.Destroy(currentRifle.GetGameObject());
                        currentRifle = rifle;
                        Debug.Log("Basic Accuracy: " + rifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }
                    else
                    {
                        currentRifle = rifle;
                        Debug.Log("Basic Accuracy: " + rifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }

                    break;

                case KeyCode.S:

                    IRifle sRifle = new BasicRifle(nextPos);
                    sRifle = new WithScope(sRifle);

                    if (currentRifle != null)
                    {
                        GameObject.Destroy(currentRifle.GetGameObject());
                        currentRifle = sRifle;
                        Debug.Log("Scoped Accuracy: " + sRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }
                    else
                    {
                        currentRifle = sRifle;
                        Debug.Log("Scoped Accuracy: " + sRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }

                    break;

                case KeyCode.T:

                    IRifle tRifle = new BasicRifle(nextPos);
                    tRifle = new WithStabilizer(tRifle);

                    if (currentRifle != null)
                    {
                        GameObject.Destroy(currentRifle.GetGameObject());
                        currentRifle = tRifle;
                        Debug.Log("With Stabilizer: " + tRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }
                    else
                    {
                        currentRifle = tRifle;
                        Debug.Log("With Stabilizer: " + tRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }

                    break;

                case KeyCode.C:

                    IRifle cRifle = new BasicRifle(nextPos);
                    cRifle = new WithBrake(cRifle);

                    if (currentRifle != null)
                    {
                        GameObject.Destroy(currentRifle.GetGameObject());
                        currentRifle = cRifle;
                        Debug.Log("With Brake: " + cRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }
                    else
                    {
                        currentRifle = cRifle;
                        Debug.Log("With Brake: " + cRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }

                    break;

                case KeyCode.L:

                    IRifle lRifle = new BasicRifle(nextPos);
                    lRifle = new WithLaser(lRifle);

                    if (currentRifle != null)
                    {
                        GameObject.Destroy(currentRifle.GetGameObject());
                        currentRifle = lRifle;
                        Debug.Log("With Laser: " + lRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }
                    else
                    {
                        currentRifle = lRifle;
                        Debug.Log("With Laser: " + lRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }

                    break;

                case KeyCode.A:

                    IRifle aRifle = new BasicRifle(nextPos);
                    aRifle = new WithScope(new WithStabilizer(new WithLaser(new WithBrake(aRifle))));

                    if (currentRifle != null)
                    {
                        GameObject.Destroy(currentRifle.GetGameObject());
                        currentRifle = aRifle;
                        Debug.Log("With All: " + aRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }
                    else
                    {
                        currentRifle = aRifle;
                        Debug.Log("With All: " + aRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }

                    break;

                default:

                    IRifle bRifle = new BasicRifle(nextPos);

                    if (currentRifle != null)
                    {
                        GameObject.Destroy(currentRifle.GetGameObject());
                        currentRifle = bRifle;
                        Debug.Log("Basic Accuracy: " + bRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }
                    else
                    {
                        currentRifle = bRifle;
                        Debug.Log("Basic Accuracy: " + bRifle.GetAccuracy());
                        //nextPos += new Vector3(1, 0, 0);
                    }

                    break;
                }
            }
        }
    }