示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (laserState == LaserStates.TRAVEL && Input.GetButtonDown("Fire1"))
        {
            timeSinceReturn = 0f;
            laserState      = LaserStates.RETURNED;
            enableLaser(false);
        }
        if (laserState == LaserStates.RETURNED && timeSinceReturn > breakAwayDelay && new Vector3(inputs.GetAxis("RightHorizontal"), 0, inputs.GetAxis("RightVertical")).normalized.magnitude > breakAway)
        {
            laserState = LaserStates.TRAVEL;
            enableLaser(true);
        }
        switch (laserState)
        {
        case LaserStates.TRAVEL:
            Move();
            break;

        case LaserStates.RETURNED:
            Orbit();
            break;

        default:
            print("error - invalid input");
            break;
        }
        timeSinceReturn += Time.deltaTime;
    }
示例#2
0
 public void Kill()
 {
     base.enabled = true;
     if (this.state != LaserStates.FADE_OUT)
     {
         this.stateTime = 0f;
     }
     this.state = LaserStates.DEAD;
 }
 private void Lauched()
 {
     if (timer > timeToStop)
     {
         rigidbody2D.isKinematic = true;
         timer            = 0;
         transform.parent = Camera.main.transform;
         laserState       = LaserStates.firing;
     }
 }
 private void Lauched()
 {
     if (timer > timeToStop)
     {
         rigidbody2D.isKinematic = true;
         timer = 0;
         transform.parent = Camera.main.transform;
         laserState = LaserStates.firing;
     }
 }
示例#5
0
 public void Show()
 {
     this.stateTime             = 0f;
     this.initialAlpha          = this.currentAlpha;
     this.state                 = LaserStates.FADE_IN;
     this.spot.enabled          = true;
     this.beginLines[0].enabled = true;
     this.beginLines[1].enabled = true;
     this.baseLines[0].enabled  = true;
     this.baseLines[1].enabled  = true;
     base.enabled               = true;
 }
示例#6
0
 private void FadeIn()
 {
     if (this.stateTime >= this.fadeInTimeSec)
     {
         this.state = LaserStates.DEFAULT;
         this.UpdateAlphaForAllParts(1f);
     }
     else
     {
         this.stateTime += Time.deltaTime;
         this.UpdateAlphaForAllParts(Mathf.Lerp(this.initialAlpha, 1f, this.stateTime / this.fadeInTimeSec));
     }
 }
示例#7
0
 public void Init()
 {
     this.spot       = base.GetComponentsInChildren <Sprite3D>(true)[0];
     this.beginLines = new List <LineRenderer>();
     this.baseLines  = new List <LineRenderer>();
     this.InitializeLineRendererList <ShaftLaserBeginUnityComponent>(this.beginLines);
     this.InitializeLineRendererList <ShaftLaserBaseUnityComponent>(this.baseLines);
     this.baseLaserTex = (Texture2D)this.baseLines[0].material.mainTexture;
     this.segment      = ((this.texScale * this.laserWidth) * this.baseLaserTex.height) / ((float)this.baseLaserTex.width);
     this.angle1       = 0f;
     this.angle2       = 0f;
     this.initialAlpha = 0f;
     this.currentAlpha = 0f;
     this.stateTime    = 0f;
     this.UpdateAlphaForAllParts(this.initialAlpha);
     this.state = LaserStates.DEFAULT;
 }
    private void Firing()
    {
        if (timer > timeToGo)
        {
            rigidbody2D.isKinematic = false;
            timer            = 0;
            transform.parent = null;
            laserState       = LaserStates.going;
        }

        if (timer / timeBetweenFire > 1)
        {
            timeBetweenFire += 2;
            PoolManager.Pools["props"].Spawn(ray.transform, transform.position, transform.rotation);
            timer = 0;
        }

        transform.Rotate(new Vector3(0, 0, 1));
    }
    private void Firing()
    {
        if (timer > timeToGo)
        {
            rigidbody2D.isKinematic = false;
            timer = 0;
            transform.parent = null;
            laserState = LaserStates.going;
        }

        if (timer/timeBetweenFire > 1)
        {
            timeBetweenFire+=2;
            PoolManager.Pools["props"].Spawn(ray.transform, transform.position, transform.rotation);
            timer = 0;
        }

        transform.Rotate(new Vector3(0,0,1));
    }
示例#10
0
 private void FadeOut(bool killAfterFade)
 {
     if (this.stateTime < this.fadeOutTimeSec)
     {
         this.stateTime += Time.deltaTime;
         this.UpdateAlphaForAllParts(Mathf.Lerp(this.initialAlpha, 0f, this.stateTime / this.fadeOutTimeSec));
     }
     else if (killAfterFade)
     {
         Destroy(base.gameObject);
     }
     else
     {
         this.state = LaserStates.DEFAULT;
         this.UpdateAlphaForAllParts(0f);
         this.spot.enabled          = false;
         this.beginLines[0].enabled = false;
         this.beginLines[1].enabled = false;
         this.baseLines[0].enabled  = false;
         this.baseLines[1].enabled  = false;
         base.enabled = false;
     }
 }
示例#11
0
        private void Update()
        {
            this.angle1 += this.speed1 * Time.deltaTime;
            this.angle2 += this.speed2 * Time.deltaTime;
            Vector2 vector  = new Vector2(-((Mathf.Sin(this.angle1) * this.delta) / this.segment), 0f);
            Vector2 vector2 = new Vector2(-((Mathf.Sin(this.angle2) * this.delta) / this.segment), 0f);

            this.baseLines[0].material.mainTextureOffset = vector;
            this.baseLines[1].material.mainTextureOffset = vector2;
            LaserStates state = this.state;

            if (state == LaserStates.FADE_IN)
            {
                this.FadeIn();
            }
            else if (state == LaserStates.FADE_OUT)
            {
                this.FadeOut(false);
            }
            else if (state == LaserStates.DEAD)
            {
                this.FadeOut(true);
            }
        }
示例#12
0
 public void Hide()
 {
     this.stateTime    = 0f;
     this.initialAlpha = this.currentAlpha;
     this.state        = LaserStates.FADE_OUT;
 }