Example #1
0
    public void Victory()
    {
        PuzzleScript script = mainScript.GetComponent <PuzzleScript>();

        script.puzzleSolved[0]  = true;
        script.puzzlesActive[0] = false;
        script.cubeSelectScreen.SetActive(true);

        Destroy(gameObject);
        Debug.Log("victory");
    }
 void Start()
 {
     // finds and attaches puzzle controller to script
     GameObject puzzleControllerObject = GameObject.FindWithTag ("PuzzleController");
     if (puzzleControllerObject != null)	//if game controller exists
     {
         //connects to puzzle controller
         puzzleController = puzzleControllerObject.GetComponent<PuzzleScript>();
     }
     //if puzzle controller cannot be found prints error
     if (puzzleController == null)
     {
         Debug.Log("Cannot find 'PuzzleController' script");
     }
 }
Example #3
0
        public Puzzle NewPuzzle(Dungeon dungeon, DungeonFloorData floorData, DungeonPuzzleData puzzleData, PuzzleScript puzzleScript)
        {
            var puzzle = new Puzzle(dungeon, this, floorData, puzzleData, puzzleScript);

            this.Puzzles.Add(puzzle);
            return(puzzle);
        }
Example #4
0
        /// <summary>
        /// Creates new puzzle.
        /// </summary>
        /// <param name="dungeon"></param>
        /// <param name="section"></param>
        /// <param name="floorData"></param>
        /// <param name="puzzleData"></param>
        /// <param name="puzzleScript"></param>
        public Puzzle(Dungeon dungeon, DungeonFloorSection section, DungeonFloorData floorData, DungeonPuzzleData puzzleData, PuzzleScript puzzleScript)
        {
            _variables        = new Dictionary <string, Object>();
            _monsterGroups    = new Dictionary <string, MonsterGroup>();
            _monsterGroupData = new Dictionary <string, DungeonMonsterGroupData>();
            this.Props        = new Dictionary <string, Prop>();
            this.Keys         = new Dictionary <string, Item>();

            _section       = section;
            this.Name      = puzzleScript.Name;
            this.Data      = puzzleData;
            this.Dungeon   = dungeon;
            this.Script    = puzzleScript;
            this.FloorData = floorData;

            for (int i = 1; i <= puzzleData.Groups.Count; ++i)
            {
                _monsterGroupData["Mob" + i] = puzzleData.Groups[i - 1].Copy();
            }
        }
    // Update is called once per frame
    void Update()
    {
        //Infinite Damage Cheat
        if (Input.GetKeyDown("o"))
        {
            pistolDamage  += 1000;
            shotgunDamage += 1000;
        }

        if (Input.GetKeyDown("q") && hasShotgun)
        {
            SwapWeapon();
        }

        laserLineL.SetPosition(0, leftBarrel.position);
        if (Input.GetButton("Fire1") && Time.time >= nextFire)                                  //Shoot
        {
            if (selectedWeapon == 0)                                                            //Blaster
            {
                var flash = Instantiate(muzzleFlash, leftBarrel.position, leftBarrel.rotation); //Create muzzle flash
                flash.transform.parent = leftBarrel;
                pistolAnimator.SetBool("Fire", true);                                           //Set fire animation

                nextFire = Time.time + fireRate;                                                //Timer for fire rate

                StartCoroutine(ShotEffect());

                RaycastHit hit;
                if (Physics.Raycast(camera.transform.position, camera.transform.forward, out hit, 100, ~layerMask)) //Raycast shooting
                {
                    laserLineL.SetPosition(1, hit.point);
                    if (hit.transform.gameObject.CompareTag("Enemy"))                                    //Check if hit enemy
                    {
                        if (hit.transform.gameObject.GetComponent <EnemyScript>())                       //Check if standard enemy
                        {
                            enemyScript         = hit.transform.gameObject.GetComponent <EnemyScript>(); //Apply damage to enemy
                            enemyScript.health -= pistolDamage;
                        }
                        else if (hit.transform.gameObject.GetComponent <SpiderBotScript>())
                        {
                            spiderBotScript         = hit.transform.gameObject.GetComponent <SpiderBotScript>(); //Apply damage to enemy
                            spiderBotScript.health -= pistolDamage;
                        }
                    }

                    Instantiate(hitParticles, hit.point, Quaternion.LookRotation(hit.normal)); //create hit particles perpendicular to the surface normal of the hit object
                }
                else
                {
                    laserLineL.SetPosition(1, camera.transform.position + (camera.transform.forward * 100)); //Shoot into thin air at a point 100 units away
                }
            }

            else if (selectedWeapon == 1 && shotgunAmmo > 0) //Shotgun
            {
                shotgunAmmo--;
                ShotgunAmmoCheck();

                var flash = Instantiate(shotgunMuzzleFlash, leftBarrel.position, leftBarrel.rotation); //Create muzzle flash
                flash.transform.parent = leftBarrel;

                var coneEffect = Instantiate(shotgunConeEffect, leftBarrel.position, leftBarrel.rotation); //Create shot effect flash
                coneEffect.transform.parent = leftBarrel;

                pistolAnimator.SetBool("Fire", true);   //Set fire animation

                nextFire = Time.time + shotgunFireRate; //Timer for fire rate

                RaycastHit sgHit;
                if (Physics.Raycast(camera.transform.position, camera.transform.forward, out sgHit, 100, ~layerMask)) //Raycast shooting
                {
                    if (sgHit.transform.gameObject.CompareTag("Enemy"))                                               //Check if hit enemy
                    {
                        float distance = Vector3.Distance(sgHit.transform.position, transform.position);

                        if (sgHit.transform.gameObject.GetComponent <EnemyScript>())                                     //Check if standard enemy
                        {
                            enemyScript = sgHit.transform.gameObject.GetComponent <EnemyScript>();                       //Apply damage to enemy
                            if (shotgunDamage - (shotgunDamage * shotgunDamageFalloff * distance) > 0)                   //Ensure that negative damage is not dealt
                            {
                                enemyScript.health -= shotgunDamage - (shotgunDamage * shotgunDamageFalloff * distance); //Linearly decrease damage taken as distance increases. for a shotgunDamageFalloff of .1, the damage taken after 1 unit of distance is 90%
                            }
                        }
                        else if (sgHit.transform.gameObject.GetComponent <SpiderBotScript>())
                        {
                            spiderBotScript = sgHit.transform.gameObject.GetComponent <SpiderBotScript>();                 //Apply damage to enemy
                            if (shotgunDamage - shotgunDamage * shotgunDamageFalloff * distance > 0)                       //Ensure that negative damage is not dealt
                            {
                                spiderBotScript.health -= shotgunDamage - shotgunDamage * shotgunDamageFalloff * distance; //Linearly decrease damage taken as distance increases. for a shotgunDamageFalloff of .1, the damage taken after 1 unit of distance is 90%
                            }
                        }
                    }
                }
            }

            else if (selectedWeapon == 1 && shotgunAmmo == 0 && hasShotgun)
            {
                SwapWeapon();
            }
        } //End of fire if statement

        else if (Input.GetButtonUp("Fire1"))
        {
            pistolAnimator.SetBool("Fire", false); //Switch off fire animation
        }

        if (Input.GetButton("Use")) //Use button
        {
            RaycastHit use;
            if (Physics.Raycast(camera.transform.position, camera.transform.forward, out use, useDistance, ~layerMask))
            {
                if (use.transform.gameObject.CompareTag("Puzzle"))     //Is puzzle
                {
                    PuzzleScript puzzleScript = use.transform.gameObject.GetComponent <PuzzleScript>();

                    puzzleScript.enabled = true;       //Turn on puzzle

                    puzzleScript.TurnOnInstructions(); //Turns on the instruction graphic thingy

                    PlayerMove playerMove = this.gameObject.GetComponent <PlayerMove>();
                    playerMove.inPuzzle = true;     //Disable movement
                }
            }
        }
    }