Exemple #1
0
    public override bool Cast()
    {
        bool wasCast = false;

        effectAlpha = 1f;

        Vector2 mousePosition  = player.GetComponent <ClickHandler>().getMousePosition();
        Vector2 playerPosition = player.GetComponent <Rigidbody2D>().position;

        RaycastHit2D[] hits = Physics2D.LinecastAll(playerPosition, mousePosition);
        foreach (RaycastHit2D hit in hits)
        {
            if (hit != null && hit.collider != null)
            {
                if (hit.collider.gameObject.GetComponent <EnemyController>() != null)
                {
                    // CombatText combatText = hit.collider.gameObject.AddComponent(typeof(CombatText)) as CombatText;
                    // combatText.text= damage.ToString();
                    CombatText.Create(hit.collider.gameObject.transform.position, 100.ToString(), false);
                    StatusText.Create(hit.collider.gameObject.transform.position, "Stunned", false);
                    hit.collider.gameObject.GetComponent <CombatTextFactory>().addCombatText("Hit Enemy with dash");
                    Debug.Log("Hit Enemy with dash");
                }
            }
        }

        player.GetComponent <Rigidbody2D>().position = mousePosition;
        DashEffect.Create(playerPosition, mousePosition);
        wasCast = true;

        Debug.Log("Cast Dash");
        return(wasCast);
    }
    public ViewModel()
    {
        // The LiveChartsCore.SkiaSharpView.Painting.EffectsPathEffect abstract class is a wrapper for
        // the SkiaSharp.SKPathEffect object, in this case we will use the DashEffect class
        // to create a dash line as the stroke of our line series

        // notice the stroke thickness affects the stroke dash array
        // if you want to learn more about stroke dash arrays please see:
        // https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/curves/effects#dots-and-dashes

        var strokeThickness = 10;
        var strokeDashArray = new float[] { 3 * strokeThickness, 2 * strokeThickness };
        var effect          = new DashEffect(strokeDashArray);

        Series = new ISeries[]
        {
            new LineSeries <int>
            {
                Values         = new [] { 4, 2, 8, 5, 3 },
                LineSmoothness = 1,
                GeometrySize   = 22,
                Stroke         = new SolidColorPaint
                {
                    Color           = SKColors.CornflowerBlue,
                    StrokeCap       = SKStrokeCap.Round,
                    StrokeThickness = strokeThickness,
                    PathEffect      = effect
                },
                Fill = null
            }
        };
    }
    private void FixedUpdate()
    {
        switch (state)
        {
        case State.Normal:
            rigidbody3D.velocity = moveDir * MOVE_SPEED;

            if (isDashButtonDown)
            {
                float   dashAmount   = 5f;
                Vector3 dashPosition = transform.position + lastMoveDir * dashAmount;

                RaycastHit2D raycastHit2d = Physics2D.Raycast(transform.position, lastMoveDir, dashAmount, dashLayerMask);
                if (raycastHit2d.collider != null)
                {
                    dashPosition = raycastHit2d.point;
                }

                // Spawn visual effect
                DashEffect.CreateDashEffect(transform.position, lastMoveDir, Vector3.Distance(transform.position, dashPosition));

                rigidbody3D.MovePosition(dashPosition);
                isDashButtonDown = false;
            }
            break;

        case State.Rolling:
            rigidbody3D.velocity = rollDir * rollSpeed;
            break;

        case State.Busy:
            break;
        }
    }
 // Use this for initialization
 // Update is called once per frame
 private void Start()
 {
     rb = GetComponentInParent <Rigidbody2D>();
     tm = GetComponentInParent <Transform>();
     de = GetComponent <DashEffect>();
     ps = GetComponentsInChildren <ParticleSystem>();
 }
    public static DashEffect Create(Vector2 startPostition, Vector2 endPosition)
    {
        // CombatText.Create(Vector2.zero, "TEST");
        Transform  dashEffectTransform = Instantiate(GameAssets.i.dashEffect, Vector3.zero, Quaternion.identity);
        DashEffect dashEffect          = dashEffectTransform.GetComponent <DashEffect>();

        dashEffect.Setup(startPostition, endPosition);
        return(dashEffect);
    }
Exemple #6
0
    public override bool Cast()
    {
        bool wasCast = false;

        effectAlpha = 1f;

        Vector2 mousePosition  = player.GetComponent <ClickHandler>().getMousePosition();
        Vector2 playerPosition = player.transform.position;
        // foreach (RaycastHit2D hit in hits)
        // {

        //     if (hit != null && hit.collider != null)
        //     {
        //         if (hit.collider.gameObject.GetComponent<EnemyController>() != null)
        //         {
        //             // CombatText combatText = hit.collider.gameObject.AddComponent(typeof(CombatText)) as CombatText;
        //             // combatText.text= damage.ToString();
        //             CombatText.Create(hit.collider.gameObject.transform.position, 100.ToString(), false);
        //             StatusText.Create(hit.collider.gameObject.transform.position, "Stunned", false);
        //             hit.collider.gameObject.GetComponent<CombatTextFactory>().addCombatText("Hit Enemy with dash");
        //             Debug.Log("Hit Enemy with dash");

        //         }
        //     }
        // }


        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit[] hits = Physics.RaycastAll(ray);
        foreach (RaycastHit hit in hits)
        {
            if (hit.transform.name.Contains("Floor"))
            {
                Vector3 newPosition = hit.point;
                newPosition.y             = .2f;
                player.transform.position = newPosition;
                DashEffect.Create(playerPosition, newPosition);
                Debug.Log(hit.point);
            }
        }


        wasCast = true;

        Debug.Log("Cast Dash");
        return(wasCast);
    }
    private void Start()
    {
        DontDestroyOnLoad(gameObject);

        PlayerReadyIndicator = Instantiate(PlayerReadyIndicatorPrefab);
        PlayerReadyIndicator.GetComponent <PlayerReadyIndicatorController>().AttachedPlayer = this;

        de  = GetComponentInChildren <DashEffect>();
        gc  = GetComponentInChildren <GravityChange>();
        dth = GetComponentInChildren <deatheffect>();

        if (GameManager.Instance.OnPlayerJoin != null)
        {
            GameManager.Instance.OnPlayerJoin(this);
        }

        ControlledPlayer.NumLives = GameRoundSettingsController.Instance.NumLivesPerRound;

        StartCoroutine(AttachInputDeviceToPlayer());
        LevelManager.Instance.SpawnPlayer(this);
    }
Exemple #8
0
    private void FixedUpdate()
    {
        rigidbody2D.velocity = moveDir * MOVE_SPEED;

        if (isDashButtonDown)
        {
            float   dashAmount   = 50f;
            Vector3 dashPosition = transform.position + moveDir * dashAmount;

            RaycastHit2D raycastHit2d = Physics2D.Raycast(transform.position, moveDir, dashAmount, dashLayerMask);
            if (raycastHit2d.collider != null)
            {
                dashPosition = raycastHit2d.point;
            }

            // Spawn visual effect
            DashEffect.CreateDashEffect(transform.position, moveDir, Vector3.Distance(transform.position, dashPosition));

            rigidbody2D.MovePosition(dashPosition);
            isDashButtonDown = false;
        }
    }