private void DecideAndMove()
    {
        int attackIndex = 0;

        //start performing double attack when low on health
        if (bossChar.health < (bossChar.maxHealth / 2))
        {
            attackIndex = Random.Range(0, bossChar.characterAttacks.Count);
        }
        else
        {
            attackIndex = Random.Range(0, bossChar.characterAttacks.Count - 1);
        }

        int[] damages = bossChar.PerformAttack(attackIndex);
        bossFight.currentAttackDamage = Random.Range(damages[0], damages[1] + 1);

        Vector3 attackPlayerPosition = new Vector3(bossChar.transform.localPosition.x, bossChar.transform.localPosition.y, -0.2f);

        //special cases
        switch (attackIndex)
        {
        case 0:
            //normal attack	 1
            //move
            Go.to(bossChar.transform, 0.4f, new GoTweenConfig()
                  .localPosition(attackPlayerPosition)
                  .setEaseType(GoEaseType.Linear)
                  .setIterations(2, GoLoopType.PingPong)
                  .onIterationEnd(tween => {
                if (tween.completedIterations < 2)
                {
                    bossFight.DamagePlayer(null);
                }
            }
                                  )
                  .onComplete(bossFight.ChangeTurn));
            break;

        case 1:
            //normal attack	 2
            //move
            Go.to(bossChar.transform, 0.6f, new GoTweenConfig()
                  .localPosition(attackPlayerPosition)
                  .setEaseType(GoEaseType.Linear)
                  .setIterations(2, GoLoopType.PingPong)
                  .onIterationEnd(tween => {
                if (tween.completedIterations < 2)
                {
                    bossFight.DamagePlayer(null);
                }
            }
                                  )
                  .onComplete(bossFight.ChangeTurn));
            break;

        case 2:
            //double attack

            int attack1 = (bossFight.currentAttackDamage / 3);
            int attack2 = bossFight.currentAttackDamage - attack1;
            //move
            Go.to(bossChar.transform, 0.4f, new GoTweenConfig()
                  .localPosition(attackPlayerPosition)
                  .setEaseType(GoEaseType.Linear)
                  .setIterations(2, GoLoopType.PingPong)
                  .onIterationEnd(tween => {
                if (tween.completedIterations < 2)
                {
                    bossFight.currentAttackDamage = attack1;
                    bossFight.DamagePlayer(null);
                }
            }
                                  )
                  .onComplete(tween2 => {
                Go.to(bossChar.transform, 0.6f, new GoTweenConfig()
                      .localPosition(attackPlayerPosition)
                      .setEaseType(GoEaseType.Linear)
                      .setIterations(2, GoLoopType.PingPong)
                      .onIterationEnd(tween3 => {
                    if (tween3.completedIterations < 2)
                    {
                        bossFight.currentAttackDamage = attack2;
                        bossFight.DamagePlayer(null);
                    }
                }
                                      )
                      .onComplete(bossFight.ChangeTurn));
            }
                              ));
            break;
        }
    }
Exemplo n.º 2
0
 public static Tween scaleTo(this Transform self, float duration, Vector3 endValue, bool isRelative = false)
 {
     return(Go.to(self, duration, new TweenConfig().scale(endValue, isRelative)));
 }
Exemplo n.º 3
0
 public static Tween colorTo(this Material self, float duration, Color endValue, MaterialColorType colorType = MaterialColorType.Color)
 {
     return(Go.to(self, duration, new TweenConfig().materialColor(endValue, colorType)));
 }
Exemplo n.º 4
0
 public static GoTween colorTo(this Material self, float duration, Color endValue, float delay, string colorName = "_Color")
 {
     return(Go.to(self, duration, new GoTweenConfig().materialColor(endValue, colorName).setDelay(delay)));
 }
Exemplo n.º 5
0
 public void Close()
 {
     instance = null;
     Go.to(this, 0.6f, new TweenConfig().x(this.x - width - 25).expoInOut().removeWhenComplete());
 }
Exemplo n.º 6
0
    public void Attack(Vector2i target)
    {
        Vector3 tPos = transform.position + (new Vector3(target.x, target.y) - transform.position) * 0.5f;

        Go.to(gameObject.transform, 0.5f, TweenManager.TweenConfigCurrent().position(tPos).setEaseType(GoEaseType.Punch).onBegin(PlayHit));
    }
Exemplo n.º 7
0
    public void Kill()
    {
//		Go.to (gameObject.transform, 0.2f, TweenManager.TweenConfigCurrent().scale(2).onIterationEnd(FinalKill));
        Go.to(gameObject.transform, 0.2f, TweenManager.TweenConfigCurrent().scale(2).materialColor(Color.clear).onIterationEnd(FinalKill));
    }
 public static GoTween localPositionTo(this Transform self, float duration, Vector3 endValue, bool isRelative = false)
 {
     return(Go.to(self, duration, new GoTweenConfig().localPosition(endValue, isRelative)));
 }
 public void OnSceneFadedOut(AbstractTween tween)
 {
     readyToStartOver = true;
     Go.to(startOverLabel, 0.3f, new TweenConfig().floatProp("alpha", 1.0f));
 }
    public void PerformAttack(int attackIndex)
    {
        if (glorten.ReadyToAttack)
        {
            int[] damages = glorten.PerformAttack(attackIndex);
            bossFight.currentAttackDamage = Random.Range(damages[0], damages[1] + 1);

            //special cases
            switch (attackIndex)
            {
            case 0:
                //normal attack
                Vector3 attackBossPosition = new Vector3(glorten.transform.localPosition.x, glorten.transform.localPosition.y, 1.0f);
                //move
                Go.to(glorten.transform, 0.4f, new GoTweenConfig()
                      .localPosition(attackBossPosition)
                      .setEaseType(GoEaseType.Linear)
                      .setIterations(2, GoLoopType.PingPong)
                      .onIterationEnd(tween => {
                    if (tween.completedIterations < 2)
                    {
                        bossFight.DamageBoss(null);
                    }
                }
                                      )
                      .onComplete(bossFight.ChangeTurn));
                break;

            case 1:
                //heal
                Transform healSpell = glorten.transform.Find("HealSpell");

                //make decal appear
                Transform Decal = healSpell.Find("Decal");
                if (Decal != null)
                {
                    SpriteRenderer sr = Decal.gameObject.GetComponent <SpriteRenderer>();
                    sr.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
                    sr.transform.localScale = new Vector3(0.4f, 0.4f, 1.0f);
                    Go.to(sr, 5.0f, new GoTweenConfig()
                          .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f))
                          .setEaseType(GoEaseType.SineOut)
                          .onComplete(tween =>
                    {
                        Go.to(sr, 0.5f, new GoTweenConfig()
                              .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 0.0f))
                              .setEaseType(GoEaseType.SineIn)
                              );

                        Go.to(sr.transform, 0.5f, new GoTweenConfig()
                              .scale(new Vector3(0.1f, 0.1f, 1.0f))
                              .setEaseType(GoEaseType.SineIn)
                              );

                        bossFight.HealPlayer(null);
                        bossFight.ChangeTurn(null);
                    })
                          );
                }

                //launch particles
                ParticleSystem[] particles = healSpell.GetComponentsInChildren <ParticleSystem>();
                foreach (ParticleSystem ps in particles)
                {
                    ps.Play();
                }

                //rotate whole group
                healSpell.localScale = new Vector3(0.6f, 1.0f, 0.6f);
                Go.to(healSpell, 5.0f, new GoTweenConfig()
                      .localRotation(new Vector3(0, 1440f, 0), true)
                      .scale(1.0f)
                      .setEaseType(GoEaseType.Linear));

                break;

            case 2:
                //fire attack
                Transform fireSpell = glorten.transform.Find("FireSpell");
                //rotate fireSpell
                Go.to(fireSpell, 10.0f, new GoTweenConfig()
                      .localRotation(new Vector3(0, 1440f, 0), true)
                      .scale(1.0f)
                      .setEaseType(GoEaseType.Linear));

                //make decal appear
                Transform fireDecal = fireSpell.Find("Decal");
                if (fireDecal != null)
                {
                    SpriteRenderer sr = fireDecal.gameObject.GetComponent <SpriteRenderer>();
                    sr.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
                    sr.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
                    Go.to(sr, 10.0f, new GoTweenConfig()
                          .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f))
                          .setEaseType(GoEaseType.SineOut)
                          .onComplete(tween =>
                    {
                        Go.to(sr, 0.5f, new GoTweenConfig()
                              .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 0.0f))
                              .setEaseType(GoEaseType.SineIn)
                              );

                        Go.to(sr.transform, 0.5f, new GoTweenConfig()
                              .scale(new Vector3(0.1f, 0.1f, 1.0f))
                              .setEaseType(GoEaseType.SineIn)
                              .onComplete(bossFight.ChangeTurn)
                              );
                    })
                          );
                }

                //launch particles
                ParticleSystem[] fireParticles = fireSpell.GetComponentsInChildren <ParticleSystem>();
                foreach (ParticleSystem ps in fireParticles)
                {
                    ps.Play();
                }

                int fireball1Damage = (bossFight.currentAttackDamage / 7) * 1;
                int fireball2Damage = (bossFight.currentAttackDamage / 7) * 2;
                int fireball3Damage = (bossFight.currentAttackDamage / 7) * 4;

                //fireball1
                Transform fireBall1 = fireSpell.Find("FireBall1");
                fireBall1.localPosition = new Vector3(0.0f, fireBall1.localPosition.y, 0.0f);
                GoTween fb1tw = new GoTween(fireBall1, 1.0f, new GoTweenConfig()
                                            .position(new Vector3(0, 0, 5f), true)
                                            .setEaseType(GoEaseType.Linear)
                                            .onComplete(tweenfb1 =>
                {
                    bossFight.currentAttackDamage = fireball1Damage;
                    bossFight.DamageBoss(null);
                }));
                //fireball2
                Transform fireBall2 = fireSpell.Find("FireBall2");
                fireBall2.localPosition = new Vector3(0.0f, fireBall2.localPosition.y, 0.0f);
                GoTween fb2tw = new GoTween(fireBall2, 1.0f, new GoTweenConfig()
                                            .position(new Vector3(0, 0, 5f), true)
                                            .setEaseType(GoEaseType.Linear)
                                            .onComplete(tweenfb2 =>
                {
                    bossFight.currentAttackDamage = fireball2Damage;
                    bossFight.DamageBoss(null);
                }));

                //fireball3
                Transform fireBall3 = fireSpell.Find("FireBall3");
                fireBall3.localPosition = new Vector3(0.0f, fireBall3.localPosition.y, 0.0f);
                GoTween fb3tw = new GoTween(fireBall3, 1.0f, new GoTweenConfig()
                                            .position(new Vector3(0, 0, 5f), true)
                                            .setEaseType(GoEaseType.Linear)
                                            .onComplete(tweenfb3 =>
                {
                    bossFight.currentAttackDamage = fireball3Damage;
                    bossFight.DamageBossBig(null);
                }));

                GoTweenChain chain = new GoTweenChain();
                chain.appendDelay(3f).append(fb1tw).appendDelay(0.5f).append(fb2tw).appendDelay(0.3f).append(fb3tw);
                chain.play();

                break;

            case 3:
                //hearthquake
                Transform earthSpell = glorten.transform.Find("EarthSpell");
                //rotate spell
                Go.to(earthSpell, 9.0f, new GoTweenConfig()
                      .localRotation(new Vector3(0, 1440f, 0), true)
                      .scale(1.0f)
                      .setEaseType(GoEaseType.Linear));

                //make decal appear
                Transform earthDecal = earthSpell.Find("Decal");
                if (earthDecal != null)
                {
                    SpriteRenderer sr = earthDecal.gameObject.GetComponent <SpriteRenderer>();
                    sr.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
                    sr.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
                    Go.to(sr, 9.0f, new GoTweenConfig()
                          .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f))
                          .setEaseType(GoEaseType.SineOut)
                          .onComplete(tween =>
                    {
                        Go.to(sr, 0.5f, new GoTweenConfig()
                              .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 0.0f))
                              .setEaseType(GoEaseType.SineIn)
                              );

                        Go.to(sr.transform, 0.5f, new GoTweenConfig()
                              .scale(new Vector3(0.1f, 0.1f, 1.0f))
                              .setEaseType(GoEaseType.SineIn)
                              .onComplete(bossFight.ChangeTurn)
                              );
                    })
                          );
                }

                //launch particles
                ParticleSystem[] earthParticles = earthSpell.GetComponentsInChildren <ParticleSystem>();
                foreach (ParticleSystem ps in earthParticles)
                {
                    ps.Play();
                }

                //earthquake rocks
                Transform movingRocks = earthSpell.Find("MovingRocks");
                movingRocks.localPosition = new Vector3(0.0f, 0.0f, 1.56f);
                Go.to(movingRocks, 1.0f, new GoTweenConfig()
                      .position(new Vector3(0, 0, 5f), true)
                      .setEaseType(GoEaseType.Linear)
                      .setDelay(5.0f)
                      .onComplete(bossFight.DamageBossBig));

                break;
            }
        }
    }
Exemplo n.º 11
0
 public void To(float targetAmount, float duration, TweenConfig tc)
 {
     Go.killAllTweensWithTarget(this);
     tc.floatProp("amount", targetAmount);
     Go.to(this, duration, tc);
 }
Exemplo n.º 12
0
 public static GoTween colorTo(this SpriteRenderer self, float duration, Color endValue, bool isRelative = false)
 {
     return(Go.to(self, duration, new GoTweenConfig().colorProp("color", endValue, isRelative)));
 }
Exemplo n.º 13
0
 public static GoTween rotationTo(this Transform self, float duration, Quaternion endValue, bool isRelative = false)
 {
     return(Go.to(self, duration, new GoTweenConfig().rotation(endValue, isRelative)));
 }
Exemplo n.º 14
0
 public static GoTween floatTo(this Material self, float duration, float endValue, string propertyName)
 {
     return(Go.to(self, duration, new GoTweenConfig().materialFloat(endValue, propertyName)));
 }
    private void NextAction()
    {
        switch (nextActionIndex)
        {
        case 0:
            //camera animation
            BossFightCamera.instance.PlayAnimation(-1);

            //glorten enter animation
            glorten.CharacterAnimator.SetBool("walking", true);

            //move
            Go.to(glorten.transform, glortenWalkInTime, new GoTweenConfig()
                  .position(glortenCombatPosition)
                  .setEaseType(GoEaseType.Linear));

            //play boss walk animation
            boss.CharacterAnimator.SetBool("walking", true);

            nextActionTime = bossWalkInTime;
            break;

        case 1:
            //teleport boss
            boss.transform.position = new Vector3(bossCombatPosition.x, bossCombatPosition.y, bossCombatPosition.z + 3.0f);

            //move boss
            Go.to(boss.transform, bossStopTime, new GoTweenConfig()
                  .position(bossCombatPosition)
                  .setEaseType(GoEaseType.SineInOut));

            nextActionTime = bossStopTime;
            break;

        case 2:

            //teleport glorten to his position
            Go.killAllTweensWithTarget(glorten.transform);
            glorten.transform.position = glortenCombatPosition;

            //glorten stop animating
            glorten.CharacterAnimator.SetBool("walking", false);

            //boss stop animating
            boss.CharacterAnimator.SetBool("walking", false);
            nextActionTime = glortenReadyTime;
            break;

        case 3:
            //glorten braces
            glorten.PlayOnce(-1);
            nextActionTime = bossRoarTime;
            break;

        case 4:
            //boss roar animation
            boss.PlayOnce(-1);
            nextActionTime = bossRoarAudioTime;
            break;

        case 5:
            //boss roar audio
            if (BossRoar != null)
            {
                this.transform.parent        = Camera.main.transform;
                this.transform.localPosition = Vector3.zero;
                AudioSource asource = this.gameObject.AddComponent <AudioSource>();
                asource.clip = BossRoar;
                asource.Play();
            }
            nextActionTime = endPause;
            break;

        case 6:
            finished       = true;
            nextActionTime = float.MaxValue;
            break;
        }

        nextActionIndex++;
    }
Exemplo n.º 16
0
 public void EnableCollidersSlow()
 {
     Go.killAllTweensWithTarget(_collider);
     Go.to(_collider, 0.5f, colliderDisableConfig);
 }
Exemplo n.º 17
0
 public void Begin(float duration, float strength, GoEaseType easeType = GoEaseType.Linear)
 {
     _beginTween = Go.to(_radialBlur, duration, new GoTweenConfig().floatProp("BlurStrength", strength).setEaseType(easeType));
 }
Exemplo n.º 18
0
    private void Kick()
    {
        justKicked = true;

        bool kickedButton = false;

        kickOffset = new Vector2(direction, Random.Range(0.1f, 0.3f));

        Player otherPlayer = null;
        int numKicks = Physics2D.OverlapCircleNonAlloc(_transform.position, kickRadius, kickScan, kickMask);

        //Collider2D[] kickScan = Physics2D.OverlapCircleAll(_transform.position, kickRadius, kickMask);
        if (UIManager.current_scene_name == GlobalStrings.SCENE_Select || GameManager.FOUND_SECRET) {
            // Code to prioritise buttons
            for (int i = 0; i < numKicks; i++) {
                Collider2D collider = kickScan[i];

                // TODO replace getcomponent by actually naming spawned prefabs by their username
                if ((collider.CompareTag(GlobalStrings.TAG_CustomiserButton) || collider.CompareTag("SECRET")) && (collider.transform.localPosition.y <= transform.localPosition.y)) {
                    collider.GetComponent<KickButton>().KickAction(this);
                    kickedButton = true;

                    // Adjust offset
                    float jitter = 0.1f;
                    Vector2 diff = (Vector2)(collider.transform.position - _transform.position);
                    kickOffset = diff + new Vector2(-0.8f * Mathf.Sign(diff.x) + Random.Range(-jitter, jitter), 0.45f);

                    break;
                }
            }
        }

        if (!kickedButton) otherPlayer = ScanKickable(kickScan, numKicks);

        bool kickSuccess = false;

        if (otherPlayer != null) {
            Vector2 posSub = otherPlayer.transform.position - _transform.position;
            if (!kickedButton) kickOffset = new Vector2(Mathf.Sign (posSub.x) * 2, Random.Range(0.35f, 0.7f));

            otherPlayer.Bop(kickOffset, BopType.KICKED, this);

            if (otherPlayer.Dashing) {
                achievementMgr.GetAxed();
            }

            // Update sorting - bring slamming pode in front
            int i0 = sortingOrder;
            int i1 = otherPlayer.sortingOrder;
            if (i0 < i1) {
                SetOrder(i1);
                otherPlayer.SetOrder(i0);
            }

            // SCREENSHAKE YESSSSSSSSSSSSSSSSSSSSSSSSSSS
            cam.ShakeScreen(posSub.normalized * Random.Range(4f, 6f), 0.5f);

            Squish(SquishType.KICK);
            kickSuccess = true;

            _audio.PlayClipOnce("kick_contact", 6f * AudioManager.sfxVol, Random.Range(0.8f, 1.3f));
        } else {
            // Missed the kick, minor visual update
            Squish(SquishType.KICKMISS);

            _audio.PlayClipOnce("kick_nocontact", 6f * AudioManager.sfxVol, Random.Range(0.8f, 1.3f));
        }

        float retractTime = (kickSuccess) ? kickHitRetractTime : kickRetractTime;
        kickTentacleIndex = (Mathf.Sign(kickOffset.x) < 0) ? 0 : 2; // send out nearest tentacle
        Leg kicker = legs[kickTentacleIndex];
        kicker.kicking = true;

        // Leg tween
        kickRetractConfig.clearEvents();
        kickRetractConfig.setDelay(kickExtendTime);

        if (kickRetractTween != null) kickRetractTween.destroy();
        kickRetractTween = Go.to(this, retractTime, kickRetractConfig);

        // Set leg thickness over total kick time
        kicker.StartKicking(kickExtendTime + retractTime);
    }
Exemplo n.º 19
0
 public void Show()
 {
     Go.killAllTweensWithTarget(gameObject.GetComponent <SpriteRenderer>());
     Go.to(gameObject.GetComponent <SpriteRenderer>(), 0.5f, new GoTweenConfig().colorProp("color", tintColor));
 }
Exemplo n.º 20
0
    public void Hit(int damage, string triggerName = "hit")
    {
        Debug.Log("receiving damage: " + damage);
        health -= damage;
        if (health <= 0)
        {
            health = 0;
        }

        //update healthbar
        if (healthBar != null)
        {
            healthBar.SetHealth(health);
        }

        //update healthText
        if (healthText != null)
        {
            healthText.gameObject.SetActive(true);
            healthText.rectTransform.anchoredPosition = healthTextOriginalPosition;
            Go.killAllTweensWithTarget(healthText);
            Go.killAllTweensWithTarget(healthText.transform);

            healthText.text  = "-" + damage;
            healthText.color = Color.red;

            Go.to(healthText, 2.0f, new GoTweenConfig()
                  .colorProp("color", new Vector4(1.0f, 0.0f, 0.0f, 0.0f))
                  .setEaseType(GoEaseType.SineOut)
                  .onComplete(tween =>
            {
                tween.rewind();
            }));

            Go.to(healthText.rectTransform, 2.0f, new GoTweenConfig()
                  .vector2Prop("anchoredPosition", new Vector2(0.0f, 100.0f), true)
                  .setEaseType(GoEaseType.SineOut)
                  .onComplete(tween =>
            {
                tween.rewind();
                healthText.gameObject.SetActive(false);
            }));
        }

        //show particles
        if (hitParticles != null)
        {
            hitParticles.Play();
        }

        //animate
        if (characterAnimator != null)
        {
            PlayClip(HitClip, true);
            characterAnimator.SetTrigger(triggerName);
        }

        if (health == 0)
        {
            readyToAttack = false;
        }
    }
Exemplo n.º 21
0
 // to tweens
 public static GoTween rotationTo(this Transform self, float duration, Vector3 endValue, float delay, bool isRelative = false)
 {
     return(Go.to(self, duration, new GoTweenConfig().rotation(endValue, isRelative).setDelay(delay)));
 }
Exemplo n.º 22
0
    private void DisplaySolution()
    {
        if (Scroll.clickedScroll == null)
        {
            return;
        }
        var index = Scroll.clickedScroll.scrollIndex;

        // show answer
        answerText.text = StarManager.Instance.CurrentAnswers[index];
        Go.to(answerText, 0.3f, new GoTweenConfig().colorProp("color", answerColor));
        questionText.text = StarManager.Instance.CurrentProblem;
        Go.to(questionText, 0.3f, new GoTweenConfig().colorProp("color", Color.white));

        // draw all stars in solution
        var stars    = new HashSet <Star>();
        var solution = SolutionManager.Instance.Solutions[index];

        for (int i = 0; i < solution.Count; i++)
        {
            stars.Add(solution[i].From);
            stars.Add(solution[i].To);
        }

        // generate stars
        var positions = new Dictionary <Star, Vector3>();

        foreach (var star in stars)
        {
            var littleStar = Instantiate <GameObject>(littleStarPrefab);
            littleStar.transform.SetParent(transform);

            var bigPosition = star.gameObject.transform.position;
            var ratioX      = (bigPosition.x - StarManager.Instance.minX) /
                              (StarManager.Instance.maxX - StarManager.Instance.minX);
            var ratioY = (bigPosition.y - StarManager.Instance.minY) /
                         (StarManager.Instance.maxY - StarManager.Instance.minY);

            var newX = minX + (maxX - minX) * ratioX;
            var newy = minY + (maxY - minY) * ratioY;
            littleStar.transform.position = new Vector3(newX, newy, -9f);
            littleStars.Add(littleStar);

            // save the position later for possible connections
            positions.Add(star, littleStar.transform.position);
        }


        // generate little connections
        for (int i = 0; i < solution.Count; i++)
        {
            Vector3 start = positions[solution[i].From];
            Vector3 end   = positions[solution[i].To];

            var dir      = end - start;
            var position = start + (dir / 2f);

            var littleConnection = Instantiate <GameObject>(littleConnectionPrefab);
            littleConnection.transform.position   = position;
            littleConnection.transform.rotation   = Quaternion.FromToRotation(Vector3.up, dir);
            littleConnection.transform.localScale = new Vector3(littleConnectionWidth, dir.magnitude / 2f, littleConnectionWidth);
            littleConnection.transform.SetParent(transform);
            littleConnections.Add(littleConnection);
        }
    }
Exemplo n.º 23
0
    override public void Start()
    {
        _background = new FSprite("JungleBlurryBG.png");
        AddChild(_background);

        //this will scale the background up to fit the screen
        //but it won't let it shrink smaller than 100%

        _monkey = new BMonkey();
        AddChild(_monkey);
        _monkey.x = -5.0f;
        _monkey.y = -2.0f;

        _againButton = new FButton("YellowButton_normal.png", "YellowButton_over.png", "ClickSound");
        _againButton.AddLabel("Franchise", "AGAIN?", new Color(0.45f, 0.25f, 0.0f, 1.0f));

        AddChild(_againButton);
        _againButton.y = -110.0f;

        _againButton.SignalRelease += HandleAgainButtonRelease;

        _scoreLabel = new FLabel("Franchise", BMain.instance.score + " Bananas");
        AddChild(_scoreLabel);

        _scoreLabel.color = new Color(1.0f, 0.9f, 0.2f);
        _scoreLabel.y     = 110.0f;

        if (BMain.instance.score > BMain.instance.bestScore)
        {
            BMain.instance.bestScore = BMain.instance.score;
            _isNewBestScore          = true;
        }
        else
        {
            _isNewBestScore = false;
        }

        _bestScoreLabel = new FLabel("Franchise", "Best score: " + BMain.instance.bestScore + " Bananas");
        AddChild(_bestScoreLabel);
        _bestScoreLabel.scale   = 0.5f;
        _bestScoreLabel.anchorX = 1.0f;
        _bestScoreLabel.anchorY = 0.0f;
        _bestScoreLabel.color   = new Color(1.0f, 0.9f, 0.2f);



        _scoreLabel.scale = 0.0f;

        Go.to(_scoreLabel, 0.5f, new TweenConfig().
              setDelay(0.3f).
              floatProp("scale", 1.0f).
              setEaseType(EaseType.BackOut));

        _monkey.scale = 0.0f;

        Go.to(_monkey, 0.5f, new TweenConfig().
              setDelay(0.1f).
              floatProp("scale", 1.0f).
              setEaseType(EaseType.BackOut));


        _againButton.scale = 0.0f;

        Go.to(_againButton, 0.5f, new TweenConfig().
              setDelay(0.3f).
              floatProp("scale", 1.0f).
              setEaseType(EaseType.BackOut));

        HandleResize(true);         //force resize to position everything at the start
    }
Exemplo n.º 24
0
    override public void Start()
    {
        _badFoodCount = 0;

        _background = new FSprite("JungleBlurryBG");
        AddChild(_background);

        _closeButton = new FButton("CloseButton_normal", "CloseButton_down", "CloseButton_over", "ClickSound");
        AddChild(_closeButton);


        _closeButton.SignalRelease += HandleCloseButtonRelease;

        _scoreLabel         = new FLabel("Franchise", "0 Bad food");
        _scoreLabel.anchorX = 0.0f;
        _scoreLabel.anchorY = 1.0f;
        _scoreLabel.scale   = 0.75f;
        _scoreLabel.color   = new Color(1.0f, 0.90f, 0.0f);

        _timeLabel         = new FLabel("Franchise", ((int)_secondsLeft) + " Seconds Left");
        _timeLabel.anchorX = 1.0f;
        _timeLabel.anchorY = 1.0f;
        _timeLabel.scale   = 0.75f;
        _timeLabel.color   = new Color(1.0f, 1.0f, 1.0f);
        AddChild(_scoreLabel);
        AddChild(_timeLabel);

        _effectHolder = new FContainer();
        AddChild(_effectHolder);

        _scoreLabel.alpha = 0.0f;
        Go.to(_scoreLabel, 0.5f, new TweenConfig().
              setDelay(0.0f).
              floatProp("alpha", 1.0f));

        _timeLabel.alpha = 0.0f;
        Go.to(_timeLabel, 0.5f, new TweenConfig().
              setDelay(0.0f).
              floatProp("alpha", 1.0f).
              setEaseType(EaseType.BackOut));

        _closeButton.scale = 0.0f;
        Go.to(_closeButton, 0.5f, new TweenConfig().
              setDelay(0.0f).
              floatProp("scale", 1.0f).
              setEaseType(EaseType.BackOut));

        TallyScore();

        HandleResize(true);         //force resize to position everything at the start

        _particlePrefab = Resources.Load("Particles/BananaParticles") as GameObject;
        //_particleGO = GameObject.CreatePrimitive(PrimitiveType.Cube);
//		_particleGO = UnityEngine.Object.Instantiate(prefab) as GameObject;
//		_particleGO.name = "Particules!";
//		_particleGO.transform.localScale = new Vector3(100,100,100);
//
//		_particleNode = new FGameObjectNode(_particleGO, true, true, true);
//		_particleNode.scale = 100.0f;
//
//		AddChild (_particleNode);

//		AddChild (_bananaContainer);
    }
Exemplo n.º 25
0
    public void HandleMultiTouch(FTouch[] touches)
    {
        // don't process input if the game is over
        if (player_lost_ || player_won_)
        {
            return;
        }



        foreach (FTouch touch in touches)
        {
            if (touch.phase == TouchPhase.Began)
            {
                if (!touch_starts.ContainsKey(touch.tapCount))
                {
                    touch_starts.Add(touch.tapCount, touch);
                }
                else
                {
                    touch_starts[touch.tapCount] = touch;                     // update the touch otherwise
                }
                touch_start_time = Time.time;
            }
            else if (touch.phase == TouchPhase.Ended)
            {
                // don't process input if the player is currently doing something else

                /*if(player_.CurrentState != PlayerCharacter.PlayerState.IDLE)
                 *      return;*/

                FTouch touch_start = touch_starts[touch.tapCount];

                Vector2 swipe_vector = touch.position - touch_start.position;

                // normalize the swipe vector
                float swipe_magnitude = Mathf.Sqrt(swipe_vector.x * swipe_vector.x + swipe_vector.y * swipe_vector.y);

                // TODO: Change this to a reasonable threshold
                if (swipe_magnitude <= 30.0f)
                {
                    // This is a tap
                    Debug.Log("Detected a tap");

                    Debug.Log("Tap delta time: " + (Time.time - touch_start_time));

                    if (Time.time - touch_start_time < .2)
                    {
                        if (touch.position.y < -Futile.screen.halfHeight / 2.0f)
                        {
                            // if already executing a move, first stop it
                            if (curr_player_movement != null)
                            {
                                curr_player_movement.destroy();
                            }

                            float final_position = touch.position.x;
                            if (touch.position.x < 0 && touch.position.x - player_.width / 2.0f < level_bounding_box.xMin)
                            {
                                final_position = level_bounding_box.xMin + player_.width / 2.0f;
                            }

                            if (touch.position.x > 0 && touch.position.x + player_.width / 2.0f > level_bounding_box.xMax)
                            {
                                final_position = level_bounding_box.xMax - player_.width / 2.0f;
                            }

                            if (final_position == player_.x)
                            {
                                return;
                            }

                            player_.scaleX = Math.Abs(player_.scaleX);

                            if (final_position - player_.x < 0)
                            {
                                player_.play("backwards_walk");
                            }
                            else
                            {
                                player_.play("walk");
                            }

                            player_.CurrentState = PlayerCharacter.PlayerState.WALK;

                            // calculate movement time based on player's speed attribute
                            float tween_time = Math.Abs(player_.x - final_position) / (Futile.screen.width * player_.Speed);

                            curr_player_movement = Go.to(player_, tween_time, new TweenConfig().floatProp("x", final_position).onComplete(originalTween => { player_.play("idle");
                                                                                                                                                             player_.CurrentState = PlayerCharacter.PlayerState.IDLE; }));
                        }
                    }
                    else
                    {
                        Vector2 bacteria_direction = new Vector2();
                        bacteria_direction.x = touch.position.x - player_.x;
                        bacteria_direction.y = touch.position.y - player_.y;

                        float magnitude = Mathf.Sqrt(bacteria_direction.x * bacteria_direction.x + bacteria_direction.y * bacteria_direction.y);

                        bacteria_direction.x /= magnitude;
                        bacteria_direction.y /= magnitude;

                        CreateBubble(bacteria_direction);

                        if ((float)player_.Health / (float)PlayerCharacter.MAX_HEALTH >= .5f)
                        {
                            bacteria_direction.x *= 1.2f;
                            bacteria_direction.y *= .8f;

                            CreateBubble(bacteria_direction);
                        }

                        if ((float)player_.Health / (float)PlayerCharacter.MAX_HEALTH >= .75f)
                        {
                            bacteria_direction.x *= .6f;
                            bacteria_direction.y *= 1.4f;

                            CreateBubble(bacteria_direction);
                        }
                    }
                }
                else
                {
                    Debug.Log("Detected a swipe");
                    swipe_vector.x /= swipe_magnitude;
                    swipe_vector.y /= swipe_magnitude;

                    if (touch.position.x < player_.x && touch_start.position.x > player_.x &&
                        touch.position.y < (player_.y + player_.height / 2.0f) && touch.position.y > (player_.y - player_.height / 2.0f) &&
                        touch_start.position.y < (player_.y + player_.width / 2.0f) && touch_start.position.y > (player_.y - player_.height / 2.0f))
                    {
                        // this is a block
                        Debug.Log("player block");
                        player_.play("block");
                        player_.CurrentState = PlayerCharacter.PlayerState.BLOCK;
                    }
                    else if (touch.position.x > enemy_.x && touch_start.position.x < enemy_.x &&
                             touch.position.y < (enemy_.y + enemy_.height / 2.0f) && touch.position.y > (enemy_.y - enemy_.height / 2.0f) &&
                             touch_start.position.y < (enemy_.y + enemy_.height / 2.0f) && touch.position.y > (enemy_.y - enemy_.height / 2.0f))
                    {
                        // this a punch
                        Debug.Log("player punch");
                        player_.play("punch");
                        player_.CurrentState    = PlayerCharacter.PlayerState.PUNCH;
                        player_punch_did_damage = false;
                    }
                    else
                    {
                        CreateBubble(swipe_vector);
                    }
                }

                touch_starts.Remove(touch.tapCount);
            }
        }
    }
Exemplo n.º 26
0
        //class objectMoveInfo
        //{
        //    public GameObject obj;
        //    public Vector3 srcPos;
        //};

        void DoFocusAction()
        {
            //计算位移距离
            FunDamageNode fun = m_oneDamageInfo.damageNode.funDamage;

            //聚怪中心点
            Vector3 centerPos = m_transform.position + m_transform.forward.normalized * fun.offDistance;

            //中间是否有空气墙
            Vector3 wallPos = CoreEntry.gBaseTool.GetWallHitPoint(m_transform.position, centerPos);

            if (!wallPos.Equals(centerPos))
            {
                //存在空气墙
                Vector3 dist = wallPos - m_transform.position;
                dist = dist * 0.9f;
                //Vector3 wallGroundPos = CoreEntry.gBaseTool.GetGroundPoint(m_transform.position + dist);
                centerPos = CoreEntry.gBaseTool.GetGroundPoint(centerPos);
            }

            if (centerPos.Equals(Vector3.zero))
            {
                centerPos = m_transform.position;
            }

            //需要聚集的怪物
            List <ActorObj> actors = CoreEntry.gActorMgr.GetAllMonsterActors();

            for (int i = 0; i < actors.Count; i++)
            {
                //对IOS出现怪物不动 报错的异常  进行错误处理
                if (GameLogicMgr.checkValid(actors[i].gameObject) == false)
                {
                    continue;
                }
                GameObject obj       = actors[i].gameObject;
                ActorObj   actorBase = actors[i];


                //塔不没有受击
                MonsterObj monsterObj = obj.GetComponent <MonsterObj>();
                if (monsterObj && monsterObj.m_bIsTower)
                {
                    continue;
                }

                //bool isSkillSuccess = false;

                if (!m_skillBase.m_actor.IsAimActorType(actorBase))
                {
                    continue;
                }

                // 有霸体的不能被拉动
                if (actorBase.IsActorEndure())
                {
                    continue;
                }

                //伤害对象
                if (CoreEntry.gBaseTool.IsPointInCircleXZ(centerPos, obj.transform.position, fun.radius, 1f))
                {
                    //isSkillSuccess = true;
                    Go.to(obj.transform, 0.4f, new GoTweenConfig().position(centerPos));
                }
            }

            StartCoroutine(destroyBox());
        }
Exemplo n.º 27
0
 public static Tween shake(this Transform self, float duration, Vector3 shakeMagnitude, ShakeType shakeType = ShakeType.Position, int frameMod = 1, bool useLocalProperties = false)
 {
     return(Go.to(self, duration, new TweenConfig().shake(shakeMagnitude, shakeType, frameMod, useLocalProperties)));
 }
Exemplo n.º 28
0
    public override void DoClickToAct()
    {
        Go.to(player.transform, ascendTime, new GoTweenConfig().position(new Vector3(0, ascendHeight, 0), true).setEaseType(GoEaseType.QuadInOut).onComplete(OnFloatComplete));

        baws = true;
    }
Exemplo n.º 29
0
 // to tweens
 public static Tween eularAnglesTo(this Transform self, float duration, Vector3 endValue, bool isRelative = false)
 {
     return(Go.to(self, duration, new TweenConfig().eulerAngles(endValue, isRelative)));
 }
Exemplo n.º 30
0
 public void Hide()
 {
     Go.to(sprite, .4f, new GoTweenConfig().colorProp("color", transparent));
     gameObject.SetActive(false);
 }