<commit_before>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Laser : MonoBehaviour {

    public float moveSpeed;

    GameObjectPool laserPool, meleeEnemyPool, rangedEnemyPool;
    Rigidbody2D physics;

    void Awake() {
        laserPool = GameObject.FindWithTag("Laserpool").GetComponent<GameObjectPool>();
        meleeEnemyPool = GameObject.FindWithTag("MEnemyPool").GetComponent<GameObjectPool>();
        rangedEnemyPool = GameObject.FindWithTag("REnemyPool").GetComponent<GameObjectPool>();
        physics = GetComponent<Rigidbody2D>();
    }

    // Use this for initialization
    void Start () {
        laserPool = GameObject.FindWithTag("Laserpool").GetComponent<GameObjectPool>();
        meleeEnemyPool = GameObject.FindWithTag("MEnemyPool").GetComponent<GameObjectPool>();
        rangedEnemyPool = GameObject.FindWithTag("REnemyPool").GetComponent<GameObjectPool>();
        physics = GetComponent<Rigidbody2D>();
    }
    
    // Update is called once per frame
    void Update () {
        //Much better way of calculating movement
        Transform temp = transform;
        temp.Translate(new Vector3(0f,1f,0f)*moveSpeed/Variables.speedDampener);
        physics.MovePosition(temp.position);
    }

    void OnCollisionEnter2D(Collision2D collision) {
        string tag = collision.gameObject.tag;
        //Check if colliding object is laser, if so, each laser 
        //calls this method and adds themselves to the pool
        if (laserPool == null) {
            laserPool = GameObject.FindWithTag("Laserpool").GetComponent<GameObjectPool>();
        }

        if (collision.gameObject.CompareTag("LaserShot")) {
            //laserPool.AddGameObject(this.gameObject);
            //For any other object that isn't a wall, 
            //we destroy the object since everything in this game 
            //is 1 a hit kill
        } else if (collision.gameObject.CompareTag("Wall")) {
            laserPool.AddGameObject(gameObject);
        } else if (collision.gameObject.CompareTag("REnemy")) {
            rangedEnemyPool.AddGameObject(collision.gameObject);
            Variables.score += 10;
            laserPool.AddGameObject(gameObject);
        } else if (collision.gameObject.CompareTag("MEnemy")) {
            meleeEnemyPool.AddGameObject(collision.gameObject);
            Variables.score += 10;
            laserPool.AddGameObject(gameObject);
        } else if (collision.gameObject.CompareTag("Player")) {
            collision.gameObject.SetActive(false);
            laserPool.AddGameObject(gameObject);
        }
    }
}
<commit_msg>Laser movement is now updated regardless of Framerate<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Laser : MonoBehaviour {

    public float moveSpeed;
    public bool isFriendly;

    GameObjectPool laserPool, meleeEnemyPool, rangedEnemyPool;
    Rigidbody2D physics;

    void Awake() {
        laserPool = GameObject.FindWithTag("Laserpool").GetComponent<GameObjectPool>();
        meleeEnemyPool = GameObject.FindWithTag("MEnemyPool").GetComponent<GameObjectPool>();
        rangedEnemyPool = GameObject.FindWithTag("REnemyPool").GetComponent<GameObjectPool>();
        physics = GetComponent<Rigidbody2D>();
    }

    // Use this for initialization
    void Start () {
        laserPool = GameObject.FindWithTag("Laserpool").GetComponent<GameObjectPool>();
        meleeEnemyPool = GameObject.FindWithTag("MEnemyPool").GetComponent<GameObjectPool>();
        rangedEnemyPool = GameObject.FindWithTag("REnemyPool").GetComponent<GameObjectPool>();
        physics = GetComponent<Rigidbody2D>();
    }
    
    // Update is called once per frame
    void Update () {
        
    }

    void FixedUpdate() {
        //Much better way of calculating movement
        Transform temp = transform;
        temp.Translate(new Vector3(0f, 1f, 0f) * moveSpeed / Variables.speedDampener);
        physics.MovePosition(temp.position);
    }

    void OnCollisionEnter2D(Collision2D collision) {
        string tag = collision.gameObject.tag;
        //Check if colliding object is laser, if so, each laser 
        //calls this method and adds themselves to the pool
        if (laserPool == null) {
            laserPool = GameObject.FindWithTag("Laserpool").GetComponent<GameObjectPool>();
        }

        if (collision.gameObject.CompareTag("LaserShot")) {
            //laserPool.AddGameObject(this.gameObject);
            //For any other object that isn't a wall, 
            //we destroy the object since everything in this game 
            //is 1 a hit kill
        } else if (collision.gameObject.CompareTag("Wall")) {
            laserPool.AddGameObject(gameObject);
        } else if (collision.gameObject.CompareTag("REnemy") && isFriendly) {
            rangedEnemyPool.AddGameObject(collision.gameObject);
            Variables.score += 10;
            laserPool.AddGameObject(gameObject);
        } else if (collision.gameObject.CompareTag("MEnemy") && isFriendly) {
            meleeEnemyPool.AddGameObject(collision.gameObject);
            Variables.score += 10;
            laserPool.AddGameObject(gameObject);
        } else if (collision.gameObject.CompareTag("Player") && !isFriendly) {
            collision.gameObject.SetActive(false);
            laserPool.AddGameObject(gameObject);
        }
    }
}

{'fraction_non_alphanumeric': 0.10335917312661498, 'fraction_numerical': 0.00516795865633075, 'mean_word_length': 2.918293564714389, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '624693', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1505, 'n_words': 301}