Exemple #1
0
    public void fireLaser()
    {
        GameObject laserClone;
        //we need to spawn the laser slightly below the centre of the player model
        //otherwise the laser appears to come out of the alien's belly button
        Vector3 tempPos = transform.position;

        if (getLaserType().Equals(LaserType.Man))
        {
            tempPos.y += 2.5f;
        }
        else
        {
            tempPos.y -= 2.5f;
        }
        //spawn the laser
        laserClone = Instantiate(laserPrefab, tempPos, transform.rotation) as GameObject;

        laserType = laserClone.GetComponent("TypeOfLaser") as TypeOfLaser;
        ls        = laserClone.GetComponent("LaserMovement") as LaserMovement;

        laserType.setTypeOfLaser(getLaserType());
        ls.setLaserType(laserType.getTypeOfLaser());
        try{
            //play laser fire sound
            audioS.PlayOneShot(fireFX, 0.3F);
        }catch (NullReferenceException e) {
            //catches a null exception
            Debug.Log("This would have errored");
        }
        ls.startMoving();
    }
        private void FindGameObjects()
        {
            var parent = GameObject.Find(ParentName);

            laser = parent.GetComponentInChildren <LaserMovement>(true);
            enemy = parent.GetComponentInChildren <EnemyAgent>();
        }
Exemple #3
0
    private void Start()
    {
        laser.GetComponent <LaserMovement>().player = player;
        laser.GetComponent <LaserMovement>().cam    = cam;
        rigidBody = GetComponent <Rigidbody2D>();

        rigidBody.MovePosition(new Vector2(UnityEngine.Random.Range(-14, 14), 12));

        playerShield  = player.GetComponentInChildren <Shield>();
        laserMovement = laser.GetComponent <LaserMovement>();
    }
        public override Laser GetLaser()
        {
            IMovement movement;

            movement = new LaserMovement(20);

            return(new KillingLaser
            {
                Movement = movement
            });
        }
    void Start()
    {
        laserLine = GetComponentInChildren <LineRenderer>();
        laserLine.useWorldSpace = true;

        particleSystem = GetComponentInChildren <ParticleSystem>();
        laserLine.SetWidth(.2f, .2f);

        laserMovement = GetComponent <LaserMovement>();

        if (isOffOnStart)
        {
            ToggleLaser();
        }
    }
Exemple #6
0
    //TODO add some sort of jumping - seperate script? (also make it so that it can be turned off for enemies that shouldn't jump)

    private void OnTriggerEnter2D(Collider2D otherCollider)
    {
        if (otherCollider.gameObject.layer == 11) //layer 11 is the projectile layer
        {
            LaserMovement laser = otherCollider.gameObject.GetComponent <LaserMovement>();

            if (laser.player.name.Equals("Player2"))
            {
                interactingPlayer = 2;
            }
            else
            {
                interactingPlayer = 1;
            }

            if (laser != null)
            {
                Damage(laser.Damage);
                Destroy(laser.gameObject);
            }
        }
    }
Exemple #7
0
        public Laser(Vector2 initialPosition, Vector2 targetPosition,
            InflictDamage inflictDamageDelegate, LaserType laserType = LaserType.Interceptor)
            : base(initialPosition, Allegiance.Neutral)
        {
            mLifeTime = int.MaxValue;
              Position = initialPosition;
              mStartPosition = initialPosition;
              mTargetPosition = targetPosition;
              mLaserType = laserType;
              mInflictDamageDelegate = inflictDamageDelegate;

              // DeathStar-Laser-Zeug
              if (laserType == LaserType.DeathStarBeam)
              {
            mLifeTime = 3;
               /* Vector2 normalizedDirVector = targetPosition - initialPosition;
            normalizedDirVector.Normalize();

            Position = initialPosition + normalizedDirVector * Global.DeathStarCollisionRadius;
            mLength = (int)(Position - (targetPosition - normalizedDirVector * Global.mPlanetRadius[PlanetSize.Medium])).Length(); */
              }

              mLaserMovement = new LaserMovement(this, targetPosition, MovementSpeed);
        }