public void Attack()
    {
        if (!Alive)
        {
            return;
        }
        //Please. Just release spores that home in on the player..
        //The projectiles are obnoxious.
        Attacking  = true;
        AttackTime = Time.time;
        MyAnimator.SetTrigger("Attack");
        JungleTreeProjectile p = GameObject.Instantiate(ProjectilePrefab, this.transform.position + (Vector3.down * 1f), new Quaternion());
        float sp = 4f * (1f + (2f * Astronaut.AggressionLevelF));

        p.transform.localScale = (p.transform.localScale * ((1f + (Astronaut.AggressionLevelF))));
        Astronaut plr = Astronaut.TheAstronaut;

        if ((plr != null) && (plr.Alive) && ((Time.time - plr.ReviveTime) >= 2f))
        {
            Vector3 dif = (plr.transform.position - this.transform.position);

            p.MyRigidbody.velocity = (dif.normalized * sp);
            p.DetonationTime       = (dif.magnitude / Mathf.Max(p.MyRigidbody.velocity.magnitude, 1f));
        }
        else
        {
            p.MyRigidbody.velocity = new Vector2(-1f * Mathf.Sign(this.transform.localScale.x), 0f) * sp;
        }
    }
    public void ReleaseSpores(bool releaseinconeorcircle)
    {
        //if (!Alive) return;

        SporeAttackTime = Time.time;
        AttackTime      = Time.time;

        MyAnimator.SetBool("WingUp", true);
        //Create a Cloud of Spores that slows the astronaut
        SporeExplosion.Play(true);
        int subs = (5 + (Astronaut.AggressionLevel * 3));


        for (int i = 0; i < (subs); i++)
        {
            JungleTreeProjectile proj = GameObject.Instantiate(SporePrefab, this.transform.position, this.transform.rotation).GetComponent <JungleTreeProjectile>();
            // proj.transform.localScale = (this.transform.localScale * (.3f));
            proj.DamageRatio = (1f * (1f / ((float)(subs))));
            float af  = (((float)i + (1 * (Random.value))) / ((float)(subs)));
            float ang = (releaseinconeorcircle ? 45f + (90f * af) : (360f * af));
            proj.MyConstantForce.enabled = true;
            proj.MyRigidbody.velocity    = ((new Vector2(Mathf.Cos((ang / 360f) * 2f * Mathf.PI), Mathf.Sin((ang / 360f) * 2f * Mathf.PI)) * 2.5f) * (((float)(i + 1)) / ((float)subs)) * (.5f + Random.value * 3f) * (1f + Astronaut.AggressionLevelF));


            proj.MyConstantForce.force = (Random.insideUnitCircle.normalized * JungleTreeProjectile.WINDFORCEFACTOR);
            //proj
        }
    }
Exemplo n.º 3
0
    public void OnTriggerTouch(Collider2D col)
    {
        //Detect for:
        //Astronaut
        //Bullets and Grenades
        //Spores
        Bullet b = col.gameObject.GetComponent <Bullet>();

        if ((b != null) && (b.Live))
        {
            //Debug.Log(col.gameObject.name);
            b.Interference += getForce(b.transform.position) * .5f;
            return;
        }
        Grenade g = col.gameObject.GetComponent <Grenade>();

        if ((g != null) && (g.Live))
        {
            //Debug.Log(col.gameObject.name);
            Vector3 f = getForce(g.transform.position);
            g.MyRigidbody.AddForce(new Vector2(f.x, f.y) * .25f);
            //g.Interference += getForce(b.transform.position);
            return;
        }
        JungleTreeProjectile Spore = col.gameObject.GetComponent <JungleTreeProjectile>();

        if (Spore != null)
        {
            Spore.MyRigidbody.AddForce(getForce(Spore.transform.position));
            return;
        }

        /*
         * TyphoonWindStreak ws = col.gameObject.GetComponent<TyphoonWindStreak>();
         * if (ws != null)
         * {
         *  //ws.MyRigidbody.AddForce(getForce(ws.transform.position));
         *  Vector3 f = (getForce(b.transform.position));
         *  //ws.MyRigidbody.velocity += (new Vector2(f.x, f.y)*Time.fixedDeltaTime*1f);
         *  return;
         * }
         */
        Astronaut a = col.gameObject.GetComponent <Astronaut>();

        if (a != null)
        {
            a.MyRigidbody.AddForce(getForce(a.transform.position) * .25f * (a.Airborne?1f:5f));
            return;
        }
    }
Exemplo n.º 4
0
    public void explode()
    {
        if (!Live)
        {
            return;
        }
        if (IsSpore)
        {
            Live = false;
            ParticleExplosion.Play(true);
            Remove();
        }
        else
        {
            if (IsSubdivided)
            {
                Live = false;
                ParticleExplosion.Play(true);
                Remove();
            }
            else
            {
                int subs    = (6 + (Astronaut.AggressionLevel * 2));
                int subsets = (1);

                for (int i = 0; i < (subs * subsets); i++)
                {
                    JungleTreeProjectile proj = GameObject.Instantiate(this.gameObject, this.transform.position, this.transform.rotation).GetComponent <JungleTreeProjectile>();
                    proj.transform.localScale = (this.transform.localScale * (.3f));
                    proj.DamageRatio          = (DamageRatio * (1f / ((float)(subs * subsets))));
                    float ang = (360f * (((float)i) / ((float)(subs))));
                    proj.MyRigidbody.velocity  = (new Vector2(Mathf.Cos((ang / 360f) * 2f * Mathf.PI), Mathf.Sin((ang / 360f) * 2f * Mathf.PI)) * this.MyRigidbody.velocity.magnitude * ((1 + (i / subs)) / subsets));
                    proj.IsSubdivided          = true;
                    proj.StartTime             = Time.time;
                    proj.MyConstantForce.force = (Random.insideUnitCircle.normalized * WINDFORCEFACTOR);
                    //proj
                }
                IsSubdivided = true;
                Live         = false;
                ParticleExplosion.Play(true);
                Remove();
            }
        }
    }
Exemplo n.º 5
0
    //public Vector2 MoveDirection = new Vector2();
    void FixedUpdate()
    {
        Astronaut plr             = Astronaut.TheAstronaut;
        bool      lookindirection = false;


        bool    stateexpired = (Time.time >= (StateTime + StateDuration));
        Vector2 move         = new Vector2();

        switch (MyState)
        {
        case State.Waiting: { break; }

        case State.Introducing:
        {
            //Introduced = false;
            //Rise up from the ground in a menacing fashion
            this.Vulnerable = false;
            //TrudgeTowards = 0;
            Astronaut.TheAstronaut.MyRigidbody.velocity = new Vector2(0f, Astronaut.TheAstronaut.MyRigidbody.velocity.y);         //Hold Still, please.


            if (ShadowSwooped < 1f)
            {
                float sv = Mathf.Clamp01(ShadowSwooped + (Time.fixedDeltaTime * 2f));
                if ((ShadowSwooped < .5f) && (sv >= .5f))
                {
                    //play a swoop sound
                }
                ShadowSwooped = sv;
                ShadowSwoop.transform.position = Vector3.Lerp(SwoopStartPos, SwoopEndPos, sv);
            }
            else if (!SwoopedIn)
            {
                Vector3 dif   = (IntroTargetPosition.position - this.transform.position);
                float   speed = 1f;
                float   du    = (IntroStartPosition - IntroTargetPosition.position).magnitude;
                ShadowSwoop.enabled = false;
                MyHiddenGroup.SetActive(true);
                Astronaut.TheAstronaut.WatchingLocation = IntroTargetPosition;

                float d = (speed * Time.deltaTime * 2.5f);
                if (introvalue >= 1f)
                {
                    this.transform.position = IntroTargetPosition.position;
                    SwoopedIn = true;
                    //SwoopingParticles.Stop(true);
                    Screeched = false;

                    //MySpriteRenderer.transform.localPosition = new Vector3(0.99f, .73f, 0f);
                }
                else
                {
                    introvalue = Mathf.Clamp01(introvalue + (d));

                    Vector2 c = (Random.insideUnitCircle.normalized * .1f);
                    this.transform.position = (Vector3.Lerp(IntroStartPosition, IntroTargetPosition.position, introvalue) + new Vector3(c.x, c.y, 0f));
                    //MySpriteRenderer.transform.localPosition = new Vector3(.99f+c.x,.73f+c.y,0f);
                }
            }
            else if (!Screeched)
            {
                ScreechParticles.Play();
                plr.addCamShake(1f, 1f, 1f, 2f, .5f);
                AudioManager.AM.crossfade(AudioManager.AM.CurrentMusic, 0f, .3f);
                screechsound = AudioManager.AM.playGeneralSound(this.transform.position, AudioManager.AM.JungleBossRoar, AudioManager.AM.PlayerAudioMixer, 1f, 1f, false, 30f);
                //MyAnimator.SetTrigger("Awaken");
                MyAnimator.SetTrigger("Screech");

                Screeched = true;

                ScreechTime = Time.time;
                //Pass some RRRRRRRAAAAAAAAWWWWWWWRRRRRRRR!!!! text.
            }
            else
            {
                if ((Time.time - ScreechTime) >= 1.75f)
                {
                    Introduced = true;
                    HighPosY   = (this.transform.position.y + 1f);

                    beginBossFight();
                    AudioManager.AM.crossfade(screechsound, 0f, 2f);
                    //setState(State.StandingBy,3f+Random.value*3f);
                    standBy();
                }
            }


            break;
        }

        case State.StandingBy:
        {
            //Move Towards the Player
            setSlashEffect(false);
            if (!Defeated)
            {
                this.Vulnerable = true;
                if ((plr != null) && (plr.Alive))
                {
                    Vector3 dif = (plr.transform.position - this.transform.position);

                    int dir = (int)Mathf.Sign(dif.x);

                    if (!MovingToTargetPosition)
                    {
                        TrudgeTowards = dir;
                        float mxl = Mathf.Max(BossBounds.bounds.min.x, this.transform.position.x - 10f);
                        float mxr = Mathf.Min(BossBounds.bounds.max.x, this.transform.position.x + 10f);
                        float myb = Mathf.Max(BossBounds.bounds.min.y, this.transform.position.y - 4f);
                        float myt = Mathf.Min(BossBounds.bounds.max.y, this.transform.position.y + 4f);
                        MoveTargetPosition = new Vector3(mxl + (Random.value * (mxr - mxl)), myb + (Random.value * (myt - myb)), this.transform.position.z);
                        //Debug.Log("Choose Target Position");
                        MovingToTargetPosition = true;
                    }
                    else
                    {
                        //MoveDirection = TrudgeTowards;
                        Vector2 destdif = (MoveTargetPosition - MyRigidbody.position);
                        LookDirection = (int)Mathf.Sign(destdif.x);

                        if ((destdif.magnitude < .1f))
                        {
                            MovingToTargetPosition = false;
                        }
                        else
                        {
                            if (Astronaut.AggressionLevel >= 3)
                            {
                                //Move using a non linear approach
                                move = (destdif * (1f) * Mathf.Clamp01(Time.fixedDeltaTime * 5f));      //((destdif.magnitude > sp) ? (destdif.normalized * sp) : destdif);
                            }
                            else
                            {
                                float sp = (FlySpeed * (2f + (2f * Astronaut.AggressionLevelF))) * Time.fixedDeltaTime;
                                move = ((destdif.magnitude > sp) ? (destdif.normalized * sp) : destdif);
                            }
                        }



                        //MyRigidbody.velocity = new Vector2(TrudgeTowards * FlySpeed * (1f + (2f * Astronaut.AggressionLevelF)), MyRigidbody.velocity.y);
                    }

                    Vector3 ldif = (plr.transform.position - transform.position);
                    LookDirection = (int)Mathf.Sign(ldif.x);

                    if (stateexpired)
                    {
                        //Choose an action
                        //MyRigidbody.velocity = new Vector2(0f, MyRigidbody.velocity.y);
                        float r = Random.value;
                        //standBy();

                        if (r < .25f)
                        {
                            startClawStrikeAttack();
                        }

                        else if (r < .5f)
                        {
                            startSporeShoot();
                        }
                        else if (r < .75f)
                        {
                            startTyphoon();
                        }
                        else
                        {
                            standBy();
                        }
                    }
                }
                //MyAnimator.SetBool("Flying", Mathf.Abs(MyRigidbody.velocity.x) > .1f);
            }
            else
            {
                //MyAnimator.SetBool("Flying", false);
            }


            break;
        }

        case State.ClawStriking:
        {
            if (!Defeated)
            {
                setSlashEffect(true);
                float tf  = (Time.time - clawStartTime);
                float pre = .3f;
                //ClawStrikeDirection
                float sf = (Time.fixedDeltaTime * CLAWSTRIKESPEED * ((tf - pre) / pre));

                if ((tf - pre) > 0f)
                {
                    //sf = sf;//(sf * sf);
                    RaycastHit2D rh = Physics2D.Raycast(new Vector2(ClawCollider.transform.position.x, ClawCollider.transform.position.y), new Vector2(ClawStrikeDirection.x, ClawStrikeDirection.y), sf, LayerMask.GetMask("Geometry"));
                    ClawCollider.enabled = true;
                    if (rh.collider != null)
                    {
                        move = new Vector2(rh.point.x - ClawCollider.transform.position.x, rh.point.y - ClawCollider.transform.position.y);
                        if (ClawImpact)
                        {
                            ClawImpact.transform.position = new Vector3(rh.point.x, rh.point.y, 0f);
                            ClawImpact.Emit(50);
                        }
                        MyAnimator.SetTrigger("SwoopImpact");
                        MyAnimator.SetBool("Swooping", false);
                        clawStartTime        = Time.time;
                        ClawCollider.enabled = false;
                        setState(State.Recoiling, 1.5f);
                    }
                    else
                    {
                        move = (new Vector2(ClawStrikeDirection.x, ClawStrikeDirection.y) * sf);
                    }
                }
                else
                {
                    ClawCollider.enabled = false;
                    move = (new Vector2(ClawStrikeDirection.x, ClawStrikeDirection.y) * sf);
                }



                if (stateexpired)
                {
                    //Choose an action


                    standBy();
                }
            }

            break;
        }

        case State.Recoiling:
        {
            if (!Defeated)
            {
                setSlashEffect(false);
                float tf = (Time.time - clawStartTime);

                //ClawStrikeDirection
                float sf = (Time.fixedDeltaTime * CLAWSTRIKESPEED * .25f * Mathf.Clamp01(1f - (tf / StateDuration)));
                move = (new Vector2(ClawStrikeDirection.x, ClawStrikeDirection.y) * -sf);


                if (stateexpired)
                {
                    //Choose an action


                    standBy();
                }
            }
            break;
        }

        case State.SporeShooting:
        {
            if (!Defeated)
            {
                setSlashEffect(false);
                //Choose an action

                if (((Time.time - StateTime) >= .5f) && (!FiredSporeAttack))
                {
                    Vector3 dif = (plr.transform.position - MouthTransform.position);
                    FiredSporeAttack = true;
                    if (Random.value < .6f)
                    {
                        //Shoot Spore projectile
                        JungleTreeProjectile p = GameObject.Instantiate(JungleProjectile, MouthTransform.position, new Quaternion());
                        float sp = 4f * (1f + (2f * Astronaut.AggressionLevelF));
                        p.transform.localScale = (p.transform.localScale * ((1f + (Astronaut.AggressionLevelF))));



                        p.MyRigidbody.velocity = (dif.normalized * sp);
                        p.DetonationTime       = (dif.magnitude / Mathf.Max(p.MyRigidbody.velocity.magnitude, 1f));


                        p.MyRigidbody.velocity = new Vector2(-1f * Mathf.Sign(this.transform.localScale.x), 0f) * sp;
                    }
                    else
                    {
                        //Release Spores
                        //Create a Cloud of Spores that slows the astronaut
                        SporeExplosion.Play(true);
                        int subs = (8 + (Astronaut.AggressionLevel * 3));


                        for (int i = 0; i < (subs); i++)
                        {
                            JungleTreeProjectile proj = GameObject.Instantiate(SporePrefab, this.transform.position, this.transform.rotation).GetComponent <JungleTreeProjectile>();
                            // proj.transform.localScale = (this.transform.localScale * (.3f));
                            proj.DamageRatio = (.25f * (1f / ((float)(subs))));
                            float af  = (((float)i + (1 * (Random.value))) / ((float)(subs)));
                            float ang = (360f * af);        //((Random.value<(2f/3f)) ? 45f + (90f * af) : (360f * af));
                            proj.MyConstantForce.enabled = true;
                            proj.transform.localScale    = (proj.transform.localScale * 5f);
                            proj.MyRigidbody.velocity    = (new Vector2(dif.x, dif.y) * 2f) + ((new Vector2(Mathf.Cos((ang / 360f) * 2f * Mathf.PI), Mathf.Sin((ang / 360f) * 2f * Mathf.PI)) * 2.5f) * (((float)(i + 1)) / ((float)subs)) * (.5f + Random.value * 5f) * (1f + Astronaut.AggressionLevelF));


                            proj.MyConstantForce.force = (Random.insideUnitCircle.normalized * JungleTreeProjectile.WINDFORCEFACTOR);
                            //proj
                        }
                    }
                }
                if (stateexpired)
                {
                    standBy();
                }
            }

            break;
        }

        case State.TyphoonStarting:
        {
            if (!Defeated)
            {
                //setSlashEffect(false);
                //float tf = (Time.time - clawStartTime);

                //ClawStrikeDirection
                //float sf = (Time.fixedDeltaTime * CLAWSTRIKESPEED * .25f * Mathf.Clamp01(1f - (tf / StateDuration)));
                //move = (new Vector2(ClawStrikeDirection.x, ClawStrikeDirection.y) * -sf);

                if (((Time.time - StateTime) >= .5f) && (!TyphoonInitiated))
                {
                    Vector3 dif = (plr.transform.position - this.transform.position);
                    TyphoonInitiated = true;
                    TyphoonGlow.Play(true);
                    Vector2 r = Random.insideUnitCircle;
                    Vector3 v = Vector3.Lerp(new Vector3(r.x, r.y, 0f), dif.normalized, Astronaut.AggressionLevelF);
                    MyTyphoonField.startTyphoon(v * (5f * (1f + (4f * Astronaut.AggressionLevelF))) + new Vector3(0f, 10f), 3f + (3f * Astronaut.AggressionLevelF));
                }


                if (stateexpired)
                {
                    //Choose an action


                    standBy();
                }
            }

            break;
        }

        case State.Defeated:
        {
            float f = (Time.time - StateTime);
            //MyIceBreath.BreathActive = false;
            //RainingIceShards = false;
            MyTyphoonField.TyphoonWindsActive = false;
            //MyAnimator.SetBool("Glowing", false);
            //MyAnimator.SetBool("IceBreathing", false);
            MyCollider.enabled            = false;
            MyWeakSpot.MyCollider.enabled = false;
            MyRigidbody.bodyType          = RigidbodyType2D.Kinematic;
            MyRigidbody.velocity          = new Vector2(0f, 0f);
            if (f < 3f)
            {
                setSlashEffect(false);

                /*
                 * MySpriteRenderer.enabled = true;
                 * MySpriteRenderer.color = new Color(MySpriteRenderer.color.r, MySpriteRenderer.color.g, MySpriteRenderer.color.b, 1f - (f / 3f));
                 * MySpriteRenderer.transform.Rotate(0f, 0f, Time.fixedDeltaTime * 360f * 4f);
                 */
                MyDroppedGoalElement.Collectable = false;
            }
            else
            {
                if (!PlayerHasBeenReleased)
                {
                    plr.PlayerHasControl = false;
                    MyDroppedGoalElement.HomingInOnAstronaut = true;
                    MyDroppedGoalElement.HomingTime          = Time.time;
                    MyDroppedGoalElement.Collectable         = true;
                    Astronaut.TheAstronaut.WatchingLocation  = null;
                    PlayerHasBeenReleased = true;
                }
                MySpriteRenderer.enabled = false;
            }


            break;
        }
        }
        if (!Defeated)
        {
            if (move.magnitude > 0f)
            {
                MyRigidbody.MovePosition(MyRigidbody.position + move);
            }
        }

        if (LookDirection != 0)
        {
            if (ForwardFacing != 0)
            {
                ForwardFacing = LookDirection;
            }
        }
        else
        {
            if (MoveDirection.magnitude > 0)
            {
                ForwardFacing = (int)Mathf.Sign(MoveDirection.x);
            }
        }

        if (LookDirection != 0)
        {
            this.transform.localScale = new Vector3(-1 * LookDirection * Mathf.Abs(this.transform.localScale.x), this.transform.localScale.y, this.transform.localScale.z);
        }
    }
Exemplo n.º 6
0
    void FixedUpdate()
    {
        if (TyphoonWindsActive)
        {
            if ((Time.time - WindStartTime) >= WindDuration)
            {
                TyphoonWindsActive = false;
            }
        }
        if (TyphoonWindsActive)
        {
            MyCollider.enabled = true;
            if ((Time.time - lastWindLineSpawnTime) >= .05f)
            {
                Vector3           wdir = new Vector3(WindForce.x, WindForce.y, 0f).normalized;
                Vector3           crs  = Vector3.Cross(wdir, Vector3.forward);
                Vector3           spos = (Astronaut.TheAstronaut.transform.position) + ((wdir * -10f) + (crs * 7.5f * ((Random.value * 2f) - 1f)));
                TyphoonWindStreak ws   = GameObject.Instantiate <TyphoonWindStreak>(WindStreakPrefab, spos, new Quaternion());
                ws.MyRigidbody.velocity = (WindForce + (new Vector2(crs.x, crs.y) * WindForce.magnitude * .25f * ((Random.value * 2f) - 1f)));
                ws.MyTyphoonField       = this;
                lastWindLineSpawnTime   = Time.time;
            }
            if (CanSpawnProjectiles)
            {
                if (Astronaut.AggressionLevel > 1)
                {
                    if ((Time.time - lastProjectileSpawnTime) >= (1.5f * (.25f + (.75f * (1f - Astronaut.AggressionLevelF)))))
                    {
                        Vector3 wdir = new Vector3(WindForce.x, WindForce.y, 0f).normalized;
                        Vector3 crs  = Vector3.Cross(wdir, Vector3.forward);
                        Vector3 spos = (Astronaut.TheAstronaut.transform.position) + ((wdir * -10f) + (crs * 7.5f * ((Random.value * 2f) - 1f)));
                        //TyphoonWindStreak ws = GameObject.Instantiate<TyphoonWindStreak>(WindStreakPrefab, spos, new Quaternion());
                        JungleTreeProjectile jp = GameObject.Instantiate <JungleTreeProjectile>(ProjectilePrefab, spos, new Quaternion());
                        jp.MyRigidbody.velocity = ((WindForce * (.1f + (.5f * Astronaut.AggressionLevelF))) + (new Vector2(crs.x, crs.y) * WindForce.magnitude * .25f * ((Random.value * 2f) - 1f)));
                        jp.SporeFactor          = 0f;
                        lastProjectileSpawnTime = Time.time;
                    }
                }
            }
        }
        else
        {
            MyCollider.enabled = false;
            //...
        }

        if (TyphoonWindsActive != windrunning)
        {
            if (TyphoonWindsActive)
            {
                Debug.Log("Initiating Typhoon Sound");
                //start the sound up
                float wf = 2f;// (WindForce.magnitude / 20f);
                if (!TyphoonSound.isPlaying)
                {
                    TyphoonSound.Play();
                }
                AudioManager.AM.crossfade(TyphoonSound, .6f + (.4f * wf), 1f);
                AudioManager.AM.crosstune(TyphoonSound, .4f + (.6f * wf), 1f);
            }
            else
            {
                Debug.Log("Fading Typhoon Sound");//Lerp the audio using a coroutine
                AudioManager.AM.crossfade(TyphoonSound, 0f, 2f);
                AudioManager.AM.crosstune(TyphoonSound, TyphoonSound.pitch * .8f, 1f);
            }
            windrunning = TyphoonWindsActive;
        }
    }