public override void OnCastCompleted()
    {
        if (prefab == null)
        {
            return;
        }
        MultiPointContext multiPoint = ability.GetContext <MultiPointContext>();
        GameObject        spawned    = null;
        Vector3           position   = ability.Caster.transform.position;
        Quaternion        rotation   = Quaternion.identity;

        if (spawnAtPoint && multiPoint != null)
        {
            position = multiPoint.points[0];
        }
        spawned = Object.Instantiate(prefab, position, rotation) as GameObject;
        IContextAware[] components = spawned.GetComponents <IContextAware>();
        if (components != null)
        {
            for (int i = 0; i < components.Length; i++)
            {
                components[i].SetContext(ability.GetContext());
            }
        }
    }
Example #2
0
    public void SetContext(Context ctx)
    {
        MultiPointContext context = ctx as MultiPointContext;

        pointList = context.points;
        RaycastHit hit;

        transform.position = pointList[0];
        if (Physics.Raycast(transform.position, Vector3.down, out hit, 100))
        {
            transform.position = hit.point + (Vector3.up * 0.1f);
        }
    }