Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        sprite = GetComponent <SpriteRenderer>();
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlatformerCharacter2D>();

        if (player != null)
        {
            controls = player.controls;
        }
        else
        {
            ZeroGPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent <BeamScript>();
            controls    = ZeroGPlayer.controls;
        }

        if (startOpaque)
        {
            sprite.color = Color.black;
            FadeOut(startingOpaqueToTransparentLag);
        }
        else
        {
            sprite.color = Color.clear;
        }
    }
Exemplo n.º 2
0
    private void SecondaryWeaponControl()
    {
        if (secondaryTarget != null)
        {
            for (int i = 0; i < secondaryParam.ShootingPoint.Length; i++)
            {
                if (secondaryParam.weaponType == WeaponType.Laser)
                {
                    GameObject muzzle = Instantiate(secondaryParam.weaponObject, secondaryParam.ShootingPoint[i].transform.position, Quaternion.identity) as GameObject;
                    BeamScript script = muzzle.GetComponent <BeamScript>();
                    muzzle.transform.parent = this.transform;
                    script.Target           = secondaryTarget;
                    script.From             = secondaryParam.ShootingPoint[i];
                    script.lifeTime         = secondaryParam.lifeTime;
                    script.damage           = secondaryParam.damage[secondaryParam.level - 1] + additional_secondaryDamage;
                }
                else if (secondaryParam.weaponType == WeaponType.Missile)
                {
                    GameObject    lunch  = Instantiate(secondaryParam.weaponObject, secondaryParam.ShootingPoint[i].transform.position, Quaternion.identity) as GameObject;
                    MissileScript script = lunch.GetComponent <MissileScript>();
                    script.Target     = secondaryTarget;
                    script.velocity   = secondaryParam.missile_velocity;
                    script.alignSpeed = secondaryParam.missile_alignSpeed;
                    script.damage     = secondaryParam.damage[secondaryParam.level - 1] + additional_secondaryDamage;
                    script.lifeTime   = secondaryParam.missile_lifeTime;
                }
            }

            secondaryTarget   = null;
            secondaryInterval = secondaryParam.shootingInterval[secondaryParam.level - 1] - additional_secondaryRate;
        }
    }
Exemplo n.º 3
0
    //Launches held object directly where the player is aiming.
    public static void Throw_Basic(BeamScript playerBeam)
    {
        if (playerBeam.CurrentObjectHeld != null)
        {
            modifiedThrowVelocity = BASE_THROW_VELOCITY * (playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().mass * 0.75f);

            playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().AddForce(playerBeam.CurrentObjectHeld.transform.right * modifiedThrowVelocity);

            playerBeam.CurrentObjectHeld.GetComponent<BoxCollider2D>().enabled = true;

            playerBeam.CurrentObjectHeld.transform.parent = null;
            playerBeam.ReleaseObject();
        }
    }
Exemplo n.º 4
0
    //Increases object's size and mass at a cost of reduced throw distance.
    public static void Throw_Enlarge(BeamScript playerBeam)
    {
        if (playerBeam.CurrentObjectHeld != null)
        {
            //Increase the object's mass and size.
            //playerBeam.CurrentObjectHeld.transform.localScale *= 2;
            playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().mass *= 2;

            modifiedThrowVelocity = BASE_THROW_VELOCITY * (playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().mass * 0.75f);

            playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().AddForce(playerBeam.CurrentObjectHeld.transform.right * modifiedThrowVelocity);

            playerBeam.CurrentObjectHeld.GetComponent<BoxCollider2D>().enabled = true;

            playerBeam.CurrentObjectHeld.transform.parent = null;
            playerBeam.ReleaseObject(2);
        }
    }
Exemplo n.º 5
0
    //Launches object along a boomerang trajectory.
    public static void Throw_Boomerang(BeamScript playerBeam)
    {
        if (playerBeam.CurrentObjectHeld != null)
        {
            modifiedThrowVelocity = BASE_THROW_VELOCITY * (playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().mass * 0.75f);

            playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().AddForce(playerBeam.CurrentObjectHeld.transform.right * modifiedThrowVelocity / 2);

            //Create the boomerang effect by rotating around a point.
            playerBeam.CurrentObjectHeld.AddComponent<ProjectileAttributeScript>();
            playerBeam.CurrentObjectHeld.GetComponent<ProjectileAttributeScript>().CurrentProjectileType = ProjectileAttributeScript.ProjectileType.Boomerang;
            playerBeam.CurrentObjectHeld.GetComponent<ProjectileAttributeScript>().TargetPoint = playerBeam.transform.position;

            playerBeam.CurrentObjectHeld.GetComponent<BoxCollider2D>().enabled = true;

            playerBeam.CurrentObjectHeld.transform.parent = null;
            playerBeam.ReleaseObject();
        }
    }
Exemplo n.º 6
0
    //Homes in on the opposing player with a slight offset for balancing.
    public static void Throw_Homing(BeamScript playerBeam)
    {
        if (playerBeam.CurrentObjectHeld != null)
        {
            modifiedThrowVelocity = BASE_THROW_VELOCITY * (playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().mass * 0.75f);

            playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().AddForce(playerBeam.CurrentObjectHeld.transform.right * modifiedThrowVelocity / 2);

            //Get the opponent's location and home in on them with an offset.
            GameObject[] playerArray = GameObject.FindGameObjectsWithTag("Player");
            List<GameObject> potentialTargetList = new List<GameObject>();

            int ownerNumber = playerBeam.transform.parent.parent.GetComponent<PlayerScript>().PlayerNumber;

            for(int i = 0; i < playerArray.Length; i++)
            {
                if(playerArray[i].GetComponent<PlayerScript>().PlayerNumber != ownerNumber)
                {
                    potentialTargetList.Add(playerArray[i]);
                }
            }

            //Randomize a target from the list of available targets.
            int randPlayer = Random.Range(0, potentialTargetList.Count);
            //opponentLocation = potentialTargetList[randPlayer].transform.position;

            playerBeam.CurrentObjectHeld.AddComponent<ProjectileAttributeScript>();
            playerBeam.CurrentObjectHeld.GetComponent<ProjectileAttributeScript>().CurrentProjectileType = ProjectileAttributeScript.ProjectileType.Homing;
            //playerBeam.CurrentObjectHeld.GetComponent<ProjectileAttributeScript>().TargetPoint = opponentLocation;
            playerBeam.CurrentObjectHeld.GetComponent<ProjectileAttributeScript>().TargetPlayer = potentialTargetList[randPlayer];

            playerBeam.CurrentObjectHeld.GetComponent<BoxCollider2D>().enabled = true;

            playerBeam.CurrentObjectHeld.transform.parent = null;
            playerBeam.ReleaseObject();
        }
    }
Exemplo n.º 7
0
    public void Awake()
    {
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlatformerCharacter2D>();

        if (player != null)
        {
            controls = player.controls;
        }
        else
        {
            BeamScript ZeroGPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent <BeamScript>();
            controls = ZeroGPlayer.controls;
        }


        if (gameObject.name == "VolumeSlider")
        {
            gameObject.GetComponent <Slider>().value = AudioListener.volume * 100;
        }
        else if (gameObject.name == "QualitySlider")
        {
            gameObject.GetComponent <Slider>().value = QualitySettings.GetQualityLevel();
        }
    }
Exemplo n.º 8
0
    //Creates 2 additional copies of held object and launches them in a spread where the player is aiming.
    public static void Throw_Spread(BeamScript playerBeam)
    {
        if (playerBeam.CurrentObjectHeld != null)
        {
            GameObject[] clonedObjs = new GameObject[2];
            float angleModifier = 1;
            float spreadAngle = 30;

            for(int i = 0; i < clonedObjs.Length; i++)
            {
                clonedObjs[i] = GameObject.Instantiate(playerBeam.CurrentObjectHeld,
                                                       playerBeam.CurrentObjectHeld.transform.position,
                                                       playerBeam.CurrentObjectHeld.transform.rotation) as GameObject;

                //Rotate the cloned object to create the spread trajectory.
                if(i == 0)
                    angleModifier = -1;
                else
                    angleModifier = 1;

                float newAngle = clonedObjs[i].transform.rotation.eulerAngles.z + (spreadAngle * angleModifier);
                Quaternion newRotation = Quaternion.AngleAxis (newAngle, Vector3.forward);
                clonedObjs[i].transform.rotation = newRotation;

                clonedObjs[i].transform.localScale = new Vector2(1, 1);

                //Launch the object
                modifiedThrowVelocity = BASE_THROW_VELOCITY * (playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().mass * 0.75f);

                clonedObjs[i].GetComponent<Rigidbody2D>().AddForce(clonedObjs[i].transform.right * modifiedThrowVelocity);

                clonedObjs[i].GetComponent<BoxCollider2D>().enabled = true;
            }

            //Launch the initial object
            playerBeam.CurrentObjectHeld.GetComponent<Rigidbody2D>().AddForce(playerBeam.CurrentObjectHeld.transform.right * modifiedThrowVelocity);

            playerBeam.CurrentObjectHeld.GetComponent<BoxCollider2D>().enabled = true;

            playerBeam.CurrentObjectHeld.transform.parent = null;

            playerBeam.ReleaseObject();
        }
    }