Exemple #1
0
 void Awake()
 {
     // Setting up references.
     groundCheck = transform.Find("groundCheck");
     swordScript = GetComponentsInChildren <SwordScript>()[0];
     animator    = GetComponent <Animator>();
 }
    void Start()
    {
        DeathFlag       = true;
        audioSource     = gameObject.AddComponent <AudioSource>();
        TapEffect       = Resources.Load <GameObject>("TapEffect");
        worldPos        = transform.position;
        PlayersStrength = GameObject.Find("GameMaster").GetComponent <StageScript>();
        trs             = GetComponent <Transform>();
        Under           = -1.3f;
        Over            = 3.5f;
        RightEnd        = 8.62f;
        LeftEnd         = -8.62f;

        SwordPrefab          = (GameObject)Resources.Load("SwordAttack");
        SwordSPr             = SwordPrefab.GetComponent <SwordScript>();
        SwordSPr.MoveSpeed   = AttackSpeed;
        SwordSPr.AttackPower = AttackPower;

        offset = new Vector3(-0.5f, 0);
        if (PlayerPrefs.HasKey("SE"))
        {
            maxVolume = PlayerPrefs.GetFloat("SE") * 0.5f;
        }
        audioSource.volume = maxVolume;
    }
 /// <summary>
 /// Gets scripts and components.
 /// </summary>
 private void Start()
 {
     _lives = GetComponent <Lives>();
     sord   = Instantiate(sord, transform.position, transform.rotation);
     sord.SetActive(false);
     _sordScript = sord.GetComponent <SwordScript>();
 }
Exemple #4
0
 void Start()
 {
     StartCoroutine("Spawn");
     m_hero     = GameObject.FindGameObjectWithTag("Player");
     swordcheck = GameObject.FindGameObjectWithTag("Player").GetComponent <SwordScript>();
     navy       = this.gameObject.GetComponent <NavMeshAgent>();
 }
Exemple #5
0
    private PlayerSpriteAnimation spriteAnimation;  // The actual animation script attached to the spriteAnimationPlane

    // Start is called before the first frame update
    void Start()
    {
        // General player script setup
        body            = gameObject.GetComponent <Rigidbody>();
        healthManager   = GetComponent <KillableScript>();
        moveDirection   = Vector3.forward;
        spriteAnimation = spriteAnimationPlane.GetComponent <PlayerSpriteAnimation>();
        StartCoroutine(DisableMessageText(5.0f)); // Hide the initial quest message after a short delay

        // Restore/update saved values from the StaticSaver
        SwordScript sword = swordHitbox.GetComponent <SwordScript>();

        if (SceneManager.GetActiveScene().name == "Outside")
        {
            StaticSaverScript.maxHealth      = maxHealth;
            StaticSaverScript.swordPower     = sword.power;
            StaticSaverScript.swordKnockback = sword.knockbackForce;
            StaticSaverScript.health         = maxHealth;
            healthManager.health             = maxHealth;
        }
        else
        {
            maxHealth            = StaticSaverScript.maxHealth;
            sword.power          = StaticSaverScript.swordPower;
            sword.knockbackForce = StaticSaverScript.swordKnockback;
            healthManager.health = StaticSaverScript.health;
        }
    }
 void Start()
 {
     maincamera = GameObject.Find("Main Camera");
     guiScript = maincamera.GetComponent<GUIScript>();
     soundManager = GameObject.Find("SoundManager").GetComponent<SoundManager>();
     shieldScript = GameObject.Find("l_arm").GetComponent<ShieldScript>();
     swordScript = GameObject.Find("r_arm").GetComponent<SwordScript>();
 }
Exemple #7
0
 public void SwordSwap(SwordScript a, Sword b)
 {
     a.damage    = b.damage;
     a.type      = b.type;
     a.kills     = b.kills;
     a.image     = b.image;
     a.knockback = b.knockback;
     a.affixes   = b.affixes;
 }
Exemple #8
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("PickUp"))
        {
            Destroy(other.gameObject);

            swordScript = swordObject.GetComponent <SwordScript>();
            hasSword    = true;
        }
    }
    void Start()
    {
        clickingArea = clickingArea.GetComponent <ClickingArea>();
        anims        = GetComponent <Animator>();
        anims.SetFloat("flying", 2);



        playerControl = GetComponent <PlayerControl>();
        shooted       = GetComponent <SwordScript>();

        startScale = rocket.GetComponent <Transform>().transform.localScale;
    }
Exemple #10
0
    void OnCollisionEnter(Collision col)
    {
        SwordScript sword = GetComponentInChildren <SwordScript>();

        //ENEMY HURTS PLAYER
        //Under 0.5 for gameTicks2 = player is temporarily invincible
        //This way the enemy doesn't instantly remove all the player's health.
        if (col.gameObject.tag == "Enemy" && gameTicks2 > 0.5 && !sword.drawn && !inv)
        {
            gameObject.GetComponentInParent <PlayerScript>().health--;
            healthDisplayer.GetComponent <HealthBarDisplay>().UpdateText();
            gameTicks2 = 0.0f;
        }
    }
Exemple #11
0
    private void OnCollisionEnter(Collision collision)
    {
        // Destroy particles the player touches so they don't affect the player's physics (a piece of bush can no longer fling the player in the air)
        if (collision.collider.gameObject.CompareTag("PolyParticle"))
        {
            Destroy(collision.collider.gameObject);
        }

        // Collect any item the player touches
        if (collision.collider.gameObject.CompareTag("Item"))
        {
            ItemScript item = collision.collider.gameObject.GetComponent <ItemScript>();
            item.Collect();

            // Handle item-specific effects
            switch (item.itemType)
            {
            case ItemScript.Type.HealthBoost:
                healthManager.health     = maxHealth;
                StaticSaverScript.health = maxHealth;
                ShowMessage("[ITEM ACQUIRED]\n\nHealth restored!", 2.0f);
                break;

            case ItemScript.Type.HealthMaxBoost:
                maxHealth++;
                healthManager.health        = maxHealth;
                StaticSaverScript.maxHealth = maxHealth;
                ShowMessage("[ITEM ACQUIRED]\n\nMaximum health increased!", 2.8f);
                break;

            case ItemScript.Type.RockbreakerSword:
                SwordScript sword = swordHitbox.GetComponent <SwordScript>();
                sword.power++;
                sword.knockbackForce            += 100.0f;
                StaticSaverScript.swordPower     = sword.power;
                StaticSaverScript.swordKnockback = sword.knockbackForce;
                ShowMessage("[ITEM ACQUIRED]\n\nRockbreaker Sword!\n\nMore powerful, and can break weak rocks.", 4.5f);
                break;

            case ItemScript.Type.Torch:
                Transform torch = collision.collider.gameObject.transform.GetChild(0);     // Just steal the torch's point light
                torch.SetParent(transform);
                torch.localPosition = new Vector3(0.0f, 0.25f, 0.0f);
                ShowMessage("[ITEM ACQUIRED]\n\nTorch!\n\nSee in the dark.", 2.5f);
                break;
            }
        }
    }
Exemple #12
0
    public void TagRobot(GameObject gRobot_)
    {
        bDisabled = false;
        bBody     = gRobot_.GetComponent <BodyScript>();
        gGun      = gRobot_.GetComponentInChildren <GunScript>();
        sSword    = gRobot_.GetComponentInChildren <SwordScript>();

        //this is super superfulous(f**k spelling lmao) and and probably be made into tags.
        bBody.sOwner  = tag;
        gGun.sOwner   = tag;
        sSword.sOwner = tag;
        //like so
        bBody.tag  = tag;
        gGun.tag   = tag;
        sSword.tag = tag;
    }
Exemple #13
0
    // It's the endgame! (nothing really happens except for the message though)
    public void Victory()
    {
        Debug.Log("Victory!");
        ShowMessage("[QUEST COMPLETE]\n\nScourge Defeated!\n\nClear out more ratbeasts, or press ESC to quit.", 7.5f);

        // Give the player a secret boost in case they want to still fight stuff
        SwordScript sword = swordHitbox.GetComponent <SwordScript>();

        healthManager.health = maxHealth;
        sword.power++;
        sword.knockbackForce            += 150.0f;
        StaticSaverScript.health         = maxHealth;
        StaticSaverScript.swordPower     = sword.power;
        StaticSaverScript.swordKnockback = sword.knockbackForce;

        // They did it.  The player finally beat the Scourge.  There's no more to see here. (...for now.)
    }
Exemple #14
0
 public static void updateEnemyHP(GameObject enemy, Vector3 transformPosition)
 {
     enemy.GetComponent <HPScript>().ChangeHP(SwordScript.getDamage() * -1, enemy.GetComponent <Collider>().ClosestPointOnBounds(transformPosition), "-" + SwordScript.getDamage().ToString());
 }
Exemple #15
0
 void Start()
 {
     sword = GetComponentInParent <SwordScript> ();
 }
    /// <summary>
    /// Initializes the character script; called from controller
    /// </summary>
    /// <param name="targetTag">the tag of the targeted objects</param>
    /// <param name="energyChanged">the handler for when the energy changes</param>
    /// <param name="healthBar">the health bar</param>
    /// <param name="timerBars">the array of timer bars</param>
    /// <param name="healthMult">the health multiplier</param>
    public override void Initialize(string targetTag, EnergyChangedHandler energyChanged, Image healthBar, Image[] timerBars, float healthMult = 1)
    {
        // Sets fields
        maxHealth = Constants.WARRIOR_HEALTH;
        moveSpeed = Constants.WARRIOR_MOVE_SPEED;
        jumpSpeed = Constants.WARRIOR_JUMP_SPEED;
        maxEnergy = Constants.WARRIOR_ENERGY;
        gCDTimer = new Timer(Constants.WARRIOR_GCD);
        secondaryCDTimer = new Timer(Constants.LIGHTNING_CD);
        powerCDTimer = new Timer(Constants.LEAP_CD);
        specialCDTimer = new Timer(Constants.WARRIOR_BOOST_CD);
        boostTimer = new Timer(Constants.WARRIOR_BOOST_TIME);
        boostTimer.Register(BoostTimerFinished);
        swordTransform = sword.transform;
        swordScript = sword.GetComponent<SwordScript>();
        swordScript.Initialize(Constants.SLASH_DAMAGE, targetTag, SlashDamageHandler);
        swordCollider = sword.GetComponent<Collider2D>();
        swordCollider.enabled = false;

        // Loads sounds
        mainAbilitySound = GameManager.Instance.GameSounds[Constants.ICE_CAST_SND];
        secondaryAbilitySound = GameManager.Instance.GameSounds[Constants.RANGER_SHOOT_SND];
        powerAbilitySound = GameManager.Instance.GameSounds[Constants.LEAP_SND];
        specialAbilitySound = GameManager.Instance.GameSounds[Constants.WARRIOR_BOOST_SND];
        if (timerBars != null)
        { boostBar = timerBars[0]; }
        base.Initialize(targetTag, energyChanged, healthBar, timerBars, healthMult);
        Energy = 0;
    }
Exemple #17
0
    // Update is called once per frame
    void Update()
    {
        //PlayerInfo info = nonPlayerObjects.GetComponent<PlayerInfo>();
        flibbityfish += Time.deltaTime;         //please keep me as flibbityfish

        //freezes the game
        if (Input.GetButton(PAUSE) == true && flibbityfish > 0.3f)
        {
            flibbityfish = 0.0f;    //i am repurposing flibbityfish because i don't want to use another variable
            pause        = !pause;
            freezePos    = transform.position;
            //info.setPause(pause);
        }

        if (pause)
        {
            transform.position = freezePos;
        }
        if (!pause)
        {
            //UPDATES ALL THE GAMETICKS TIMERS
            gameTicks  += Time.deltaTime;
            gameTicks2 += Time.deltaTime;
            thingy     += Time.deltaTime;


            //RIGHT (d)
            if (Input.GetButton(RIGHT) == true)

            {
                //Move you right at the correct speed, accounting for different lengths of frames
                transform.Translate(Vector2.right * horizSpeed * Time.deltaTime);
                player.GetComponent <PlayerRotate>().Rotate(DIR_RIGHT);
                direction = DIR_RIGHT;
            }

            //LEFT (a)
            if (Input.GetButton(LEFT) == true)
            {
                transform.Translate(Vector2.left * horizSpeed * Time.deltaTime);
                player.GetComponent <PlayerRotate>().Rotate(DIR_LEFT);
                direction = DIR_LEFT;
            }

            //SUICIDE (x)
            if (Input.GetButton(SUICIDE) == true)
            {
                kill();
            }

            //UPDATE COOLDOWN TIMERS
            //0 indicates that the sword is usable. So while the cooldown isn't reloaded, increment it upwards.
            SwordScript sword = GetComponentInChildren <SwordScript>();
            if (hasSword != 0)
            {
                hasSword += Time.deltaTime;
                if (hasSword > swordCooldown)
                {
                    hasSword    = 0;
                    sword.drawn = false;
                }
            }
            //ShotCoolDown indicates that the gun is usable. While the cooldown isn't reloaded, increment.
            if (hasShot != shotCooldown)
            {
                hasShot += Time.deltaTime;
                if (hasShot > shotCooldown)
                {
                    hasShot = shotCooldown;
                }
                //Update the gun display.
                gunBarDisplay.GetComponent <GunBarDisplay>().UpdateText();
            }

            //SWORD (Space)
            if (Input.GetButton(SWORD) == true && hasSword == 0)
            {
                //The sword increments upwards from 1 to swordCooldown, then gets set to 0. 0 is usable.
                hasSword    = 1;
                sword.drawn = true;

                //Marks the monitor as used
                didSword = true;
            }

            //REDRAW THE SWORD TO ACCOUNT FOR RECENT CHANGES
            bool drawn = sword.drawn;
            if (drawn)
            {
                sword.swordUp(direction);
            }
            else
            {
                sword.swordDown(direction);
            }

            //SHOOT (L shift)
            if (Input.GetButton(SHOOT) == true && hasShot == shotCooldown)
            {
                //The gun increments from .1 to shotCooldown, then stops. ShotCooldown is usable.
                hasShot = .1f;

                //This value will be added to the position on the Y axis so the bullet starts to the side of the player
                float toAdd = 0;

                //The amount that the bullet will be rotated on the Z axis (so it's facing the correct direction)
                float rotation = 0;

                //The direction the bullet will go in
                Vector3 force;

                if (direction == DIR_LEFT)
                {
                    toAdd    = -.5f;
                    rotation = 90;
                    force    = Vector3.left;
                }
                else //direction is right
                {
                    toAdd    = .5f;
                    rotation = -90;
                    force    = Vector3.right;
                }
                //Make the bullet face the correct direction, appear on the correct side of the player, and move in the correct direction.
                Vector3 pos       = new Vector3(transform.position.x + toAdd, transform.position.y, transform.position.z);
                var     newBullet = Instantiate(bullet, pos, Quaternion.Euler(0, 0, rotation));
                var     rbBullet  = newBullet.GetComponent <Rigidbody>();
                rbBullet.velocity = newBullet.GetComponent <BulletScript>().speed *force;

                //Marks the monitor as used
                didShoot = true;
            }

            //Tell if there is anything in a sphere shape below the player
            RaycastHit hitInfo;
            isGrounded = Physics.SphereCast(rb.position, 0.75f, Vector3.down, out hitInfo, GetComponent <Collider>().bounds.size.y / 2, groundLayers);

            //If there's something beneath you that you can jump from and you push the JUMP key (w), you jump
            if (Input.GetButtonDown(JUMP) == true && isGrounded)
            {
                rb.AddForce(Vector3.up * jumpSpeed, ForceMode.Impulse);
            }

            //FILL_CHARGES (t)
            if (Input.GetButton(FILL_CHARGES) == true && charges > 0)
            {
                charges = GetComponent <TrackMovement>().currLevelCharges();
            }

            //Apply gravity relative to the player's mass
            rb.AddForce(Vector2.down * gravity * rb.mass);

            //GET INFORMATION (i) - contains lots of debugs
            if (Input.GetButton(INFO) == true && thingy > 0.2f)
            {
                Debug.Log("isGrounded: " + isGrounded);
                Debug.Log("inv: " + inv);
                thingy = 0.0f;
            }

            //If you're invincible, toggle invincibility. (KEY: C)
            //FlibbityFish is there so that the invincibility doesn't toggle super fast when you press and hold a key.
            if (Input.GetButton(INVINCIBLE) == true && flibbityfish > 0.3f)
            {
                inv = !inv;
                gameObject.GetComponentInParent <PlayerScript>().health = 3;
                flibbityfish = 0.0f;
            }

            //If you've fallen below -25 or your health is 0, you die
            if (health <= 0 || GetComponent <Transform>().position.y <= -25f)
            {
                Debug.Log("Health: " + health);
                Debug.Log("Position" + GetComponent <Transform>().position.y);
                Debug.Log("bop bop bop to the top");
                instaKill();
            }
        }

        //press the m button
        if (Input.GetButton(MUSIC) == true && flibbityfish > 0.3f)
        {
            ValueHolder.music = !ValueHolder.music;
            flibbityfish      = 0.0f;
        }
    }
Exemple #18
0
    /// <summary>
    /// Raises the collision enter2 d event.
    /// </summary>
    /// <param name="coll">Coll.</param>
    /// Checs all the collisions and changes score of health of player when needed.
    void OnCollisionEnter2D(Collision2D coll)
    {
        string name = coll.gameObject.name;

        if (name.Contains("GemPrefab"))
        {
            this.ChangeScore(20);
            GameObject.Destroy(coll.collider.gameObject);
        }
        if (name.Contains("SpikebushPrefab"))
        {
            this.ChangeHealth(-50);
        }
        if (name.Contains("EnemyPrefab"))
        {
            this.ChangeHealth(-10);
        }
        if (name.Equals("sword"))
        {
            GameObject.Destroy(coll.collider.gameObject);
            SwordScript sword = new SwordScript();
            this.inventory.AddItemToInventory(sword);
            Debug.Log(slotOne);
            this.slotOne.SetActive(true);
        }
        if (name.Contains("CupPrefab"))
        {
            GameObject.Destroy(coll.collider.gameObject);
            this.inventory.AddItemToInventory(cup);
            this.ChangeScore(100);
            this.slotTwo.SetActive(true);
        }
        if (name.Contains("KeyPrefab"))
        {
            GameObject.Destroy(coll.collider.gameObject);
            this.inventory.AddItemToInventory(key);
            this.slotThree.SetActive(true);
            this.ChangeScore(50);
            this.hasKey = true;
        }
        if (name.Equals("book"))
        {
            GameObject.Destroy(coll.collider.gameObject);
            this.inventory.AddItemToInventory(book);
            this.slotFour.SetActive(true);
        }
        if (name.Equals("Home"))
        {
            this.needChangeLevel = true;
        }
        if (name.Contains("LockPrefab") && this.hasKey)
        {
            GameObject.Destroy(coll.collider.gameObject);
        }
        if (name.Contains("MushroomPrefab"))
        {
            this.ChangeHealth(20);
            this.ChangeScore(5);
            GameObject.Destroy(coll.collider.gameObject);
        }
        if (name.Contains("Fireball"))
        {
            this.ChangeHealth(-20);
        }
    }
    void Start()
    {
        Speed = 50;
        totalHealth = 100;
        Health = totalHealth;
        exp = 0;
        skillpoints = 0;
        level = 1;
        expToGet = 100;

        distGround = collider.bounds.extents.y;
        Screen.lockCursor = true;
        Moving = false;
        CanAttack = false;

        sword = GameObject.Find("sword");
        shield = GameObject.Find("shield");
        unit = GameObject.Find("player");
        rightF = GameObject.Find("feetR");
        leftF = GameObject.Find("feetL");

        slashHash = Animator.StringToHash("slash");
        block = Animator.StringToHash("block");

        animSW = sword.GetComponent<Animator>();
        animSH = shield.GetComponent<Animator>();
        animPL = unit.GetComponent<Animator>();
        animFL = leftF.GetComponent<Animator>();
        animFR = rightF.GetComponent<Animator>();

        CS = GetComponent<GUIScript>();
        SW = sword.GetComponent<SwordScript>();
        parti = GetComponentInChildren<ParticleSystem>();
        SRender = sword.GetComponent<MeshFilter>();
    }
Exemple #20
0
 protected override void ClassStart()
 {
     sword = GetComponentInChildren <SwordScript>(true);
     sword.gameObject.SetActive(false);
 }
Exemple #21
0
 void Start()
 {
     polyCol = GetComponent <PolygonCollider2D>();
     sword   = GetComponentInChildren <SwordScript>();
 }