Exemple #1
0
    public void ShootWind()
    {
        windAnimator.TriggerGust();
        PositionWind();

        Vector3 mousePosition = PlayerAimWeapon.GetMouseWorldPosition();

        // working on a 2d game, rotation works differently

        Vector3 aimDirection = (mousePosition - transform.position).normalized;

        float angle = Mathf.Atan2(aimDirection.y, aimDirection.x) * Mathf.Rad2Deg;

        Collider2D[] hits = Physics2D.OverlapBoxAll(transform.position, new Vector2(5, 1), angle, interactables);

        foreach (Collider2D collider in hits)
        {
            Debug.Log(collider.name);

            IWindable wind = collider.transform.GetComponent <IWindable>();

            if (wind != null)
            {
                wind.Wind(aimDirection.normalized);
            }
        }
    }
Exemple #2
0
    public void WindBlast(Vector3 startPos, Vector2 direction)
    {
        RaycastHit2D hit = Physics2D.Raycast(startPos, direction, 100f, interactables);

        if (hit.collider != null)
        {
            Debug.Log(hit.collider.name);

            IWindable wind = hit.collider.GetComponent <IWindable>();

            Debug.Log("Wind Object Hit");
            wind.Wind(direction);
        }
    }
        static void Main(string[] args)
        {
            BadWeather  badWeather  = new BadWeather();
            GoodWeather goodWeather = new GoodWeather();

            IRainable rainable = badWeather as IRainable;

            rainable.BadMethod();
            IWindable windable = badWeather as IWindable;

            windable.BadMethod();

            ISunable sunable = goodWeather as ISunable;

            sunable.GoodMethod();
            IWarmable warmable = goodWeather as IWarmable;

            warmable.GoodMethod();

            Console.ReadKey();
        }