コード例 #1
0
        private IEnumerator PlayCoinsExplosionRoutine(Stork stork)
        {
            int time     = 0;
            int duration = 1200;

            yield return(null);

            _cartoonCoinsExplosion.SetActive(true);
            stork.AddChild(_cartoonCoinsExplosion);
            _cartoonCoinsExplosion.SetXY(0, 0);
            _cartoonCoinsExplosion.alpha = 1f;

            SpriteTweener.TweenAlpha(_cartoonCoinsExplosion, 1, 0, duration - 500, null, 500);

            while (time < duration)
            {
                float fFrame = Mathf.Map(time, 0, duration, 0, _cartoonCoinsExplosion.frameCount - 1);
                int   frame  = Mathf.Round(fFrame) % _cartoonCoinsExplosion.frameCount;

                _cartoonCoinsExplosion.SetFrame(frame);

                time += Time.deltaTime;

                yield return(null);
            }

            yield return(new WaitForMilliSeconds(200));

            stork.RemoveChild(_cartoonCoinsExplosion);
            _cartoonCoinsExplosion.SetActive(false);
        }
コード例 #2
0
        public void FadeInOut(GameObject parent, int duration = 1400, OnTransition onTransition = null,
                              OnFinished onFinished           = null, CenterMode centerMode = CenterMode.Min)
        {
            parent.AddChild(this);

            if (centerMode == CenterMode.Center)
            {
                SetXY(-width * 0.5f, -height * 0.5f);
            }
            else
            {
                SetXY(0, 0);
            }

            SetActive(true);

            SpriteTweener.TweenAlpha(this, 0, 1, duration / 2, o =>
            {
                onTransition?.Invoke();

                SpriteTweener.TweenAlpha(this, 1, 0, duration / 2, go =>
                {
                    onFinished?.Invoke();

                    SetActive(false);

                    this.parent.RemoveChild(this);
                });
            });

            //CoroutineManager.StartCoroutine(instance.FadeInOutRoutine(time, onFinished));
        }
コード例 #3
0
        private IEnumerator ShowSmokeOnStork00Routine(Stork stork)
        {
            int time     = 0;
            int duration = 1500;

            yield return(null);

            _smoke00.visible = true;
            stork.AddChild(_smoke00);
            _smoke00.SetXY(0, 0);
            _smoke00.alpha = 1f;

            SpriteTweener.TweenAlpha(_smoke00, 1, 0, duration - 500, null, 500);

            while (time < duration)
            {
                float fFrame = Mathf.Map(time, 0, duration, 0, _smoke00.frameCount - 1);
                int   frame  = Mathf.Round(fFrame) % _smoke00.frameCount;

                _smoke00.SetFrame(frame);

                time += Time.deltaTime;

                yield return(null);
            }

            yield return(new WaitForMilliSeconds(200));

            stork.RemoveChild(_smoke00);
            _smoke00.visible = false;
        }
コード例 #4
0
        private IEnumerator LockingCrossHairOnEnemy()
        {
            _state = HunterState.LOCKING_CROSSHAIR_ON_ENEMY;

            _crossHair.visible = true;

            SpriteTweener.TweenAlpha(_hunterFollowRangeCone, 0, 0.4f, 500);

            //Seeking target
            do
            {
                var crossHairWorldPos = TransformPoint(_crossHair.Pos.x, _crossHair.Pos.y);
                var distance          = _enemy.Pos - crossHairWorldPos;
                var distanceNorm      = distance.Normalized;

                var nextPos = distanceNorm * _sightSpeed * Time.delta;

                _crossHair.Translate(nextPos.x, nextPos.y);

                if (!IsEnemyInRange())
                {
                    _lostLockOnEnemyOutOfRangeRoutine     =
                        _lostLockOnEnemyOutOfRangeRoutine =
                            CoroutineManager.StartCoroutine(LostLockOnEnemyOutOfRangeRoutine(_enemy), this);
                }

                yield return(null);
            } while (_state == HunterState.LOCKING_CROSSHAIR_ON_ENEMY);
        }
コード例 #5
0
        private IEnumerator EndLevelRoutine()
        {
            SpriteTweener.TweenAlpha(_crossHair, 1, 0, 400);

            SpriteTweener.TweenAlpha(_hunterFollowRangeCone, _hunterFollowRangeCone.alpha, 0, 400);

            yield return(null);
        }
コード例 #6
0
        public LevelEndScreen() : base("data/Next level screen.png")
        {
            _nextLevelSprite = new Sprite("data/Next Level Text.png", true, false);
            AddChild(_nextLevelSprite);
            _nextLevelSprite.SetXY(1225, 743);
            _nextLevelSprite.SetOrigin(_nextLevelSprite.width * 0.5f, _nextLevelSprite.height * 0.5f);

            //Wait some time to enable input
            CoroutineManager.StartCoroutine(WaitSomeTime(), this);

            //Animate Text
            SpriteTweener.TweenScalePingPong(_nextLevelSprite, 1, 1.05f, 300);
        }
コード例 #7
0
        private IEnumerator SnapCrossHairToEnemy(GameObject enemy)
        {
            _state = HunterState.CROSSHAIR_LOCKED_ON_ENEMY;

            int time     = 0;
            int duration = 300;

            var     crossStartPos = TransformPoint(_crossHair.Pos.x, _crossHair.Pos.y);
            Vector2 localPos;

            while (time < duration)
            {
                float pointX = Easing.Ease(Easing.Equation.QuadEaseOut, time, crossStartPos.x,
                                           enemy.x - crossStartPos.x, duration);
                float pointY = Easing.Ease(Easing.Equation.QuadEaseOut, time, crossStartPos.y,
                                           enemy.y - crossStartPos.y, duration);

                localPos = InverseTransformPoint(pointX, pointY);

                _crossHair.SetXY(localPos.x, localPos.y);

                time += Time.deltaTime;
                yield return(null);
            }

            SpriteTweener.TweenColor(_crossHair, _crossHair.StartColor, ColorTools.ColorToUInt(Color.Red), 300);

            //After Snap, follow target while distance less than range
            //Countdown to Shoot
            _countDownToShootRoutine = CoroutineManager.StartCoroutine(CountDownToShootRoutine(enemy), this);

            do
            {
                _distanceToTarget = enemy.Pos - _pos;
                float distanceMag = _distanceToTarget.Magnitude;

                localPos = InverseTransformPoint(enemy.x, enemy.y);
                _crossHair.SetXY(localPos.x, localPos.y);

                //Lost lock on enemy, out of range
                if (distanceMag > _scanEnemyRange)
                {
                    CoroutineManager.StopCoroutine(_countDownToShootRoutine);

                    _lostLockOnEnemyOutOfRangeRoutine =
                        CoroutineManager.StartCoroutine(LostLockOnEnemyOutOfRangeRoutine(enemy), this);
                }

                yield return(null);
            } while (_state == HunterState.CROSSHAIR_LOCKED_ON_ENEMY);
        }
コード例 #8
0
        private IEnumerator EnemyDetectedRoutine()
        {
            _state = HunterState.ENEMY_DETECTED;

            SpriteTweener.TweenAlpha(_crossHair, 0, 1, 400);

            SoundManager.Instance.SetFxVolume(4, 0.5f);

            yield return(new WaitForMilliSeconds(500));

            //Start Lock enemy

            _lockingCrossHairOnEnemy = CoroutineManager.StartCoroutine(LockingCrossHairOnEnemy(), this);
        }
コード例 #9
0
        public void Show(GameObject target, Vector2 pos, Vector2 offset2)
        {
            _target  = target;
            _offset  = pos;
            _offset2 = offset2;

            this.SetScaleXY(1f, 1f);
            this.alpha = 1;
            SpriteTweener.TweenScale(this, 1f, 2, 400, o =>
            {
                parent?.RemoveChild(this);
                _target = null;
            });
            //SpriteTweener.TweenAlpha(this, 1, 0.4f, 400);
        }
コード例 #10
0
        public static void TweenScalePingPong(Sprite sprite, float from, float to, int duration,
                                              OnTweenComplete onComplete = null, int delay = 0, Easing.Equation equation = Easing.Equation.QuadEaseOut)
        {
            if (sprite == null || sprite.Destroyed)
            {
                return;
            }

            SpriteTweener.TweenScale(sprite, from, to, duration, go =>
            {
                SpriteTweener.TweenScale(sprite, to, from, duration, go1 =>
                {
                    TweenScalePingPong(sprite, from, to, duration, null, delay, equation);
                });
            });
        }
コード例 #11
0
        public StartScreen() : base("data/Startscreen Bg.png")
        {
            //1260 207

            _startText = new Sprite("data/Start Screen - pressstart.png", true, false);
            AddChild(_startText);
            _startText.SetOrigin(_startText.width * 0.5f, _startText.height * 0.5f);
            _startText.SetXY(1260, 207);


            float mScale = _startText.scale;

            SpriteTweener.TweenScalePingPong(_startText, mScale, mScale * 1.02f, 300);

            SoundManager.Instance.PlayMusic(0);
        }
コード例 #12
0
        private void FadeInOut()
        {
            visible          = true;
            _isFading        = true;
            _offSetAnimTimer = 0;

            SpriteTweener.TweenAlpha(this.EasyDraw, 0, 1, _fadeInOutDuration / 2,
                                     go =>
            {
                SpriteTweener.TweenAlpha(this.EasyDraw, 1, 0, _fadeInOutDuration / 2, go2 =>
                {
                    _offSetAnimTimer = 0;
                    _isFading        = false;
                    visible          = false;
                });
            });
        }
コード例 #13
0
        private IEnumerator ChasingRoutine(GameObject target)
        {
            _state = DroneState.CHASING_ENEMY;

            var chasingMoveRoutine = ChasingMovementRoutine(target);

            _iesDebug.Add(chasingMoveRoutine);

            SpriteTweener.TweenAlpha(_droneFollowRangeCone, 0, 0.4f, 500);

            yield return(chasingMoveRoutine);

            SpriteTweener.TweenAlpha(_droneFollowRangeCone, 0.4f, 0, 500);

            _iesDebug.Remove(chasingMoveRoutine);
            _iesDebug.Remove(_chasingRoutine);
        }
コード例 #14
0
        IEnumerator DroneReleasePizzaRoutine(DroneGameObject drone, Sprite pizza)
        {
            while (drone.State == DroneGameObject.DroneState.HIT_ENEMY ||
                   drone.State == DroneGameObject.DroneState.RETURN_TO_START_POINT_AFTER_HIT)
            {
                yield return(null);
            }

            int duration = 1000;

            SpriteTweener.TweenAlpha(pizza, 1, 0, duration);

            yield return(new WaitForMilliSeconds(duration));

            pizza.visible = false;
            pizza.alpha   = 1;
            pizza.parent  = _level;
        }
コード例 #15
0
        private IEnumerator EndLevelByLost()
        {
            Console.WriteLine($"{this}: EndLevelByLost");

            _level.IsLevelEndingByLost = true;

            //Send all drones away
            _level.DronesesManager.EndLevelAllDrones();

            //Stop all hunters
            _level.HuntersManager.EndLevelAllHunters();

            //Cry 3 times
            CoroutineManager.StartCoroutine(Cry3Times(), this);

            if (_isLevelEndingTimesUp)
            {
                //PingPong scale Thermometer
                float mScale = HUD.Instance.Thermometer.scale;
                SpriteTweener.TweenScalePingPong(HUD.Instance.Thermometer, mScale, mScale * 1.10f, 300);
            }

            yield return(new WaitForMilliSeconds(3 * 1200));

            var gameOverScreen = new GameOverScreen();

            HudScreenFader.instance.FadeInOut(MyGame.ThisInstance.Camera, 1400,
                                              () =>
            {
                MyGame.ThisInstance.UnLoadCurrentLevel();

                SoundManager.Instance.DisableAllSounds();

                _level.RemoveChild(MyGame.ThisInstance.Camera);
                HudScreenFader.instance.parent = MyGame.ThisInstance;
                HudScreenFader.instance.SetXY(0, 0);
                MyGame.ThisInstance.AddChildAt(gameOverScreen, HudScreenFader.instance.Index - 1);
            },
                                              null, CenterMode.Center);
        }
コード例 #16
0
        private IEnumerator LostLockOnEnemyOutOfRangeRoutine(GameObject enemy)
        {
            _state = HunterState.LOST_LOCK_ON_ENEMY;

            SpriteTweener.TweenAlpha(_hunterFollowRangeCone, 0.4f, 0, 500);

            SpriteTweener.TweenAlpha(_crossHair, 1, 0, 400);

            //Only get points when evading the first time
            if (_lostLockOnEnemyCounter == 0)
            {
                LocalEvents.Instance.Raise(new LevelLocalEvent(_enemy, (GameObject)this, null,
                                                               LevelLocalEvent.EventType.STORK_GET_POINTS_EVADE_HUNTER));
            }

            _lostLockOnEnemyCounter++;

            yield return(new WaitForMilliSeconds(1000));

            //Return to scanning state
            _scanningForEnemyRoutine =
                CoroutineManager.StartCoroutine(ScanningForEnemy(HunterState.SCANNING, true), this);
        }
コード例 #17
0
ファイル: Level.cs プロジェクト: vlab22/Team23_GXPEngine
        public bool ActivateNextDeliveryPoint()
        {
            var lastDeliveryPoint = _deliveryPoints[_currentDeliveryPoint];

            SpriteTweener.TweenAlpha(lastDeliveryPoint, 1, 0, 600, go =>
            {
                go.SetActive(false);
            });

            if (_currentDeliveryPoint >= _deliveryPoints.Length - 1)
            {
                return(false);
            }

            _currentDeliveryPoint++;

            var nextDeliveryPoint = _deliveryPoints[_currentDeliveryPoint];

            nextDeliveryPoint.SetActive(true);
            SpriteTweener.TweenAlpha(nextDeliveryPoint, 0, 1, 600);

            return(true);
        }
コード例 #18
0
        public GameOverScreen() : base("data/GameOver Screen.png")
        {
            _buttonPressed = true;

            _scoreTitle = new HudTextBoard("Score Board", 0, 0, 500, 500, FONT_SIZE, CenterMode.Center,
                                           CenterMode.Center);
            AddChild(_scoreTitle);
            _scoreTitle.SetClearColor(Color.FromArgb(0, 1, 1, 1));
            ((IHasColor)_scoreTitle).MainColor = GlobalVars.DarkBlue;

            _scoreTitle.EasyDraw.TextFont(FONT_PATH, FONT_SIZE);
            _scoreTitle.SetText("Score Board");
            _scoreTitle.x = SCOREBOARD_X + 60;
            _scoreTitle.y = 100;

            _scoreTitle.EasyDraw.TextFont(FONT_PATH, FONT_SIZE);

            var playerScoreData = new PlayerScoreData()
            {
                name  = "you",
                score = MyGame.ThisInstance.TotalScore
            };

            var scorePointsList = new List <PlayerScoreData>(MyGame.ThisInstance.ScoreBoardList)
            {
                playerScoreData
            };

            scorePointsList = scorePointsList.OrderByDescending(ps => ps.score).ToList();

            int pad = 0;

            if (scorePointsList.Count > 0)
            {
                pad = scorePointsList[0].score.ToString().Length;
            }

            var first10Scores = scorePointsList.Take(10).ToList();

            _scoreBoardTexts = new List <HudTextBoard>();
            for (int i = 0; i < first10Scores.Count; i++)
            {
                var scoreData = scorePointsList[i];

                var format = "{0,2}\t{1}\t{2," + pad + "}";

                var text = string.Format(format, i + 1, scoreData.name.ToUpper().Substring(0, 3),
                                         scoreData.score); //$"{scoreData.name.ToUpper().Substring(0, 3)} {$"{scoreData.score:10}"}";

                var hudScoreText = new HudTextBoard(text, 0, 0, 1000, 200, FONT_SIZE, CenterMode.Min, CenterMode.Min);
                AddChild(hudScoreText);
                hudScoreText.SetClearColor(Color.FromArgb(0, 1, 1, 1));

                ((IHasColor)hudScoreText).MainColor =
                    (scoreData.name == "you") ? GlobalVars.DimGreen : GlobalVars.DarkBlue;

                hudScoreText.EasyDraw.TextFont(FONT_PATH, FONT_SIZE);

                hudScoreText.SetText(text);

                if (scoreData.name == "you")
                {
                    hudScoreText.EasyDraw.SetOrigin(hudScoreText.EasyDraw.width * 0.5f,
                                                    hudScoreText.EasyDraw.height * 0.5f);

                    hudScoreText.x = SCOREBOARD_X + hudScoreText.EasyDraw.width * 0.5f;
                    hudScoreText.y = 210 + i * 40 + hudScoreText.EasyDraw.height * 0.5f;

                    //Anim score
                    float mScale = hudScoreText.EasyDraw.scale;
                    SpriteTweener.TweenScalePingPong(hudScoreText.EasyDraw, mScale, mScale * 1.02f, 200);
                }
                else
                {
                    hudScoreText.x = SCOREBOARD_X;
                    hudScoreText.y = 200 + i * 40;
                }
            }

            //Get player position, if greater than 10, put it at the end
            var playerPos = scorePointsList.Select(ps => ps.name).ToList().IndexOf("you");

            if (playerPos > 9)
            {
                var format = "{0,2}\t{1}\t{2," + pad + "}";

                var text = string.Format(format, playerPos + 1, playerScoreData.name.ToUpper().Substring(0, 3),
                                         playerScoreData.score);

                var hudScoreText = new HudTextBoard(text, 0, 0, 1000, 200, FONT_SIZE, CenterMode.Min, CenterMode.Min);
                AddChild(hudScoreText);
                hudScoreText.SetClearColor(Color.FromArgb(0, 1, 1, 1));

                ((IHasColor)hudScoreText).MainColor = GlobalVars.DimGreen;

                hudScoreText.EasyDraw.TextFont(FONT_PATH, FONT_SIZE);

                hudScoreText.SetText(text);

                hudScoreText.EasyDraw.SetOrigin(hudScoreText.EasyDraw.width * 0.5f,
                                                hudScoreText.EasyDraw.height * 0.5f);

                hudScoreText.x = SCOREBOARD_X + hudScoreText.EasyDraw.width * 0.5f;
                hudScoreText.y = 200 + 30 + first10Scores.Count * 40 + hudScoreText.EasyDraw.height * 0.5f;

                //Anim score
                float mScale = hudScoreText.EasyDraw.scale;
                SpriteTweener.TweenScalePingPong(hudScoreText.EasyDraw, mScale, mScale * 1.02f, 200);
            }

            MyGame.ThisInstance.SaveScoreBoard();

            CoroutineManager.StartCoroutine(WaitSomeTimeToEnableInput(), this);
        }