当前位置: 首页>>代码示例>>C#>>正文


C# Attack.SetDirection方法代码示例

本文整理汇总了C#中Attack.SetDirection方法的典型用法代码示例。如果您正苦于以下问题:C# Attack.SetDirection方法的具体用法?C# Attack.SetDirection怎么用?C# Attack.SetDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Attack的用法示例。


在下文中一共展示了Attack.SetDirection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Attack

    public void Attack()
    {
        Vector2 dirVect = new Vector2(Input.mousePosition.x - (x - C.getCameraInstance().x) * Futile.displayScale - Futile.screen.pixelWidth / 2f, Input.mousePosition.y - (this.y - C.getCameraInstance().y) * Futile.displayScale - Futile.screen.pixelHeight / 2f).normalized;
        Direction d = Direction.UP;
        if (Mathf.Abs(dirVect.x) > Mathf.Abs(dirVect.y))
        {
            if (dirVect.x < 0)
                d = Direction.LEFT;
            else
                d = Direction.RIGHT;
        }
        else if (dirVect.y < 0)
            d = Direction.DOWN;
        else
            d = Direction.UP;

        float dist = 30;
        Attack attack;
        Attack attack2;
        Attack attack3;
        Attack attack4;
        switch (currentAttack)
        {
            case AttackType.NORMAL:

                attack = new Attack(world, d);
                attack.SetDirection(d);
                attack.SetPosition(this.GetPosition() + dirVect * 5);
                Go.to(attack, .35f, new TweenConfig().floatProp("x", dirVect.x * dist, true).floatProp("y", dirVect.y * dist, true).setEaseType(EaseType.QuadOut).onComplete(() => { world.RemoveObject(attack); }));
                world.AddObject(attack);
                break;
            case AttackType.WIDE:

                attack = new Attack(world, d);
                attack.SetPosition(this.GetPosition() + dirVect * 5);
                float angle = Mathf.Atan2(dirVect.y, dirVect.x);
                dirVect.x = Mathf.Cos(angle - Mathf.PI / 7f);
                dirVect.y = Mathf.Sin(angle - Mathf.PI / 7f);
                Go.to(attack, .3f, new TweenConfig().floatProp("x", dirVect.x * dist, true).floatProp("y", dirVect.y * dist, true).setEaseType(EaseType.QuadOut).onComplete(() => { world.RemoveObject(attack); }));
                world.AddObject(attack);

                attack2 = new Attack(world, d);
                world.AddObject(attack2);
                Vector2 secondAttackDir = new Vector2(Mathf.Cos(angle + Mathf.PI / 7f), Mathf.Sin(angle + Mathf.PI / 7f));
                attack2.SetPosition(this.GetPosition() + secondAttackDir * 5);
                Go.to(attack2, .3f, new TweenConfig().floatProp("x", secondAttackDir.x * dist, true).floatProp("y", secondAttackDir.y * dist, true).setEaseType(EaseType.QuadOut).onComplete(() => { world.RemoveObject(attack2); }));

                break;
            case AttackType.WIDE_TWO:
                attack = new Attack(world, d);
                attack.SetPosition(this.GetPosition() + dirVect * 5);
                angle = Mathf.Atan2(dirVect.y, dirVect.x);
                dirVect.x = Mathf.Cos(angle - Mathf.PI / 10f);
                dirVect.y = Mathf.Sin(angle - Mathf.PI / 10f);
                Go.to(attack, .3f, new TweenConfig().floatProp("x", dirVect.x * dist * 1.5f, true).floatProp("y", dirVect.y * dist * 2f, true).setEaseType(EaseType.QuadOut).onComplete(() => { world.RemoveObject(attack); }));
                world.AddObject(attack);

                attack2 = new Attack(world, d);
                world.AddObject(attack2);
                secondAttackDir = new Vector2(Mathf.Cos(angle + Mathf.PI / 10f), Mathf.Sin(angle + Mathf.PI / 10f));
                attack2.SetPosition(this.GetPosition() + secondAttackDir * 5);
                Go.to(attack2, .3f, new TweenConfig().floatProp("x", secondAttackDir.x * dist * 1.5f, true).floatProp("y", secondAttackDir.y * dist * 2f, true).setEaseType(EaseType.QuadOut).onComplete(() => { world.RemoveObject(attack2); }));

                attack3 = new Attack(world, d);
                secondAttackDir = new Vector2(Mathf.Cos(angle - Mathf.PI / 4f), Mathf.Sin(angle - Mathf.PI / 4f));
                attack3.SetPosition(this.GetPosition() + secondAttackDir * 5);
                Go.to(attack3, .3f, new TweenConfig().floatProp("x", secondAttackDir.x * dist, true).floatProp("y", secondAttackDir.y * dist , true).setEaseType(EaseType.QuadOut).onComplete(() => { world.RemoveObject(attack3); }));
                world.AddObject(attack3);

                attack4 = new Attack(world, d);
                world.AddObject(attack4);
                secondAttackDir = new Vector2(Mathf.Cos(angle + Mathf.PI / 4f), Mathf.Sin(angle + Mathf.PI / 4f));
                attack4.SetPosition(this.GetPosition() + secondAttackDir * 5);
                Go.to(attack4, .3f, new TweenConfig().floatProp("x", secondAttackDir.x * dist, true).floatProp("y", secondAttackDir.y * dist, true).setEaseType(EaseType.QuadOut).onComplete(() => { world.RemoveObject(attack4); }));

                break;
            case AttackType.WIDE_360:

                angle = Mathf.Atan2(dirVect.y, dirVect.x);
                for (int i = 0; i < 8; i++)
                {
                    Direction attackDir = Direction.UP;
                    if (Mathf.Abs(dirVect.x) > Mathf.Abs(dirVect.y))
                    {
                        if (dirVect.x < 0)
                            attackDir = Direction.LEFT;
                        else
                            attackDir = Direction.RIGHT;
                    }
                    else if (dirVect.y < 0)
                        attackDir = Direction.DOWN;
                    else
                        attackDir = Direction.UP;
                    Attack tempAttackWide = new Attack(world, attackDir);
                    Vector2 newDirVect = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle));
                    tempAttackWide.SetPosition(this.GetPosition() + newDirVect * 5);
                    tempAttackWide.alpha = 0;
                    Go.to(tempAttackWide, (i + 1) * .03f, new TweenConfig().floatProp("alpha", 1).onComplete(() =>
                        {
                            Go.to(tempAttackWide, .3f, new TweenConfig().floatProp("x", newDirVect.x * dist, true).floatProp("y", newDirVect.y * dist, true).setEaseType(EaseType.QuadOut).onComplete(() => { world.RemoveObject(tempAttackWide); }));
//.........这里部分代码省略.........
开发者ID:maggardJosh,项目名称:OGREAT,代码行数:101,代码来源:Player.cs


注:本文中的Attack.SetDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。