示例#1
0
    public void TurnOff(float time = 0.1f, Action <AbstractGoTween> onComplete = null)
    {
        if (!isOn && time != 0)
        {
            Debug.LogWarning("trying to lower shield while already lowered");
        }

        Go.killAllTweensWithTarget(sprite);

        Action <AbstractGoTween> internalOnComplete = (tween) => {
            shieldCollider.enabled = false;
            isOn = false;
            if (onComplete != null)
            {
                onComplete(tween);
            }
        };

        Color newColor = sprite.color;

        if (time == 0)
        {
            newColor.a   = 0;
            sprite.color = newColor;
            internalOnComplete(null);
        }
        else
        {
            newColor.a = 0;
            GoTweenConfig config = new GoTweenConfig().colorProp("color", newColor).onComplete(internalOnComplete);

            Go.to(sprite, time, config);
        }
    }
示例#2
0
    void PlayNextSong()
    {
        currentSong = nextSong;
        nextSong    = null;

        AudioClip clip = LoadAudioClip(currentSong.resourcePath);

        if (clip != null)
        {
            audioSource.clip   = clip;
            audioSource.volume = 0;
            Go.killAllTweensWithTarget(audioSource);
            Go.to(audioSource, fadeInDuration, new TweenConfig().floatProp("volume", currentSong.volume));
            audioSource.loop = true;

            if (_isPaused)
            {
                songPauseTime = audioSource.time = currentSong.playTime;
                audioSource.Stop();
            }
            else
            {
                songPauseTime = audioSource.time = currentSong.playTime;
                audioSource.Play();
            }
        }
        else
        {
            audioSource.clip = null;            //don't play anything
            audioSource.Stop();
            currentSong = null;
        }
    }
示例#3
0
 public void TransformIntoWolf()
 {
     isTransformingToWolf = true;
     tranPercent          = 0.0f;
     Go.killAllTweensWithTarget(healthBar);
     Go.to(healthBar, 1.0f, new TweenConfig().alpha(0.0f));
 }
示例#4
0
    private IEnumerator ElasticStandUp()
    {
        float passed = 0;
        passed += Time.fixedDeltaTime;

        Go.killAllTweensWithTarget(_collider);
        _collider.offset = new Vector2(0, 0.5f);
        _collider.size = new Vector2(1f, 1f);

        Vector2 interpSize = startSize;
        Vector2 interpOffset = startOffset;

        while (passed < 1f) {
            if (!canControl) yield break;

            passed += Time.fixedDeltaTime * 0.85f;

            float t = passed;
              float u = Mathf.Sin(-13.0f * (t + 1.0f) * Mathf.PI * 0.5f) * Mathf.Pow(2.0f, -10.0f * t) + 1.0f;
            interpSize.x = (1 - u) * startSize.x + u * finalSize.x;
            interpSize.y = (1 - u) * startSize.y + u * finalSize.y;

            interpOffset.x = (1 - u) * startOffset.x + u * finalOffset.x;
            interpOffset.y = (1 - u) * startOffset.y + u * finalOffset.y;

            _collider.size = interpSize;
            _collider.offset = interpOffset;

            yield return wffu;
        }

        _collider.size = finalSize;
        _collider.offset = finalOffset;
    }
示例#5
0
 private void CloseMathMode()
 {
     _mathModeAmount = 0.0f;
     _isMathMode     = false;
     Go.killAllTweensWithTarget(scoreBox);
     Go.to(scoreBox.mathMode, 0.4f, new TweenConfig().floatProp("amount", 0.0f).setEaseType(EaseType.ExpoOut).onComplete(HandleMathModeCloseComplete));
     FSoundManager.PlaySound("UI/MathClose");
 }
示例#6
0
 public void SetPositionImmediate(int x, int y)
 {
     positionI.x        = x;
     positionI.y        = y;
     targetPosition     = new Vector3(x, y, 0);
     transform.position = targetPosition;
     Go.killAllTweensWithTarget(gameObject.transform);
 }
 public void HaltThenGotoWaypoint()
 {
     Go.killAllTweensWithTarget(this.transform);
     UkenTimer.SetTimeout(0f, () => {
         curWaypointIndex -= 1;
         NextWaypoint();
     });
 }
 public void FollowWaypoints(Level level)
 {
     curLevel = level;
     Go.killAllTweensWithTarget(this.transform);
     this.transform.position = initialPosition;
     if (level.waypoints != null && level.waypoints.Length > 0)
     {
         curWaypointIndex = 0;
         HaltThenGotoWaypoint();
     }
 }
示例#9
0
 public static void Conclude()
 {
     if (EnginesComparison.ts != null)
     {
         for (int i = 0; i < EnginesComparison.ts.Length; ++i)
         {
             Go.killAllTweensWithTarget(EnginesComparison.ts[i]);
         }
     }
     UnityEngine.Object.Destroy(GameObject.Find("GoKit (" + EnginesComparison.totTweens + " tweens)"));
 }
示例#10
0
    void Update()
    {
        bool didTeamChange       = false;
        bool didPlayerPressStart = false;

        foreach (var row in rows)
        {
            var  player  = row.player;
            Team newTeam = null;

            if (player.team.teamToTheLeft != null && player.device.LeftStick.Left.WasPressed)
            {
                newTeam = player.team.teamToTheLeft;
            }
            else if (player.team.teamToTheRight != null && player.device.LeftStick.Right.WasPressed)
            {
                newTeam = player.team.teamToTheRight;
            }

            if (newTeam != null)
            {
                player.team = newTeam;
                TeamCol col = GetColForTeam(newTeam);
                Go.killAllTweensWithTarget(row.inner);
                Go.to(row.inner, 0.3f, new TweenConfig().x(col.x).expoOut());
                didTeamChange = true;

                if (newTeam == PlayerManager.Team_Villagers)
                {
                    FXPlayer.VillAttack();
                }
                else if (newTeam == PlayerManager.Team_Wolves)
                {
                    FXPlayer.WolfAttack();
                }
            }

            if (player.device.MenuWasPressed)
            {
                didPlayerPressStart = true;
            }
        }

        if (didTeamChange)
        {
            CheckStatus();
        }

        if (isReady && didPlayerPressStart)
        {
            StartGame();
        }
    }
示例#11
0
    public void Hide()
    {
        if (!_isShown)
        {
            return;
        }

        _isShown = false;

        Go.killAllTweensWithTarget(this);
        Go.to(this, hideDuration, new TweenConfig().floatProp("alpha", 0.0f).onComplete(HandleHideComplete));
    }
示例#12
0
 public static void GoToColor(FMeshNode meshNode, float duration, Color goalColor)
 {
     Go.killAllTweensWithTarget(meshNode);
     if (duration == 0)
     {
         meshNode.color = goalColor;
     }
     else
     {
         Go.to(meshNode, duration, new TweenConfig().colorProp("color", goalColor));
     }
 }
示例#13
0
    public void EndResetMode()
    {
        UnshrinkMainboxes();
        EnableMegaBoxes();
        slotList.EndResetMode();

        Go.killAllTweensWithTarget(slotList);
        Go.to(slotList, 0.7f, new TweenConfig().x(0).expoInOut());

        resetGroup.Close();        //it should remove itself
        resetGroup = null;
    }
示例#14
0
    private IEnumerator Blink_Coroutine(Vector3 direction, Vector3 mousePos, bool charge)
    {
        _blink = true;
        Vector3 pos = transform.position;

        pos.y      = 0;
        mousePos.y = 0;
        Vector3 bodyScale = body.localScale;
        float   yPos      = transform.position.y;

        Go.to(body, 0.25f, new GoTweenConfig().scale(Vector3.one * 0.25f).setEaseType(GoEaseType.BackIn));

        yield return(new WaitForSeconds(0.25f));

        Vector3 newPos = mousePos;

        newPos.y = yPos;

        Go.to(transform, 0.5f, new GoTweenConfig().position(newPos).setEaseType(GoEaseType.BackInOut));

        yield return(new WaitForSeconds(0.5f));

        transform.position = newPos;

        Go.to(body, 0.25f, new GoTweenConfig().scale(bodyScale).setEaseType(GoEaseType.BackOut));

        if (charge)
        {
            GameObject punch = GameObject.CreatePrimitive(PrimitiveType.Cube);
            punch.GetComponent <MeshRenderer>().material = attackMaterial;
            punch.transform.position   = transform.position;
            punch.transform.localScale = Vector3.zero;

            GoTweenChain chain       = new GoTweenChain();
            GoTween      growTween   = Go.to(punch.transform, chargeBlinkFXTime * 0.25f, new GoTweenConfig().scale(Vector3.one * 3).setEaseType(GoEaseType.BackOut));
            GoTween      shrinkTween = Go.to(punch.transform, chargeBlinkFXTime * 0.75f, new GoTweenConfig().scale(Vector3.zero).setEaseType(GoEaseType.ExpoIn));
            chain.append(growTween);
            chain.append(shrinkTween);
            chain.play();

            yield return(new WaitForSeconds(chargeBlinkFXTime));

            yield return(new WaitForSeconds(blinkRecoverTime));
        }
        else
        {
            yield return(new WaitForSeconds(0.25f));
        }

        Go.killAllTweensWithTarget(body.GetChild(0).GetComponent <MeshRenderer>());
        Go.to(body.GetChild(0).GetComponent <MeshRenderer>(), 0.2f, new GoTweenConfig().materialColor(new Color(62f / 255f, 1f, 0)));
        _blink = false;
    }
示例#15
0
 public static void GoToColor(FSprite sprite, float duration, Color goalColor)
 {
     Go.killAllTweensWithTarget(sprite);
     if (duration == 0)
     {
         sprite.color = goalColor;
     }
     else
     {
         Go.to(sprite, duration, new TweenConfig().colorProp("color", goalColor));
     }
 }
示例#16
0
 static public int killAllTweensWithTarget_s(IntPtr l)
 {
     try {
         System.Object a1;
         checkType(l, 1, out a1);
         Go.killAllTweensWithTarget(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#17
0
    public void Show(float duration)
    {
        if (_isShown)
        {
            return;
        }

        _isShown = true;

        _containerToUse.AddChildAtBack(this);
        Go.killAllTweensWithTarget(this);
        Go.to(this, duration, new TweenConfig().floatProp("alpha", 1.0f).onComplete(HandleShowComplete));
    }
示例#18
0
    private void HandleUpdate()
    {
        _scroller.SetPos(-slotContainer.y);
        _scroller.SetBounds(_minScrollY, _maxScrollY);

        if (_canScroll && isTouchable)
        {
            if (_touchSlot.didJustBegin)
            {
                Vector2 touchPos = GetLocalTouchPosition(_touchSlot.touch);

                if (touchableRect.Contains(touchPos))
                {
                    _scroller.BeginDrag(touchPos.y);
                }
            }
        }

        if (_touchSlot.didJustEnd || _touchSlot.didJustCancel)
        {
            _scroller.EndDrag(GetLocalTouchPosition(_touchSlot.touch).y);
        }
        else if (_touchSlot.doesHaveTouch)
        {
            if (_canScroll && isTouchable && _scroller.isDragging)
            {
                Vector2 touchPos = GetLocalTouchPosition(_touchSlot.touch);

                _scroller.UpdateDrag(touchPos.y);

                if (!_touchSlot.wasArtificiallyCanceled)
                {
                    if (_scroller.GetDragDistance() > Config.MIN_DRAG_DISTANCE)
                    {
                        _touchSlot.Cancel();
                    }
                }
            }
        }

        bool isMoving = _scroller.Update();

        if (isMoving)
        {
            Go.killAllTweensWithTarget(slotContainer);
            slotContainer.y = -_scroller.GetPos();
        }
        else
        {
        }
    }
示例#19
0
    public void Bop(Vector2 posSub, BopType bopType, Player otherPlayer = null)
    {
        if (invincible) return; // Can't get bopped if recently been bopped

        // Bop up, up and away
        if (bopType == BopType.KICKED) {
            bopForce.x = Mathf.Sign(posSub.x);
            rbody.velocity = bopForce;
        }
        // Enable stun particles
        if (bopType != BopType.INKED) {
            Go.killAllTweensWithTarget(stunHalo);
            stunHalo.gameObject.SetActive(true);
            stunHalo.localScale *= 0.7f;

            Go.to(stunHalo, 1.5f, haloConfig);
        }
        // Audiovisual update
        if (bopType == BopType.INKED) {
            // Ink splat
            head.EnableInkSplat();
            isInked = true;
            face.SetFace(Face.FaceType.Surprised);
            _audio.PlayClipOnce("inkhit", 1f * AudioManager.sfxVol, Random.Range(0.4f, 0.7f));
        } else if (bopType == BopType.NOPED) {
            face.SetFace(Face.FaceType.Surprised);
            _audio.PlayClipOnce("kick", 1.5f * AudioManager.sfxVol, 0.5f);
        } else {
            face.SetFace(Face.FaceType.Bopped);
            _audio.PlayClipOnce("kick", 1.5f * AudioManager.sfxVol, 1f);
        }

        invincible = true;
        canControl = false;

        Go.killAllTweensWithTarget(_collider);
        _collider.offset = new Vector2(0, 0.5f);
        _collider.size = new Vector2(1f, 1f);

        // Present-release
        if (hasGift) {
            hasGift = false;
            GameManager.gift.SetFree(posSub, otherPlayer);
        }

        // Time to recover depends on what hit you - ink shooter or other player
        WaitForSeconds wfs = wfs_unBopDelay;
        if (bopType == BopType.INKED) wfs = wfs_unBopInkDelay;
        if (bopType == BopType.NOPED) wfs = wfs_unBopNopeDelay;
        StartCoroutine(ThenUnbop(wfs));
    }
示例#20
0
    public void ShowInstantly()
    {
        if (_isShown)
        {
            return;
        }

        _isShown = true;

        _containerToUse.AddChildAtBack(this);
        Go.killAllTweensWithTarget(this);
        this.alpha = 1.0f;
        HandleShowComplete(null);
    }
    void OnDrag(Vector2 curPos, Vector2 deltaPos)
    {
        Vector3 curCastPos = Layout.ScreenPos2WorldPos(MapCamera, curPos);
        Vector3 oriCastPos = Layout.ScreenPos2WorldPos(MapCamera, curPos - deltaPos);

        if (_clickAnimationing)
        {
            Go.killAllTweensWithTarget(MapCamera.transform);
            _clickAnimationing = false;
        }
        else
        {
            MoveCamera(MapCamera.transform.localPosition - (curCastPos - oriCastPos) * DragDistanceFactor);
        }
    }
示例#22
0
    public void StartMathMode()
    {
        _mathModeAmount = 1.0f;

        if (!_isMathMode)        //just increment the timer
        {
            if (scoreBox.mathMode.amount == 0)
            {
                scoreBox.ResetBaseScore();
            }
            _isMathMode = true;
            Go.killAllTweensWithTarget(scoreBox);
            Go.to(scoreBox.mathMode, 0.4f, new TweenConfig().floatProp("amount", 1.0f).setEaseType(EaseType.ExpoOut).onComplete(HandleMathModeOpenComplete));
            FSoundManager.PlaySound("UI/MathOpen");
        }
    }
示例#23
0
    void GoNight()
    {
        isDay = false;

        ShowMessage("NIGHT HAS COME!", "CHASE THE VILLAGERS!", new Color(0.9f, 0.95f, 1f));

        Go.killAllTweensWithTarget(arena.colorOverlay);
        Go.to(arena.colorOverlay, Config.DAY_TRANSITION_DURATION, new TweenConfig().colorProp("color", new Color(0, 0.03f, 0.18f, 0.5f)));

        foreach (var human in arena.humans)
        {
            human.TransformIntoWolf();
        }

        FXPlayer.NightStart();
    }
示例#24
0
    public void Shake(float intensity, float time)
    {
        if (isShaking)
        {
            Go.killAllTweensWithTarget(transform);
            transform.position = originalPosition;
        }

        isShaking = true;

        Go.to(transform, time, new GoTweenConfig()
              .shake(new Vector3(intensity, intensity, 0), GoShakeType.Position)
              .onComplete((tween) => {
            isShaking = false;
        }));
    }
示例#25
0
    // the crab will choose a destination to move to and go there
    private void Move()
    {
        // kill all pre-existing tweens on this transform
        Go.killAllTweensWithTarget(transform);
        // pick a destination
        destination = new Vector2(Random.Range(MIN_X_WANDER, MAX_X_WANDER), Random.Range(MIN_Y_WANDER, MAX_Y_WANDER));
        speed       = Random.Range(MIN_SPEED, MAX_SPEED);
        float time = speed * Vector2.Distance(destination, transform.localPosition);

        // and go there
        Go.to(transform, time, new GoTweenConfig().localPosition(destination));
        // also wobble
        Wobble();

        currently  = State.Moving;
        stateTimer = time; //set timer to end after movement
    }
示例#26
0
    void Unbop()
    {
        if (canControl) return;

        StartCoroutine(InvincibilityTimeout());

        canControl = true;

        // Tween cleanup, remove stun halo
        Go.killAllTweensWithTarget(stunHalo);
        haloUndoConfig.clearEvents();
        haloUndoConfig.onComplete(c => {
            stunHalo.gameObject.SetActive(false);
        });
        Go.to(stunHalo, 0.5f, haloUndoConfig);

        if (tired) {
            face.SetFace(Face.FaceType.Tired);
        } else {
            // return to default face if we're not in 'surprised' mode
            if (face.ActiveFace != Face.FaceType.Surprised) {
                var reaction = Random.Range(0f, 1f) < 0.5f ?
                    Face.FaceType.Default :
                    Face.FaceType.Frowning;

                face.SetFace(reaction);
            }
        }

        isInked = false;
        head.DisableInkSplat();

        bopTweenConfig.clearEvents();
        bopTweenConfig.clearProperties();
        bopTweenConfig.setEaseType(GoEaseType.ElasticOut);

        if (elasticRoutine != null) StopCoroutine(elasticRoutine);
        elasticRoutine = StartCoroutine(ElasticStandUp());

        // Jump up from bopped position
        if (surface == Surface.Ground) {
            cachedVelocity = rbody.velocity;
            cachedVelocity.y = jumpSpeed / 1.5f;
            rbody.velocity = cachedVelocity;
        }
    }
示例#27
0
 // GoKit has no "KillAll" method, so we'll have to kill the tweens one by one based on target
 void KillAllGoTweens()
 {
     if (testObjsTrans != null)
     {
         foreach (Transform t in testObjsTrans)
         {
             Go.killAllTweensWithTarget(t);
         }
     }
     if (testObjsData != null)
     {
         foreach (TestObjectData t in testObjsData)
         {
             Go.killAllTweensWithTarget(t);
         }
     }
 }
示例#28
0
    void GoDay()
    {
        isDay = true;

        ShowMessage("DAY IS HERE!", "CHASE THE WEREWOLF!", new Color(1f, 1f, 0.9f));

        Go.killAllTweensWithTarget(arena.colorOverlay);
        Go.to(arena.colorOverlay, Config.DAY_TRANSITION_DURATION, new TweenConfig().colorProp("color", new Color(0, 0, 0, 0.0f)));

        for (int w = arena.wolves.Count - 1; w >= 0; w--)    //reversed for removals
        {
            var wolf = arena.wolves[w];
            wolf.TransformIntoHuman();
        }

        FXPlayer.DayStart();
    }
示例#29
0
    // crabs gonna hang here a while
    private void Idle()
    {
        // kill all pre-existing tweens on this transform
        Go.killAllTweensWithTarget(transform);

        // return to neutral wobble
        float distance = Mathf.Abs(transform.rotation.z);

        if (distance > 0)
        {
            float time = speed * WOBBLE_SPEED_MODIFIER * distance; // use whatever speed we were last wobbling with
            Go.to(transform, time, new GoTweenConfig().rotation(Vector3.zero));
        }

        // stay a while...
        stateTimer = Random.Range(MIN_WAIT, MAX_WAIT);
        currently  = State.Idle;
    }
示例#30
0
    private IEnumerator ChargePush_Coroutine(Vector3 direction)
    {
        _chargePush = true;
        GameObject punch = GameObject.CreatePrimitive(PrimitiveType.Cube);

        punch.GetComponent <MeshRenderer>().material = attackMaterial;
        punch.transform.position   = transform.position + direction;
        punch.transform.localScale = Vector3.one;
        float speed        = chargePushFXSpeed;
        bool  tweenPlaying = true;
        float time         = 0;

        Vector3 dirToPush = direction + (Vector3.down * 0.25f);

        dirToPush.Normalize();
        Quaternion rot = Quaternion.LookRotation(dirToPush);

        GoTweenFlow flow       = new GoTweenFlow();
        GoTween     punchTween = Go.to(punch.transform, chargePushFXDuration, new GoTweenConfig().scale(Vector3.zero).setEaseType(GoEaseType.ExpoIn).onComplete(c => tweenPlaying = false));

        flow.insert(0, punchTween);

        Go.killAllTweensWithTarget(body);
        GoTween rotationTween = new GoTween(body, chargePushFXDuration * 0.15f, new GoTweenConfig().rotation(rot).setEaseType(GoEaseType.ExpoOut).setIterations(2, GoLoopType.PingPong));

        flow.insert(0, rotationTween);
        flow.play();

        while (tweenPlaying)
        {
            time += Time.deltaTime;
            punch.transform.position += direction * speed * Time.deltaTime;
            speed *= chargePunchFXSpeedIncrement;
            yield return(null);
        }

        yield return(new WaitForSeconds(chargePushRecoverTime));

        Go.to(body.GetChild(0).GetComponent <MeshRenderer>(), 0.2f, new GoTweenConfig().materialColor(new Color(62f / 255f, 1f, 0)));
        body.transform.localPosition = Vector3.zero;

        Destroy(punch);
        _chargePush = false;
    }