Esempio n. 1
0
    /*
     * =========================
     * === FRAMEWORK METHODS ===
     * =========================
     */

    private void Awake()
    {
        /*
         * initialise important components for framework
         */

        // initialize markers to important objects
        playerObject = gameObject;
        parentObject = gameObject.transform.parent.gameObject;

        // initialize instances
        Instance        = GetComponent <PlayerController>();
        ghostingEffect  = GetComponent <GhostingEffect>();
        soundController = SoundController.Instance;
        morphIndicator  = MorphIndicator.Instance;
        scriptedEvents  = ScriptedEventsManager.Instance;

        // initialize physic components
        rb2d = GetComponent <Rigidbody2D>();
        triangleLineRenderer = GetComponent <LineRenderer>();

        // load morphing sprites into memory
        loadMorphAnimationSprites();

        Log.Print($"Initialised player with parent object '{parentObject.name}'.", parentObject);

        OnAwake();
    }
    public void Dash(Rigidbody2D rBody, Vector2 dashDirection, float dashAmount, LayerMask dashFilter)
    {
        Vector2 dashPosition = (Vector2)transform.position + dashDirection * dashAmount;

        RaycastHit2D raycastHit2D = Physics2D.Raycast(transform.position, dashDirection, dashAmount, dashFilter);

        if (raycastHit2D.collider != null)
        {
            dashPosition = raycastHit2D.point;
        }

        // Do Dash Effect here
        ghostingEffect = GhostingEffect.CreateEffect(this.gameObject, ghostTrailColor, ghostFadeColor, ghostFadeTime, ghostInterval, ghostAmount);
        ghostingEffect.ShowGhost();

        rBody.MovePosition(dashPosition);
    }