Exemplo n.º 1
0
        private static CoroutinePlus StartCoroutine(Yielder yielder)
        {
            var routine = new CoroutinePlus(yielder);

            StartCoroutine(routine);
            return(routine);
        }
Exemplo n.º 2
0
    IEnumerator BehaveA(float advance, GameObject originalShot, float awayAngle)
    {
        SetMovement(StgFrame.height / 1.2f, -90);

        {
            var _adv = 0f;

            while (_adv < advance)
            {
                yield return(null);

                _adv += Speed;
            }
        }

        Acceleration = -Speed / 0.5f;
        while (Speed != 0)
        {
            yield return(null);
        }

        FireWay(originalShot, 3, 5, StgFrame.height / 2.5f, -90);
        yield return(Yielder.WaitForFixedSeconds(0.5f));

        Angle        = awayAngle;
        Acceleration = StgFrame.height / 3;
        SpeedLimit   = StgFrame.height / 2.5f;
    }
Exemplo n.º 3
0
    public IEnumerator Behave009(float x, float arrivalY, float sX, float t, GameObject originalShot)
    {
        transform.position = new Vector3(x, StgFrame.topS + BodyRadius);
        SetDestAtTime(this.X, arrivalY, t);

        {
            var curT = 0f;
            while (Speed != 0)
            {
                yield return(null);

                curT  += TimeManager.DeltaTime;
                this.X = x + sX / 2 + sX / 2 * Mathfd.Cos(-180f + 180f * curT / t);
            }
        }

        for (var i = 0; i < 3; i++)
        {
            Fire(originalShot, StgFrame.height / 1.8f, -90f);
            yield return(Yielder.WaitForFixedSeconds(0.25f));
        }

        Acceleration = StgFrame.height / 4;
        SpeedLimit   = StgFrame.height / 1;
    }
Exemplo n.º 4
0
    void Start()
    {
        GameObject player = default;

        if (Utils.IsNull(PlayerSync.LocalPlayerInst))
        {
            player      = PhotonNetwork.Instantiate("Player", new Vector3(0.0f, 50.0f, 150.0f), Quaternion.identity);
            player.name = "LocalPlayer";
            LogicEventListener.Invoke(eEventType.FOR_ALL, eEventMessage.ON_LOCAL_PLAYER_CREATED, player);
        }

        // Preload all the required scenes for the stage1.
        //AsyncOperation[] additionalSceneStatus = new AsyncOperation[2]{
        //    SceneManager.LoadSceneAsync("ChatUI", LoadSceneMode.Additive),
        //    SceneManager.LoadSceneAsync("MenuUI", LoadSceneMode.Additive)
        //};

        SceneManager.LoadScene("ChatUI", LoadSceneMode.Additive);
        SceneManager.LoadScene("MenuUI", LoadSceneMode.Additive);

        Scenes[0] = SceneManager.GetSceneAt(1);
        Scenes[1] = SceneManager.GetSceneAt(2);

        // GetRootGameObjects works properly after the scene has been fully loaded!
        StartCoroutine(Yielder.GetCoroutine(() =>
        {
            Scenes[0].GetRootGameObjects(ChatSceneGOs);
            SwitchChatUI(false);

            Scenes[1].GetRootGameObjects(MenuSceneGOs);
            SwitchMenuUI(false);
        }, 0.25f));
    }
Exemplo n.º 5
0
    void Start()
    {
        RectTf           = GetComponent <RectTransform>();
        OriginalPosition = new Vector2(RectTf.anchoredPosition.x, RectTf.anchoredPosition.y);
        switch (PushingDirection)
        {
        case ePushDirection.NORTH:
            MovingDir = Vector2.up;
            break;

        case ePushDirection.EAST:
            MovingDir = Vector2.right;
            break;

        case ePushDirection.WEST:
            MovingDir = Vector2.left;
            break;

        case ePushDirection.SOUTH:
            MovingDir = Vector2.down;
            break;
        }
        ;
        StartCoroutine(Yielder.GetCoroutine(() =>
        {
            CrosshairCoroutines[0] = StartCoroutine(_SpreadCrosshair());
            CrosshairCoroutines[1] = StartCoroutine(_CloseCrosshair());
        }, 0.5f));
    }
Exemplo n.º 6
0
    public IEnumerator Behave008(float x, float arrivalY, GameObject originalShot, float awayAngle = -90f, bool another = false)
    {
        transform.position = new Vector3(x, StgFrame.topS + BodyRadius);
        SetDestAtTime(x, arrivalY, 1);
        yield return(WaitForStop());

        Angle = Angle2Player;
        FireWay(originalShot, 3, 5, StgFrame.height / 1.8f, Angle);
        yield return(Yielder.WaitForFixedSeconds(0.5f));

        if (another)
        {
            yield return(Yielder.WaitForFixedSeconds(0.5f));
        }

        Acceleration = StgFrame.height / 2f;
        SpeedLimit   = StgFrame.height / 1f;
        Angle        = awayAngle;

        if (another)
        {
            for (var i = 0; i < 3; i++)
            {
                yield return(Yielder.WaitForFixedSeconds(0.3f));

                FireRoundWay(originalShot, 6, 2, 3f, StgFrame.height / 2.8f, Mathfd.RandomAngle());
            }
        }
    }
        public void FiniteYielderExtensionTake()
        {
            var yielder = Yielder.NaturalNumber().Skip(1).Map(v => v * v).Take(6);
            var taken   = yielder.Take(5);

            Assert.Equal(1, taken.Next());
            Assert.Equal(4, taken.Next());
            Assert.Equal(9, taken.Next());
            Assert.Equal(16, taken.Next());
            Assert.True(taken.HasNext());
            Assert.Equal(25, taken.Next());
            Assert.False(taken.HasNext());
            Assert.False(taken.HasNext());

            yielder = Yielder.NaturalNumber().Skip(1).Map(v => v * v).Take(6);
            taken   = yielder.Take(7);

            Assert.Equal(1, taken.Next());
            Assert.Equal(4, taken.Next());
            Assert.Equal(9, taken.Next());
            Assert.Equal(16, taken.Next());
            Assert.Equal(25, taken.Next());
            Assert.True(taken.HasNext());
            Assert.Equal(36, taken.Next());
            Assert.False(taken.HasNext());
            Assert.False(taken.HasNext());
        }
Exemplo n.º 8
0
    IEnumerator BehaveB(float x, float arrivalY, float t, GameObject originalShot, float awayAcceleration, float awaySpeedLimit, float awayAngle)
    {
        transform.position = new Vector3(x, StgFrame.topS + BodyRadius);

        Acceleration  = -2 * -(arrivalY - Y) / Mathf.Pow(t, 2);
        Speed         = -Acceleration * t;
        SpeedLimit    = 0;
        Angle         = -90;
        MoveAngleLink = false;

        while (Speed != 0)
        {
            BodyAngle = Angle2Player;

            yield return(null);
        }

        //FireWay(originalShot, 3, 5, StgFrame.height / 2.5f, bodyAngle);
        Fire(originalShot, StgFrame.height / 2.8f, BodyAngle);
        yield return(Yielder.WaitForFixedSeconds(0.5f));

        MoveAngleLink = true;
        Angle         = awayAngle;
        Acceleration  = StgFrame.height / 3;
        SpeedLimit    = StgFrame.height / 2.5f;
    }
Exemplo n.º 9
0
        public void YielderExtensionOfType()
        {
            bool v = true;
            int  x = 0;
            // ReSharper disable once AssignmentInConditionalExpression
            var yielder = Yielder.Repeat(() => ((v = !v)) ? (Base) new A {
                Num = x++
            } : new B()
            {
                Str = $"{x++}"
            });

            var aYielder = yielder.OfType <Base, A>();

            Assert.Equal(1, aYielder.Next().Num);
            Assert.Equal(3, aYielder.Next().Num);
            Assert.Equal(5, aYielder.Next().Num);
            Assert.Equal(7, aYielder.Next().Num);

            var bYielder = yielder.OfType <Base, B>();

            Assert.Equal("8", bYielder.Next().Str);
            Assert.Equal("10", bYielder.Next().Str);
            Assert.Equal("12", bYielder.Next().Str);
            Assert.Equal("14", bYielder.Next().Str);
        }
Exemplo n.º 10
0
 public IEnumerator Behave101(GameObject originalShot)
 {
     while (true)
     {
         FireRoundR210(originalShot, 5, Random.Range(0, StgFrame.halfWidth / 3), Mathfd.RandomAngle(), StgFrame.halfWidth / 40, StgFrame.height / 2, Mathfd.RandomAngle(), -StgFrame.height / 1, StgFrame.height / 2.5f);
         yield return(Yielder.WaitForFixedSeconds(0.2f));
     }
 }
Exemplo n.º 11
0
    public async void YielderIsNotActiveWhenAsserting()
    {
        await ToSignal(UntilTimeout(0.1), YIELD);

        bool result = (bool)Yielder.Call("is_active");

        Assert.IsTrue(!result, "Then yielder is not active");
    }
Exemplo n.º 12
0
    /// <summary>
    /// ドバーッ
    /// </summary>
    /// <param name="originalEnemy"></param>
    /// <param name="x"></param>
    /// <param name="firstSpeed"></param>
    /// <param name="intervalSpeed"></param>
    /// <param name="angle"></param>
    /// <param name="fireTime"></param>
    /// <param name="originalShot"></param>
    /// <param name="n"></param>
    /// <param name="createIntervalTime"></param>
    /// <returns></returns>
    public static IEnumerator CreateFormation003(GameObject originalEnemy, float x, float firstSpeed, float intervalSpeed, float angle, float fireTime, GameObject originalShot, int n, float createIntervalTime)
    {
        for (var i = 0; i < n; i++)
        {
            CreateBehave003Enemy(originalEnemy, x, firstSpeed - intervalSpeed * i, angle, fireTime, originalShot);

            yield return(Yielder.WaitForFixedSeconds(createIntervalTime));
        }
    }
Exemplo n.º 13
0
 /// <summary>
 /// 横に並ぶ奴
 /// </summary>
 /// <param name="original"></param>
 /// <param name="n"></param>
 /// <param name="firstX"></param>
 /// <param name="intervalX"></param>
 /// <param name="arrivalY"></param>
 /// <param name="firstT"></param>
 /// <param name="intervalT"></param>
 /// <param name="originalShot"></param>
 /// <param name="awayAcceleration"></param>
 /// <param name="awaySpeedLimit"></param>
 /// <param name="awayAngle"></param>
 /// <returns></returns>
 public static IEnumerator CreateFormationB(GameObject original, int n, float firstX, float intervalX, float arrivalY, float firstT, float intervalT, GameObject originalShot, float awayAcceleration, float awaySpeedLimit, float awayAngle)
 {
     for (var i = 0; i < n; i++)
     {
         StgAct clone = StgAct.ApparentInstantiate(original);
         clone.StartCoroutine(clone.BehaveB(firstX + intervalX * i, arrivalY, firstT - intervalT * i, originalShot, awayAcceleration, awaySpeedLimit, awayAngle));
         yield return(Yielder.WaitForFixedSeconds(intervalT));
     }
 }
Exemplo n.º 14
0
    public async void WhenASignalBeingYieldedOnIsEmittedTheYielderIsStopped()
    {
        CallDeferred("emit_signal", "abc");
        await ToSignal(UntilSignal(this, "abc", 0.3), YIELD);

        bool paused = (bool)Yielder.Call("get", "paused");

        Assert.IsTrue(paused, "Then the yielder is paused");
    }
Exemplo n.º 15
0
    public void YieldSingle_ExpectCollectionLengthEqualsOne(
        object?sourceValue)
    {
        var actual = Yielder <object?> .YieldSingle(sourceValue);

        var actualLength = actual.Count();

        Assert.AreEqual(1, actualLength);
    }
Exemplo n.º 16
0
    public void YieldSingle_ExpectFirstItemIsSameAsSourceValue(
        object?sourceValue)
    {
        var actual = Yielder <object?> .YieldSingle(sourceValue);

        var actualFirst = actual.FirstOrDefault();

        Assert.AreSame(sourceValue, actualFirst);
    }
Exemplo n.º 17
0
    public async void WhenTheYielderTimesOut()
    {
        await ToSignal(UntilTimeout(0.1), YIELD);

        bool paused    = (bool)Yielder.Call("get", "paused");
        bool connected = (bool)Yielder.Call("is_connected", "timeout", Yielder, "_on_resume");

        Assert.IsTrue(paused, "Then the yielder is paused");
        Assert.IsTrue(!connected, "The timeout signal of the yielder is not connected");
    }
Exemplo n.º 18
0
        public void YielderExtensionFilterAndMap()
        {
            var yielder  = Yielder.NaturalNumber().Map(v => v * 2 + 3);
            var selected = yielder.Filter(v => v % 3 < 2).Map(v => v + 4);

            Assert.Equal(7, selected.Next());
            Assert.Equal(11, selected.Next());
            Assert.Equal(13, selected.Next());
            Assert.Equal(17, selected.Next());
        }
Exemplo n.º 19
0
        public void YielderExtensionMap()
        {
            var yielder = Yielder.NaturalNumber().Map(v => v * 2 + 3);
            var mapped  = yielder.Map(v => v % 3);

            Assert.Equal(0, mapped.Next());
            Assert.Equal(2, mapped.Next());
            Assert.Equal(1, mapped.Next());
            Assert.Equal(0, mapped.Next());
        }
Exemplo n.º 20
0
    public IEnumerator Behave003(float x, float speed, float angle, float fireTime, GameObject originalShot)
    {
        transform.position = new Vector3(x, StgFrame.topS + BodyRadius);
        this.Speed         = speed;
        this.Angle         = angle;

        yield return(Yielder.WaitForFixedSeconds(fireTime));

        FireRound(originalShot, 5, StgFrame.height / 1.8f, Angle2Player);
    }
Exemplo n.º 21
0
    public async void WhenYielderIsFinishedSignalsAreDisconnected()
    {
        await ToSignal(UntilSignal(this, "abc", 0.1), YIELD);

        bool connected  = (bool)Yielder.Call("is_connected", "timeout", Yielder, "_on_resume");
        bool connected2 = IsConnected("abc", Yielder, "_on_resume");

        Assert.IsTrue(!connected, "Then the timeout signal is disconnected");
        Assert.IsTrue(!connected2, "Then the signal signal is disconnected");
    }
Exemplo n.º 22
0
        public void YielderExtensionFilter()
        {
            int x        = 1;
            var yielder  = Yielder.Repeat(() => x += 2);
            var filtered = yielder.Filter(v => v % 3 == 0);

            Assert.Equal(3, filtered.Next());
            Assert.Equal(9, filtered.Next());
            Assert.Equal(15, filtered.Next());
            Assert.Equal(21, filtered.Next());
        }
Exemplo n.º 23
0
        public void YielderExtensionTakeWhile()
        {
            var yielder = Yielder.NaturalNumber().Skip(1).Map(v => v * v);
            var taken   = yielder.TakeWhile(v => v < 25);

            Assert.Equal(1, taken.Next());
            Assert.Equal(4, taken.Next());
            Assert.Equal(9, taken.Next());
            Assert.Equal(16, taken.Next());
            Assert.False(taken.HasNext());
        }
Exemplo n.º 24
0
        public void YielderExtensionSkip()
        {
            var yielder = Yielder.NaturalNumber().Skip(1).Map(v => v * v);
            var skipped = yielder.Skip(5);

            Assert.Equal(36, skipped.Next());
            Assert.Equal(49, skipped.Next());
            Assert.Equal(64, skipped.Next());
            Assert.Equal(81, skipped.Next());
            Assert.Equal(100, skipped.Next());
        }
Exemplo n.º 25
0
        public static void Main(string[] args)
        {
            yielder = new Yielder();

            Bot bot = new Bot(APIKeys.DiscordToken, "n!");

            updateThread = new Thread(new ThreadStart(Update));
            updateThread.Start();

            AppDomain.CurrentDomain.ProcessExit += new EventHandler(Close);
        }
Exemplo n.º 26
0
        public void Update()
        {
            if (!IsRunning)
            {
                return;
            }

            Yielder.ProcessCoroutines();
            EntityManager.Update();
            FrameCount++;
        }
Exemplo n.º 27
0
    private IEnumerator MeasureTime()
    {
        var delay = Yielder.WaitForSeconds(1f);

        while (true)
        {
            yield return(delay);

            elapsedSeconds++;
            OnTimeChanged?.Invoke(elapsedSeconds);
        }
    }
Exemplo n.º 28
0
        public void FiniteYielderExtensionFilterAndMap()
        {
            var yielder  = Yielder.NaturalNumber().Map(v => v * 2 + 3).Take(4);
            var selected = yielder.Filter(v => v % 3 < 2).Map(v => v + 4);

            Assert.Equal(7, selected.Next());
            Assert.Equal(11, selected.Next());
            Assert.True(selected.HasNext());
            Assert.Equal(13, selected.Next());
            Assert.False(selected.HasNext());
            Assert.False(selected.HasNext());
        }
Exemplo n.º 29
0
        public void FiniteYielderExtensionFilter()
        {
            int x        = 1;
            var yielder  = Yielder.Repeat(() => x += 2).Take(4);
            var filtered = yielder.Filter(v => v % 3 == 0);

            Assert.Equal(3, filtered.Next());
            Assert.True(filtered.HasNext());
            Assert.Equal(9, filtered.Next());
            Assert.False(filtered.HasNext());
            Assert.False(filtered.HasNext());
        }
Exemplo n.º 30
0
 public IEnumerator FireBehave002(GameObject original, int roundN, int lineN, float speed, float lineIntervalT, int roundCount)
 {
     for (var i = 0; i < roundCount; i++)
     {
         float angle = Mathfd.RandomAngle();
         for (var j = 0; j < lineN; j++)
         {
             FireRound(original, roundN, speed, angle);
             yield return(Yielder.WaitForFixedSeconds(lineIntervalT));
         }
     }
 }
Exemplo n.º 31
0
 public override Node VisitQueryYielder(QueryYielder qy) {
   bool savedFoldQuery = this.foldQuery;
   this.foldQuery = true;
   Block feBlock = (Block) this.Visit(qy.Source);
   this.foldQuery = false;
   Yielder yielder = new Yielder(this.typeSystem, this.TypeViewer);
   return this.Visit(yielder.YieldTo(feBlock, qy.Body, qy.Target, qy.State));
 }